sta2x11-mfd.c 16 KB

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