i5100_edac.c 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243
  1. /*
  2. * Intel 5100 Memory Controllers kernel module
  3. *
  4. * This file may be distributed under the terms of the
  5. * GNU General Public License.
  6. *
  7. * This module is based on the following document:
  8. *
  9. * Intel 5100X Chipset Memory Controller Hub (MCH) - Datasheet
  10. * http://download.intel.com/design/chipsets/datashts/318378.pdf
  11. *
  12. * The intel 5100 has two independent channels. EDAC core currently
  13. * can not reflect this configuration so instead the chip-select
  14. * rows for each respective channel are laid out one after another,
  15. * the first half belonging to channel 0, the second half belonging
  16. * to channel 1.
  17. *
  18. * This driver is for DDR2 DIMMs, and it uses chip select to select among the
  19. * several ranks. However, instead of showing memories as ranks, it outputs
  20. * them as DIMM's. An internal table creates the association between ranks
  21. * and DIMM's.
  22. */
  23. #include <linux/module.h>
  24. #include <linux/init.h>
  25. #include <linux/pci.h>
  26. #include <linux/pci_ids.h>
  27. #include <linux/edac.h>
  28. #include <linux/delay.h>
  29. #include <linux/mmzone.h>
  30. #include <linux/debugfs.h>
  31. #include "edac_module.h"
  32. /* register addresses */
  33. /* device 16, func 1 */
  34. #define I5100_MC 0x40 /* Memory Control Register */
  35. #define I5100_MC_SCRBEN_MASK (1 << 7)
  36. #define I5100_MC_SCRBDONE_MASK (1 << 4)
  37. #define I5100_MS 0x44 /* Memory Status Register */
  38. #define I5100_SPDDATA 0x48 /* Serial Presence Detect Status Reg */
  39. #define I5100_SPDCMD 0x4c /* Serial Presence Detect Command Reg */
  40. #define I5100_TOLM 0x6c /* Top of Low Memory */
  41. #define I5100_MIR0 0x80 /* Memory Interleave Range 0 */
  42. #define I5100_MIR1 0x84 /* Memory Interleave Range 1 */
  43. #define I5100_AMIR_0 0x8c /* Adjusted Memory Interleave Range 0 */
  44. #define I5100_AMIR_1 0x90 /* Adjusted Memory Interleave Range 1 */
  45. #define I5100_FERR_NF_MEM 0xa0 /* MC First Non Fatal Errors */
  46. #define I5100_FERR_NF_MEM_M16ERR_MASK (1 << 16)
  47. #define I5100_FERR_NF_MEM_M15ERR_MASK (1 << 15)
  48. #define I5100_FERR_NF_MEM_M14ERR_MASK (1 << 14)
  49. #define I5100_FERR_NF_MEM_M12ERR_MASK (1 << 12)
  50. #define I5100_FERR_NF_MEM_M11ERR_MASK (1 << 11)
  51. #define I5100_FERR_NF_MEM_M10ERR_MASK (1 << 10)
  52. #define I5100_FERR_NF_MEM_M6ERR_MASK (1 << 6)
  53. #define I5100_FERR_NF_MEM_M5ERR_MASK (1 << 5)
  54. #define I5100_FERR_NF_MEM_M4ERR_MASK (1 << 4)
  55. #define I5100_FERR_NF_MEM_M1ERR_MASK (1 << 1)
  56. #define I5100_FERR_NF_MEM_ANY_MASK \
  57. (I5100_FERR_NF_MEM_M16ERR_MASK | \
  58. I5100_FERR_NF_MEM_M15ERR_MASK | \
  59. I5100_FERR_NF_MEM_M14ERR_MASK | \
  60. I5100_FERR_NF_MEM_M12ERR_MASK | \
  61. I5100_FERR_NF_MEM_M11ERR_MASK | \
  62. I5100_FERR_NF_MEM_M10ERR_MASK | \
  63. I5100_FERR_NF_MEM_M6ERR_MASK | \
  64. I5100_FERR_NF_MEM_M5ERR_MASK | \
  65. I5100_FERR_NF_MEM_M4ERR_MASK | \
  66. I5100_FERR_NF_MEM_M1ERR_MASK)
  67. #define I5100_NERR_NF_MEM 0xa4 /* MC Next Non-Fatal Errors */
  68. #define I5100_EMASK_MEM 0xa8 /* MC Error Mask Register */
  69. #define I5100_MEM0EINJMSK0 0x200 /* Injection Mask0 Register Channel 0 */
  70. #define I5100_MEM1EINJMSK0 0x208 /* Injection Mask0 Register Channel 1 */
  71. #define I5100_MEMXEINJMSK0_EINJEN (1 << 27)
  72. #define I5100_MEM0EINJMSK1 0x204 /* Injection Mask1 Register Channel 0 */
  73. #define I5100_MEM1EINJMSK1 0x206 /* Injection Mask1 Register Channel 1 */
  74. /* Device 19, Function 0 */
  75. #define I5100_DINJ0 0x9a
  76. /* device 21 and 22, func 0 */
  77. #define I5100_MTR_0 0x154 /* Memory Technology Registers 0-3 */
  78. #define I5100_DMIR 0x15c /* DIMM Interleave Range */
  79. #define I5100_VALIDLOG 0x18c /* Valid Log Markers */
  80. #define I5100_NRECMEMA 0x190 /* Non-Recoverable Memory Error Log Reg A */
  81. #define I5100_NRECMEMB 0x194 /* Non-Recoverable Memory Error Log Reg B */
  82. #define I5100_REDMEMA 0x198 /* Recoverable Memory Data Error Log Reg A */
  83. #define I5100_REDMEMB 0x19c /* Recoverable Memory Data Error Log Reg B */
  84. #define I5100_RECMEMA 0x1a0 /* Recoverable Memory Error Log Reg A */
  85. #define I5100_RECMEMB 0x1a4 /* Recoverable Memory Error Log Reg B */
  86. #define I5100_MTR_4 0x1b0 /* Memory Technology Registers 4,5 */
  87. /* bit field accessors */
  88. static inline u32 i5100_mc_scrben(u32 mc)
  89. {
  90. return mc >> 7 & 1;
  91. }
  92. static inline u32 i5100_mc_errdeten(u32 mc)
  93. {
  94. return mc >> 5 & 1;
  95. }
  96. static inline u32 i5100_mc_scrbdone(u32 mc)
  97. {
  98. return mc >> 4 & 1;
  99. }
  100. static inline u16 i5100_spddata_rdo(u16 a)
  101. {
  102. return a >> 15 & 1;
  103. }
  104. static inline u16 i5100_spddata_sbe(u16 a)
  105. {
  106. return a >> 13 & 1;
  107. }
  108. static inline u16 i5100_spddata_busy(u16 a)
  109. {
  110. return a >> 12 & 1;
  111. }
  112. static inline u16 i5100_spddata_data(u16 a)
  113. {
  114. return a & ((1 << 8) - 1);
  115. }
  116. static inline u32 i5100_spdcmd_create(u32 dti, u32 ckovrd, u32 sa, u32 ba,
  117. u32 data, u32 cmd)
  118. {
  119. return ((dti & ((1 << 4) - 1)) << 28) |
  120. ((ckovrd & 1) << 27) |
  121. ((sa & ((1 << 3) - 1)) << 24) |
  122. ((ba & ((1 << 8) - 1)) << 16) |
  123. ((data & ((1 << 8) - 1)) << 8) |
  124. (cmd & 1);
  125. }
  126. static inline u16 i5100_tolm_tolm(u16 a)
  127. {
  128. return a >> 12 & ((1 << 4) - 1);
  129. }
  130. static inline u16 i5100_mir_limit(u16 a)
  131. {
  132. return a >> 4 & ((1 << 12) - 1);
  133. }
  134. static inline u16 i5100_mir_way1(u16 a)
  135. {
  136. return a >> 1 & 1;
  137. }
  138. static inline u16 i5100_mir_way0(u16 a)
  139. {
  140. return a & 1;
  141. }
  142. static inline u32 i5100_ferr_nf_mem_chan_indx(u32 a)
  143. {
  144. return a >> 28 & 1;
  145. }
  146. static inline u32 i5100_ferr_nf_mem_any(u32 a)
  147. {
  148. return a & I5100_FERR_NF_MEM_ANY_MASK;
  149. }
  150. static inline u32 i5100_nerr_nf_mem_any(u32 a)
  151. {
  152. return i5100_ferr_nf_mem_any(a);
  153. }
  154. static inline u32 i5100_dmir_limit(u32 a)
  155. {
  156. return a >> 16 & ((1 << 11) - 1);
  157. }
  158. static inline u32 i5100_dmir_rank(u32 a, u32 i)
  159. {
  160. return a >> (4 * i) & ((1 << 2) - 1);
  161. }
  162. static inline u16 i5100_mtr_present(u16 a)
  163. {
  164. return a >> 10 & 1;
  165. }
  166. static inline u16 i5100_mtr_ethrottle(u16 a)
  167. {
  168. return a >> 9 & 1;
  169. }
  170. static inline u16 i5100_mtr_width(u16 a)
  171. {
  172. return a >> 8 & 1;
  173. }
  174. static inline u16 i5100_mtr_numbank(u16 a)
  175. {
  176. return a >> 6 & 1;
  177. }
  178. static inline u16 i5100_mtr_numrow(u16 a)
  179. {
  180. return a >> 2 & ((1 << 2) - 1);
  181. }
  182. static inline u16 i5100_mtr_numcol(u16 a)
  183. {
  184. return a & ((1 << 2) - 1);
  185. }
  186. static inline u32 i5100_validlog_redmemvalid(u32 a)
  187. {
  188. return a >> 2 & 1;
  189. }
  190. static inline u32 i5100_validlog_recmemvalid(u32 a)
  191. {
  192. return a >> 1 & 1;
  193. }
  194. static inline u32 i5100_validlog_nrecmemvalid(u32 a)
  195. {
  196. return a & 1;
  197. }
  198. static inline u32 i5100_nrecmema_merr(u32 a)
  199. {
  200. return a >> 15 & ((1 << 5) - 1);
  201. }
  202. static inline u32 i5100_nrecmema_bank(u32 a)
  203. {
  204. return a >> 12 & ((1 << 3) - 1);
  205. }
  206. static inline u32 i5100_nrecmema_rank(u32 a)
  207. {
  208. return a >> 8 & ((1 << 3) - 1);
  209. }
  210. static inline u32 i5100_nrecmema_dm_buf_id(u32 a)
  211. {
  212. return a & ((1 << 8) - 1);
  213. }
  214. static inline u32 i5100_nrecmemb_cas(u32 a)
  215. {
  216. return a >> 16 & ((1 << 13) - 1);
  217. }
  218. static inline u32 i5100_nrecmemb_ras(u32 a)
  219. {
  220. return a & ((1 << 16) - 1);
  221. }
  222. static inline u32 i5100_redmemb_ecc_locator(u32 a)
  223. {
  224. return a & ((1 << 18) - 1);
  225. }
  226. static inline u32 i5100_recmema_merr(u32 a)
  227. {
  228. return i5100_nrecmema_merr(a);
  229. }
  230. static inline u32 i5100_recmema_bank(u32 a)
  231. {
  232. return i5100_nrecmema_bank(a);
  233. }
  234. static inline u32 i5100_recmema_rank(u32 a)
  235. {
  236. return i5100_nrecmema_rank(a);
  237. }
  238. static inline u32 i5100_recmemb_cas(u32 a)
  239. {
  240. return i5100_nrecmemb_cas(a);
  241. }
  242. static inline u32 i5100_recmemb_ras(u32 a)
  243. {
  244. return i5100_nrecmemb_ras(a);
  245. }
  246. /* some generic limits */
  247. #define I5100_MAX_RANKS_PER_CHAN 6
  248. #define I5100_CHANNELS 2
  249. #define I5100_MAX_RANKS_PER_DIMM 4
  250. #define I5100_DIMM_ADDR_LINES (6 - 3) /* 64 bits / 8 bits per byte */
  251. #define I5100_MAX_DIMM_SLOTS_PER_CHAN 4
  252. #define I5100_MAX_RANK_INTERLEAVE 4
  253. #define I5100_MAX_DMIRS 5
  254. #define I5100_SCRUB_REFRESH_RATE (5 * 60 * HZ)
  255. struct i5100_priv {
  256. /* ranks on each dimm -- 0 maps to not present -- obtained via SPD */
  257. int dimm_numrank[I5100_CHANNELS][I5100_MAX_DIMM_SLOTS_PER_CHAN];
  258. /*
  259. * mainboard chip select map -- maps i5100 chip selects to
  260. * DIMM slot chip selects. In the case of only 4 ranks per
  261. * channel, the mapping is fairly obvious but not unique.
  262. * we map -1 -> NC and assume both channels use the same
  263. * map...
  264. *
  265. */
  266. int dimm_csmap[I5100_MAX_DIMM_SLOTS_PER_CHAN][I5100_MAX_RANKS_PER_DIMM];
  267. /* memory interleave range */
  268. struct {
  269. u64 limit;
  270. unsigned way[2];
  271. } mir[I5100_CHANNELS];
  272. /* adjusted memory interleave range register */
  273. unsigned amir[I5100_CHANNELS];
  274. /* dimm interleave range */
  275. struct {
  276. unsigned rank[I5100_MAX_RANK_INTERLEAVE];
  277. u64 limit;
  278. } dmir[I5100_CHANNELS][I5100_MAX_DMIRS];
  279. /* memory technology registers... */
  280. struct {
  281. unsigned present; /* 0 or 1 */
  282. unsigned ethrottle; /* 0 or 1 */
  283. unsigned width; /* 4 or 8 bits */
  284. unsigned numbank; /* 2 or 3 lines */
  285. unsigned numrow; /* 13 .. 16 lines */
  286. unsigned numcol; /* 11 .. 12 lines */
  287. } mtr[I5100_CHANNELS][I5100_MAX_RANKS_PER_CHAN];
  288. u64 tolm; /* top of low memory in bytes */
  289. unsigned ranksperchan; /* number of ranks per channel */
  290. struct pci_dev *mc; /* device 16 func 1 */
  291. struct pci_dev *einj; /* device 19 func 0 */
  292. struct pci_dev *ch0mm; /* device 21 func 0 */
  293. struct pci_dev *ch1mm; /* device 22 func 0 */
  294. struct delayed_work i5100_scrubbing;
  295. int scrub_enable;
  296. /* Error injection */
  297. u8 inject_channel;
  298. u8 inject_hlinesel;
  299. u8 inject_deviceptr1;
  300. u8 inject_deviceptr2;
  301. u16 inject_eccmask1;
  302. u16 inject_eccmask2;
  303. struct dentry *debugfs;
  304. };
  305. static struct dentry *i5100_debugfs;
  306. /* map a rank/chan to a slot number on the mainboard */
  307. static int i5100_rank_to_slot(const struct mem_ctl_info *mci,
  308. int chan, int rank)
  309. {
  310. const struct i5100_priv *priv = mci->pvt_info;
  311. int i;
  312. for (i = 0; i < I5100_MAX_DIMM_SLOTS_PER_CHAN; i++) {
  313. int j;
  314. const int numrank = priv->dimm_numrank[chan][i];
  315. for (j = 0; j < numrank; j++)
  316. if (priv->dimm_csmap[i][j] == rank)
  317. return i * 2 + chan;
  318. }
  319. return -1;
  320. }
  321. static const char *i5100_err_msg(unsigned err)
  322. {
  323. static const char *merrs[] = {
  324. "unknown", /* 0 */
  325. "uncorrectable data ECC on replay", /* 1 */
  326. "unknown", /* 2 */
  327. "unknown", /* 3 */
  328. "aliased uncorrectable demand data ECC", /* 4 */
  329. "aliased uncorrectable spare-copy data ECC", /* 5 */
  330. "aliased uncorrectable patrol data ECC", /* 6 */
  331. "unknown", /* 7 */
  332. "unknown", /* 8 */
  333. "unknown", /* 9 */
  334. "non-aliased uncorrectable demand data ECC", /* 10 */
  335. "non-aliased uncorrectable spare-copy data ECC", /* 11 */
  336. "non-aliased uncorrectable patrol data ECC", /* 12 */
  337. "unknown", /* 13 */
  338. "correctable demand data ECC", /* 14 */
  339. "correctable spare-copy data ECC", /* 15 */
  340. "correctable patrol data ECC", /* 16 */
  341. "unknown", /* 17 */
  342. "SPD protocol error", /* 18 */
  343. "unknown", /* 19 */
  344. "spare copy initiated", /* 20 */
  345. "spare copy completed", /* 21 */
  346. };
  347. unsigned i;
  348. for (i = 0; i < ARRAY_SIZE(merrs); i++)
  349. if (1 << i & err)
  350. return merrs[i];
  351. return "none";
  352. }
  353. /* convert csrow index into a rank (per channel -- 0..5) */
  354. static int i5100_csrow_to_rank(const struct mem_ctl_info *mci, int csrow)
  355. {
  356. const struct i5100_priv *priv = mci->pvt_info;
  357. return csrow % priv->ranksperchan;
  358. }
  359. /* convert csrow index into a channel (0..1) */
  360. static int i5100_csrow_to_chan(const struct mem_ctl_info *mci, int csrow)
  361. {
  362. const struct i5100_priv *priv = mci->pvt_info;
  363. return csrow / priv->ranksperchan;
  364. }
  365. static void i5100_handle_ce(struct mem_ctl_info *mci,
  366. int chan,
  367. unsigned bank,
  368. unsigned rank,
  369. unsigned long syndrome,
  370. unsigned cas,
  371. unsigned ras,
  372. const char *msg)
  373. {
  374. char detail[80];
  375. /* Form out message */
  376. snprintf(detail, sizeof(detail),
  377. "bank %u, cas %u, ras %u\n",
  378. bank, cas, ras);
  379. edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1,
  380. 0, 0, syndrome,
  381. chan, rank, -1,
  382. msg, detail);
  383. }
  384. static void i5100_handle_ue(struct mem_ctl_info *mci,
  385. int chan,
  386. unsigned bank,
  387. unsigned rank,
  388. unsigned long syndrome,
  389. unsigned cas,
  390. unsigned ras,
  391. const char *msg)
  392. {
  393. char detail[80];
  394. /* Form out message */
  395. snprintf(detail, sizeof(detail),
  396. "bank %u, cas %u, ras %u\n",
  397. bank, cas, ras);
  398. edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1,
  399. 0, 0, syndrome,
  400. chan, rank, -1,
  401. msg, detail);
  402. }
  403. static void i5100_read_log(struct mem_ctl_info *mci, int chan,
  404. u32 ferr, u32 nerr)
  405. {
  406. struct i5100_priv *priv = mci->pvt_info;
  407. struct pci_dev *pdev = (chan) ? priv->ch1mm : priv->ch0mm;
  408. u32 dw;
  409. u32 dw2;
  410. unsigned syndrome = 0;
  411. unsigned ecc_loc = 0;
  412. unsigned merr;
  413. unsigned bank;
  414. unsigned rank;
  415. unsigned cas;
  416. unsigned ras;
  417. pci_read_config_dword(pdev, I5100_VALIDLOG, &dw);
  418. if (i5100_validlog_redmemvalid(dw)) {
  419. pci_read_config_dword(pdev, I5100_REDMEMA, &dw2);
  420. syndrome = dw2;
  421. pci_read_config_dword(pdev, I5100_REDMEMB, &dw2);
  422. ecc_loc = i5100_redmemb_ecc_locator(dw2);
  423. }
  424. if (i5100_validlog_recmemvalid(dw)) {
  425. const char *msg;
  426. pci_read_config_dword(pdev, I5100_RECMEMA, &dw2);
  427. merr = i5100_recmema_merr(dw2);
  428. bank = i5100_recmema_bank(dw2);
  429. rank = i5100_recmema_rank(dw2);
  430. pci_read_config_dword(pdev, I5100_RECMEMB, &dw2);
  431. cas = i5100_recmemb_cas(dw2);
  432. ras = i5100_recmemb_ras(dw2);
  433. /* FIXME: not really sure if this is what merr is...
  434. */
  435. if (!merr)
  436. msg = i5100_err_msg(ferr);
  437. else
  438. msg = i5100_err_msg(nerr);
  439. i5100_handle_ce(mci, chan, bank, rank, syndrome, cas, ras, msg);
  440. }
  441. if (i5100_validlog_nrecmemvalid(dw)) {
  442. const char *msg;
  443. pci_read_config_dword(pdev, I5100_NRECMEMA, &dw2);
  444. merr = i5100_nrecmema_merr(dw2);
  445. bank = i5100_nrecmema_bank(dw2);
  446. rank = i5100_nrecmema_rank(dw2);
  447. pci_read_config_dword(pdev, I5100_NRECMEMB, &dw2);
  448. cas = i5100_nrecmemb_cas(dw2);
  449. ras = i5100_nrecmemb_ras(dw2);
  450. /* FIXME: not really sure if this is what merr is...
  451. */
  452. if (!merr)
  453. msg = i5100_err_msg(ferr);
  454. else
  455. msg = i5100_err_msg(nerr);
  456. i5100_handle_ue(mci, chan, bank, rank, syndrome, cas, ras, msg);
  457. }
  458. pci_write_config_dword(pdev, I5100_VALIDLOG, dw);
  459. }
  460. static void i5100_check_error(struct mem_ctl_info *mci)
  461. {
  462. struct i5100_priv *priv = mci->pvt_info;
  463. u32 dw, dw2;
  464. pci_read_config_dword(priv->mc, I5100_FERR_NF_MEM, &dw);
  465. if (i5100_ferr_nf_mem_any(dw)) {
  466. pci_read_config_dword(priv->mc, I5100_NERR_NF_MEM, &dw2);
  467. i5100_read_log(mci, i5100_ferr_nf_mem_chan_indx(dw),
  468. i5100_ferr_nf_mem_any(dw),
  469. i5100_nerr_nf_mem_any(dw2));
  470. pci_write_config_dword(priv->mc, I5100_NERR_NF_MEM, dw2);
  471. }
  472. pci_write_config_dword(priv->mc, I5100_FERR_NF_MEM, dw);
  473. }
  474. /* The i5100 chipset will scrub the entire memory once, then
  475. * set a done bit. Continuous scrubbing is achieved by enqueing
  476. * delayed work to a workqueue, checking every few minutes if
  477. * the scrubbing has completed and if so reinitiating it.
  478. */
  479. static void i5100_refresh_scrubbing(struct work_struct *work)
  480. {
  481. struct delayed_work *i5100_scrubbing = to_delayed_work(work);
  482. struct i5100_priv *priv = container_of(i5100_scrubbing,
  483. struct i5100_priv,
  484. i5100_scrubbing);
  485. u32 dw;
  486. pci_read_config_dword(priv->mc, I5100_MC, &dw);
  487. if (priv->scrub_enable) {
  488. pci_read_config_dword(priv->mc, I5100_MC, &dw);
  489. if (i5100_mc_scrbdone(dw)) {
  490. dw |= I5100_MC_SCRBEN_MASK;
  491. pci_write_config_dword(priv->mc, I5100_MC, dw);
  492. pci_read_config_dword(priv->mc, I5100_MC, &dw);
  493. }
  494. schedule_delayed_work(&(priv->i5100_scrubbing),
  495. I5100_SCRUB_REFRESH_RATE);
  496. }
  497. }
  498. /*
  499. * The bandwidth is based on experimentation, feel free to refine it.
  500. */
  501. static int i5100_set_scrub_rate(struct mem_ctl_info *mci, u32 bandwidth)
  502. {
  503. struct i5100_priv *priv = mci->pvt_info;
  504. u32 dw;
  505. pci_read_config_dword(priv->mc, I5100_MC, &dw);
  506. if (bandwidth) {
  507. priv->scrub_enable = 1;
  508. dw |= I5100_MC_SCRBEN_MASK;
  509. schedule_delayed_work(&(priv->i5100_scrubbing),
  510. I5100_SCRUB_REFRESH_RATE);
  511. } else {
  512. priv->scrub_enable = 0;
  513. dw &= ~I5100_MC_SCRBEN_MASK;
  514. cancel_delayed_work(&(priv->i5100_scrubbing));
  515. }
  516. pci_write_config_dword(priv->mc, I5100_MC, dw);
  517. pci_read_config_dword(priv->mc, I5100_MC, &dw);
  518. bandwidth = 5900000 * i5100_mc_scrben(dw);
  519. return bandwidth;
  520. }
  521. static int i5100_get_scrub_rate(struct mem_ctl_info *mci)
  522. {
  523. struct i5100_priv *priv = mci->pvt_info;
  524. u32 dw;
  525. pci_read_config_dword(priv->mc, I5100_MC, &dw);
  526. return 5900000 * i5100_mc_scrben(dw);
  527. }
  528. static struct pci_dev *pci_get_device_func(unsigned vendor,
  529. unsigned device,
  530. unsigned func)
  531. {
  532. struct pci_dev *ret = NULL;
  533. while (1) {
  534. ret = pci_get_device(vendor, device, ret);
  535. if (!ret)
  536. break;
  537. if (PCI_FUNC(ret->devfn) == func)
  538. break;
  539. }
  540. return ret;
  541. }
  542. static unsigned long i5100_npages(struct mem_ctl_info *mci, int csrow)
  543. {
  544. struct i5100_priv *priv = mci->pvt_info;
  545. const unsigned chan_rank = i5100_csrow_to_rank(mci, csrow);
  546. const unsigned chan = i5100_csrow_to_chan(mci, csrow);
  547. unsigned addr_lines;
  548. /* dimm present? */
  549. if (!priv->mtr[chan][chan_rank].present)
  550. return 0ULL;
  551. addr_lines =
  552. I5100_DIMM_ADDR_LINES +
  553. priv->mtr[chan][chan_rank].numcol +
  554. priv->mtr[chan][chan_rank].numrow +
  555. priv->mtr[chan][chan_rank].numbank;
  556. return (unsigned long)
  557. ((unsigned long long) (1ULL << addr_lines) / PAGE_SIZE);
  558. }
  559. static void i5100_init_mtr(struct mem_ctl_info *mci)
  560. {
  561. struct i5100_priv *priv = mci->pvt_info;
  562. struct pci_dev *mms[2] = { priv->ch0mm, priv->ch1mm };
  563. int i;
  564. for (i = 0; i < I5100_CHANNELS; i++) {
  565. int j;
  566. struct pci_dev *pdev = mms[i];
  567. for (j = 0; j < I5100_MAX_RANKS_PER_CHAN; j++) {
  568. const unsigned addr =
  569. (j < 4) ? I5100_MTR_0 + j * 2 :
  570. I5100_MTR_4 + (j - 4) * 2;
  571. u16 w;
  572. pci_read_config_word(pdev, addr, &w);
  573. priv->mtr[i][j].present = i5100_mtr_present(w);
  574. priv->mtr[i][j].ethrottle = i5100_mtr_ethrottle(w);
  575. priv->mtr[i][j].width = 4 + 4 * i5100_mtr_width(w);
  576. priv->mtr[i][j].numbank = 2 + i5100_mtr_numbank(w);
  577. priv->mtr[i][j].numrow = 13 + i5100_mtr_numrow(w);
  578. priv->mtr[i][j].numcol = 10 + i5100_mtr_numcol(w);
  579. }
  580. }
  581. }
  582. /*
  583. * FIXME: make this into a real i2c adapter (so that dimm-decode
  584. * will work)?
  585. */
  586. static int i5100_read_spd_byte(const struct mem_ctl_info *mci,
  587. u8 ch, u8 slot, u8 addr, u8 *byte)
  588. {
  589. struct i5100_priv *priv = mci->pvt_info;
  590. u16 w;
  591. unsigned long et;
  592. pci_read_config_word(priv->mc, I5100_SPDDATA, &w);
  593. if (i5100_spddata_busy(w))
  594. return -1;
  595. pci_write_config_dword(priv->mc, I5100_SPDCMD,
  596. i5100_spdcmd_create(0xa, 1, ch * 4 + slot, addr,
  597. 0, 0));
  598. /* wait up to 100ms */
  599. et = jiffies + HZ / 10;
  600. udelay(100);
  601. while (1) {
  602. pci_read_config_word(priv->mc, I5100_SPDDATA, &w);
  603. if (!i5100_spddata_busy(w))
  604. break;
  605. udelay(100);
  606. }
  607. if (!i5100_spddata_rdo(w) || i5100_spddata_sbe(w))
  608. return -1;
  609. *byte = i5100_spddata_data(w);
  610. return 0;
  611. }
  612. /*
  613. * fill dimm chip select map
  614. *
  615. * FIXME:
  616. * o not the only way to may chip selects to dimm slots
  617. * o investigate if there is some way to obtain this map from the bios
  618. */
  619. static void i5100_init_dimm_csmap(struct mem_ctl_info *mci)
  620. {
  621. struct i5100_priv *priv = mci->pvt_info;
  622. int i;
  623. for (i = 0; i < I5100_MAX_DIMM_SLOTS_PER_CHAN; i++) {
  624. int j;
  625. for (j = 0; j < I5100_MAX_RANKS_PER_DIMM; j++)
  626. priv->dimm_csmap[i][j] = -1; /* default NC */
  627. }
  628. /* only 2 chip selects per slot... */
  629. if (priv->ranksperchan == 4) {
  630. priv->dimm_csmap[0][0] = 0;
  631. priv->dimm_csmap[0][1] = 3;
  632. priv->dimm_csmap[1][0] = 1;
  633. priv->dimm_csmap[1][1] = 2;
  634. priv->dimm_csmap[2][0] = 2;
  635. priv->dimm_csmap[3][0] = 3;
  636. } else {
  637. priv->dimm_csmap[0][0] = 0;
  638. priv->dimm_csmap[0][1] = 1;
  639. priv->dimm_csmap[1][0] = 2;
  640. priv->dimm_csmap[1][1] = 3;
  641. priv->dimm_csmap[2][0] = 4;
  642. priv->dimm_csmap[2][1] = 5;
  643. }
  644. }
  645. static void i5100_init_dimm_layout(struct pci_dev *pdev,
  646. struct mem_ctl_info *mci)
  647. {
  648. struct i5100_priv *priv = mci->pvt_info;
  649. int i;
  650. for (i = 0; i < I5100_CHANNELS; i++) {
  651. int j;
  652. for (j = 0; j < I5100_MAX_DIMM_SLOTS_PER_CHAN; j++) {
  653. u8 rank;
  654. if (i5100_read_spd_byte(mci, i, j, 5, &rank) < 0)
  655. priv->dimm_numrank[i][j] = 0;
  656. else
  657. priv->dimm_numrank[i][j] = (rank & 3) + 1;
  658. }
  659. }
  660. i5100_init_dimm_csmap(mci);
  661. }
  662. static void i5100_init_interleaving(struct pci_dev *pdev,
  663. struct mem_ctl_info *mci)
  664. {
  665. u16 w;
  666. u32 dw;
  667. struct i5100_priv *priv = mci->pvt_info;
  668. struct pci_dev *mms[2] = { priv->ch0mm, priv->ch1mm };
  669. int i;
  670. pci_read_config_word(pdev, I5100_TOLM, &w);
  671. priv->tolm = (u64) i5100_tolm_tolm(w) * 256 * 1024 * 1024;
  672. pci_read_config_word(pdev, I5100_MIR0, &w);
  673. priv->mir[0].limit = (u64) i5100_mir_limit(w) << 28;
  674. priv->mir[0].way[1] = i5100_mir_way1(w);
  675. priv->mir[0].way[0] = i5100_mir_way0(w);
  676. pci_read_config_word(pdev, I5100_MIR1, &w);
  677. priv->mir[1].limit = (u64) i5100_mir_limit(w) << 28;
  678. priv->mir[1].way[1] = i5100_mir_way1(w);
  679. priv->mir[1].way[0] = i5100_mir_way0(w);
  680. pci_read_config_word(pdev, I5100_AMIR_0, &w);
  681. priv->amir[0] = w;
  682. pci_read_config_word(pdev, I5100_AMIR_1, &w);
  683. priv->amir[1] = w;
  684. for (i = 0; i < I5100_CHANNELS; i++) {
  685. int j;
  686. for (j = 0; j < 5; j++) {
  687. int k;
  688. pci_read_config_dword(mms[i], I5100_DMIR + j * 4, &dw);
  689. priv->dmir[i][j].limit =
  690. (u64) i5100_dmir_limit(dw) << 28;
  691. for (k = 0; k < I5100_MAX_RANKS_PER_DIMM; k++)
  692. priv->dmir[i][j].rank[k] =
  693. i5100_dmir_rank(dw, k);
  694. }
  695. }
  696. i5100_init_mtr(mci);
  697. }
  698. static void i5100_init_csrows(struct mem_ctl_info *mci)
  699. {
  700. int i;
  701. struct i5100_priv *priv = mci->pvt_info;
  702. for (i = 0; i < mci->tot_dimms; i++) {
  703. struct dimm_info *dimm;
  704. const unsigned long npages = i5100_npages(mci, i);
  705. const unsigned chan = i5100_csrow_to_chan(mci, i);
  706. const unsigned rank = i5100_csrow_to_rank(mci, i);
  707. if (!npages)
  708. continue;
  709. dimm = EDAC_DIMM_PTR(mci->layers, mci->dimms, mci->n_layers,
  710. chan, rank, 0);
  711. dimm->nr_pages = npages;
  712. dimm->grain = 32;
  713. dimm->dtype = (priv->mtr[chan][rank].width == 4) ?
  714. DEV_X4 : DEV_X8;
  715. dimm->mtype = MEM_RDDR2;
  716. dimm->edac_mode = EDAC_SECDED;
  717. snprintf(dimm->label, sizeof(dimm->label), "DIMM%u",
  718. i5100_rank_to_slot(mci, chan, rank));
  719. edac_dbg(2, "dimm channel %d, rank %d, size %ld\n",
  720. chan, rank, (long)PAGES_TO_MiB(npages));
  721. }
  722. }
  723. /****************************************************************************
  724. * Error injection routines
  725. ****************************************************************************/
  726. static void i5100_do_inject(struct mem_ctl_info *mci)
  727. {
  728. struct i5100_priv *priv = mci->pvt_info;
  729. u32 mask0;
  730. u16 mask1;
  731. /* MEM[1:0]EINJMSK0
  732. * 31 - ADDRMATCHEN
  733. * 29:28 - HLINESEL
  734. * 00 Reserved
  735. * 01 Lower half of cache line
  736. * 10 Upper half of cache line
  737. * 11 Both upper and lower parts of cache line
  738. * 27 - EINJEN
  739. * 25:19 - XORMASK1 for deviceptr1
  740. * 9:5 - SEC2RAM for deviceptr2
  741. * 4:0 - FIR2RAM for deviceptr1
  742. */
  743. mask0 = ((priv->inject_hlinesel & 0x3) << 28) |
  744. I5100_MEMXEINJMSK0_EINJEN |
  745. ((priv->inject_eccmask1 & 0xffff) << 10) |
  746. ((priv->inject_deviceptr2 & 0x1f) << 5) |
  747. (priv->inject_deviceptr1 & 0x1f);
  748. /* MEM[1:0]EINJMSK1
  749. * 15:0 - XORMASK2 for deviceptr2
  750. */
  751. mask1 = priv->inject_eccmask2;
  752. if (priv->inject_channel == 0) {
  753. pci_write_config_dword(priv->mc, I5100_MEM0EINJMSK0, mask0);
  754. pci_write_config_word(priv->mc, I5100_MEM0EINJMSK1, mask1);
  755. } else {
  756. pci_write_config_dword(priv->mc, I5100_MEM1EINJMSK0, mask0);
  757. pci_write_config_word(priv->mc, I5100_MEM1EINJMSK1, mask1);
  758. }
  759. /* Error Injection Response Function
  760. * Intel 5100 Memory Controller Hub Chipset (318378) datasheet
  761. * hints about this register but carry no data about them. All
  762. * data regarding device 19 is based on experimentation and the
  763. * Intel 7300 Chipset Memory Controller Hub (318082) datasheet
  764. * which appears to be accurate for the i5100 in this area.
  765. *
  766. * The injection code don't work without setting this register.
  767. * The register needs to be flipped off then on else the hardware
  768. * will only preform the first injection.
  769. *
  770. * Stop condition bits 7:4
  771. * 1010 - Stop after one injection
  772. * 1011 - Never stop injecting faults
  773. *
  774. * Start condition bits 3:0
  775. * 1010 - Never start
  776. * 1011 - Start immediately
  777. */
  778. pci_write_config_byte(priv->einj, I5100_DINJ0, 0xaa);
  779. pci_write_config_byte(priv->einj, I5100_DINJ0, 0xab);
  780. }
  781. #define to_mci(k) container_of(k, struct mem_ctl_info, dev)
  782. static ssize_t inject_enable_write(struct file *file, const char __user *data,
  783. size_t count, loff_t *ppos)
  784. {
  785. struct device *dev = file->private_data;
  786. struct mem_ctl_info *mci = to_mci(dev);
  787. i5100_do_inject(mci);
  788. return count;
  789. }
  790. static const struct file_operations i5100_inject_enable_fops = {
  791. .open = simple_open,
  792. .write = inject_enable_write,
  793. .llseek = generic_file_llseek,
  794. };
  795. static int i5100_setup_debugfs(struct mem_ctl_info *mci)
  796. {
  797. struct i5100_priv *priv = mci->pvt_info;
  798. if (!i5100_debugfs)
  799. return -ENODEV;
  800. priv->debugfs = edac_debugfs_create_dir_at(mci->bus->name, i5100_debugfs);
  801. if (!priv->debugfs)
  802. return -ENOMEM;
  803. edac_debugfs_create_x8("inject_channel", S_IRUGO | S_IWUSR, priv->debugfs,
  804. &priv->inject_channel);
  805. edac_debugfs_create_x8("inject_hlinesel", S_IRUGO | S_IWUSR, priv->debugfs,
  806. &priv->inject_hlinesel);
  807. edac_debugfs_create_x8("inject_deviceptr1", S_IRUGO | S_IWUSR, priv->debugfs,
  808. &priv->inject_deviceptr1);
  809. edac_debugfs_create_x8("inject_deviceptr2", S_IRUGO | S_IWUSR, priv->debugfs,
  810. &priv->inject_deviceptr2);
  811. edac_debugfs_create_x16("inject_eccmask1", S_IRUGO | S_IWUSR, priv->debugfs,
  812. &priv->inject_eccmask1);
  813. edac_debugfs_create_x16("inject_eccmask2", S_IRUGO | S_IWUSR, priv->debugfs,
  814. &priv->inject_eccmask2);
  815. edac_debugfs_create_file("inject_enable", S_IWUSR, priv->debugfs,
  816. &mci->dev, &i5100_inject_enable_fops);
  817. return 0;
  818. }
  819. static int i5100_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
  820. {
  821. int rc;
  822. struct mem_ctl_info *mci;
  823. struct edac_mc_layer layers[2];
  824. struct i5100_priv *priv;
  825. struct pci_dev *ch0mm, *ch1mm, *einj;
  826. int ret = 0;
  827. u32 dw;
  828. int ranksperch;
  829. if (PCI_FUNC(pdev->devfn) != 1)
  830. return -ENODEV;
  831. rc = pci_enable_device(pdev);
  832. if (rc < 0) {
  833. ret = rc;
  834. goto bail;
  835. }
  836. /* ECC enabled? */
  837. pci_read_config_dword(pdev, I5100_MC, &dw);
  838. if (!i5100_mc_errdeten(dw)) {
  839. printk(KERN_INFO "i5100_edac: ECC not enabled.\n");
  840. ret = -ENODEV;
  841. goto bail_pdev;
  842. }
  843. /* figure out how many ranks, from strapped state of 48GB_Mode input */
  844. pci_read_config_dword(pdev, I5100_MS, &dw);
  845. ranksperch = !!(dw & (1 << 8)) * 2 + 4;
  846. /* enable error reporting... */
  847. pci_read_config_dword(pdev, I5100_EMASK_MEM, &dw);
  848. dw &= ~I5100_FERR_NF_MEM_ANY_MASK;
  849. pci_write_config_dword(pdev, I5100_EMASK_MEM, dw);
  850. /* device 21, func 0, Channel 0 Memory Map, Error Flag/Mask, etc... */
  851. ch0mm = pci_get_device_func(PCI_VENDOR_ID_INTEL,
  852. PCI_DEVICE_ID_INTEL_5100_21, 0);
  853. if (!ch0mm) {
  854. ret = -ENODEV;
  855. goto bail_pdev;
  856. }
  857. rc = pci_enable_device(ch0mm);
  858. if (rc < 0) {
  859. ret = rc;
  860. goto bail_ch0;
  861. }
  862. /* device 22, func 0, Channel 1 Memory Map, Error Flag/Mask, etc... */
  863. ch1mm = pci_get_device_func(PCI_VENDOR_ID_INTEL,
  864. PCI_DEVICE_ID_INTEL_5100_22, 0);
  865. if (!ch1mm) {
  866. ret = -ENODEV;
  867. goto bail_disable_ch0;
  868. }
  869. rc = pci_enable_device(ch1mm);
  870. if (rc < 0) {
  871. ret = rc;
  872. goto bail_ch1;
  873. }
  874. layers[0].type = EDAC_MC_LAYER_CHANNEL;
  875. layers[0].size = 2;
  876. layers[0].is_virt_csrow = false;
  877. layers[1].type = EDAC_MC_LAYER_SLOT;
  878. layers[1].size = ranksperch;
  879. layers[1].is_virt_csrow = true;
  880. mci = edac_mc_alloc(0, ARRAY_SIZE(layers), layers,
  881. sizeof(*priv));
  882. if (!mci) {
  883. ret = -ENOMEM;
  884. goto bail_disable_ch1;
  885. }
  886. /* device 19, func 0, Error injection */
  887. einj = pci_get_device_func(PCI_VENDOR_ID_INTEL,
  888. PCI_DEVICE_ID_INTEL_5100_19, 0);
  889. if (!einj) {
  890. ret = -ENODEV;
  891. goto bail_einj;
  892. }
  893. rc = pci_enable_device(einj);
  894. if (rc < 0) {
  895. ret = rc;
  896. goto bail_disable_einj;
  897. }
  898. mci->pdev = &pdev->dev;
  899. priv = mci->pvt_info;
  900. priv->ranksperchan = ranksperch;
  901. priv->mc = pdev;
  902. priv->ch0mm = ch0mm;
  903. priv->ch1mm = ch1mm;
  904. priv->einj = einj;
  905. INIT_DELAYED_WORK(&(priv->i5100_scrubbing), i5100_refresh_scrubbing);
  906. /* If scrubbing was already enabled by the bios, start maintaining it */
  907. pci_read_config_dword(pdev, I5100_MC, &dw);
  908. if (i5100_mc_scrben(dw)) {
  909. priv->scrub_enable = 1;
  910. schedule_delayed_work(&(priv->i5100_scrubbing),
  911. I5100_SCRUB_REFRESH_RATE);
  912. }
  913. i5100_init_dimm_layout(pdev, mci);
  914. i5100_init_interleaving(pdev, mci);
  915. mci->mtype_cap = MEM_FLAG_FB_DDR2;
  916. mci->edac_ctl_cap = EDAC_FLAG_SECDED;
  917. mci->edac_cap = EDAC_FLAG_SECDED;
  918. mci->mod_name = "i5100_edac.c";
  919. mci->ctl_name = "i5100";
  920. mci->dev_name = pci_name(pdev);
  921. mci->ctl_page_to_phys = NULL;
  922. mci->edac_check = i5100_check_error;
  923. mci->set_sdram_scrub_rate = i5100_set_scrub_rate;
  924. mci->get_sdram_scrub_rate = i5100_get_scrub_rate;
  925. priv->inject_channel = 0;
  926. priv->inject_hlinesel = 0;
  927. priv->inject_deviceptr1 = 0;
  928. priv->inject_deviceptr2 = 0;
  929. priv->inject_eccmask1 = 0;
  930. priv->inject_eccmask2 = 0;
  931. i5100_init_csrows(mci);
  932. /* this strange construction seems to be in every driver, dunno why */
  933. switch (edac_op_state) {
  934. case EDAC_OPSTATE_POLL:
  935. case EDAC_OPSTATE_NMI:
  936. break;
  937. default:
  938. edac_op_state = EDAC_OPSTATE_POLL;
  939. break;
  940. }
  941. if (edac_mc_add_mc(mci)) {
  942. ret = -ENODEV;
  943. goto bail_scrub;
  944. }
  945. i5100_setup_debugfs(mci);
  946. return ret;
  947. bail_scrub:
  948. priv->scrub_enable = 0;
  949. cancel_delayed_work_sync(&(priv->i5100_scrubbing));
  950. edac_mc_free(mci);
  951. bail_disable_einj:
  952. pci_disable_device(einj);
  953. bail_einj:
  954. pci_dev_put(einj);
  955. bail_disable_ch1:
  956. pci_disable_device(ch1mm);
  957. bail_ch1:
  958. pci_dev_put(ch1mm);
  959. bail_disable_ch0:
  960. pci_disable_device(ch0mm);
  961. bail_ch0:
  962. pci_dev_put(ch0mm);
  963. bail_pdev:
  964. pci_disable_device(pdev);
  965. bail:
  966. return ret;
  967. }
  968. static void i5100_remove_one(struct pci_dev *pdev)
  969. {
  970. struct mem_ctl_info *mci;
  971. struct i5100_priv *priv;
  972. mci = edac_mc_del_mc(&pdev->dev);
  973. if (!mci)
  974. return;
  975. priv = mci->pvt_info;
  976. edac_debugfs_remove_recursive(priv->debugfs);
  977. priv->scrub_enable = 0;
  978. cancel_delayed_work_sync(&(priv->i5100_scrubbing));
  979. pci_disable_device(pdev);
  980. pci_disable_device(priv->ch0mm);
  981. pci_disable_device(priv->ch1mm);
  982. pci_disable_device(priv->einj);
  983. pci_dev_put(priv->ch0mm);
  984. pci_dev_put(priv->ch1mm);
  985. pci_dev_put(priv->einj);
  986. edac_mc_free(mci);
  987. }
  988. static const struct pci_device_id i5100_pci_tbl[] = {
  989. /* Device 16, Function 0, Channel 0 Memory Map, Error Flag/Mask, ... */
  990. { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_5100_16) },
  991. { 0, }
  992. };
  993. MODULE_DEVICE_TABLE(pci, i5100_pci_tbl);
  994. static struct pci_driver i5100_driver = {
  995. .name = KBUILD_BASENAME,
  996. .probe = i5100_init_one,
  997. .remove = i5100_remove_one,
  998. .id_table = i5100_pci_tbl,
  999. };
  1000. static int __init i5100_init(void)
  1001. {
  1002. int pci_rc;
  1003. i5100_debugfs = edac_debugfs_create_dir_at("i5100_edac", NULL);
  1004. pci_rc = pci_register_driver(&i5100_driver);
  1005. return (pci_rc < 0) ? pci_rc : 0;
  1006. }
  1007. static void __exit i5100_exit(void)
  1008. {
  1009. edac_debugfs_remove(i5100_debugfs);
  1010. pci_unregister_driver(&i5100_driver);
  1011. }
  1012. module_init(i5100_init);
  1013. module_exit(i5100_exit);
  1014. MODULE_LICENSE("GPL");
  1015. MODULE_AUTHOR
  1016. ("Arthur Jones <ajones@riverbed.com>");
  1017. MODULE_DESCRIPTION("MC Driver for Intel I5100 memory controllers");