pmc_atom.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. /*
  2. * Intel Atom SOC Power Management Controller Driver
  3. * Copyright (c) 2014, Intel Corporation.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms and conditions of the GNU General Public License,
  7. * version 2, as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. */
  15. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  16. #include <linux/debugfs.h>
  17. #include <linux/device.h>
  18. #include <linux/dmi.h>
  19. #include <linux/init.h>
  20. #include <linux/io.h>
  21. #include <linux/platform_data/x86/clk-pmc-atom.h>
  22. #include <linux/platform_data/x86/pmc_atom.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/pci.h>
  25. #include <linux/seq_file.h>
  26. struct pmc_bit_map {
  27. const char *name;
  28. u32 bit_mask;
  29. };
  30. struct pmc_reg_map {
  31. const struct pmc_bit_map *d3_sts_0;
  32. const struct pmc_bit_map *d3_sts_1;
  33. const struct pmc_bit_map *func_dis;
  34. const struct pmc_bit_map *func_dis_2;
  35. const struct pmc_bit_map *pss;
  36. };
  37. struct pmc_data {
  38. const struct pmc_reg_map *map;
  39. const struct pmc_clk *clks;
  40. };
  41. struct pmc_dev {
  42. u32 base_addr;
  43. void __iomem *regmap;
  44. const struct pmc_reg_map *map;
  45. #ifdef CONFIG_DEBUG_FS
  46. struct dentry *dbgfs_dir;
  47. #endif /* CONFIG_DEBUG_FS */
  48. bool init;
  49. };
  50. static struct pmc_dev pmc_device;
  51. static u32 acpi_base_addr;
  52. static const struct pmc_clk byt_clks[] = {
  53. {
  54. .name = "xtal",
  55. .freq = 25000000,
  56. .parent_name = NULL,
  57. },
  58. {
  59. .name = "pll",
  60. .freq = 19200000,
  61. .parent_name = "xtal",
  62. },
  63. {},
  64. };
  65. static const struct pmc_clk cht_clks[] = {
  66. {
  67. .name = "xtal",
  68. .freq = 19200000,
  69. .parent_name = NULL,
  70. },
  71. {},
  72. };
  73. static const struct pmc_bit_map d3_sts_0_map[] = {
  74. {"LPSS1_F0_DMA", BIT_LPSS1_F0_DMA},
  75. {"LPSS1_F1_PWM1", BIT_LPSS1_F1_PWM1},
  76. {"LPSS1_F2_PWM2", BIT_LPSS1_F2_PWM2},
  77. {"LPSS1_F3_HSUART1", BIT_LPSS1_F3_HSUART1},
  78. {"LPSS1_F4_HSUART2", BIT_LPSS1_F4_HSUART2},
  79. {"LPSS1_F5_SPI", BIT_LPSS1_F5_SPI},
  80. {"LPSS1_F6_Reserved", BIT_LPSS1_F6_XXX},
  81. {"LPSS1_F7_Reserved", BIT_LPSS1_F7_XXX},
  82. {"SCC_EMMC", BIT_SCC_EMMC},
  83. {"SCC_SDIO", BIT_SCC_SDIO},
  84. {"SCC_SDCARD", BIT_SCC_SDCARD},
  85. {"SCC_MIPI", BIT_SCC_MIPI},
  86. {"HDA", BIT_HDA},
  87. {"LPE", BIT_LPE},
  88. {"OTG", BIT_OTG},
  89. {"USH", BIT_USH},
  90. {"GBE", BIT_GBE},
  91. {"SATA", BIT_SATA},
  92. {"USB_EHCI", BIT_USB_EHCI},
  93. {"SEC", BIT_SEC},
  94. {"PCIE_PORT0", BIT_PCIE_PORT0},
  95. {"PCIE_PORT1", BIT_PCIE_PORT1},
  96. {"PCIE_PORT2", BIT_PCIE_PORT2},
  97. {"PCIE_PORT3", BIT_PCIE_PORT3},
  98. {"LPSS2_F0_DMA", BIT_LPSS2_F0_DMA},
  99. {"LPSS2_F1_I2C1", BIT_LPSS2_F1_I2C1},
  100. {"LPSS2_F2_I2C2", BIT_LPSS2_F2_I2C2},
  101. {"LPSS2_F3_I2C3", BIT_LPSS2_F3_I2C3},
  102. {"LPSS2_F3_I2C4", BIT_LPSS2_F4_I2C4},
  103. {"LPSS2_F5_I2C5", BIT_LPSS2_F5_I2C5},
  104. {"LPSS2_F6_I2C6", BIT_LPSS2_F6_I2C6},
  105. {"LPSS2_F7_I2C7", BIT_LPSS2_F7_I2C7},
  106. {},
  107. };
  108. static struct pmc_bit_map byt_d3_sts_1_map[] = {
  109. {"SMB", BIT_SMB},
  110. {"OTG_SS_PHY", BIT_OTG_SS_PHY},
  111. {"USH_SS_PHY", BIT_USH_SS_PHY},
  112. {"DFX", BIT_DFX},
  113. {},
  114. };
  115. static struct pmc_bit_map cht_d3_sts_1_map[] = {
  116. {"SMB", BIT_SMB},
  117. {"GMM", BIT_STS_GMM},
  118. {"ISH", BIT_STS_ISH},
  119. {},
  120. };
  121. static struct pmc_bit_map cht_func_dis_2_map[] = {
  122. {"SMB", BIT_SMB},
  123. {"GMM", BIT_FD_GMM},
  124. {"ISH", BIT_FD_ISH},
  125. {},
  126. };
  127. static const struct pmc_bit_map byt_pss_map[] = {
  128. {"GBE", PMC_PSS_BIT_GBE},
  129. {"SATA", PMC_PSS_BIT_SATA},
  130. {"HDA", PMC_PSS_BIT_HDA},
  131. {"SEC", PMC_PSS_BIT_SEC},
  132. {"PCIE", PMC_PSS_BIT_PCIE},
  133. {"LPSS", PMC_PSS_BIT_LPSS},
  134. {"LPE", PMC_PSS_BIT_LPE},
  135. {"DFX", PMC_PSS_BIT_DFX},
  136. {"USH_CTRL", PMC_PSS_BIT_USH_CTRL},
  137. {"USH_SUS", PMC_PSS_BIT_USH_SUS},
  138. {"USH_VCCS", PMC_PSS_BIT_USH_VCCS},
  139. {"USH_VCCA", PMC_PSS_BIT_USH_VCCA},
  140. {"OTG_CTRL", PMC_PSS_BIT_OTG_CTRL},
  141. {"OTG_VCCS", PMC_PSS_BIT_OTG_VCCS},
  142. {"OTG_VCCA_CLK", PMC_PSS_BIT_OTG_VCCA_CLK},
  143. {"OTG_VCCA", PMC_PSS_BIT_OTG_VCCA},
  144. {"USB", PMC_PSS_BIT_USB},
  145. {"USB_SUS", PMC_PSS_BIT_USB_SUS},
  146. {},
  147. };
  148. static const struct pmc_bit_map cht_pss_map[] = {
  149. {"SATA", PMC_PSS_BIT_SATA},
  150. {"HDA", PMC_PSS_BIT_HDA},
  151. {"SEC", PMC_PSS_BIT_SEC},
  152. {"PCIE", PMC_PSS_BIT_PCIE},
  153. {"LPSS", PMC_PSS_BIT_LPSS},
  154. {"LPE", PMC_PSS_BIT_LPE},
  155. {"UFS", PMC_PSS_BIT_CHT_UFS},
  156. {"UXD", PMC_PSS_BIT_CHT_UXD},
  157. {"UXD_FD", PMC_PSS_BIT_CHT_UXD_FD},
  158. {"UX_ENG", PMC_PSS_BIT_CHT_UX_ENG},
  159. {"USB_SUS", PMC_PSS_BIT_CHT_USB_SUS},
  160. {"GMM", PMC_PSS_BIT_CHT_GMM},
  161. {"ISH", PMC_PSS_BIT_CHT_ISH},
  162. {"DFX_MASTER", PMC_PSS_BIT_CHT_DFX_MASTER},
  163. {"DFX_CLUSTER1", PMC_PSS_BIT_CHT_DFX_CLUSTER1},
  164. {"DFX_CLUSTER2", PMC_PSS_BIT_CHT_DFX_CLUSTER2},
  165. {"DFX_CLUSTER3", PMC_PSS_BIT_CHT_DFX_CLUSTER3},
  166. {"DFX_CLUSTER4", PMC_PSS_BIT_CHT_DFX_CLUSTER4},
  167. {"DFX_CLUSTER5", PMC_PSS_BIT_CHT_DFX_CLUSTER5},
  168. {},
  169. };
  170. static const struct pmc_reg_map byt_reg_map = {
  171. .d3_sts_0 = d3_sts_0_map,
  172. .d3_sts_1 = byt_d3_sts_1_map,
  173. .func_dis = d3_sts_0_map,
  174. .func_dis_2 = byt_d3_sts_1_map,
  175. .pss = byt_pss_map,
  176. };
  177. static const struct pmc_reg_map cht_reg_map = {
  178. .d3_sts_0 = d3_sts_0_map,
  179. .d3_sts_1 = cht_d3_sts_1_map,
  180. .func_dis = d3_sts_0_map,
  181. .func_dis_2 = cht_func_dis_2_map,
  182. .pss = cht_pss_map,
  183. };
  184. static const struct pmc_data byt_data = {
  185. .map = &byt_reg_map,
  186. .clks = byt_clks,
  187. };
  188. static const struct pmc_data cht_data = {
  189. .map = &cht_reg_map,
  190. .clks = cht_clks,
  191. };
  192. static inline u32 pmc_reg_read(struct pmc_dev *pmc, int reg_offset)
  193. {
  194. return readl(pmc->regmap + reg_offset);
  195. }
  196. static inline void pmc_reg_write(struct pmc_dev *pmc, int reg_offset, u32 val)
  197. {
  198. writel(val, pmc->regmap + reg_offset);
  199. }
  200. int pmc_atom_read(int offset, u32 *value)
  201. {
  202. struct pmc_dev *pmc = &pmc_device;
  203. if (!pmc->init)
  204. return -ENODEV;
  205. *value = pmc_reg_read(pmc, offset);
  206. return 0;
  207. }
  208. EXPORT_SYMBOL_GPL(pmc_atom_read);
  209. int pmc_atom_write(int offset, u32 value)
  210. {
  211. struct pmc_dev *pmc = &pmc_device;
  212. if (!pmc->init)
  213. return -ENODEV;
  214. pmc_reg_write(pmc, offset, value);
  215. return 0;
  216. }
  217. EXPORT_SYMBOL_GPL(pmc_atom_write);
  218. static void pmc_power_off(void)
  219. {
  220. u16 pm1_cnt_port;
  221. u32 pm1_cnt_value;
  222. pr_info("Preparing to enter system sleep state S5\n");
  223. pm1_cnt_port = acpi_base_addr + PM1_CNT;
  224. pm1_cnt_value = inl(pm1_cnt_port);
  225. pm1_cnt_value &= SLEEP_TYPE_MASK;
  226. pm1_cnt_value |= SLEEP_TYPE_S5;
  227. pm1_cnt_value |= SLEEP_ENABLE;
  228. outl(pm1_cnt_value, pm1_cnt_port);
  229. }
  230. static void pmc_hw_reg_setup(struct pmc_dev *pmc)
  231. {
  232. /*
  233. * Disable PMC S0IX_WAKE_EN events coming from:
  234. * - LPC clock run
  235. * - GPIO_SUS ored dedicated IRQs
  236. * - GPIO_SCORE ored dedicated IRQs
  237. * - GPIO_SUS shared IRQ
  238. * - GPIO_SCORE shared IRQ
  239. */
  240. pmc_reg_write(pmc, PMC_S0IX_WAKE_EN, (u32)PMC_WAKE_EN_SETTING);
  241. }
  242. #ifdef CONFIG_DEBUG_FS
  243. static void pmc_dev_state_print(struct seq_file *s, int reg_index,
  244. u32 sts, const struct pmc_bit_map *sts_map,
  245. u32 fd, const struct pmc_bit_map *fd_map)
  246. {
  247. int offset = PMC_REG_BIT_WIDTH * reg_index;
  248. int index;
  249. for (index = 0; sts_map[index].name; index++) {
  250. seq_printf(s, "Dev: %-2d - %-32s\tState: %s [%s]\n",
  251. offset + index, sts_map[index].name,
  252. fd_map[index].bit_mask & fd ? "Disabled" : "Enabled ",
  253. sts_map[index].bit_mask & sts ? "D3" : "D0");
  254. }
  255. }
  256. static int pmc_dev_state_show(struct seq_file *s, void *unused)
  257. {
  258. struct pmc_dev *pmc = s->private;
  259. const struct pmc_reg_map *m = pmc->map;
  260. u32 func_dis, func_dis_2;
  261. u32 d3_sts_0, d3_sts_1;
  262. func_dis = pmc_reg_read(pmc, PMC_FUNC_DIS);
  263. func_dis_2 = pmc_reg_read(pmc, PMC_FUNC_DIS_2);
  264. d3_sts_0 = pmc_reg_read(pmc, PMC_D3_STS_0);
  265. d3_sts_1 = pmc_reg_read(pmc, PMC_D3_STS_1);
  266. /* Low part */
  267. pmc_dev_state_print(s, 0, d3_sts_0, m->d3_sts_0, func_dis, m->func_dis);
  268. /* High part */
  269. pmc_dev_state_print(s, 1, d3_sts_1, m->d3_sts_1, func_dis_2, m->func_dis_2);
  270. return 0;
  271. }
  272. static int pmc_dev_state_open(struct inode *inode, struct file *file)
  273. {
  274. return single_open(file, pmc_dev_state_show, inode->i_private);
  275. }
  276. static const struct file_operations pmc_dev_state_ops = {
  277. .open = pmc_dev_state_open,
  278. .read = seq_read,
  279. .llseek = seq_lseek,
  280. .release = single_release,
  281. };
  282. static int pmc_pss_state_show(struct seq_file *s, void *unused)
  283. {
  284. struct pmc_dev *pmc = s->private;
  285. const struct pmc_bit_map *map = pmc->map->pss;
  286. u32 pss = pmc_reg_read(pmc, PMC_PSS);
  287. int index;
  288. for (index = 0; map[index].name; index++) {
  289. seq_printf(s, "Island: %-2d - %-32s\tState: %s\n",
  290. index, map[index].name,
  291. map[index].bit_mask & pss ? "Off" : "On");
  292. }
  293. return 0;
  294. }
  295. static int pmc_pss_state_open(struct inode *inode, struct file *file)
  296. {
  297. return single_open(file, pmc_pss_state_show, inode->i_private);
  298. }
  299. static const struct file_operations pmc_pss_state_ops = {
  300. .open = pmc_pss_state_open,
  301. .read = seq_read,
  302. .llseek = seq_lseek,
  303. .release = single_release,
  304. };
  305. static int pmc_sleep_tmr_show(struct seq_file *s, void *unused)
  306. {
  307. struct pmc_dev *pmc = s->private;
  308. u64 s0ir_tmr, s0i1_tmr, s0i2_tmr, s0i3_tmr, s0_tmr;
  309. s0ir_tmr = (u64)pmc_reg_read(pmc, PMC_S0IR_TMR) << PMC_TMR_SHIFT;
  310. s0i1_tmr = (u64)pmc_reg_read(pmc, PMC_S0I1_TMR) << PMC_TMR_SHIFT;
  311. s0i2_tmr = (u64)pmc_reg_read(pmc, PMC_S0I2_TMR) << PMC_TMR_SHIFT;
  312. s0i3_tmr = (u64)pmc_reg_read(pmc, PMC_S0I3_TMR) << PMC_TMR_SHIFT;
  313. s0_tmr = (u64)pmc_reg_read(pmc, PMC_S0_TMR) << PMC_TMR_SHIFT;
  314. seq_printf(s, "S0IR Residency:\t%lldus\n", s0ir_tmr);
  315. seq_printf(s, "S0I1 Residency:\t%lldus\n", s0i1_tmr);
  316. seq_printf(s, "S0I2 Residency:\t%lldus\n", s0i2_tmr);
  317. seq_printf(s, "S0I3 Residency:\t%lldus\n", s0i3_tmr);
  318. seq_printf(s, "S0 Residency:\t%lldus\n", s0_tmr);
  319. return 0;
  320. }
  321. static int pmc_sleep_tmr_open(struct inode *inode, struct file *file)
  322. {
  323. return single_open(file, pmc_sleep_tmr_show, inode->i_private);
  324. }
  325. static const struct file_operations pmc_sleep_tmr_ops = {
  326. .open = pmc_sleep_tmr_open,
  327. .read = seq_read,
  328. .llseek = seq_lseek,
  329. .release = single_release,
  330. };
  331. static void pmc_dbgfs_unregister(struct pmc_dev *pmc)
  332. {
  333. debugfs_remove_recursive(pmc->dbgfs_dir);
  334. }
  335. static int pmc_dbgfs_register(struct pmc_dev *pmc)
  336. {
  337. struct dentry *dir, *f;
  338. dir = debugfs_create_dir("pmc_atom", NULL);
  339. if (!dir)
  340. return -ENOMEM;
  341. pmc->dbgfs_dir = dir;
  342. f = debugfs_create_file("dev_state", S_IFREG | S_IRUGO,
  343. dir, pmc, &pmc_dev_state_ops);
  344. if (!f)
  345. goto err;
  346. f = debugfs_create_file("pss_state", S_IFREG | S_IRUGO,
  347. dir, pmc, &pmc_pss_state_ops);
  348. if (!f)
  349. goto err;
  350. f = debugfs_create_file("sleep_state", S_IFREG | S_IRUGO,
  351. dir, pmc, &pmc_sleep_tmr_ops);
  352. if (!f)
  353. goto err;
  354. return 0;
  355. err:
  356. pmc_dbgfs_unregister(pmc);
  357. return -ENODEV;
  358. }
  359. #else
  360. static int pmc_dbgfs_register(struct pmc_dev *pmc)
  361. {
  362. return 0;
  363. }
  364. #endif /* CONFIG_DEBUG_FS */
  365. /*
  366. * Some systems need one or more of their pmc_plt_clks to be
  367. * marked as critical.
  368. */
  369. static const struct dmi_system_id critclk_systems[] = {
  370. {
  371. /* pmc_plt_clk0 is used for an external HSIC USB HUB */
  372. .ident = "MPL CEC1x",
  373. .matches = {
  374. DMI_MATCH(DMI_SYS_VENDOR, "MPL AG"),
  375. DMI_MATCH(DMI_PRODUCT_NAME, "CEC10 Family"),
  376. },
  377. },
  378. {
  379. /* pmc_plt_clk0 - 3 are used for the 4 ethernet controllers */
  380. .ident = "Lex 3I380D",
  381. .matches = {
  382. DMI_MATCH(DMI_SYS_VENDOR, "Lex BayTrail"),
  383. DMI_MATCH(DMI_PRODUCT_NAME, "3I380D"),
  384. },
  385. },
  386. {
  387. /* pmc_plt_clk* - are used for ethernet controllers */
  388. .ident = "Lex 2I385SW",
  389. .matches = {
  390. DMI_MATCH(DMI_SYS_VENDOR, "Lex BayTrail"),
  391. DMI_MATCH(DMI_PRODUCT_NAME, "2I385SW"),
  392. },
  393. },
  394. {
  395. /* pmc_plt_clk* - are used for ethernet controllers */
  396. .ident = "Beckhoff Baytrail",
  397. .matches = {
  398. DMI_MATCH(DMI_SYS_VENDOR, "Beckhoff Automation"),
  399. DMI_MATCH(DMI_PRODUCT_FAMILY, "CBxx63"),
  400. },
  401. },
  402. {
  403. .ident = "SIMATIC IPC227E",
  404. .matches = {
  405. DMI_MATCH(DMI_SYS_VENDOR, "SIEMENS AG"),
  406. DMI_MATCH(DMI_PRODUCT_VERSION, "6ES7647-8B"),
  407. },
  408. },
  409. {
  410. .ident = "CONNECT X300",
  411. .matches = {
  412. DMI_MATCH(DMI_SYS_VENDOR, "SIEMENS AG"),
  413. DMI_MATCH(DMI_PRODUCT_VERSION, "A5E45074588"),
  414. },
  415. },
  416. { /*sentinel*/ }
  417. };
  418. static int pmc_setup_clks(struct pci_dev *pdev, void __iomem *pmc_regmap,
  419. const struct pmc_data *pmc_data)
  420. {
  421. struct platform_device *clkdev;
  422. struct pmc_clk_data *clk_data;
  423. const struct dmi_system_id *d = dmi_first_match(critclk_systems);
  424. clk_data = kzalloc(sizeof(*clk_data), GFP_KERNEL);
  425. if (!clk_data)
  426. return -ENOMEM;
  427. clk_data->base = pmc_regmap; /* offset is added by client */
  428. clk_data->clks = pmc_data->clks;
  429. if (d) {
  430. clk_data->critical = true;
  431. pr_info("%s critclks quirk enabled\n", d->ident);
  432. }
  433. clkdev = platform_device_register_data(&pdev->dev, "clk-pmc-atom",
  434. PLATFORM_DEVID_NONE,
  435. clk_data, sizeof(*clk_data));
  436. if (IS_ERR(clkdev)) {
  437. kfree(clk_data);
  438. return PTR_ERR(clkdev);
  439. }
  440. kfree(clk_data);
  441. return 0;
  442. }
  443. static int pmc_setup_dev(struct pci_dev *pdev, const struct pci_device_id *ent)
  444. {
  445. struct pmc_dev *pmc = &pmc_device;
  446. const struct pmc_data *data = (struct pmc_data *)ent->driver_data;
  447. const struct pmc_reg_map *map = data->map;
  448. int ret;
  449. /* Obtain ACPI base address */
  450. pci_read_config_dword(pdev, ACPI_BASE_ADDR_OFFSET, &acpi_base_addr);
  451. acpi_base_addr &= ACPI_BASE_ADDR_MASK;
  452. /* Install power off function */
  453. if (acpi_base_addr != 0 && pm_power_off == NULL)
  454. pm_power_off = pmc_power_off;
  455. pci_read_config_dword(pdev, PMC_BASE_ADDR_OFFSET, &pmc->base_addr);
  456. pmc->base_addr &= PMC_BASE_ADDR_MASK;
  457. pmc->regmap = ioremap_nocache(pmc->base_addr, PMC_MMIO_REG_LEN);
  458. if (!pmc->regmap) {
  459. dev_err(&pdev->dev, "error: ioremap failed\n");
  460. return -ENOMEM;
  461. }
  462. pmc->map = map;
  463. /* PMC hardware registers setup */
  464. pmc_hw_reg_setup(pmc);
  465. ret = pmc_dbgfs_register(pmc);
  466. if (ret)
  467. dev_warn(&pdev->dev, "debugfs register failed\n");
  468. /* Register platform clocks - PMC_PLT_CLK [0..5] */
  469. ret = pmc_setup_clks(pdev, pmc->regmap, data);
  470. if (ret)
  471. dev_warn(&pdev->dev, "platform clocks register failed: %d\n",
  472. ret);
  473. pmc->init = true;
  474. return ret;
  475. }
  476. /*
  477. * Data for PCI driver interface
  478. *
  479. * used by pci_match_id() call below.
  480. */
  481. static const struct pci_device_id pmc_pci_ids[] = {
  482. { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_VLV_PMC), (kernel_ulong_t)&byt_data },
  483. { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_CHT_PMC), (kernel_ulong_t)&cht_data },
  484. { 0, },
  485. };
  486. static int __init pmc_atom_init(void)
  487. {
  488. struct pci_dev *pdev = NULL;
  489. const struct pci_device_id *ent;
  490. /* We look for our device - PCU PMC
  491. * we assume that there is max. one device.
  492. *
  493. * We can't use plain pci_driver mechanism,
  494. * as the device is really a multiple function device,
  495. * main driver that binds to the pci_device is lpc_ich
  496. * and have to find & bind to the device this way.
  497. */
  498. for_each_pci_dev(pdev) {
  499. ent = pci_match_id(pmc_pci_ids, pdev);
  500. if (ent)
  501. return pmc_setup_dev(pdev, ent);
  502. }
  503. /* Device not found. */
  504. return -ENODEV;
  505. }
  506. device_initcall(pmc_atom_init);
  507. /*
  508. MODULE_AUTHOR("Aubrey Li <aubrey.li@linux.intel.com>");
  509. MODULE_DESCRIPTION("Intel Atom SOC Power Management Controller Interface");
  510. MODULE_LICENSE("GPL v2");
  511. */