i82975x_edac.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. /*
  2. * Intel 82975X Memory Controller kernel module
  3. * (C) 2007 aCarLab (India) Pvt. Ltd. (http://acarlab.com)
  4. * (C) 2007 jetzbroadband (http://jetzbroadband.com)
  5. * This file may be distributed under the terms of the
  6. * GNU General Public License.
  7. *
  8. * Written by Arvind R.
  9. * Copied from i82875p_edac.c source:
  10. */
  11. #include <linux/module.h>
  12. #include <linux/init.h>
  13. #include <linux/pci.h>
  14. #include <linux/pci_ids.h>
  15. #include <linux/edac.h>
  16. #include "edac_core.h"
  17. #define I82975X_REVISION " Ver: 1.0.0 " __DATE__
  18. #define EDAC_MOD_STR "i82975x_edac"
  19. #define i82975x_printk(level, fmt, arg...) \
  20. edac_printk(level, "i82975x", fmt, ##arg)
  21. #define i82975x_mc_printk(mci, level, fmt, arg...) \
  22. edac_mc_chipset_printk(mci, level, "i82975x", fmt, ##arg)
  23. #ifndef PCI_DEVICE_ID_INTEL_82975_0
  24. #define PCI_DEVICE_ID_INTEL_82975_0 0x277c
  25. #endif /* PCI_DEVICE_ID_INTEL_82975_0 */
  26. #define I82975X_NR_CSROWS(nr_chans) (8/(nr_chans))
  27. /* Intel 82975X register addresses - device 0 function 0 - DRAM Controller */
  28. #define I82975X_EAP 0x58 /* Dram Error Address Pointer (32b)
  29. *
  30. * 31:7 128 byte cache-line address
  31. * 6:1 reserved
  32. * 0 0: CH0; 1: CH1
  33. */
  34. #define I82975X_DERRSYN 0x5c /* Dram Error SYNdrome (8b)
  35. *
  36. * 7:0 DRAM ECC Syndrome
  37. */
  38. #define I82975X_DES 0x5d /* Dram ERRor DeSTination (8b)
  39. * 0h: Processor Memory Reads
  40. * 1h:7h reserved
  41. * More - See Page 65 of Intel DocSheet.
  42. */
  43. #define I82975X_ERRSTS 0xc8 /* Error Status Register (16b)
  44. *
  45. * 15:12 reserved
  46. * 11 Thermal Sensor Event
  47. * 10 reserved
  48. * 9 non-DRAM lock error (ndlock)
  49. * 8 Refresh Timeout
  50. * 7:2 reserved
  51. * 1 ECC UE (multibit DRAM error)
  52. * 0 ECC CE (singlebit DRAM error)
  53. */
  54. /* Error Reporting is supported by 3 mechanisms:
  55. 1. DMI SERR generation ( ERRCMD )
  56. 2. SMI DMI generation ( SMICMD )
  57. 3. SCI DMI generation ( SCICMD )
  58. NOTE: Only ONE of the three must be enabled
  59. */
  60. #define I82975X_ERRCMD 0xca /* Error Command (16b)
  61. *
  62. * 15:12 reserved
  63. * 11 Thermal Sensor Event
  64. * 10 reserved
  65. * 9 non-DRAM lock error (ndlock)
  66. * 8 Refresh Timeout
  67. * 7:2 reserved
  68. * 1 ECC UE (multibit DRAM error)
  69. * 0 ECC CE (singlebit DRAM error)
  70. */
  71. #define I82975X_SMICMD 0xcc /* Error Command (16b)
  72. *
  73. * 15:2 reserved
  74. * 1 ECC UE (multibit DRAM error)
  75. * 0 ECC CE (singlebit DRAM error)
  76. */
  77. #define I82975X_SCICMD 0xce /* Error Command (16b)
  78. *
  79. * 15:2 reserved
  80. * 1 ECC UE (multibit DRAM error)
  81. * 0 ECC CE (singlebit DRAM error)
  82. */
  83. #define I82975X_XEAP 0xfc /* Extended Dram Error Address Pointer (8b)
  84. *
  85. * 7:1 reserved
  86. * 0 Bit32 of the Dram Error Address
  87. */
  88. #define I82975X_MCHBAR 0x44 /*
  89. *
  90. * 31:14 Base Addr of 16K memory-mapped
  91. * configuration space
  92. * 13:1 reserverd
  93. * 0 mem-mapped config space enable
  94. */
  95. /* NOTE: Following addresses have to indexed using MCHBAR offset (44h, 32b) */
  96. /* Intel 82975x memory mapped register space */
  97. #define I82975X_DRB_SHIFT 25 /* fixed 32MiB grain */
  98. #define I82975X_DRB 0x100 /* DRAM Row Boundary (8b x 8)
  99. *
  100. * 7 set to 1 in highest DRB of
  101. * channel if 4GB in ch.
  102. * 6:2 upper boundary of rank in
  103. * 32MB grains
  104. * 1:0 set to 0
  105. */
  106. #define I82975X_DRB_CH0R0 0x100
  107. #define I82975X_DRB_CH0R1 0x101
  108. #define I82975X_DRB_CH0R2 0x102
  109. #define I82975X_DRB_CH0R3 0x103
  110. #define I82975X_DRB_CH1R0 0x180
  111. #define I82975X_DRB_CH1R1 0x181
  112. #define I82975X_DRB_CH1R2 0x182
  113. #define I82975X_DRB_CH1R3 0x183
  114. #define I82975X_DRA 0x108 /* DRAM Row Attribute (4b x 8)
  115. * defines the PAGE SIZE to be used
  116. * for the rank
  117. * 7 reserved
  118. * 6:4 row attr of odd rank, i.e. 1
  119. * 3 reserved
  120. * 2:0 row attr of even rank, i.e. 0
  121. *
  122. * 000 = unpopulated
  123. * 001 = reserved
  124. * 010 = 4KiB
  125. * 011 = 8KiB
  126. * 100 = 16KiB
  127. * others = reserved
  128. */
  129. #define I82975X_DRA_CH0R01 0x108
  130. #define I82975X_DRA_CH0R23 0x109
  131. #define I82975X_DRA_CH1R01 0x188
  132. #define I82975X_DRA_CH1R23 0x189
  133. #define I82975X_BNKARC 0x10e /* Type of device in each rank - Bank Arch (16b)
  134. *
  135. * 15:8 reserved
  136. * 7:6 Rank 3 architecture
  137. * 5:4 Rank 2 architecture
  138. * 3:2 Rank 1 architecture
  139. * 1:0 Rank 0 architecture
  140. *
  141. * 00 => x16 devices; i.e 4 banks
  142. * 01 => x8 devices; i.e 8 banks
  143. */
  144. #define I82975X_C0BNKARC 0x10e
  145. #define I82975X_C1BNKARC 0x18e
  146. #define I82975X_DRC 0x120 /* DRAM Controller Mode0 (32b)
  147. *
  148. * 31:30 reserved
  149. * 29 init complete
  150. * 28:11 reserved, according to Intel
  151. * 22:21 number of channels
  152. * 00=1 01=2 in 82875
  153. * seems to be ECC mode
  154. * bits in 82975 in Asus
  155. * P5W
  156. * 19:18 Data Integ Mode
  157. * 00=none 01=ECC in 82875
  158. * 10:8 refresh mode
  159. * 7 reserved
  160. * 6:4 mode select
  161. * 3:2 reserved
  162. * 1:0 DRAM type 10=Second Revision
  163. * DDR2 SDRAM
  164. * 00, 01, 11 reserved
  165. */
  166. #define I82975X_DRC_CH0M0 0x120
  167. #define I82975X_DRC_CH1M0 0x1A0
  168. #define I82975X_DRC_M1 0x124 /* DRAM Controller Mode1 (32b)
  169. * 31 0=Standard Address Map
  170. * 1=Enhanced Address Map
  171. * 30:0 reserved
  172. */
  173. #define I82975X_DRC_CH0M1 0x124
  174. #define I82975X_DRC_CH1M1 0x1A4
  175. enum i82975x_chips {
  176. I82975X = 0,
  177. };
  178. struct i82975x_pvt {
  179. void __iomem *mch_window;
  180. };
  181. struct i82975x_dev_info {
  182. const char *ctl_name;
  183. };
  184. struct i82975x_error_info {
  185. u16 errsts;
  186. u32 eap;
  187. u8 des;
  188. u8 derrsyn;
  189. u16 errsts2;
  190. u8 chan; /* the channel is bit 0 of EAP */
  191. u8 xeap; /* extended eap bit */
  192. };
  193. static const struct i82975x_dev_info i82975x_devs[] = {
  194. [I82975X] = {
  195. .ctl_name = "i82975x"
  196. },
  197. };
  198. static struct pci_dev *mci_pdev; /* init dev: in case that AGP code has
  199. * already registered driver
  200. */
  201. static int i82975x_registered = 1;
  202. static void i82975x_get_error_info(struct mem_ctl_info *mci,
  203. struct i82975x_error_info *info)
  204. {
  205. struct pci_dev *pdev;
  206. pdev = to_pci_dev(mci->dev);
  207. /*
  208. * This is a mess because there is no atomic way to read all the
  209. * registers at once and the registers can transition from CE being
  210. * overwritten by UE.
  211. */
  212. pci_read_config_word(pdev, I82975X_ERRSTS, &info->errsts);
  213. pci_read_config_dword(pdev, I82975X_EAP, &info->eap);
  214. pci_read_config_byte(pdev, I82975X_XEAP, &info->xeap);
  215. pci_read_config_byte(pdev, I82975X_DES, &info->des);
  216. pci_read_config_byte(pdev, I82975X_DERRSYN, &info->derrsyn);
  217. pci_read_config_word(pdev, I82975X_ERRSTS, &info->errsts2);
  218. pci_write_bits16(pdev, I82975X_ERRSTS, 0x0003, 0x0003);
  219. /*
  220. * If the error is the same then we can for both reads then
  221. * the first set of reads is valid. If there is a change then
  222. * there is a CE no info and the second set of reads is valid
  223. * and should be UE info.
  224. */
  225. if (!(info->errsts2 & 0x0003))
  226. return;
  227. if ((info->errsts ^ info->errsts2) & 0x0003) {
  228. pci_read_config_dword(pdev, I82975X_EAP, &info->eap);
  229. pci_read_config_byte(pdev, I82975X_XEAP, &info->xeap);
  230. pci_read_config_byte(pdev, I82975X_DES, &info->des);
  231. pci_read_config_byte(pdev, I82975X_DERRSYN,
  232. &info->derrsyn);
  233. }
  234. }
  235. static int i82975x_process_error_info(struct mem_ctl_info *mci,
  236. struct i82975x_error_info *info, int handle_errors)
  237. {
  238. int row, multi_chan, chan;
  239. multi_chan = mci->csrows[0].nr_channels - 1;
  240. if (!(info->errsts2 & 0x0003))
  241. return 0;
  242. if (!handle_errors)
  243. return 1;
  244. if ((info->errsts ^ info->errsts2) & 0x0003) {
  245. edac_mc_handle_ce_no_info(mci, "UE overwrote CE");
  246. info->errsts = info->errsts2;
  247. }
  248. chan = info->eap & 1;
  249. info->eap >>= 1;
  250. if (info->xeap )
  251. info->eap |= 0x80000000;
  252. info->eap >>= PAGE_SHIFT;
  253. row = edac_mc_find_csrow_by_page(mci, info->eap);
  254. if (info->errsts & 0x0002)
  255. edac_mc_handle_ue(mci, info->eap, 0, row, "i82975x UE");
  256. else
  257. edac_mc_handle_ce(mci, info->eap, 0, info->derrsyn, row,
  258. multi_chan ? chan : 0,
  259. "i82975x CE");
  260. return 1;
  261. }
  262. static void i82975x_check(struct mem_ctl_info *mci)
  263. {
  264. struct i82975x_error_info info;
  265. debugf1("MC%d: %s()\n", mci->mc_idx, __func__);
  266. i82975x_get_error_info(mci, &info);
  267. i82975x_process_error_info(mci, &info, 1);
  268. }
  269. /* Return 1 if dual channel mode is active. Else return 0. */
  270. static int dual_channel_active(void __iomem *mch_window)
  271. {
  272. /*
  273. * We treat interleaved-symmetric configuration as dual-channel - EAP's
  274. * bit-0 giving the channel of the error location.
  275. *
  276. * All other configurations are treated as single channel - the EAP's
  277. * bit-0 will resolve ok in symmetric area of mixed
  278. * (symmetric/asymmetric) configurations
  279. */
  280. u8 drb[4][2];
  281. int row;
  282. int dualch;
  283. for (dualch = 1, row = 0; dualch && (row < 4); row++) {
  284. drb[row][0] = readb(mch_window + I82975X_DRB + row);
  285. drb[row][1] = readb(mch_window + I82975X_DRB + row + 0x80);
  286. dualch = dualch && (drb[row][0] == drb[row][1]);
  287. }
  288. return dualch;
  289. }
  290. static enum dev_type i82975x_dram_type(void __iomem *mch_window, int rank)
  291. {
  292. /*
  293. * ASUS P5W DH either does not program this register or programs
  294. * it wrong!
  295. * ECC is possible on i92975x ONLY with DEV_X8 which should mean 'val'
  296. * for each rank should be 01b - the LSB of the word should be 0x55;
  297. * but it reads 0!
  298. */
  299. return DEV_X8;
  300. }
  301. static void i82975x_init_csrows(struct mem_ctl_info *mci,
  302. struct pci_dev *pdev, void __iomem *mch_window)
  303. {
  304. struct csrow_info *csrow;
  305. unsigned long last_cumul_size;
  306. u8 value;
  307. u32 cumul_size;
  308. int index;
  309. last_cumul_size = 0;
  310. /*
  311. * 82875 comment:
  312. * The dram row boundary (DRB) reg values are boundary address
  313. * for each DRAM row with a granularity of 32 or 64MB (single/dual
  314. * channel operation). DRB regs are cumulative; therefore DRB7 will
  315. * contain the total memory contained in all eight rows.
  316. *
  317. * FIXME:
  318. * EDAC currently works for Dual-channel Interleaved configuration.
  319. * Other configurations, which the chip supports, need fixing/testing.
  320. *
  321. */
  322. for (index = 0; index < mci->nr_csrows; index++) {
  323. csrow = &mci->csrows[index];
  324. value = readb(mch_window + I82975X_DRB + index +
  325. ((index >= 4) ? 0x80 : 0));
  326. cumul_size = value;
  327. cumul_size <<= (I82975X_DRB_SHIFT - PAGE_SHIFT);
  328. debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index,
  329. cumul_size);
  330. if (cumul_size == last_cumul_size)
  331. continue; /* not populated */
  332. csrow->first_page = last_cumul_size;
  333. csrow->last_page = cumul_size - 1;
  334. csrow->nr_pages = cumul_size - last_cumul_size;
  335. last_cumul_size = cumul_size;
  336. csrow->grain = 1 << 7; /* I82975X_EAP has 128B resolution */
  337. csrow->mtype = MEM_DDR; /* i82975x supports only DDR2 */
  338. csrow->dtype = i82975x_dram_type(mch_window, index);
  339. csrow->edac_mode = EDAC_SECDED; /* only supported */
  340. }
  341. }
  342. /* #define i82975x_DEBUG_IOMEM */
  343. #ifdef i82975x_DEBUG_IOMEM
  344. static void i82975x_print_dram_timings(void __iomem *mch_window)
  345. {
  346. /*
  347. * The register meanings are from Intel specs;
  348. * (shows 13-5-5-5 for 800-DDR2)
  349. * Asus P5W Bios reports 15-5-4-4
  350. * What's your religion?
  351. */
  352. static const int caslats[4] = { 5, 4, 3, 6 };
  353. u32 dtreg[2];
  354. dtreg[0] = readl(mch_window + 0x114);
  355. dtreg[1] = readl(mch_window + 0x194);
  356. i82975x_printk(KERN_INFO, "DRAM Timings : Ch0 Ch1\n"
  357. " RAS Active Min = %d %d\n"
  358. " CAS latency = %d %d\n"
  359. " RAS to CAS = %d %d\n"
  360. " RAS precharge = %d %d\n",
  361. (dtreg[0] >> 19 ) & 0x0f,
  362. (dtreg[1] >> 19) & 0x0f,
  363. caslats[(dtreg[0] >> 8) & 0x03],
  364. caslats[(dtreg[1] >> 8) & 0x03],
  365. ((dtreg[0] >> 4) & 0x07) + 2,
  366. ((dtreg[1] >> 4) & 0x07) + 2,
  367. (dtreg[0] & 0x07) + 2,
  368. (dtreg[1] & 0x07) + 2
  369. );
  370. }
  371. #endif
  372. static int i82975x_probe1(struct pci_dev *pdev, int dev_idx)
  373. {
  374. int rc = -ENODEV;
  375. struct mem_ctl_info *mci;
  376. struct i82975x_pvt *pvt;
  377. void __iomem *mch_window;
  378. u32 mchbar;
  379. u32 drc[2];
  380. struct i82975x_error_info discard;
  381. int chans;
  382. #ifdef i82975x_DEBUG_IOMEM
  383. u8 c0drb[4];
  384. u8 c1drb[4];
  385. #endif
  386. debugf0("%s()\n", __func__);
  387. pci_read_config_dword(pdev, I82975X_MCHBAR, &mchbar);
  388. if (!(mchbar & 1)) {
  389. debugf3("%s(): failed, MCHBAR disabled!\n", __func__);
  390. goto fail0;
  391. }
  392. mchbar &= 0xffffc000; /* bits 31:14 used for 16K window */
  393. mch_window = ioremap_nocache(mchbar, 0x1000);
  394. #ifdef i82975x_DEBUG_IOMEM
  395. i82975x_printk(KERN_INFO, "MCHBAR real = %0x, remapped = %p\n",
  396. mchbar, mch_window);
  397. c0drb[0] = readb(mch_window + I82975X_DRB_CH0R0);
  398. c0drb[1] = readb(mch_window + I82975X_DRB_CH0R1);
  399. c0drb[2] = readb(mch_window + I82975X_DRB_CH0R2);
  400. c0drb[3] = readb(mch_window + I82975X_DRB_CH0R3);
  401. c1drb[0] = readb(mch_window + I82975X_DRB_CH1R0);
  402. c1drb[1] = readb(mch_window + I82975X_DRB_CH1R1);
  403. c1drb[2] = readb(mch_window + I82975X_DRB_CH1R2);
  404. c1drb[3] = readb(mch_window + I82975X_DRB_CH1R3);
  405. i82975x_printk(KERN_INFO, "DRBCH0R0 = 0x%02x\n", c0drb[0]);
  406. i82975x_printk(KERN_INFO, "DRBCH0R1 = 0x%02x\n", c0drb[1]);
  407. i82975x_printk(KERN_INFO, "DRBCH0R2 = 0x%02x\n", c0drb[2]);
  408. i82975x_printk(KERN_INFO, "DRBCH0R3 = 0x%02x\n", c0drb[3]);
  409. i82975x_printk(KERN_INFO, "DRBCH1R0 = 0x%02x\n", c1drb[0]);
  410. i82975x_printk(KERN_INFO, "DRBCH1R1 = 0x%02x\n", c1drb[1]);
  411. i82975x_printk(KERN_INFO, "DRBCH1R2 = 0x%02x\n", c1drb[2]);
  412. i82975x_printk(KERN_INFO, "DRBCH1R3 = 0x%02x\n", c1drb[3]);
  413. #endif
  414. drc[0] = readl(mch_window + I82975X_DRC_CH0M0);
  415. drc[1] = readl(mch_window + I82975X_DRC_CH1M0);
  416. #ifdef i82975x_DEBUG_IOMEM
  417. i82975x_printk(KERN_INFO, "DRC_CH0 = %0x, %s\n", drc[0],
  418. ((drc[0] >> 21) & 3) == 1 ?
  419. "ECC enabled" : "ECC disabled");
  420. i82975x_printk(KERN_INFO, "DRC_CH1 = %0x, %s\n", drc[1],
  421. ((drc[1] >> 21) & 3) == 1 ?
  422. "ECC enabled" : "ECC disabled");
  423. i82975x_printk(KERN_INFO, "C0 BNKARC = %0x\n",
  424. readw(mch_window + I82975X_C0BNKARC));
  425. i82975x_printk(KERN_INFO, "C1 BNKARC = %0x\n",
  426. readw(mch_window + I82975X_C1BNKARC));
  427. i82975x_print_dram_timings(mch_window);
  428. goto fail1;
  429. #endif
  430. if (!(((drc[0] >> 21) & 3) == 1 || ((drc[1] >> 21) & 3) == 1)) {
  431. i82975x_printk(KERN_INFO, "ECC disabled on both channels.\n");
  432. goto fail1;
  433. }
  434. chans = dual_channel_active(mch_window) + 1;
  435. /* assuming only one controller, index thus is 0 */
  436. mci = edac_mc_alloc(sizeof(*pvt), I82975X_NR_CSROWS(chans),
  437. chans, 0);
  438. if (!mci) {
  439. rc = -ENOMEM;
  440. goto fail1;
  441. }
  442. debugf3("%s(): init mci\n", __func__);
  443. mci->dev = &pdev->dev;
  444. mci->mtype_cap = MEM_FLAG_DDR;
  445. mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED;
  446. mci->edac_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED;
  447. mci->mod_name = EDAC_MOD_STR;
  448. mci->mod_ver = I82975X_REVISION;
  449. mci->ctl_name = i82975x_devs[dev_idx].ctl_name;
  450. mci->edac_check = i82975x_check;
  451. mci->ctl_page_to_phys = NULL;
  452. debugf3("%s(): init pvt\n", __func__);
  453. pvt = (struct i82975x_pvt *) mci->pvt_info;
  454. pvt->mch_window = mch_window;
  455. i82975x_init_csrows(mci, pdev, mch_window);
  456. i82975x_get_error_info(mci, &discard); /* clear counters */
  457. /* finalize this instance of memory controller with edac core */
  458. if (edac_mc_add_mc(mci)) {
  459. debugf3("%s(): failed edac_mc_add_mc()\n", __func__);
  460. goto fail2;
  461. }
  462. /* get this far and it's successful */
  463. debugf3("%s(): success\n", __func__);
  464. return 0;
  465. fail2:
  466. edac_mc_free(mci);
  467. fail1:
  468. iounmap(mch_window);
  469. fail0:
  470. return rc;
  471. }
  472. /* returns count (>= 0), or negative on error */
  473. static int __devinit i82975x_init_one(struct pci_dev *pdev,
  474. const struct pci_device_id *ent)
  475. {
  476. int rc;
  477. debugf0("%s()\n", __func__);
  478. if (pci_enable_device(pdev) < 0)
  479. return -EIO;
  480. rc = i82975x_probe1(pdev, ent->driver_data);
  481. if (mci_pdev == NULL)
  482. mci_pdev = pci_dev_get(pdev);
  483. return rc;
  484. }
  485. static void __devexit i82975x_remove_one(struct pci_dev *pdev)
  486. {
  487. struct mem_ctl_info *mci;
  488. struct i82975x_pvt *pvt;
  489. debugf0("%s()\n", __func__);
  490. mci = edac_mc_del_mc(&pdev->dev);
  491. if (mci == NULL)
  492. return;
  493. pvt = mci->pvt_info;
  494. if (pvt->mch_window)
  495. iounmap( pvt->mch_window );
  496. edac_mc_free(mci);
  497. }
  498. static const struct pci_device_id i82975x_pci_tbl[] __devinitdata = {
  499. {
  500. PCI_VEND_DEV(INTEL, 82975_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
  501. I82975X
  502. },
  503. {
  504. 0,
  505. } /* 0 terminated list. */
  506. };
  507. MODULE_DEVICE_TABLE(pci, i82975x_pci_tbl);
  508. static struct pci_driver i82975x_driver = {
  509. .name = EDAC_MOD_STR,
  510. .probe = i82975x_init_one,
  511. .remove = __devexit_p(i82975x_remove_one),
  512. .id_table = i82975x_pci_tbl,
  513. };
  514. static int __init i82975x_init(void)
  515. {
  516. int pci_rc;
  517. debugf3("%s()\n", __func__);
  518. /* Ensure that the OPSTATE is set correctly for POLL or NMI */
  519. opstate_init();
  520. pci_rc = pci_register_driver(&i82975x_driver);
  521. if (pci_rc < 0)
  522. goto fail0;
  523. if (mci_pdev == NULL) {
  524. mci_pdev = pci_get_device(PCI_VENDOR_ID_INTEL,
  525. PCI_DEVICE_ID_INTEL_82975_0, NULL);
  526. if (!mci_pdev) {
  527. debugf0("i82975x pci_get_device fail\n");
  528. pci_rc = -ENODEV;
  529. goto fail1;
  530. }
  531. pci_rc = i82975x_init_one(mci_pdev, i82975x_pci_tbl);
  532. if (pci_rc < 0) {
  533. debugf0("i82975x init fail\n");
  534. pci_rc = -ENODEV;
  535. goto fail1;
  536. }
  537. }
  538. return 0;
  539. fail1:
  540. pci_unregister_driver(&i82975x_driver);
  541. fail0:
  542. if (mci_pdev != NULL)
  543. pci_dev_put(mci_pdev);
  544. return pci_rc;
  545. }
  546. static void __exit i82975x_exit(void)
  547. {
  548. debugf3("%s()\n", __func__);
  549. pci_unregister_driver(&i82975x_driver);
  550. if (!i82975x_registered) {
  551. i82975x_remove_one(mci_pdev);
  552. pci_dev_put(mci_pdev);
  553. }
  554. }
  555. module_init(i82975x_init);
  556. module_exit(i82975x_exit);
  557. MODULE_LICENSE("GPL");
  558. MODULE_AUTHOR("Arvind R. <arvind@acarlab.com>");
  559. MODULE_DESCRIPTION("MC support for Intel 82975 memory hub controllers");
  560. module_param(edac_op_state, int, 0444);
  561. MODULE_PARM_DESC(edac_op_state, "EDAC Error Reporting state: 0=Poll,1=NMI");