sta2x11-mfd.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. /*
  2. * Copyright (c) 2009-2011 Wind River Systems, Inc.
  3. * Copyright (c) 2011 ST Microelectronics (Alessandro Rubini)
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. * See the GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. *
  18. */
  19. #include <linux/kernel.h>
  20. #include <linux/module.h>
  21. #include <linux/spinlock.h>
  22. #include <linux/errno.h>
  23. #include <linux/device.h>
  24. #include <linux/slab.h>
  25. #include <linux/list.h>
  26. #include <linux/io.h>
  27. #include <linux/ioport.h>
  28. #include <linux/pci.h>
  29. #include <linux/seq_file.h>
  30. #include <linux/platform_device.h>
  31. #include <linux/mfd/core.h>
  32. #include <linux/mfd/sta2x11-mfd.h>
  33. #include <linux/regmap.h>
  34. #include <asm/sta2x11.h>
  35. static inline int __reg_within_range(unsigned int r,
  36. unsigned int start,
  37. unsigned int end)
  38. {
  39. return ((r >= start) && (r <= end));
  40. }
  41. /* This describes STA2X11 MFD chip for us, we may have several */
  42. struct sta2x11_mfd {
  43. struct sta2x11_instance *instance;
  44. struct regmap *regmap[sta2x11_n_mfd_plat_devs];
  45. spinlock_t lock;
  46. struct list_head list;
  47. void __iomem *regs[sta2x11_n_mfd_plat_devs];
  48. };
  49. static LIST_HEAD(sta2x11_mfd_list);
  50. /* Three functions to act on the list */
  51. static struct sta2x11_mfd *sta2x11_mfd_find(struct pci_dev *pdev)
  52. {
  53. struct sta2x11_instance *instance;
  54. struct sta2x11_mfd *mfd;
  55. if (!pdev && !list_empty(&sta2x11_mfd_list)) {
  56. pr_warning("%s: Unspecified device, "
  57. "using first instance\n", __func__);
  58. return list_entry(sta2x11_mfd_list.next,
  59. struct sta2x11_mfd, list);
  60. }
  61. instance = sta2x11_get_instance(pdev);
  62. if (!instance)
  63. return NULL;
  64. list_for_each_entry(mfd, &sta2x11_mfd_list, list) {
  65. if (mfd->instance == instance)
  66. return mfd;
  67. }
  68. return NULL;
  69. }
  70. static int __devinit sta2x11_mfd_add(struct pci_dev *pdev, gfp_t flags)
  71. {
  72. struct sta2x11_mfd *mfd = sta2x11_mfd_find(pdev);
  73. struct sta2x11_instance *instance;
  74. if (mfd)
  75. return -EBUSY;
  76. instance = sta2x11_get_instance(pdev);
  77. if (!instance)
  78. return -EINVAL;
  79. mfd = kzalloc(sizeof(*mfd), flags);
  80. if (!mfd)
  81. return -ENOMEM;
  82. INIT_LIST_HEAD(&mfd->list);
  83. spin_lock_init(&mfd->lock);
  84. mfd->instance = instance;
  85. list_add(&mfd->list, &sta2x11_mfd_list);
  86. return 0;
  87. }
  88. static int __devexit mfd_remove(struct pci_dev *pdev)
  89. {
  90. struct sta2x11_mfd *mfd = sta2x11_mfd_find(pdev);
  91. if (!mfd)
  92. return -ENODEV;
  93. list_del(&mfd->list);
  94. kfree(mfd);
  95. return 0;
  96. }
  97. /* This function is exported and is not expected to fail */
  98. u32 __sta2x11_mfd_mask(struct pci_dev *pdev, u32 reg, u32 mask, u32 val,
  99. enum sta2x11_mfd_plat_dev index)
  100. {
  101. struct sta2x11_mfd *mfd = sta2x11_mfd_find(pdev);
  102. u32 r;
  103. unsigned long flags;
  104. void __iomem *regs = mfd->regs[index];
  105. if (!mfd) {
  106. dev_warn(&pdev->dev, ": can't access sctl regs\n");
  107. return 0;
  108. }
  109. if (!regs) {
  110. dev_warn(&pdev->dev, ": system ctl not initialized\n");
  111. return 0;
  112. }
  113. spin_lock_irqsave(&mfd->lock, flags);
  114. r = readl(regs + reg);
  115. r &= ~mask;
  116. r |= val;
  117. if (mask)
  118. writel(r, regs + reg);
  119. spin_unlock_irqrestore(&mfd->lock, flags);
  120. return r;
  121. }
  122. EXPORT_SYMBOL(__sta2x11_mfd_mask);
  123. int sta2x11_mfd_get_regs_data(struct platform_device *dev,
  124. enum sta2x11_mfd_plat_dev index,
  125. void __iomem **regs,
  126. spinlock_t **lock)
  127. {
  128. struct pci_dev *pdev = *(struct pci_dev **)(dev->dev.platform_data);
  129. struct sta2x11_mfd *mfd;
  130. if (!pdev)
  131. return -ENODEV;
  132. mfd = sta2x11_mfd_find(pdev);
  133. if (!mfd)
  134. return -ENODEV;
  135. if (index >= sta2x11_n_mfd_plat_devs)
  136. return -ENODEV;
  137. *regs = mfd->regs[index];
  138. *lock = &mfd->lock[index];
  139. pr_debug("%s %d *regs = %p\n", __func__, __LINE__, *regs);
  140. return *regs ? 0 : -ENODEV;
  141. }
  142. EXPORT_SYMBOL(sta2x11_mfd_get_regs_data);
  143. /*
  144. * Special sta2x11-mfd regmap lock/unlock functions
  145. */
  146. static void sta2x11_regmap_lock(void *__lock)
  147. {
  148. spinlock_t *lock = __lock;
  149. spin_lock(lock);
  150. }
  151. static void sta2x11_regmap_unlock(void *__lock)
  152. {
  153. spinlock_t *lock = __lock;
  154. spin_unlock(lock);
  155. }
  156. static const char *sta2x11_mfd_names[sta2x11_n_mfd_plat_devs] = {
  157. [sta2x11_sctl] = "sta2x11-sctl",
  158. [sta2x11_apbreg] = "sta2x11-apbreg",
  159. [sta2x11_apb_soc_regs] = "sta2x11-apb-soc-regs",
  160. };
  161. static bool sta2x11_sctl_writeable_reg(struct device *dev, unsigned int reg)
  162. {
  163. return !__reg_within_range(reg, SCTL_SCPCIECSBRST, SCTL_SCRSTSTA);
  164. }
  165. static struct regmap_config sta2x11_sctl_regmap_config = {
  166. .reg_bits = 32,
  167. .reg_stride = 4,
  168. .val_bits = 32,
  169. .lock = sta2x11_regmap_lock,
  170. .unlock = sta2x11_regmap_unlock,
  171. .max_register = SCTL_SCRSTSTA,
  172. .writeable_reg = sta2x11_sctl_writeable_reg,
  173. };
  174. static bool sta2x11_apbreg_readable_reg(struct device *dev, unsigned int reg)
  175. {
  176. /* Two blocks (CAN and MLB, SARAC) 0x100 bytes apart */
  177. if (reg >= APBREG_BSR_SARAC)
  178. reg -= APBREG_BSR_SARAC;
  179. switch (reg) {
  180. case APBREG_BSR:
  181. case APBREG_PAER:
  182. case APBREG_PWAC:
  183. case APBREG_PRAC:
  184. case APBREG_PCG:
  185. case APBREG_PUR:
  186. case APBREG_EMU_PCG:
  187. return true;
  188. default:
  189. return false;
  190. }
  191. }
  192. static bool sta2x11_apbreg_writeable_reg(struct device *dev, unsigned int reg)
  193. {
  194. if (reg >= APBREG_BSR_SARAC)
  195. reg -= APBREG_BSR_SARAC;
  196. if (!sta2x11_apbreg_readable_reg(dev, reg))
  197. return false;
  198. return reg != APBREG_PAER;
  199. }
  200. static struct regmap_config sta2x11_apbreg_regmap_config = {
  201. .reg_bits = 32,
  202. .reg_stride = 4,
  203. .val_bits = 32,
  204. .lock = sta2x11_regmap_lock,
  205. .unlock = sta2x11_regmap_unlock,
  206. .max_register = APBREG_EMU_PCG_SARAC,
  207. .readable_reg = sta2x11_apbreg_readable_reg,
  208. .writeable_reg = sta2x11_apbreg_writeable_reg,
  209. };
  210. static bool sta2x11_apb_soc_regs_readable_reg(struct device *dev,
  211. unsigned int reg)
  212. {
  213. return reg <= PCIE_SoC_INT_ROUTER_STATUS3_REG ||
  214. __reg_within_range(reg, DMA_IP_CTRL_REG, SPARE3_RESERVED) ||
  215. __reg_within_range(reg, MASTER_LOCK_REG,
  216. SYSTEM_CONFIG_STATUS_REG) ||
  217. reg == MSP_CLK_CTRL_REG ||
  218. __reg_within_range(reg, COMPENSATION_REG1, TEST_CTL_REG);
  219. }
  220. static bool sta2x11_apb_soc_regs_writeable_reg(struct device *dev,
  221. unsigned int reg)
  222. {
  223. if (!sta2x11_apb_soc_regs_readable_reg(dev, reg))
  224. return false;
  225. switch (reg) {
  226. case PCIE_COMMON_CLOCK_CONFIG_0_4_0:
  227. case SYSTEM_CONFIG_STATUS_REG:
  228. case COMPENSATION_REG1:
  229. case PCIE_SoC_INT_ROUTER_STATUS0_REG...PCIE_SoC_INT_ROUTER_STATUS3_REG:
  230. case PCIE_PM_STATUS_0_PORT_0_4...PCIE_PM_STATUS_7_0_EP4:
  231. return false;
  232. default:
  233. return true;
  234. }
  235. }
  236. static struct regmap_config sta2x11_apb_soc_regs_regmap_config = {
  237. .reg_bits = 32,
  238. .reg_stride = 4,
  239. .val_bits = 32,
  240. .lock = sta2x11_regmap_lock,
  241. .unlock = sta2x11_regmap_unlock,
  242. .max_register = TEST_CTL_REG,
  243. .readable_reg = sta2x11_apb_soc_regs_readable_reg,
  244. .writeable_reg = sta2x11_apb_soc_regs_writeable_reg,
  245. };
  246. static struct regmap_config *
  247. sta2x11_mfd_regmap_configs[sta2x11_n_mfd_plat_devs] = {
  248. [sta2x11_sctl] = &sta2x11_sctl_regmap_config,
  249. [sta2x11_apbreg] = &sta2x11_apbreg_regmap_config,
  250. [sta2x11_apb_soc_regs] = &sta2x11_apb_soc_regs_regmap_config,
  251. };
  252. /* Probe for the three platform devices */
  253. static int sta2x11_mfd_platform_probe(struct platform_device *dev,
  254. enum sta2x11_mfd_plat_dev index)
  255. {
  256. struct pci_dev **pdev;
  257. struct sta2x11_mfd *mfd;
  258. struct resource *res;
  259. const char *name = sta2x11_mfd_names[index];
  260. struct regmap_config *regmap_config = sta2x11_mfd_regmap_configs[index];
  261. pdev = dev->dev.platform_data;
  262. mfd = sta2x11_mfd_find(*pdev);
  263. if (!mfd)
  264. return -ENODEV;
  265. if (!regmap_config)
  266. return -ENODEV;
  267. res = platform_get_resource(dev, IORESOURCE_MEM, 0);
  268. if (!res)
  269. return -ENOMEM;
  270. if (!request_mem_region(res->start, resource_size(res), name))
  271. return -EBUSY;
  272. mfd->regs[index] = ioremap(res->start, resource_size(res));
  273. if (!mfd->regs[index]) {
  274. release_mem_region(res->start, resource_size(res));
  275. return -ENOMEM;
  276. }
  277. regmap_config->lock_arg = &mfd->lock;
  278. /*
  279. No caching, registers could be reached both via regmap and via
  280. void __iomem *
  281. */
  282. regmap_config->cache_type = REGCACHE_NONE;
  283. mfd->regmap[index] = devm_regmap_init_mmio(&dev->dev, mfd->regs[index],
  284. regmap_config);
  285. WARN_ON(!mfd->regmap[index]);
  286. return 0;
  287. }
  288. static int sta2x11_sctl_probe(struct platform_device *dev)
  289. {
  290. return sta2x11_mfd_platform_probe(dev, sta2x11_sctl);
  291. }
  292. static int sta2x11_apbreg_probe(struct platform_device *dev)
  293. {
  294. return sta2x11_mfd_platform_probe(dev, sta2x11_apbreg);
  295. }
  296. static int sta2x11_apb_soc_regs_probe(struct platform_device *dev)
  297. {
  298. return sta2x11_mfd_platform_probe(dev, sta2x11_apb_soc_regs);
  299. }
  300. /* The three platform drivers */
  301. static struct platform_driver sta2x11_sctl_platform_driver = {
  302. .driver = {
  303. .name = "sta2x11-sctl",
  304. .owner = THIS_MODULE,
  305. },
  306. .probe = sta2x11_sctl_probe,
  307. };
  308. static int __init sta2x11_sctl_init(void)
  309. {
  310. pr_info("%s\n", __func__);
  311. return platform_driver_register(&sta2x11_sctl_platform_driver);
  312. }
  313. static struct platform_driver sta2x11_platform_driver = {
  314. .driver = {
  315. .name = "sta2x11-apbreg",
  316. .owner = THIS_MODULE,
  317. },
  318. .probe = sta2x11_apbreg_probe,
  319. };
  320. static int __init sta2x11_apbreg_init(void)
  321. {
  322. pr_info("%s\n", __func__);
  323. return platform_driver_register(&sta2x11_platform_driver);
  324. }
  325. static struct platform_driver sta2x11_apb_soc_regs_platform_driver = {
  326. .driver = {
  327. .name = "sta2x11-apb-soc-regs",
  328. .owner = THIS_MODULE,
  329. },
  330. .probe = sta2x11_apb_soc_regs_probe,
  331. };
  332. static int __init sta2x11_apb_soc_regs_init(void)
  333. {
  334. pr_info("%s\n", __func__);
  335. return platform_driver_register(&sta2x11_apb_soc_regs_platform_driver);
  336. }
  337. /*
  338. * What follows are the PCI devices that host the above pdevs.
  339. * Each logic block is 4kB and they are all consecutive: we use this info.
  340. */
  341. /* Mfd 0 device */
  342. /* Mfd 0, Bar 0 */
  343. enum mfd0_bar0_cells {
  344. STA2X11_GPIO_0 = 0,
  345. STA2X11_GPIO_1,
  346. STA2X11_GPIO_2,
  347. STA2X11_GPIO_3,
  348. STA2X11_SCTL,
  349. STA2X11_SCR,
  350. STA2X11_TIME,
  351. };
  352. /* Mfd 0 , Bar 1 */
  353. enum mfd0_bar1_cells {
  354. STA2X11_APBREG = 0,
  355. };
  356. #define CELL_4K(_name, _cell) { \
  357. .name = _name, \
  358. .start = _cell * 4096, .end = _cell * 4096 + 4095, \
  359. .flags = IORESOURCE_MEM, \
  360. }
  361. static const __devinitconst struct resource gpio_resources[] = {
  362. {
  363. .name = "sta2x11_gpio", /* 4 consecutive cells, 1 driver */
  364. .start = 0,
  365. .end = (4 * 4096) - 1,
  366. .flags = IORESOURCE_MEM,
  367. }
  368. };
  369. static const __devinitconst struct resource sctl_resources[] = {
  370. CELL_4K("sta2x11-sctl", STA2X11_SCTL),
  371. };
  372. static const __devinitconst struct resource scr_resources[] = {
  373. CELL_4K("sta2x11-scr", STA2X11_SCR),
  374. };
  375. static const __devinitconst struct resource time_resources[] = {
  376. CELL_4K("sta2x11-time", STA2X11_TIME),
  377. };
  378. static const __devinitconst struct resource apbreg_resources[] = {
  379. CELL_4K("sta2x11-apbreg", STA2X11_APBREG),
  380. };
  381. #define DEV(_name, _r) \
  382. { .name = _name, .num_resources = ARRAY_SIZE(_r), .resources = _r, }
  383. static __devinitdata struct mfd_cell sta2x11_mfd0_bar0[] = {
  384. DEV("sta2x11-gpio", gpio_resources), /* offset 0: we add pdata later */
  385. DEV("sta2x11-sctl", sctl_resources),
  386. DEV("sta2x11-scr", scr_resources),
  387. DEV("sta2x11-time", time_resources),
  388. };
  389. static __devinitdata struct mfd_cell sta2x11_mfd0_bar1[] = {
  390. DEV("sta2x11-apbreg", apbreg_resources),
  391. };
  392. /* Mfd 1 devices */
  393. /* Mfd 1, Bar 0 */
  394. enum mfd1_bar0_cells {
  395. STA2X11_VIC = 0,
  396. };
  397. /* Mfd 1, Bar 1 */
  398. enum mfd1_bar1_cells {
  399. STA2X11_APB_SOC_REGS = 0,
  400. };
  401. static const __devinitconst struct resource vic_resources[] = {
  402. CELL_4K("sta2x11-vic", STA2X11_VIC),
  403. };
  404. static const __devinitconst struct resource apb_soc_regs_resources[] = {
  405. CELL_4K("sta2x11-apb-soc-regs", STA2X11_APB_SOC_REGS),
  406. };
  407. static __devinitdata struct mfd_cell sta2x11_mfd1_bar0[] = {
  408. DEV("sta2x11-vic", vic_resources),
  409. };
  410. static __devinitdata struct mfd_cell sta2x11_mfd1_bar1[] = {
  411. DEV("sta2x11-apb-soc-regs", apb_soc_regs_resources),
  412. };
  413. static int sta2x11_mfd_suspend(struct pci_dev *pdev, pm_message_t state)
  414. {
  415. pci_save_state(pdev);
  416. pci_disable_device(pdev);
  417. pci_set_power_state(pdev, pci_choose_state(pdev, state));
  418. return 0;
  419. }
  420. static int sta2x11_mfd_resume(struct pci_dev *pdev)
  421. {
  422. int err;
  423. pci_set_power_state(pdev, 0);
  424. err = pci_enable_device(pdev);
  425. if (err)
  426. return err;
  427. pci_restore_state(pdev);
  428. return 0;
  429. }
  430. struct sta2x11_mfd_bar_setup_data {
  431. struct mfd_cell *cells;
  432. int ncells;
  433. };
  434. struct sta2x11_mfd_setup_data {
  435. struct sta2x11_mfd_bar_setup_data bars[2];
  436. };
  437. #define STA2X11_MFD0 0
  438. #define STA2X11_MFD1 1
  439. static struct sta2x11_mfd_setup_data mfd_setup_data[] = {
  440. /* Mfd 0: gpio, sctl, scr, timers / apbregs */
  441. [STA2X11_MFD0] = {
  442. .bars = {
  443. [0] = {
  444. .cells = sta2x11_mfd0_bar0,
  445. .ncells = ARRAY_SIZE(sta2x11_mfd0_bar0),
  446. },
  447. [1] = {
  448. .cells = sta2x11_mfd0_bar1,
  449. .ncells = ARRAY_SIZE(sta2x11_mfd0_bar1),
  450. },
  451. },
  452. },
  453. /* Mfd 1: vic / apb-soc-regs */
  454. [STA2X11_MFD1] = {
  455. .bars = {
  456. [0] = {
  457. .cells = sta2x11_mfd1_bar0,
  458. .ncells = ARRAY_SIZE(sta2x11_mfd1_bar0),
  459. },
  460. [1] = {
  461. .cells = sta2x11_mfd1_bar1,
  462. .ncells = ARRAY_SIZE(sta2x11_mfd1_bar1),
  463. },
  464. },
  465. },
  466. };
  467. static void __devinit sta2x11_mfd_setup(struct pci_dev *pdev,
  468. struct sta2x11_mfd_setup_data *sd)
  469. {
  470. int i, j;
  471. for (i = 0; i < ARRAY_SIZE(sd->bars); i++)
  472. for (j = 0; j < sd->bars[i].ncells; j++) {
  473. sd->bars[i].cells[j].pdata_size = sizeof(pdev);
  474. sd->bars[i].cells[j].platform_data = &pdev;
  475. }
  476. }
  477. static int __devinit sta2x11_mfd_probe(struct pci_dev *pdev,
  478. const struct pci_device_id *pci_id)
  479. {
  480. int err, i;
  481. struct sta2x11_mfd_setup_data *setup_data;
  482. struct sta2x11_gpio_pdata *gpio_data;
  483. dev_info(&pdev->dev, "%s\n", __func__);
  484. err = pci_enable_device(pdev);
  485. if (err) {
  486. dev_err(&pdev->dev, "Can't enable device.\n");
  487. return err;
  488. }
  489. err = pci_enable_msi(pdev);
  490. if (err)
  491. dev_info(&pdev->dev, "Enable msi failed\n");
  492. setup_data = pci_id->device == PCI_DEVICE_ID_STMICRO_GPIO ?
  493. &mfd_setup_data[STA2X11_MFD0] :
  494. &mfd_setup_data[STA2X11_MFD1];
  495. /* Read gpio config data as pci device's platform data */
  496. gpio_data = dev_get_platdata(&pdev->dev);
  497. if (!gpio_data)
  498. dev_warn(&pdev->dev, "no gpio configuration\n");
  499. dev_dbg(&pdev->dev, "%s, gpio_data = %p (%p)\n", __func__,
  500. gpio_data, &gpio_data);
  501. dev_dbg(&pdev->dev, "%s, pdev = %p (%p)\n", __func__,
  502. pdev, &pdev);
  503. /* platform data is the pci device for all of them */
  504. sta2x11_mfd_setup(pdev, setup_data);
  505. /* Record this pdev before mfd_add_devices: their probe looks for it */
  506. sta2x11_mfd_add(pdev, GFP_ATOMIC);
  507. /* Just 2 bars for all mfd's at present */
  508. for (i = 0; i < 2; i++) {
  509. err = mfd_add_devices(&pdev->dev, -1,
  510. setup_data->bars[i].cells,
  511. setup_data->bars[i].ncells,
  512. &pdev->resource[i],
  513. 0, NULL);
  514. if (err) {
  515. dev_err(&pdev->dev,
  516. "mfd_add_devices[%d] failed: %d\n", i, err);
  517. goto err_disable;
  518. }
  519. }
  520. return 0;
  521. err_disable:
  522. mfd_remove_devices(&pdev->dev);
  523. pci_disable_device(pdev);
  524. pci_disable_msi(pdev);
  525. return err;
  526. }
  527. static DEFINE_PCI_DEVICE_TABLE(sta2x11_mfd_tbl) = {
  528. {PCI_DEVICE(PCI_VENDOR_ID_STMICRO, PCI_DEVICE_ID_STMICRO_GPIO)},
  529. {PCI_DEVICE(PCI_VENDOR_ID_STMICRO, PCI_DEVICE_ID_STMICRO_VIC)},
  530. {0,},
  531. };
  532. static struct pci_driver sta2x11_mfd_driver = {
  533. .name = "sta2x11-mfd",
  534. .id_table = sta2x11_mfd_tbl,
  535. .probe = sta2x11_mfd_probe,
  536. .suspend = sta2x11_mfd_suspend,
  537. .resume = sta2x11_mfd_resume,
  538. };
  539. static int __init sta2x11_mfd_init(void)
  540. {
  541. pr_info("%s\n", __func__);
  542. return pci_register_driver(&sta2x11_mfd_driver);
  543. }
  544. /*
  545. * All of this must be ready before "normal" devices like MMCI appear.
  546. * But MFD (the pci device) can't be too early. The following choice
  547. * prepares platform drivers very early and probe the PCI device later,
  548. * but before other PCI devices.
  549. */
  550. subsys_initcall(sta2x11_apbreg_init);
  551. subsys_initcall(sta2x11_sctl_init);
  552. subsys_initcall(sta2x11_apb_soc_regs_init);
  553. rootfs_initcall(sta2x11_mfd_init);
  554. MODULE_LICENSE("GPL v2");
  555. MODULE_AUTHOR("Wind River");
  556. MODULE_DESCRIPTION("STA2x11 mfd for GPIO, SCTL and APBREG");
  557. MODULE_DEVICE_TABLE(pci, sta2x11_mfd_tbl);