lpc_ich.c 31 KB

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