lpc_ich.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888
  1. /*
  2. * lpc_ich.c - LPC interface for Intel ICH
  3. *
  4. * LPC bridge function of the Intel ICH contains many other
  5. * functional units, such as Interrupt controllers, Timers,
  6. * Power Management, System Management, GPIO, RTC, and LPC
  7. * Configuration Registers.
  8. *
  9. * This driver is derived from lpc_sch.
  10. * Copyright (c) 2011 Extreme Engineering Solution, Inc.
  11. * Author: Aaron Sierra <asierra@xes-inc.com>
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License 2 as published
  15. * by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; see the file COPYING. If not, write to
  24. * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  25. *
  26. * This driver supports the following I/O Controller hubs:
  27. * (See the intel documentation on http://developer.intel.com.)
  28. * document number 290655-003, 290677-014: 82801AA (ICH), 82801AB (ICHO)
  29. * document number 290687-002, 298242-027: 82801BA (ICH2)
  30. * document number 290733-003, 290739-013: 82801CA (ICH3-S)
  31. * document number 290716-001, 290718-007: 82801CAM (ICH3-M)
  32. * document number 290744-001, 290745-025: 82801DB (ICH4)
  33. * document number 252337-001, 252663-008: 82801DBM (ICH4-M)
  34. * document number 273599-001, 273645-002: 82801E (C-ICH)
  35. * document number 252516-001, 252517-028: 82801EB (ICH5), 82801ER (ICH5R)
  36. * document number 300641-004, 300884-013: 6300ESB
  37. * document number 301473-002, 301474-026: 82801F (ICH6)
  38. * document number 313082-001, 313075-006: 631xESB, 632xESB
  39. * document number 307013-003, 307014-024: 82801G (ICH7)
  40. * document number 322896-001, 322897-001: NM10
  41. * document number 313056-003, 313057-017: 82801H (ICH8)
  42. * document number 316972-004, 316973-012: 82801I (ICH9)
  43. * document number 319973-002, 319974-002: 82801J (ICH10)
  44. * document number 322169-001, 322170-003: 5 Series, 3400 Series (PCH)
  45. * document number 320066-003, 320257-008: EP80597 (IICH)
  46. * document number 324645-001, 324646-001: Cougar Point (CPT)
  47. * document number TBD : Patsburg (PBG)
  48. * document number TBD : DH89xxCC
  49. * document number TBD : Panther Point
  50. * document number TBD : Lynx Point
  51. */
  52. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  53. #include <linux/init.h>
  54. #include <linux/kernel.h>
  55. #include <linux/module.h>
  56. #include <linux/errno.h>
  57. #include <linux/acpi.h>
  58. #include <linux/pci.h>
  59. #include <linux/mfd/core.h>
  60. #include <linux/mfd/lpc_ich.h>
  61. #define ACPIBASE 0x40
  62. #define ACPIBASE_GPE_OFF 0x28
  63. #define ACPIBASE_GPE_END 0x2f
  64. #define ACPIBASE_SMI_OFF 0x30
  65. #define ACPIBASE_SMI_END 0x33
  66. #define ACPIBASE_TCO_OFF 0x60
  67. #define ACPIBASE_TCO_END 0x7f
  68. #define ACPICTRL 0x44
  69. #define ACPIBASE_GCS_OFF 0x3410
  70. #define ACPIBASE_GCS_END 0x3414
  71. #define GPIOBASE 0x48
  72. #define GPIOCTRL 0x4C
  73. #define RCBABASE 0xf0
  74. #define wdt_io_res(i) wdt_res(0, i)
  75. #define wdt_mem_res(i) wdt_res(ICH_RES_MEM_OFF, i)
  76. #define wdt_res(b, i) (&wdt_ich_res[(b) + (i)])
  77. static int lpc_ich_acpi_save = -1;
  78. static int lpc_ich_gpio_save = -1;
  79. static struct resource wdt_ich_res[] = {
  80. /* ACPI - TCO */
  81. {
  82. .flags = IORESOURCE_IO,
  83. },
  84. /* ACPI - SMI */
  85. {
  86. .flags = IORESOURCE_IO,
  87. },
  88. /* GCS */
  89. {
  90. .flags = IORESOURCE_MEM,
  91. },
  92. };
  93. static struct resource gpio_ich_res[] = {
  94. /* GPIO */
  95. {
  96. .flags = IORESOURCE_IO,
  97. },
  98. /* ACPI - GPE0 */
  99. {
  100. .flags = IORESOURCE_IO,
  101. },
  102. };
  103. enum lpc_cells {
  104. LPC_WDT = 0,
  105. LPC_GPIO,
  106. };
  107. static struct mfd_cell lpc_ich_cells[] = {
  108. [LPC_WDT] = {
  109. .name = "iTCO_wdt",
  110. .num_resources = ARRAY_SIZE(wdt_ich_res),
  111. .resources = wdt_ich_res,
  112. .ignore_resource_conflicts = true,
  113. },
  114. [LPC_GPIO] = {
  115. .name = "gpio_ich",
  116. .num_resources = ARRAY_SIZE(gpio_ich_res),
  117. .resources = gpio_ich_res,
  118. .ignore_resource_conflicts = true,
  119. },
  120. };
  121. /* chipset related info */
  122. enum lpc_chipsets {
  123. LPC_ICH = 0, /* ICH */
  124. LPC_ICH0, /* ICH0 */
  125. LPC_ICH2, /* ICH2 */
  126. LPC_ICH2M, /* ICH2-M */
  127. LPC_ICH3, /* ICH3-S */
  128. LPC_ICH3M, /* ICH3-M */
  129. LPC_ICH4, /* ICH4 */
  130. LPC_ICH4M, /* ICH4-M */
  131. LPC_CICH, /* C-ICH */
  132. LPC_ICH5, /* ICH5 & ICH5R */
  133. LPC_6300ESB, /* 6300ESB */
  134. LPC_ICH6, /* ICH6 & ICH6R */
  135. LPC_ICH6M, /* ICH6-M */
  136. LPC_ICH6W, /* ICH6W & ICH6RW */
  137. LPC_631XESB, /* 631xESB/632xESB */
  138. LPC_ICH7, /* ICH7 & ICH7R */
  139. LPC_ICH7DH, /* ICH7DH */
  140. LPC_ICH7M, /* ICH7-M & ICH7-U */
  141. LPC_ICH7MDH, /* ICH7-M DH */
  142. LPC_NM10, /* NM10 */
  143. LPC_ICH8, /* ICH8 & ICH8R */
  144. LPC_ICH8DH, /* ICH8DH */
  145. LPC_ICH8DO, /* ICH8DO */
  146. LPC_ICH8M, /* ICH8M */
  147. LPC_ICH8ME, /* ICH8M-E */
  148. LPC_ICH9, /* ICH9 */
  149. LPC_ICH9R, /* ICH9R */
  150. LPC_ICH9DH, /* ICH9DH */
  151. LPC_ICH9DO, /* ICH9DO */
  152. LPC_ICH9M, /* ICH9M */
  153. LPC_ICH9ME, /* ICH9M-E */
  154. LPC_ICH10, /* ICH10 */
  155. LPC_ICH10R, /* ICH10R */
  156. LPC_ICH10D, /* ICH10D */
  157. LPC_ICH10DO, /* ICH10DO */
  158. LPC_PCH, /* PCH Desktop Full Featured */
  159. LPC_PCHM, /* PCH Mobile Full Featured */
  160. LPC_P55, /* P55 */
  161. LPC_PM55, /* PM55 */
  162. LPC_H55, /* H55 */
  163. LPC_QM57, /* QM57 */
  164. LPC_H57, /* H57 */
  165. LPC_HM55, /* HM55 */
  166. LPC_Q57, /* Q57 */
  167. LPC_HM57, /* HM57 */
  168. LPC_PCHMSFF, /* PCH Mobile SFF Full Featured */
  169. LPC_QS57, /* QS57 */
  170. LPC_3400, /* 3400 */
  171. LPC_3420, /* 3420 */
  172. LPC_3450, /* 3450 */
  173. LPC_EP80579, /* EP80579 */
  174. LPC_CPT, /* Cougar Point */
  175. LPC_CPTD, /* Cougar Point Desktop */
  176. LPC_CPTM, /* Cougar Point Mobile */
  177. LPC_PBG, /* Patsburg */
  178. LPC_DH89XXCC, /* DH89xxCC */
  179. LPC_PPT, /* Panther Point */
  180. LPC_LPT, /* Lynx Point */
  181. };
  182. struct lpc_ich_info lpc_chipset_info[] __devinitdata = {
  183. [LPC_ICH] = {
  184. .name = "ICH",
  185. .iTCO_version = 1,
  186. },
  187. [LPC_ICH0] = {
  188. .name = "ICH0",
  189. .iTCO_version = 1,
  190. },
  191. [LPC_ICH2] = {
  192. .name = "ICH2",
  193. .iTCO_version = 1,
  194. },
  195. [LPC_ICH2M] = {
  196. .name = "ICH2-M",
  197. .iTCO_version = 1,
  198. },
  199. [LPC_ICH3] = {
  200. .name = "ICH3-S",
  201. .iTCO_version = 1,
  202. },
  203. [LPC_ICH3M] = {
  204. .name = "ICH3-M",
  205. .iTCO_version = 1,
  206. },
  207. [LPC_ICH4] = {
  208. .name = "ICH4",
  209. .iTCO_version = 1,
  210. },
  211. [LPC_ICH4M] = {
  212. .name = "ICH4-M",
  213. .iTCO_version = 1,
  214. },
  215. [LPC_CICH] = {
  216. .name = "C-ICH",
  217. .iTCO_version = 1,
  218. },
  219. [LPC_ICH5] = {
  220. .name = "ICH5 or ICH5R",
  221. .iTCO_version = 1,
  222. },
  223. [LPC_6300ESB] = {
  224. .name = "6300ESB",
  225. .iTCO_version = 1,
  226. },
  227. [LPC_ICH6] = {
  228. .name = "ICH6 or ICH6R",
  229. .iTCO_version = 2,
  230. .gpio_version = ICH_V6_GPIO,
  231. },
  232. [LPC_ICH6M] = {
  233. .name = "ICH6-M",
  234. .iTCO_version = 2,
  235. .gpio_version = ICH_V6_GPIO,
  236. },
  237. [LPC_ICH6W] = {
  238. .name = "ICH6W or ICH6RW",
  239. .iTCO_version = 2,
  240. .gpio_version = ICH_V6_GPIO,
  241. },
  242. [LPC_631XESB] = {
  243. .name = "631xESB/632xESB",
  244. .iTCO_version = 2,
  245. .gpio_version = ICH_V6_GPIO,
  246. },
  247. [LPC_ICH7] = {
  248. .name = "ICH7 or ICH7R",
  249. .iTCO_version = 2,
  250. .gpio_version = ICH_V7_GPIO,
  251. },
  252. [LPC_ICH7DH] = {
  253. .name = "ICH7DH",
  254. .iTCO_version = 2,
  255. .gpio_version = ICH_V7_GPIO,
  256. },
  257. [LPC_ICH7M] = {
  258. .name = "ICH7-M or ICH7-U",
  259. .iTCO_version = 2,
  260. .gpio_version = ICH_V7_GPIO,
  261. },
  262. [LPC_ICH7MDH] = {
  263. .name = "ICH7-M DH",
  264. .iTCO_version = 2,
  265. .gpio_version = ICH_V7_GPIO,
  266. },
  267. [LPC_NM10] = {
  268. .name = "NM10",
  269. .iTCO_version = 2,
  270. },
  271. [LPC_ICH8] = {
  272. .name = "ICH8 or ICH8R",
  273. .iTCO_version = 2,
  274. .gpio_version = ICH_V7_GPIO,
  275. },
  276. [LPC_ICH8DH] = {
  277. .name = "ICH8DH",
  278. .iTCO_version = 2,
  279. .gpio_version = ICH_V7_GPIO,
  280. },
  281. [LPC_ICH8DO] = {
  282. .name = "ICH8DO",
  283. .iTCO_version = 2,
  284. .gpio_version = ICH_V7_GPIO,
  285. },
  286. [LPC_ICH8M] = {
  287. .name = "ICH8M",
  288. .iTCO_version = 2,
  289. .gpio_version = ICH_V7_GPIO,
  290. },
  291. [LPC_ICH8ME] = {
  292. .name = "ICH8M-E",
  293. .iTCO_version = 2,
  294. .gpio_version = ICH_V7_GPIO,
  295. },
  296. [LPC_ICH9] = {
  297. .name = "ICH9",
  298. .iTCO_version = 2,
  299. .gpio_version = ICH_V9_GPIO,
  300. },
  301. [LPC_ICH9R] = {
  302. .name = "ICH9R",
  303. .iTCO_version = 2,
  304. .gpio_version = ICH_V9_GPIO,
  305. },
  306. [LPC_ICH9DH] = {
  307. .name = "ICH9DH",
  308. .iTCO_version = 2,
  309. .gpio_version = ICH_V9_GPIO,
  310. },
  311. [LPC_ICH9DO] = {
  312. .name = "ICH9DO",
  313. .iTCO_version = 2,
  314. .gpio_version = ICH_V9_GPIO,
  315. },
  316. [LPC_ICH9M] = {
  317. .name = "ICH9M",
  318. .iTCO_version = 2,
  319. .gpio_version = ICH_V9_GPIO,
  320. },
  321. [LPC_ICH9ME] = {
  322. .name = "ICH9M-E",
  323. .iTCO_version = 2,
  324. .gpio_version = ICH_V9_GPIO,
  325. },
  326. [LPC_ICH10] = {
  327. .name = "ICH10",
  328. .iTCO_version = 2,
  329. .gpio_version = ICH_V10CONS_GPIO,
  330. },
  331. [LPC_ICH10R] = {
  332. .name = "ICH10R",
  333. .iTCO_version = 2,
  334. .gpio_version = ICH_V10CONS_GPIO,
  335. },
  336. [LPC_ICH10D] = {
  337. .name = "ICH10D",
  338. .iTCO_version = 2,
  339. .gpio_version = ICH_V10CORP_GPIO,
  340. },
  341. [LPC_ICH10DO] = {
  342. .name = "ICH10DO",
  343. .iTCO_version = 2,
  344. .gpio_version = ICH_V10CORP_GPIO,
  345. },
  346. [LPC_PCH] = {
  347. .name = "PCH Desktop Full Featured",
  348. .iTCO_version = 2,
  349. .gpio_version = ICH_V5_GPIO,
  350. },
  351. [LPC_PCHM] = {
  352. .name = "PCH Mobile Full Featured",
  353. .iTCO_version = 2,
  354. .gpio_version = ICH_V5_GPIO,
  355. },
  356. [LPC_P55] = {
  357. .name = "P55",
  358. .iTCO_version = 2,
  359. .gpio_version = ICH_V5_GPIO,
  360. },
  361. [LPC_PM55] = {
  362. .name = "PM55",
  363. .iTCO_version = 2,
  364. .gpio_version = ICH_V5_GPIO,
  365. },
  366. [LPC_H55] = {
  367. .name = "H55",
  368. .iTCO_version = 2,
  369. .gpio_version = ICH_V5_GPIO,
  370. },
  371. [LPC_QM57] = {
  372. .name = "QM57",
  373. .iTCO_version = 2,
  374. .gpio_version = ICH_V5_GPIO,
  375. },
  376. [LPC_H57] = {
  377. .name = "H57",
  378. .iTCO_version = 2,
  379. .gpio_version = ICH_V5_GPIO,
  380. },
  381. [LPC_HM55] = {
  382. .name = "HM55",
  383. .iTCO_version = 2,
  384. .gpio_version = ICH_V5_GPIO,
  385. },
  386. [LPC_Q57] = {
  387. .name = "Q57",
  388. .iTCO_version = 2,
  389. .gpio_version = ICH_V5_GPIO,
  390. },
  391. [LPC_HM57] = {
  392. .name = "HM57",
  393. .iTCO_version = 2,
  394. .gpio_version = ICH_V5_GPIO,
  395. },
  396. [LPC_PCHMSFF] = {
  397. .name = "PCH Mobile SFF Full Featured",
  398. .iTCO_version = 2,
  399. .gpio_version = ICH_V5_GPIO,
  400. },
  401. [LPC_QS57] = {
  402. .name = "QS57",
  403. .iTCO_version = 2,
  404. .gpio_version = ICH_V5_GPIO,
  405. },
  406. [LPC_3400] = {
  407. .name = "3400",
  408. .iTCO_version = 2,
  409. .gpio_version = ICH_V5_GPIO,
  410. },
  411. [LPC_3420] = {
  412. .name = "3420",
  413. .iTCO_version = 2,
  414. .gpio_version = ICH_V5_GPIO,
  415. },
  416. [LPC_3450] = {
  417. .name = "3450",
  418. .iTCO_version = 2,
  419. .gpio_version = ICH_V5_GPIO,
  420. },
  421. [LPC_EP80579] = {
  422. .name = "EP80579",
  423. .iTCO_version = 2,
  424. },
  425. [LPC_CPT] = {
  426. .name = "Cougar Point",
  427. .iTCO_version = 2,
  428. .gpio_version = ICH_V5_GPIO,
  429. },
  430. [LPC_CPTD] = {
  431. .name = "Cougar Point Desktop",
  432. .iTCO_version = 2,
  433. .gpio_version = ICH_V5_GPIO,
  434. },
  435. [LPC_CPTM] = {
  436. .name = "Cougar Point Mobile",
  437. .iTCO_version = 2,
  438. .gpio_version = ICH_V5_GPIO,
  439. },
  440. [LPC_PBG] = {
  441. .name = "Patsburg",
  442. .iTCO_version = 2,
  443. },
  444. [LPC_DH89XXCC] = {
  445. .name = "DH89xxCC",
  446. .iTCO_version = 2,
  447. },
  448. [LPC_PPT] = {
  449. .name = "Panther Point",
  450. .iTCO_version = 2,
  451. },
  452. [LPC_LPT] = {
  453. .name = "Lynx Point",
  454. .iTCO_version = 2,
  455. },
  456. };
  457. /*
  458. * This data only exists for exporting the supported PCI ids
  459. * via MODULE_DEVICE_TABLE. We do not actually register a
  460. * pci_driver, because the I/O Controller Hub has also other
  461. * functions that probably will be registered by other drivers.
  462. */
  463. static DEFINE_PCI_DEVICE_TABLE(lpc_ich_ids) = {
  464. { PCI_VDEVICE(INTEL, 0x2410), LPC_ICH},
  465. { PCI_VDEVICE(INTEL, 0x2420), LPC_ICH0},
  466. { PCI_VDEVICE(INTEL, 0x2440), LPC_ICH2},
  467. { PCI_VDEVICE(INTEL, 0x244c), LPC_ICH2M},
  468. { PCI_VDEVICE(INTEL, 0x2480), LPC_ICH3},
  469. { PCI_VDEVICE(INTEL, 0x248c), LPC_ICH3M},
  470. { PCI_VDEVICE(INTEL, 0x24c0), LPC_ICH4},
  471. { PCI_VDEVICE(INTEL, 0x24cc), LPC_ICH4M},
  472. { PCI_VDEVICE(INTEL, 0x2450), LPC_CICH},
  473. { PCI_VDEVICE(INTEL, 0x24d0), LPC_ICH5},
  474. { PCI_VDEVICE(INTEL, 0x25a1), LPC_6300ESB},
  475. { PCI_VDEVICE(INTEL, 0x2640), LPC_ICH6},
  476. { PCI_VDEVICE(INTEL, 0x2641), LPC_ICH6M},
  477. { PCI_VDEVICE(INTEL, 0x2642), LPC_ICH6W},
  478. { PCI_VDEVICE(INTEL, 0x2670), LPC_631XESB},
  479. { PCI_VDEVICE(INTEL, 0x2671), LPC_631XESB},
  480. { PCI_VDEVICE(INTEL, 0x2672), LPC_631XESB},
  481. { PCI_VDEVICE(INTEL, 0x2673), LPC_631XESB},
  482. { PCI_VDEVICE(INTEL, 0x2674), LPC_631XESB},
  483. { PCI_VDEVICE(INTEL, 0x2675), LPC_631XESB},
  484. { PCI_VDEVICE(INTEL, 0x2676), LPC_631XESB},
  485. { PCI_VDEVICE(INTEL, 0x2677), LPC_631XESB},
  486. { PCI_VDEVICE(INTEL, 0x2678), LPC_631XESB},
  487. { PCI_VDEVICE(INTEL, 0x2679), LPC_631XESB},
  488. { PCI_VDEVICE(INTEL, 0x267a), LPC_631XESB},
  489. { PCI_VDEVICE(INTEL, 0x267b), LPC_631XESB},
  490. { PCI_VDEVICE(INTEL, 0x267c), LPC_631XESB},
  491. { PCI_VDEVICE(INTEL, 0x267d), LPC_631XESB},
  492. { PCI_VDEVICE(INTEL, 0x267e), LPC_631XESB},
  493. { PCI_VDEVICE(INTEL, 0x267f), LPC_631XESB},
  494. { PCI_VDEVICE(INTEL, 0x27b8), LPC_ICH7},
  495. { PCI_VDEVICE(INTEL, 0x27b0), LPC_ICH7DH},
  496. { PCI_VDEVICE(INTEL, 0x27b9), LPC_ICH7M},
  497. { PCI_VDEVICE(INTEL, 0x27bd), LPC_ICH7MDH},
  498. { PCI_VDEVICE(INTEL, 0x27bc), LPC_NM10},
  499. { PCI_VDEVICE(INTEL, 0x2810), LPC_ICH8},
  500. { PCI_VDEVICE(INTEL, 0x2812), LPC_ICH8DH},
  501. { PCI_VDEVICE(INTEL, 0x2814), LPC_ICH8DO},
  502. { PCI_VDEVICE(INTEL, 0x2815), LPC_ICH8M},
  503. { PCI_VDEVICE(INTEL, 0x2811), LPC_ICH8ME},
  504. { PCI_VDEVICE(INTEL, 0x2918), LPC_ICH9},
  505. { PCI_VDEVICE(INTEL, 0x2916), LPC_ICH9R},
  506. { PCI_VDEVICE(INTEL, 0x2912), LPC_ICH9DH},
  507. { PCI_VDEVICE(INTEL, 0x2914), LPC_ICH9DO},
  508. { PCI_VDEVICE(INTEL, 0x2919), LPC_ICH9M},
  509. { PCI_VDEVICE(INTEL, 0x2917), LPC_ICH9ME},
  510. { PCI_VDEVICE(INTEL, 0x3a18), LPC_ICH10},
  511. { PCI_VDEVICE(INTEL, 0x3a16), LPC_ICH10R},
  512. { PCI_VDEVICE(INTEL, 0x3a1a), LPC_ICH10D},
  513. { PCI_VDEVICE(INTEL, 0x3a14), LPC_ICH10DO},
  514. { PCI_VDEVICE(INTEL, 0x3b00), LPC_PCH},
  515. { PCI_VDEVICE(INTEL, 0x3b01), LPC_PCHM},
  516. { PCI_VDEVICE(INTEL, 0x3b02), LPC_P55},
  517. { PCI_VDEVICE(INTEL, 0x3b03), LPC_PM55},
  518. { PCI_VDEVICE(INTEL, 0x3b06), LPC_H55},
  519. { PCI_VDEVICE(INTEL, 0x3b07), LPC_QM57},
  520. { PCI_VDEVICE(INTEL, 0x3b08), LPC_H57},
  521. { PCI_VDEVICE(INTEL, 0x3b09), LPC_HM55},
  522. { PCI_VDEVICE(INTEL, 0x3b0a), LPC_Q57},
  523. { PCI_VDEVICE(INTEL, 0x3b0b), LPC_HM57},
  524. { PCI_VDEVICE(INTEL, 0x3b0d), LPC_PCHMSFF},
  525. { PCI_VDEVICE(INTEL, 0x3b0f), LPC_QS57},
  526. { PCI_VDEVICE(INTEL, 0x3b12), LPC_3400},
  527. { PCI_VDEVICE(INTEL, 0x3b14), LPC_3420},
  528. { PCI_VDEVICE(INTEL, 0x3b16), LPC_3450},
  529. { PCI_VDEVICE(INTEL, 0x5031), LPC_EP80579},
  530. { PCI_VDEVICE(INTEL, 0x1c41), LPC_CPT},
  531. { PCI_VDEVICE(INTEL, 0x1c42), LPC_CPTD},
  532. { PCI_VDEVICE(INTEL, 0x1c43), LPC_CPTM},
  533. { PCI_VDEVICE(INTEL, 0x1c44), LPC_CPT},
  534. { PCI_VDEVICE(INTEL, 0x1c45), LPC_CPT},
  535. { PCI_VDEVICE(INTEL, 0x1c46), LPC_CPT},
  536. { PCI_VDEVICE(INTEL, 0x1c47), LPC_CPT},
  537. { PCI_VDEVICE(INTEL, 0x1c48), LPC_CPT},
  538. { PCI_VDEVICE(INTEL, 0x1c49), LPC_CPT},
  539. { PCI_VDEVICE(INTEL, 0x1c4a), LPC_CPT},
  540. { PCI_VDEVICE(INTEL, 0x1c4b), LPC_CPT},
  541. { PCI_VDEVICE(INTEL, 0x1c4c), LPC_CPT},
  542. { PCI_VDEVICE(INTEL, 0x1c4d), LPC_CPT},
  543. { PCI_VDEVICE(INTEL, 0x1c4e), LPC_CPT},
  544. { PCI_VDEVICE(INTEL, 0x1c4f), LPC_CPT},
  545. { PCI_VDEVICE(INTEL, 0x1c50), LPC_CPT},
  546. { PCI_VDEVICE(INTEL, 0x1c51), LPC_CPT},
  547. { PCI_VDEVICE(INTEL, 0x1c52), LPC_CPT},
  548. { PCI_VDEVICE(INTEL, 0x1c53), LPC_CPT},
  549. { PCI_VDEVICE(INTEL, 0x1c54), LPC_CPT},
  550. { PCI_VDEVICE(INTEL, 0x1c55), LPC_CPT},
  551. { PCI_VDEVICE(INTEL, 0x1c56), LPC_CPT},
  552. { PCI_VDEVICE(INTEL, 0x1c57), LPC_CPT},
  553. { PCI_VDEVICE(INTEL, 0x1c58), LPC_CPT},
  554. { PCI_VDEVICE(INTEL, 0x1c59), LPC_CPT},
  555. { PCI_VDEVICE(INTEL, 0x1c5a), LPC_CPT},
  556. { PCI_VDEVICE(INTEL, 0x1c5b), LPC_CPT},
  557. { PCI_VDEVICE(INTEL, 0x1c5c), LPC_CPT},
  558. { PCI_VDEVICE(INTEL, 0x1c5d), LPC_CPT},
  559. { PCI_VDEVICE(INTEL, 0x1c5e), LPC_CPT},
  560. { PCI_VDEVICE(INTEL, 0x1c5f), LPC_CPT},
  561. { PCI_VDEVICE(INTEL, 0x1d40), LPC_PBG},
  562. { PCI_VDEVICE(INTEL, 0x1d41), LPC_PBG},
  563. { PCI_VDEVICE(INTEL, 0x2310), LPC_DH89XXCC},
  564. { PCI_VDEVICE(INTEL, 0x1e40), LPC_PPT},
  565. { PCI_VDEVICE(INTEL, 0x1e41), LPC_PPT},
  566. { PCI_VDEVICE(INTEL, 0x1e42), LPC_PPT},
  567. { PCI_VDEVICE(INTEL, 0x1e43), LPC_PPT},
  568. { PCI_VDEVICE(INTEL, 0x1e44), LPC_PPT},
  569. { PCI_VDEVICE(INTEL, 0x1e45), LPC_PPT},
  570. { PCI_VDEVICE(INTEL, 0x1e46), LPC_PPT},
  571. { PCI_VDEVICE(INTEL, 0x1e47), LPC_PPT},
  572. { PCI_VDEVICE(INTEL, 0x1e48), LPC_PPT},
  573. { PCI_VDEVICE(INTEL, 0x1e49), LPC_PPT},
  574. { PCI_VDEVICE(INTEL, 0x1e4a), LPC_PPT},
  575. { PCI_VDEVICE(INTEL, 0x1e4b), LPC_PPT},
  576. { PCI_VDEVICE(INTEL, 0x1e4c), LPC_PPT},
  577. { PCI_VDEVICE(INTEL, 0x1e4d), LPC_PPT},
  578. { PCI_VDEVICE(INTEL, 0x1e4e), LPC_PPT},
  579. { PCI_VDEVICE(INTEL, 0x1e4f), LPC_PPT},
  580. { PCI_VDEVICE(INTEL, 0x1e50), LPC_PPT},
  581. { PCI_VDEVICE(INTEL, 0x1e51), LPC_PPT},
  582. { PCI_VDEVICE(INTEL, 0x1e52), LPC_PPT},
  583. { PCI_VDEVICE(INTEL, 0x1e53), LPC_PPT},
  584. { PCI_VDEVICE(INTEL, 0x1e54), LPC_PPT},
  585. { PCI_VDEVICE(INTEL, 0x1e55), LPC_PPT},
  586. { PCI_VDEVICE(INTEL, 0x1e56), LPC_PPT},
  587. { PCI_VDEVICE(INTEL, 0x1e57), LPC_PPT},
  588. { PCI_VDEVICE(INTEL, 0x1e58), LPC_PPT},
  589. { PCI_VDEVICE(INTEL, 0x1e59), LPC_PPT},
  590. { PCI_VDEVICE(INTEL, 0x1e5a), LPC_PPT},
  591. { PCI_VDEVICE(INTEL, 0x1e5b), LPC_PPT},
  592. { PCI_VDEVICE(INTEL, 0x1e5c), LPC_PPT},
  593. { PCI_VDEVICE(INTEL, 0x1e5d), LPC_PPT},
  594. { PCI_VDEVICE(INTEL, 0x1e5e), LPC_PPT},
  595. { PCI_VDEVICE(INTEL, 0x1e5f), LPC_PPT},
  596. { PCI_VDEVICE(INTEL, 0x8c40), LPC_LPT},
  597. { PCI_VDEVICE(INTEL, 0x8c41), LPC_LPT},
  598. { PCI_VDEVICE(INTEL, 0x8c42), LPC_LPT},
  599. { PCI_VDEVICE(INTEL, 0x8c43), LPC_LPT},
  600. { PCI_VDEVICE(INTEL, 0x8c44), LPC_LPT},
  601. { PCI_VDEVICE(INTEL, 0x8c45), LPC_LPT},
  602. { PCI_VDEVICE(INTEL, 0x8c46), LPC_LPT},
  603. { PCI_VDEVICE(INTEL, 0x8c47), LPC_LPT},
  604. { PCI_VDEVICE(INTEL, 0x8c48), LPC_LPT},
  605. { PCI_VDEVICE(INTEL, 0x8c49), LPC_LPT},
  606. { PCI_VDEVICE(INTEL, 0x8c4a), LPC_LPT},
  607. { PCI_VDEVICE(INTEL, 0x8c4b), LPC_LPT},
  608. { PCI_VDEVICE(INTEL, 0x8c4c), LPC_LPT},
  609. { PCI_VDEVICE(INTEL, 0x8c4d), LPC_LPT},
  610. { PCI_VDEVICE(INTEL, 0x8c4e), LPC_LPT},
  611. { PCI_VDEVICE(INTEL, 0x8c4f), LPC_LPT},
  612. { PCI_VDEVICE(INTEL, 0x8c50), LPC_LPT},
  613. { PCI_VDEVICE(INTEL, 0x8c51), LPC_LPT},
  614. { PCI_VDEVICE(INTEL, 0x8c52), LPC_LPT},
  615. { PCI_VDEVICE(INTEL, 0x8c53), LPC_LPT},
  616. { PCI_VDEVICE(INTEL, 0x8c54), LPC_LPT},
  617. { PCI_VDEVICE(INTEL, 0x8c55), LPC_LPT},
  618. { PCI_VDEVICE(INTEL, 0x8c56), LPC_LPT},
  619. { PCI_VDEVICE(INTEL, 0x8c57), LPC_LPT},
  620. { PCI_VDEVICE(INTEL, 0x8c58), LPC_LPT},
  621. { PCI_VDEVICE(INTEL, 0x8c59), LPC_LPT},
  622. { PCI_VDEVICE(INTEL, 0x8c5a), LPC_LPT},
  623. { PCI_VDEVICE(INTEL, 0x8c5b), LPC_LPT},
  624. { PCI_VDEVICE(INTEL, 0x8c5c), LPC_LPT},
  625. { PCI_VDEVICE(INTEL, 0x8c5d), LPC_LPT},
  626. { PCI_VDEVICE(INTEL, 0x8c5e), LPC_LPT},
  627. { PCI_VDEVICE(INTEL, 0x8c5f), LPC_LPT},
  628. { 0, }, /* End of list */
  629. };
  630. MODULE_DEVICE_TABLE(pci, lpc_ich_ids);
  631. static void lpc_ich_restore_config_space(struct pci_dev *dev)
  632. {
  633. if (lpc_ich_acpi_save >= 0) {
  634. pci_write_config_byte(dev, ACPICTRL, lpc_ich_acpi_save);
  635. lpc_ich_acpi_save = -1;
  636. }
  637. if (lpc_ich_gpio_save >= 0) {
  638. pci_write_config_byte(dev, GPIOCTRL, lpc_ich_gpio_save);
  639. lpc_ich_gpio_save = -1;
  640. }
  641. }
  642. static void __devinit lpc_ich_enable_acpi_space(struct pci_dev *dev)
  643. {
  644. u8 reg_save;
  645. pci_read_config_byte(dev, ACPICTRL, &reg_save);
  646. pci_write_config_byte(dev, ACPICTRL, reg_save | 0x10);
  647. lpc_ich_acpi_save = reg_save;
  648. }
  649. static void __devinit lpc_ich_enable_gpio_space(struct pci_dev *dev)
  650. {
  651. u8 reg_save;
  652. pci_read_config_byte(dev, GPIOCTRL, &reg_save);
  653. pci_write_config_byte(dev, GPIOCTRL, reg_save | 0x10);
  654. lpc_ich_gpio_save = reg_save;
  655. }
  656. static void __devinit lpc_ich_finalize_cell(struct mfd_cell *cell,
  657. const struct pci_device_id *id)
  658. {
  659. cell->platform_data = &lpc_chipset_info[id->driver_data];
  660. cell->pdata_size = sizeof(struct lpc_ich_info);
  661. }
  662. static int __devinit lpc_ich_init_gpio(struct pci_dev *dev,
  663. const struct pci_device_id *id)
  664. {
  665. u32 base_addr_cfg;
  666. u32 base_addr;
  667. int ret;
  668. bool acpi_conflict = false;
  669. struct resource *res;
  670. /* Setup power management base register */
  671. pci_read_config_dword(dev, ACPIBASE, &base_addr_cfg);
  672. base_addr = base_addr_cfg & 0x0000ff80;
  673. if (!base_addr) {
  674. dev_err(&dev->dev, "I/O space for ACPI uninitialized\n");
  675. lpc_ich_cells[LPC_GPIO].num_resources--;
  676. goto gpe0_done;
  677. }
  678. res = &gpio_ich_res[ICH_RES_GPE0];
  679. res->start = base_addr + ACPIBASE_GPE_OFF;
  680. res->end = base_addr + ACPIBASE_GPE_END;
  681. ret = acpi_check_resource_conflict(res);
  682. if (ret) {
  683. /*
  684. * This isn't fatal for the GPIO, but we have to make sure that
  685. * the platform_device subsystem doesn't see this resource
  686. * or it will register an invalid region.
  687. */
  688. lpc_ich_cells[LPC_GPIO].num_resources--;
  689. acpi_conflict = true;
  690. } else {
  691. lpc_ich_enable_acpi_space(dev);
  692. }
  693. gpe0_done:
  694. /* Setup GPIO base register */
  695. pci_read_config_dword(dev, GPIOBASE, &base_addr_cfg);
  696. base_addr = base_addr_cfg & 0x0000ff80;
  697. if (!base_addr) {
  698. dev_err(&dev->dev, "I/O space for GPIO uninitialized\n");
  699. ret = -ENODEV;
  700. goto gpio_done;
  701. }
  702. /* Older devices provide fewer GPIO and have a smaller resource size. */
  703. res = &gpio_ich_res[ICH_RES_GPIO];
  704. res->start = base_addr;
  705. switch (lpc_chipset_info[id->driver_data].gpio_version) {
  706. case ICH_V5_GPIO:
  707. case ICH_V10CORP_GPIO:
  708. res->end = res->start + 128 - 1;
  709. break;
  710. default:
  711. res->end = res->start + 64 - 1;
  712. break;
  713. }
  714. ret = acpi_check_resource_conflict(res);
  715. if (ret) {
  716. /* this isn't necessarily fatal for the GPIO */
  717. acpi_conflict = true;
  718. goto gpio_done;
  719. }
  720. lpc_ich_enable_gpio_space(dev);
  721. lpc_ich_finalize_cell(&lpc_ich_cells[LPC_GPIO], id);
  722. ret = mfd_add_devices(&dev->dev, -1, &lpc_ich_cells[LPC_GPIO],
  723. 1, NULL, 0);
  724. gpio_done:
  725. if (acpi_conflict)
  726. pr_warn("Resource conflict(s) found affecting %s\n",
  727. lpc_ich_cells[LPC_GPIO].name);
  728. return ret;
  729. }
  730. static int __devinit lpc_ich_init_wdt(struct pci_dev *dev,
  731. const struct pci_device_id *id)
  732. {
  733. u32 base_addr_cfg;
  734. u32 base_addr;
  735. int ret;
  736. bool acpi_conflict = false;
  737. struct resource *res;
  738. /* Setup power management base register */
  739. pci_read_config_dword(dev, ACPIBASE, &base_addr_cfg);
  740. base_addr = base_addr_cfg & 0x0000ff80;
  741. if (!base_addr) {
  742. dev_err(&dev->dev, "I/O space for ACPI uninitialized\n");
  743. ret = -ENODEV;
  744. goto wdt_done;
  745. }
  746. res = wdt_io_res(ICH_RES_IO_TCO);
  747. res->start = base_addr + ACPIBASE_TCO_OFF;
  748. res->end = base_addr + ACPIBASE_TCO_END;
  749. ret = acpi_check_resource_conflict(res);
  750. if (ret) {
  751. acpi_conflict = true;
  752. goto wdt_done;
  753. }
  754. res = wdt_io_res(ICH_RES_IO_SMI);
  755. res->start = base_addr + ACPIBASE_SMI_OFF;
  756. res->end = base_addr + ACPIBASE_SMI_END;
  757. ret = acpi_check_resource_conflict(res);
  758. if (ret) {
  759. acpi_conflict = true;
  760. goto wdt_done;
  761. }
  762. lpc_ich_enable_acpi_space(dev);
  763. /*
  764. * Get the Memory-Mapped GCS register. To get access to it
  765. * we have to read RCBA from PCI Config space 0xf0 and use
  766. * it as base. GCS = RCBA + ICH6_GCS(0x3410).
  767. */
  768. if (lpc_chipset_info[id->driver_data].iTCO_version == 2) {
  769. pci_read_config_dword(dev, RCBABASE, &base_addr_cfg);
  770. base_addr = base_addr_cfg & 0xffffc000;
  771. if (!(base_addr_cfg & 1)) {
  772. pr_err("RCBA is disabled by hardware/BIOS, "
  773. "device disabled\n");
  774. ret = -ENODEV;
  775. goto wdt_done;
  776. }
  777. res = wdt_mem_res(ICH_RES_MEM_GCS);
  778. res->start = base_addr + ACPIBASE_GCS_OFF;
  779. res->end = base_addr + ACPIBASE_GCS_END;
  780. ret = acpi_check_resource_conflict(res);
  781. if (ret) {
  782. acpi_conflict = true;
  783. goto wdt_done;
  784. }
  785. }
  786. lpc_ich_finalize_cell(&lpc_ich_cells[LPC_WDT], id);
  787. ret = mfd_add_devices(&dev->dev, -1, &lpc_ich_cells[LPC_WDT],
  788. 1, NULL, 0);
  789. wdt_done:
  790. if (acpi_conflict)
  791. pr_warn("Resource conflict(s) found affecting %s\n",
  792. lpc_ich_cells[LPC_WDT].name);
  793. return ret;
  794. }
  795. static int __devinit lpc_ich_probe(struct pci_dev *dev,
  796. const struct pci_device_id *id)
  797. {
  798. int ret;
  799. bool cell_added = false;
  800. ret = lpc_ich_init_wdt(dev, id);
  801. if (!ret)
  802. cell_added = true;
  803. ret = lpc_ich_init_gpio(dev, id);
  804. if (!ret)
  805. cell_added = true;
  806. /*
  807. * We only care if at least one or none of the cells registered
  808. * successfully.
  809. */
  810. if (!cell_added) {
  811. lpc_ich_restore_config_space(dev);
  812. return -ENODEV;
  813. }
  814. return 0;
  815. }
  816. static void __devexit lpc_ich_remove(struct pci_dev *dev)
  817. {
  818. mfd_remove_devices(&dev->dev);
  819. lpc_ich_restore_config_space(dev);
  820. }
  821. static struct pci_driver lpc_ich_driver = {
  822. .name = "lpc_ich",
  823. .id_table = lpc_ich_ids,
  824. .probe = lpc_ich_probe,
  825. .remove = __devexit_p(lpc_ich_remove),
  826. };
  827. static int __init lpc_ich_init(void)
  828. {
  829. return pci_register_driver(&lpc_ich_driver);
  830. }
  831. static void __exit lpc_ich_exit(void)
  832. {
  833. pci_unregister_driver(&lpc_ich_driver);
  834. }
  835. module_init(lpc_ich_init);
  836. module_exit(lpc_ich_exit);
  837. MODULE_AUTHOR("Aaron Sierra <asierra@xes-inc.com>");
  838. MODULE_DESCRIPTION("LPC interface for Intel ICH");
  839. MODULE_LICENSE("GPL");