lpc_ich.c 30 KB

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