lpc_ich.c 24 KB

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