12 #include <linux/module.h>
14 #include <linux/pci.h>
19 #define I82975X_REVISION " Ver: 1.0.0"
20 #define EDAC_MOD_STR "i82975x_edac"
22 #define i82975x_printk(level, fmt, arg...) \
23 edac_printk(level, "i82975x", fmt, ##arg)
25 #define i82975x_mc_printk(mci, level, fmt, arg...) \
26 edac_mc_chipset_printk(mci, level, "i82975x", fmt, ##arg)
28 #ifndef PCI_DEVICE_ID_INTEL_82975_0
29 #define PCI_DEVICE_ID_INTEL_82975_0 0x277c
32 #define I82975X_NR_DIMMS 8
33 #define I82975X_NR_CSROWS(nr_chans) (I82975X_NR_DIMMS / (nr_chans))
36 #define I82975X_EAP 0x58
43 #define I82975X_DERRSYN 0x5c
48 #define I82975X_DES 0x5d
54 #define I82975X_ERRSTS 0xc8
72 #define I82975X_ERRCMD 0xca
84 #define I82975X_SMICMD 0xcc
91 #define I82975X_SCICMD 0xce
98 #define I82975X_XEAP 0xfc
104 #define I82975X_MCHBAR 0x44
115 #define I82975X_DRB_SHIFT 25
117 #define I82975X_DRB 0x100
125 #define I82975X_DRB_CH0R0 0x100
126 #define I82975X_DRB_CH0R1 0x101
127 #define I82975X_DRB_CH0R2 0x102
128 #define I82975X_DRB_CH0R3 0x103
129 #define I82975X_DRB_CH1R0 0x180
130 #define I82975X_DRB_CH1R1 0x181
131 #define I82975X_DRB_CH1R2 0x182
132 #define I82975X_DRB_CH1R3 0x183
135 #define I82975X_DRA 0x108
150 #define I82975X_DRA_CH0R01 0x108
151 #define I82975X_DRA_CH0R23 0x109
152 #define I82975X_DRA_CH1R01 0x188
153 #define I82975X_DRA_CH1R23 0x189
156 #define I82975X_BNKARC 0x10e
167 #define I82975X_C0BNKARC 0x10e
168 #define I82975X_C1BNKARC 0x18e
172 #define I82975X_DRC 0x120
192 #define I82975X_DRC_CH0M0 0x120
193 #define I82975X_DRC_CH1M0 0x1A0
196 #define I82975X_DRC_M1 0x124
202 #define I82975X_DRC_CH0M1 0x124
203 #define I82975X_DRC_CH1M1 0x1A4
229 .ctl_name =
"i82975x"
233 static struct pci_dev *mci_pdev;
237 static int i82975x_registered = 1;
278 static int i82975x_process_error_info(
struct mem_ctl_info *mci,
282 unsigned long offst,
page;
292 -1, -1, -1,
"UE overwrote CE",
"");
296 page = (
unsigned long) info->
eap;
308 (info->
xeap & 1) ? 1 : 0, info->
eap, (
unsigned int) page);
311 chan = (mci->
csrows[row]->nr_channels == 1) ? 0 : info->
eap & 1;
314 (1 << mci->
csrows[row]->channels[chan]->dimm->grain));
316 if (info->
errsts & 0x0002)
324 row, chan ? chan : 0, -1,
335 i82975x_get_error_info(mci, &info);
336 i82975x_process_error_info(mci, &info, 1);
340 static int dual_channel_active(
void __iomem *mch_window)
354 for (dualch = 1, row = 0; dualch && (row < 4); row++) {
357 dualch = dualch && (drb[row][0] == drb[row][1]);
362 static enum dev_type i82975x_dram_type(
void __iomem *mch_window,
int rank)
370 static void i82975x_init_csrows(
struct mem_ctl_info *mci,
374 unsigned long last_cumul_size;
376 u32 cumul_size, nr_pages;
392 for (index = 0; index < mci->
nr_csrows; index++) {
396 ((index >= 4) ? 0x80 : 0));
405 edac_dbg(3,
"(%d) cumul_size 0x%x\n", index, cumul_size);
407 nr_pages = cumul_size - last_cumul_size;
417 dtype = i82975x_dram_type(mch_window, index);
418 for (chan = 0; chan < csrow->
nr_channels; chan++) {
424 (chan == 0) ?
'A' :
'B',
426 dimm->
grain = 1 << 7;
427 dimm->
dtype = i82975x_dram_type(mch_window, index);
434 last_cumul_size = cumul_size;
440 #ifdef i82975x_DEBUG_IOMEM
441 static void i82975x_print_dram_timings(
void __iomem *mch_window)
449 static const int caslats[4] = { 5, 4, 3, 6 };
452 dtreg[0] =
readl(mch_window + 0x114);
453 dtreg[1] =
readl(mch_window + 0x194);
455 " RAS Active Min = %d %d\n"
456 " CAS latency = %d %d\n"
457 " RAS to CAS = %d %d\n"
458 " RAS precharge = %d %d\n",
459 (dtreg[0] >> 19 ) & 0x0f,
460 (dtreg[1] >> 19) & 0x0f,
461 caslats[(dtreg[0] >> 8) & 0x03],
462 caslats[(dtreg[1] >> 8) & 0x03],
463 ((dtreg[0] >> 4) & 0x07) + 2,
464 ((dtreg[1] >> 4) & 0x07) + 2,
465 (dtreg[0] & 0x07) + 2,
466 (dtreg[1] & 0x07) + 2
472 static int i82975x_probe1(
struct pci_dev *pdev,
int dev_idx)
483 #ifdef i82975x_DEBUG_IOMEM
492 edac_dbg(3,
"failed, MCHBAR disabled!\n");
495 mchbar &= 0xffffc000;
498 #ifdef i82975x_DEBUG_IOMEM
522 #ifdef i82975x_DEBUG_IOMEM
524 ((drc[0] >> 21) & 3) == 1 ?
525 "ECC enabled" :
"ECC disabled");
527 ((drc[1] >> 21) & 3) == 1 ?
528 "ECC enabled" :
"ECC disabled");
534 i82975x_print_dram_timings(mch_window);
537 if (!(((drc[0] >> 21) & 3) == 1 || ((drc[1] >> 21) & 3) == 1)) {
542 chans = dual_channel_active(mch_window) + 1;
547 layers[0].is_virt_csrow =
true;
550 layers[1].is_virt_csrow =
false;
571 i82975x_init_csrows(mci, pdev, mch_window);
573 i82975x_get_error_info(mci, &
discard);
577 edac_dbg(3,
"failed edac_mc_add_mc()\n");
607 if (mci_pdev ==
NULL)
645 .probe = i82975x_init_one,
647 .id_table = i82975x_pci_tbl,
650 static int __init i82975x_init(
void)
659 pci_rc = pci_register_driver(&i82975x_driver);
663 if (mci_pdev ==
NULL) {
668 edac_dbg(0,
"i82975x pci_get_device fail\n");
673 pci_rc = i82975x_init_one(mci_pdev, i82975x_pci_tbl);
688 if (mci_pdev !=
NULL)
694 static void __exit i82975x_exit(
void)
700 if (!i82975x_registered) {
701 i82975x_remove_one(mci_pdev);