Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Intel e7xxx Memory Controller kernel module |
| 3 | * (C) 2003 Linux Networx (http://lnxi.com) |
| 4 | * This file may be distributed under the terms of the |
| 5 | * GNU General Public License. |
| 6 | * |
| 7 | * See "enum e7xxx_chips" below for supported chipsets |
| 8 | * |
| 9 | * Written by Thayne Harbaugh |
| 10 | * Based on work by Dan Hollis <goemon at anime dot net> and others. |
| 11 | * http://www.anime.net/~goemon/linux-ecc/ |
| 12 | * |
Mauro Carvalho Chehab | 30ac440 | 2012-04-16 15:07:09 -0300 | [diff] [blame] | 13 | * Datasheet: |
| 14 | * http://www.intel.com/content/www/us/en/chipsets/e7501-chipset-memory-controller-hub-datasheet.html |
| 15 | * |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 16 | * Contributors: |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 17 | * Eric Biederman (Linux Networx) |
| 18 | * Tom Zimmerman (Linux Networx) |
| 19 | * Jim Garlick (Lawrence Livermore National Labs) |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 20 | * Dave Peterson (Lawrence Livermore National Labs) |
| 21 | * That One Guy (Some other place) |
| 22 | * Wang Zhenyu (intel.com) |
| 23 | * |
| 24 | * $Id: edac_e7xxx.c,v 1.5.2.9 2005/10/05 00:43:44 dsp_llnl Exp $ |
| 25 | * |
| 26 | */ |
| 27 | |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 28 | #include <linux/module.h> |
| 29 | #include <linux/init.h> |
| 30 | #include <linux/pci.h> |
| 31 | #include <linux/pci_ids.h> |
Dave Jiang | c0d1217 | 2007-07-19 01:49:46 -0700 | [diff] [blame] | 32 | #include <linux/edac.h> |
Douglas Thompson | 20bcb7a | 2007-07-19 01:49:47 -0700 | [diff] [blame] | 33 | #include "edac_core.h" |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 34 | |
Michal Marek | 152ba39 | 2011-04-01 12:41:20 +0200 | [diff] [blame] | 35 | #define E7XXX_REVISION " Ver: 2.0.2" |
Doug Thompson | 929a40e | 2006-07-01 04:35:45 -0700 | [diff] [blame] | 36 | #define EDAC_MOD_STR "e7xxx_edac" |
Doug Thompson | 37f0458 | 2006-06-30 01:56:07 -0700 | [diff] [blame] | 37 | |
Dave Peterson | 537fba2 | 2006-03-26 01:38:40 -0800 | [diff] [blame] | 38 | #define e7xxx_printk(level, fmt, arg...) \ |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 39 | edac_printk(level, "e7xxx", fmt, ##arg) |
Dave Peterson | 537fba2 | 2006-03-26 01:38:40 -0800 | [diff] [blame] | 40 | |
| 41 | #define e7xxx_mc_printk(mci, level, fmt, arg...) \ |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 42 | edac_mc_chipset_printk(mci, level, "e7xxx", fmt, ##arg) |
Dave Peterson | 537fba2 | 2006-03-26 01:38:40 -0800 | [diff] [blame] | 43 | |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 44 | #ifndef PCI_DEVICE_ID_INTEL_7205_0 |
| 45 | #define PCI_DEVICE_ID_INTEL_7205_0 0x255d |
| 46 | #endif /* PCI_DEVICE_ID_INTEL_7205_0 */ |
| 47 | |
| 48 | #ifndef PCI_DEVICE_ID_INTEL_7205_1_ERR |
| 49 | #define PCI_DEVICE_ID_INTEL_7205_1_ERR 0x2551 |
| 50 | #endif /* PCI_DEVICE_ID_INTEL_7205_1_ERR */ |
| 51 | |
| 52 | #ifndef PCI_DEVICE_ID_INTEL_7500_0 |
| 53 | #define PCI_DEVICE_ID_INTEL_7500_0 0x2540 |
| 54 | #endif /* PCI_DEVICE_ID_INTEL_7500_0 */ |
| 55 | |
| 56 | #ifndef PCI_DEVICE_ID_INTEL_7500_1_ERR |
| 57 | #define PCI_DEVICE_ID_INTEL_7500_1_ERR 0x2541 |
| 58 | #endif /* PCI_DEVICE_ID_INTEL_7500_1_ERR */ |
| 59 | |
| 60 | #ifndef PCI_DEVICE_ID_INTEL_7501_0 |
| 61 | #define PCI_DEVICE_ID_INTEL_7501_0 0x254c |
| 62 | #endif /* PCI_DEVICE_ID_INTEL_7501_0 */ |
| 63 | |
| 64 | #ifndef PCI_DEVICE_ID_INTEL_7501_1_ERR |
| 65 | #define PCI_DEVICE_ID_INTEL_7501_1_ERR 0x2541 |
| 66 | #endif /* PCI_DEVICE_ID_INTEL_7501_1_ERR */ |
| 67 | |
| 68 | #ifndef PCI_DEVICE_ID_INTEL_7505_0 |
| 69 | #define PCI_DEVICE_ID_INTEL_7505_0 0x2550 |
| 70 | #endif /* PCI_DEVICE_ID_INTEL_7505_0 */ |
| 71 | |
| 72 | #ifndef PCI_DEVICE_ID_INTEL_7505_1_ERR |
| 73 | #define PCI_DEVICE_ID_INTEL_7505_1_ERR 0x2551 |
| 74 | #endif /* PCI_DEVICE_ID_INTEL_7505_1_ERR */ |
| 75 | |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 76 | #define E7XXX_NR_CSROWS 8 /* number of csrows */ |
Mauro Carvalho Chehab | 30ac440 | 2012-04-16 15:07:09 -0300 | [diff] [blame] | 77 | #define E7XXX_NR_DIMMS 8 /* 2 channels, 4 dimms/channel */ |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 78 | |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 79 | /* E7XXX register addresses - device 0 function 0 */ |
| 80 | #define E7XXX_DRB 0x60 /* DRAM row boundary register (8b) */ |
| 81 | #define E7XXX_DRA 0x70 /* DRAM row attribute register (8b) */ |
| 82 | /* |
| 83 | * 31 Device width row 7 0=x8 1=x4 |
| 84 | * 27 Device width row 6 |
| 85 | * 23 Device width row 5 |
| 86 | * 19 Device width row 4 |
| 87 | * 15 Device width row 3 |
| 88 | * 11 Device width row 2 |
| 89 | * 7 Device width row 1 |
| 90 | * 3 Device width row 0 |
| 91 | */ |
| 92 | #define E7XXX_DRC 0x7C /* DRAM controller mode reg (32b) */ |
| 93 | /* |
| 94 | * 22 Number channels 0=1,1=2 |
| 95 | * 19:18 DRB Granularity 32/64MB |
| 96 | */ |
| 97 | #define E7XXX_TOLM 0xC4 /* DRAM top of low memory reg (16b) */ |
| 98 | #define E7XXX_REMAPBASE 0xC6 /* DRAM remap base address reg (16b) */ |
| 99 | #define E7XXX_REMAPLIMIT 0xC8 /* DRAM remap limit address reg (16b) */ |
| 100 | |
| 101 | /* E7XXX register addresses - device 0 function 1 */ |
| 102 | #define E7XXX_DRAM_FERR 0x80 /* DRAM first error register (8b) */ |
| 103 | #define E7XXX_DRAM_NERR 0x82 /* DRAM next error register (8b) */ |
| 104 | #define E7XXX_DRAM_CELOG_ADD 0xA0 /* DRAM first correctable memory */ |
| 105 | /* error address register (32b) */ |
| 106 | /* |
| 107 | * 31:28 Reserved |
| 108 | * 27:6 CE address (4k block 33:12) |
| 109 | * 5:0 Reserved |
| 110 | */ |
| 111 | #define E7XXX_DRAM_UELOG_ADD 0xB0 /* DRAM first uncorrectable memory */ |
| 112 | /* error address register (32b) */ |
| 113 | /* |
| 114 | * 31:28 Reserved |
| 115 | * 27:6 CE address (4k block 33:12) |
| 116 | * 5:0 Reserved |
| 117 | */ |
| 118 | #define E7XXX_DRAM_CELOG_SYNDROME 0xD0 /* DRAM first correctable memory */ |
| 119 | /* error syndrome register (16b) */ |
| 120 | |
| 121 | enum e7xxx_chips { |
| 122 | E7500 = 0, |
| 123 | E7501, |
| 124 | E7505, |
| 125 | E7205, |
| 126 | }; |
| 127 | |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 128 | struct e7xxx_pvt { |
| 129 | struct pci_dev *bridge_ck; |
| 130 | u32 tolm; |
| 131 | u32 remapbase; |
| 132 | u32 remaplimit; |
| 133 | const struct e7xxx_dev_info *dev_info; |
| 134 | }; |
| 135 | |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 136 | struct e7xxx_dev_info { |
| 137 | u16 err_dev; |
| 138 | const char *ctl_name; |
| 139 | }; |
| 140 | |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 141 | struct e7xxx_error_info { |
| 142 | u8 dram_ferr; |
| 143 | u8 dram_nerr; |
| 144 | u32 dram_celog_add; |
| 145 | u16 dram_celog_syndrome; |
| 146 | u32 dram_uelog_add; |
| 147 | }; |
| 148 | |
Dave Jiang | 456a2f9 | 2007-07-19 01:50:10 -0700 | [diff] [blame] | 149 | static struct edac_pci_ctl_info *e7xxx_pci; |
| 150 | |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 151 | static const struct e7xxx_dev_info e7xxx_devs[] = { |
| 152 | [E7500] = { |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 153 | .err_dev = PCI_DEVICE_ID_INTEL_7500_1_ERR, |
| 154 | .ctl_name = "E7500"}, |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 155 | [E7501] = { |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 156 | .err_dev = PCI_DEVICE_ID_INTEL_7501_1_ERR, |
| 157 | .ctl_name = "E7501"}, |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 158 | [E7505] = { |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 159 | .err_dev = PCI_DEVICE_ID_INTEL_7505_1_ERR, |
| 160 | .ctl_name = "E7505"}, |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 161 | [E7205] = { |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 162 | .err_dev = PCI_DEVICE_ID_INTEL_7205_1_ERR, |
| 163 | .ctl_name = "E7205"}, |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 164 | }; |
| 165 | |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 166 | /* FIXME - is this valid for both SECDED and S4ECD4ED? */ |
| 167 | static inline int e7xxx_find_channel(u16 syndrome) |
| 168 | { |
Joe Perches | 956b9ba | 2012-04-29 17:08:39 -0300 | [diff] [blame] | 169 | edac_dbg(3, "\n"); |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 170 | |
| 171 | if ((syndrome & 0xff00) == 0) |
| 172 | return 0; |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 173 | |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 174 | if ((syndrome & 0x00ff) == 0) |
| 175 | return 1; |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 176 | |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 177 | if ((syndrome & 0xf000) == 0 || (syndrome & 0x0f00) == 0) |
| 178 | return 0; |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 179 | |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 180 | return 1; |
| 181 | } |
| 182 | |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 183 | static unsigned long ctl_page_to_phys(struct mem_ctl_info *mci, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 184 | unsigned long page) |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 185 | { |
| 186 | u32 remap; |
Dave Jiang | 849a4c3 | 2007-07-19 01:50:03 -0700 | [diff] [blame] | 187 | struct e7xxx_pvt *pvt = (struct e7xxx_pvt *)mci->pvt_info; |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 188 | |
Joe Perches | 956b9ba | 2012-04-29 17:08:39 -0300 | [diff] [blame] | 189 | edac_dbg(3, "\n"); |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 190 | |
| 191 | if ((page < pvt->tolm) || |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 192 | ((page >= 0x100000) && (page < pvt->remapbase))) |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 193 | return page; |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 194 | |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 195 | remap = (page - pvt->tolm) + pvt->remapbase; |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 196 | |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 197 | if (remap < pvt->remaplimit) |
| 198 | return remap; |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 199 | |
Dave Peterson | 537fba2 | 2006-03-26 01:38:40 -0800 | [diff] [blame] | 200 | e7xxx_printk(KERN_ERR, "Invalid page %lx - out of range\n", page); |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 201 | return pvt->tolm - 1; |
| 202 | } |
| 203 | |
Dave Jiang | 849a4c3 | 2007-07-19 01:50:03 -0700 | [diff] [blame] | 204 | static void process_ce(struct mem_ctl_info *mci, struct e7xxx_error_info *info) |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 205 | { |
| 206 | u32 error_1b, page; |
| 207 | u16 syndrome; |
| 208 | int row; |
| 209 | int channel; |
| 210 | |
Joe Perches | 956b9ba | 2012-04-29 17:08:39 -0300 | [diff] [blame] | 211 | edac_dbg(3, "\n"); |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 212 | /* read the error address */ |
| 213 | error_1b = info->dram_celog_add; |
| 214 | /* FIXME - should use PAGE_SHIFT */ |
Dave Jiang | 849a4c3 | 2007-07-19 01:50:03 -0700 | [diff] [blame] | 215 | page = error_1b >> 6; /* convert the address to 4k page */ |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 216 | /* read the syndrome */ |
| 217 | syndrome = info->dram_celog_syndrome; |
| 218 | /* FIXME - check for -1 */ |
| 219 | row = edac_mc_find_csrow_by_page(mci, page); |
| 220 | /* convert syndrome to channel */ |
| 221 | channel = e7xxx_find_channel(syndrome); |
Mauro Carvalho Chehab | 9eb07a7 | 2012-06-04 13:27:43 -0300 | [diff] [blame] | 222 | edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1, page, 0, syndrome, |
Mauro Carvalho Chehab | 03f7eae | 2012-06-04 11:29:25 -0300 | [diff] [blame] | 223 | row, channel, -1, "e7xxx CE", ""); |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 224 | } |
| 225 | |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 226 | static void process_ce_no_info(struct mem_ctl_info *mci) |
| 227 | { |
Joe Perches | 956b9ba | 2012-04-29 17:08:39 -0300 | [diff] [blame] | 228 | edac_dbg(3, "\n"); |
Mauro Carvalho Chehab | 9eb07a7 | 2012-06-04 13:27:43 -0300 | [diff] [blame] | 229 | edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1, 0, 0, 0, -1, -1, -1, |
Mauro Carvalho Chehab | 03f7eae | 2012-06-04 11:29:25 -0300 | [diff] [blame] | 230 | "e7xxx CE log register overflow", ""); |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 231 | } |
| 232 | |
Dave Jiang | 849a4c3 | 2007-07-19 01:50:03 -0700 | [diff] [blame] | 233 | static void process_ue(struct mem_ctl_info *mci, struct e7xxx_error_info *info) |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 234 | { |
| 235 | u32 error_2b, block_page; |
| 236 | int row; |
| 237 | |
Joe Perches | 956b9ba | 2012-04-29 17:08:39 -0300 | [diff] [blame] | 238 | edac_dbg(3, "\n"); |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 239 | /* read the error address */ |
| 240 | error_2b = info->dram_uelog_add; |
| 241 | /* FIXME - should use PAGE_SHIFT */ |
Dave Jiang | 849a4c3 | 2007-07-19 01:50:03 -0700 | [diff] [blame] | 242 | block_page = error_2b >> 6; /* convert to 4k address */ |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 243 | row = edac_mc_find_csrow_by_page(mci, block_page); |
Mauro Carvalho Chehab | 30ac440 | 2012-04-16 15:07:09 -0300 | [diff] [blame] | 244 | |
Mauro Carvalho Chehab | 9eb07a7 | 2012-06-04 13:27:43 -0300 | [diff] [blame] | 245 | edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1, block_page, 0, 0, |
Mauro Carvalho Chehab | 03f7eae | 2012-06-04 11:29:25 -0300 | [diff] [blame] | 246 | row, -1, -1, "e7xxx UE", ""); |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 247 | } |
| 248 | |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 249 | static void process_ue_no_info(struct mem_ctl_info *mci) |
| 250 | { |
Joe Perches | 956b9ba | 2012-04-29 17:08:39 -0300 | [diff] [blame] | 251 | edac_dbg(3, "\n"); |
Mauro Carvalho Chehab | 30ac440 | 2012-04-16 15:07:09 -0300 | [diff] [blame] | 252 | |
Mauro Carvalho Chehab | 9eb07a7 | 2012-06-04 13:27:43 -0300 | [diff] [blame] | 253 | edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1, 0, 0, 0, -1, -1, -1, |
Mauro Carvalho Chehab | 03f7eae | 2012-06-04 11:29:25 -0300 | [diff] [blame] | 254 | "e7xxx UE log register overflow", ""); |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 255 | } |
| 256 | |
Dave Jiang | 849a4c3 | 2007-07-19 01:50:03 -0700 | [diff] [blame] | 257 | static void e7xxx_get_error_info(struct mem_ctl_info *mci, |
| 258 | struct e7xxx_error_info *info) |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 259 | { |
| 260 | struct e7xxx_pvt *pvt; |
| 261 | |
Dave Jiang | 849a4c3 | 2007-07-19 01:50:03 -0700 | [diff] [blame] | 262 | pvt = (struct e7xxx_pvt *)mci->pvt_info; |
| 263 | pci_read_config_byte(pvt->bridge_ck, E7XXX_DRAM_FERR, &info->dram_ferr); |
| 264 | pci_read_config_byte(pvt->bridge_ck, E7XXX_DRAM_NERR, &info->dram_nerr); |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 265 | |
| 266 | if ((info->dram_ferr & 1) || (info->dram_nerr & 1)) { |
| 267 | pci_read_config_dword(pvt->bridge_ck, E7XXX_DRAM_CELOG_ADD, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 268 | &info->dram_celog_add); |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 269 | pci_read_config_word(pvt->bridge_ck, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 270 | E7XXX_DRAM_CELOG_SYNDROME, |
| 271 | &info->dram_celog_syndrome); |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | if ((info->dram_ferr & 2) || (info->dram_nerr & 2)) |
| 275 | pci_read_config_dword(pvt->bridge_ck, E7XXX_DRAM_UELOG_ADD, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 276 | &info->dram_uelog_add); |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 277 | |
| 278 | if (info->dram_ferr & 3) |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 279 | pci_write_bits8(pvt->bridge_ck, E7XXX_DRAM_FERR, 0x03, 0x03); |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 280 | |
| 281 | if (info->dram_nerr & 3) |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 282 | pci_write_bits8(pvt->bridge_ck, E7XXX_DRAM_NERR, 0x03, 0x03); |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 283 | } |
| 284 | |
Dave Jiang | 849a4c3 | 2007-07-19 01:50:03 -0700 | [diff] [blame] | 285 | static int e7xxx_process_error_info(struct mem_ctl_info *mci, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 286 | struct e7xxx_error_info *info, |
| 287 | int handle_errors) |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 288 | { |
| 289 | int error_found; |
| 290 | |
| 291 | error_found = 0; |
| 292 | |
| 293 | /* decode and report errors */ |
| 294 | if (info->dram_ferr & 1) { /* check first error correctable */ |
| 295 | error_found = 1; |
| 296 | |
| 297 | if (handle_errors) |
| 298 | process_ce(mci, info); |
| 299 | } |
| 300 | |
| 301 | if (info->dram_ferr & 2) { /* check first error uncorrectable */ |
| 302 | error_found = 1; |
| 303 | |
| 304 | if (handle_errors) |
| 305 | process_ue(mci, info); |
| 306 | } |
| 307 | |
| 308 | if (info->dram_nerr & 1) { /* check next error correctable */ |
| 309 | error_found = 1; |
| 310 | |
| 311 | if (handle_errors) { |
| 312 | if (info->dram_ferr & 1) |
| 313 | process_ce_no_info(mci); |
| 314 | else |
| 315 | process_ce(mci, info); |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | if (info->dram_nerr & 2) { /* check next error uncorrectable */ |
| 320 | error_found = 1; |
| 321 | |
| 322 | if (handle_errors) { |
| 323 | if (info->dram_ferr & 2) |
| 324 | process_ue_no_info(mci); |
| 325 | else |
| 326 | process_ue(mci, info); |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | return error_found; |
| 331 | } |
| 332 | |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 333 | static void e7xxx_check(struct mem_ctl_info *mci) |
| 334 | { |
| 335 | struct e7xxx_error_info info; |
| 336 | |
Joe Perches | 956b9ba | 2012-04-29 17:08:39 -0300 | [diff] [blame] | 337 | edac_dbg(3, "\n"); |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 338 | e7xxx_get_error_info(mci, &info); |
| 339 | e7xxx_process_error_info(mci, &info, 1); |
| 340 | } |
| 341 | |
Doug Thompson | 1318952 | 2006-06-30 01:56:08 -0700 | [diff] [blame] | 342 | /* Return 1 if dual channel mode is active. Else return 0. */ |
| 343 | static inline int dual_channel_active(u32 drc, int dev_idx) |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 344 | { |
Doug Thompson | 1318952 | 2006-06-30 01:56:08 -0700 | [diff] [blame] | 345 | return (dev_idx == E7501) ? ((drc >> 22) & 0x1) : 1; |
| 346 | } |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 347 | |
Doug Thompson | 1318952 | 2006-06-30 01:56:08 -0700 | [diff] [blame] | 348 | /* Return DRB granularity (0=32mb, 1=64mb). */ |
| 349 | static inline int drb_granularity(u32 drc, int dev_idx) |
| 350 | { |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 351 | /* only e7501 can be single channel */ |
Doug Thompson | 1318952 | 2006-06-30 01:56:08 -0700 | [diff] [blame] | 352 | return (dev_idx == E7501) ? ((drc >> 18) & 0x3) : 1; |
| 353 | } |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 354 | |
Doug Thompson | 1318952 | 2006-06-30 01:56:08 -0700 | [diff] [blame] | 355 | static void e7xxx_init_csrows(struct mem_ctl_info *mci, struct pci_dev *pdev, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 356 | int dev_idx, u32 drc) |
Doug Thompson | 1318952 | 2006-06-30 01:56:08 -0700 | [diff] [blame] | 357 | { |
| 358 | unsigned long last_cumul_size; |
Mauro Carvalho Chehab | 084a4fc | 2012-01-27 18:38:08 -0300 | [diff] [blame] | 359 | int index, j; |
Doug Thompson | 1318952 | 2006-06-30 01:56:08 -0700 | [diff] [blame] | 360 | u8 value; |
Mauro Carvalho Chehab | a895bf8 | 2012-01-28 09:09:38 -0300 | [diff] [blame] | 361 | u32 dra, cumul_size, nr_pages; |
Doug Thompson | 1318952 | 2006-06-30 01:56:08 -0700 | [diff] [blame] | 362 | int drc_chan, drc_drbg, drc_ddim, mem_dev; |
| 363 | struct csrow_info *csrow; |
Mauro Carvalho Chehab | 084a4fc | 2012-01-27 18:38:08 -0300 | [diff] [blame] | 364 | struct dimm_info *dimm; |
Mauro Carvalho Chehab | fd63312 | 2012-03-28 19:37:59 -0300 | [diff] [blame] | 365 | enum edac_type edac_mode; |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 366 | |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 367 | pci_read_config_dword(pdev, E7XXX_DRA, &dra); |
Doug Thompson | 1318952 | 2006-06-30 01:56:08 -0700 | [diff] [blame] | 368 | drc_chan = dual_channel_active(drc, dev_idx); |
| 369 | drc_drbg = drb_granularity(drc, dev_idx); |
| 370 | drc_ddim = (drc >> 20) & 0x3; |
| 371 | last_cumul_size = 0; |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 372 | |
Doug Thompson | 1318952 | 2006-06-30 01:56:08 -0700 | [diff] [blame] | 373 | /* The dram row boundary (DRB) reg values are boundary address |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 374 | * for each DRAM row with a granularity of 32 or 64MB (single/dual |
| 375 | * channel operation). DRB regs are cumulative; therefore DRB7 will |
| 376 | * contain the total memory contained in all eight rows. |
| 377 | */ |
Doug Thompson | 1318952 | 2006-06-30 01:56:08 -0700 | [diff] [blame] | 378 | for (index = 0; index < mci->nr_csrows; index++) { |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 379 | /* mem_dev 0=x8, 1=x4 */ |
Doug Thompson | 1318952 | 2006-06-30 01:56:08 -0700 | [diff] [blame] | 380 | mem_dev = (dra >> (index * 4 + 3)) & 0x1; |
Mauro Carvalho Chehab | de3910eb | 2012-04-24 15:05:43 -0300 | [diff] [blame] | 381 | csrow = mci->csrows[index]; |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 382 | |
Doug Thompson | 37f0458 | 2006-06-30 01:56:07 -0700 | [diff] [blame] | 383 | pci_read_config_byte(pdev, E7XXX_DRB + index, &value); |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 384 | /* convert a 64 or 32 MiB DRB to a page size. */ |
| 385 | cumul_size = value << (25 + drc_drbg - PAGE_SHIFT); |
Joe Perches | 956b9ba | 2012-04-29 17:08:39 -0300 | [diff] [blame] | 386 | edac_dbg(3, "(%d) cumul_size 0x%x\n", index, cumul_size); |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 387 | if (cumul_size == last_cumul_size) |
Doug Thompson | 1318952 | 2006-06-30 01:56:08 -0700 | [diff] [blame] | 388 | continue; /* not populated */ |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 389 | |
| 390 | csrow->first_page = last_cumul_size; |
| 391 | csrow->last_page = cumul_size - 1; |
Mauro Carvalho Chehab | a895bf8 | 2012-01-28 09:09:38 -0300 | [diff] [blame] | 392 | nr_pages = cumul_size - last_cumul_size; |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 393 | last_cumul_size = cumul_size; |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 394 | |
Mauro Carvalho Chehab | fd63312 | 2012-03-28 19:37:59 -0300 | [diff] [blame] | 395 | /* |
| 396 | * if single channel or x8 devices then SECDED |
| 397 | * if dual channel and x4 then S4ECD4ED |
| 398 | */ |
| 399 | if (drc_ddim) { |
| 400 | if (drc_chan && mem_dev) { |
| 401 | edac_mode = EDAC_S4ECD4ED; |
| 402 | mci->edac_cap |= EDAC_FLAG_S4ECD4ED; |
| 403 | } else { |
| 404 | edac_mode = EDAC_SECDED; |
| 405 | mci->edac_cap |= EDAC_FLAG_SECDED; |
| 406 | } |
| 407 | } else |
| 408 | edac_mode = EDAC_NONE; |
| 409 | |
Mauro Carvalho Chehab | 084a4fc | 2012-01-27 18:38:08 -0300 | [diff] [blame] | 410 | for (j = 0; j < drc_chan + 1; j++) { |
Mauro Carvalho Chehab | de3910eb | 2012-04-24 15:05:43 -0300 | [diff] [blame] | 411 | dimm = csrow->channels[j]->dimm; |
Mauro Carvalho Chehab | 084a4fc | 2012-01-27 18:38:08 -0300 | [diff] [blame] | 412 | |
Mauro Carvalho Chehab | a895bf8 | 2012-01-28 09:09:38 -0300 | [diff] [blame] | 413 | dimm->nr_pages = nr_pages / (drc_chan + 1); |
Mauro Carvalho Chehab | 084a4fc | 2012-01-27 18:38:08 -0300 | [diff] [blame] | 414 | dimm->grain = 1 << 12; /* 4KiB - resolution of CELOG */ |
| 415 | dimm->mtype = MEM_RDDR; /* only one type supported */ |
| 416 | dimm->dtype = mem_dev ? DEV_X4 : DEV_X8; |
Mauro Carvalho Chehab | fd63312 | 2012-03-28 19:37:59 -0300 | [diff] [blame] | 417 | dimm->edac_mode = edac_mode; |
Mauro Carvalho Chehab | 084a4fc | 2012-01-27 18:38:08 -0300 | [diff] [blame] | 418 | } |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 419 | } |
Doug Thompson | 1318952 | 2006-06-30 01:56:08 -0700 | [diff] [blame] | 420 | } |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 421 | |
Doug Thompson | 1318952 | 2006-06-30 01:56:08 -0700 | [diff] [blame] | 422 | static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx) |
| 423 | { |
| 424 | u16 pci_data; |
| 425 | struct mem_ctl_info *mci = NULL; |
Mauro Carvalho Chehab | 30ac440 | 2012-04-16 15:07:09 -0300 | [diff] [blame] | 426 | struct edac_mc_layer layers[2]; |
Doug Thompson | 1318952 | 2006-06-30 01:56:08 -0700 | [diff] [blame] | 427 | struct e7xxx_pvt *pvt = NULL; |
| 428 | u32 drc; |
| 429 | int drc_chan; |
| 430 | struct e7xxx_error_info discard; |
| 431 | |
Joe Perches | 956b9ba | 2012-04-29 17:08:39 -0300 | [diff] [blame] | 432 | edac_dbg(0, "mci\n"); |
Dave Jiang | c0d1217 | 2007-07-19 01:49:46 -0700 | [diff] [blame] | 433 | |
Doug Thompson | 1318952 | 2006-06-30 01:56:08 -0700 | [diff] [blame] | 434 | pci_read_config_dword(pdev, E7XXX_DRC, &drc); |
| 435 | |
| 436 | drc_chan = dual_channel_active(drc, dev_idx); |
Mauro Carvalho Chehab | 30ac440 | 2012-04-16 15:07:09 -0300 | [diff] [blame] | 437 | /* |
| 438 | * According with the datasheet, this device has a maximum of |
| 439 | * 4 DIMMS per channel, either single-rank or dual-rank. So, the |
| 440 | * total amount of dimms is 8 (E7XXX_NR_DIMMS). |
| 441 | * That means that the DIMM is mapped as CSROWs, and the channel |
| 442 | * will map the rank. So, an error to either channel should be |
| 443 | * attributed to the same dimm. |
| 444 | */ |
| 445 | layers[0].type = EDAC_MC_LAYER_CHIP_SELECT; |
| 446 | layers[0].size = E7XXX_NR_CSROWS; |
| 447 | layers[0].is_virt_csrow = true; |
| 448 | layers[1].type = EDAC_MC_LAYER_CHANNEL; |
| 449 | layers[1].size = drc_chan + 1; |
| 450 | layers[1].is_virt_csrow = false; |
Mauro Carvalho Chehab | ca0907b | 2012-05-02 14:37:00 -0300 | [diff] [blame] | 451 | mci = edac_mc_alloc(0, ARRAY_SIZE(layers), layers, sizeof(*pvt)); |
Doug Thompson | 1318952 | 2006-06-30 01:56:08 -0700 | [diff] [blame] | 452 | if (mci == NULL) |
| 453 | return -ENOMEM; |
| 454 | |
Joe Perches | 956b9ba | 2012-04-29 17:08:39 -0300 | [diff] [blame] | 455 | edac_dbg(3, "init mci\n"); |
Doug Thompson | 1318952 | 2006-06-30 01:56:08 -0700 | [diff] [blame] | 456 | mci->mtype_cap = MEM_FLAG_RDDR; |
| 457 | mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED | |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 458 | EDAC_FLAG_S4ECD4ED; |
Doug Thompson | 1318952 | 2006-06-30 01:56:08 -0700 | [diff] [blame] | 459 | /* FIXME - what if different memory types are in different csrows? */ |
| 460 | mci->mod_name = EDAC_MOD_STR; |
| 461 | mci->mod_ver = E7XXX_REVISION; |
Mauro Carvalho Chehab | fd68750 | 2012-03-16 07:44:18 -0300 | [diff] [blame] | 462 | mci->pdev = &pdev->dev; |
Joe Perches | 956b9ba | 2012-04-29 17:08:39 -0300 | [diff] [blame] | 463 | edac_dbg(3, "init pvt\n"); |
Dave Jiang | 849a4c3 | 2007-07-19 01:50:03 -0700 | [diff] [blame] | 464 | pvt = (struct e7xxx_pvt *)mci->pvt_info; |
Doug Thompson | 1318952 | 2006-06-30 01:56:08 -0700 | [diff] [blame] | 465 | pvt->dev_info = &e7xxx_devs[dev_idx]; |
| 466 | pvt->bridge_ck = pci_get_device(PCI_VENDOR_ID_INTEL, |
Dave Jiang | 849a4c3 | 2007-07-19 01:50:03 -0700 | [diff] [blame] | 467 | pvt->dev_info->err_dev, pvt->bridge_ck); |
Doug Thompson | 1318952 | 2006-06-30 01:56:08 -0700 | [diff] [blame] | 468 | |
| 469 | if (!pvt->bridge_ck) { |
| 470 | e7xxx_printk(KERN_ERR, "error reporting device not found:" |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 471 | "vendor %x device 0x%x (broken BIOS?)\n", |
| 472 | PCI_VENDOR_ID_INTEL, e7xxx_devs[dev_idx].err_dev); |
Doug Thompson | 1318952 | 2006-06-30 01:56:08 -0700 | [diff] [blame] | 473 | goto fail0; |
| 474 | } |
| 475 | |
Joe Perches | 956b9ba | 2012-04-29 17:08:39 -0300 | [diff] [blame] | 476 | edac_dbg(3, "more mci init\n"); |
Doug Thompson | 1318952 | 2006-06-30 01:56:08 -0700 | [diff] [blame] | 477 | mci->ctl_name = pvt->dev_info->ctl_name; |
Dave Jiang | c419270 | 2007-07-19 01:49:47 -0700 | [diff] [blame] | 478 | mci->dev_name = pci_name(pdev); |
Doug Thompson | 1318952 | 2006-06-30 01:56:08 -0700 | [diff] [blame] | 479 | mci->edac_check = e7xxx_check; |
| 480 | mci->ctl_page_to_phys = ctl_page_to_phys; |
| 481 | e7xxx_init_csrows(mci, pdev, dev_idx, drc); |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 482 | mci->edac_cap |= EDAC_FLAG_NONE; |
Joe Perches | 956b9ba | 2012-04-29 17:08:39 -0300 | [diff] [blame] | 483 | edac_dbg(3, "tolm, remapbase, remaplimit\n"); |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 484 | /* load the top of low memory, remap base, and remap limit vars */ |
Doug Thompson | 37f0458 | 2006-06-30 01:56:07 -0700 | [diff] [blame] | 485 | pci_read_config_word(pdev, E7XXX_TOLM, &pci_data); |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 486 | pvt->tolm = ((u32) pci_data) << 4; |
Doug Thompson | 37f0458 | 2006-06-30 01:56:07 -0700 | [diff] [blame] | 487 | pci_read_config_word(pdev, E7XXX_REMAPBASE, &pci_data); |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 488 | pvt->remapbase = ((u32) pci_data) << 14; |
Doug Thompson | 37f0458 | 2006-06-30 01:56:07 -0700 | [diff] [blame] | 489 | pci_read_config_word(pdev, E7XXX_REMAPLIMIT, &pci_data); |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 490 | pvt->remaplimit = ((u32) pci_data) << 14; |
Dave Peterson | 537fba2 | 2006-03-26 01:38:40 -0800 | [diff] [blame] | 491 | e7xxx_printk(KERN_INFO, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 492 | "tolm = %x, remapbase = %x, remaplimit = %x\n", pvt->tolm, |
| 493 | pvt->remapbase, pvt->remaplimit); |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 494 | |
| 495 | /* clear any pending errors, or initial state bits */ |
Dave Peterson | 749ede5 | 2006-03-26 01:38:45 -0800 | [diff] [blame] | 496 | e7xxx_get_error_info(mci, &discard); |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 497 | |
Doug Thompson | 2d7bbb9 | 2006-06-30 01:56:08 -0700 | [diff] [blame] | 498 | /* Here we assume that we will never see multiple instances of this |
| 499 | * type of memory controller. The ID is therefore hardcoded to 0. |
| 500 | */ |
Doug Thompson | b8f6f97 | 2007-07-19 01:50:26 -0700 | [diff] [blame] | 501 | if (edac_mc_add_mc(mci)) { |
Joe Perches | 956b9ba | 2012-04-29 17:08:39 -0300 | [diff] [blame] | 502 | edac_dbg(3, "failed edac_mc_add_mc()\n"); |
Doug Thompson | 1318952 | 2006-06-30 01:56:08 -0700 | [diff] [blame] | 503 | goto fail1; |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 504 | } |
| 505 | |
Dave Jiang | 456a2f9 | 2007-07-19 01:50:10 -0700 | [diff] [blame] | 506 | /* allocating generic PCI control info */ |
| 507 | e7xxx_pci = edac_pci_create_generic_ctl(&pdev->dev, EDAC_MOD_STR); |
| 508 | if (!e7xxx_pci) { |
| 509 | printk(KERN_WARNING |
| 510 | "%s(): Unable to create PCI control\n", |
| 511 | __func__); |
| 512 | printk(KERN_WARNING |
| 513 | "%s(): PCI error report via EDAC not setup\n", |
| 514 | __func__); |
| 515 | } |
| 516 | |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 517 | /* get this far and it's successful */ |
Joe Perches | 956b9ba | 2012-04-29 17:08:39 -0300 | [diff] [blame] | 518 | edac_dbg(3, "success\n"); |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 519 | return 0; |
| 520 | |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 521 | fail1: |
Doug Thompson | 1318952 | 2006-06-30 01:56:08 -0700 | [diff] [blame] | 522 | pci_dev_put(pvt->bridge_ck); |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 523 | |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 524 | fail0: |
Doug Thompson | 1318952 | 2006-06-30 01:56:08 -0700 | [diff] [blame] | 525 | edac_mc_free(mci); |
| 526 | |
| 527 | return -ENODEV; |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 528 | } |
| 529 | |
| 530 | /* returns count (>= 0), or negative on error */ |
Greg Kroah-Hartman | 9b3c6e8 | 2012-12-21 13:23:51 -0800 | [diff] [blame] | 531 | static int e7xxx_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 532 | { |
Joe Perches | 956b9ba | 2012-04-29 17:08:39 -0300 | [diff] [blame] | 533 | edac_dbg(0, "\n"); |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 534 | |
| 535 | /* wake up and enable device */ |
| 536 | return pci_enable_device(pdev) ? |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 537 | -EIO : e7xxx_probe1(pdev, ent->driver_data); |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 538 | } |
| 539 | |
Greg Kroah-Hartman | 9b3c6e8 | 2012-12-21 13:23:51 -0800 | [diff] [blame] | 540 | static void e7xxx_remove_one(struct pci_dev *pdev) |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 541 | { |
| 542 | struct mem_ctl_info *mci; |
| 543 | struct e7xxx_pvt *pvt; |
| 544 | |
Joe Perches | 956b9ba | 2012-04-29 17:08:39 -0300 | [diff] [blame] | 545 | edac_dbg(0, "\n"); |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 546 | |
Dave Jiang | 456a2f9 | 2007-07-19 01:50:10 -0700 | [diff] [blame] | 547 | if (e7xxx_pci) |
| 548 | edac_pci_release_generic_ctl(e7xxx_pci); |
| 549 | |
Doug Thompson | 37f0458 | 2006-06-30 01:56:07 -0700 | [diff] [blame] | 550 | if ((mci = edac_mc_del_mc(&pdev->dev)) == NULL) |
Dave Peterson | 18dbc33 | 2006-03-26 01:38:50 -0800 | [diff] [blame] | 551 | return; |
| 552 | |
Dave Jiang | 849a4c3 | 2007-07-19 01:50:03 -0700 | [diff] [blame] | 553 | pvt = (struct e7xxx_pvt *)mci->pvt_info; |
Dave Peterson | 18dbc33 | 2006-03-26 01:38:50 -0800 | [diff] [blame] | 554 | pci_dev_put(pvt->bridge_ck); |
| 555 | edac_mc_free(mci); |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 556 | } |
| 557 | |
Lionel Debroux | 36c46f3 | 2012-02-27 07:41:47 +0100 | [diff] [blame] | 558 | static DEFINE_PCI_DEVICE_TABLE(e7xxx_pci_tbl) = { |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 559 | { |
Dave Jiang | 849a4c3 | 2007-07-19 01:50:03 -0700 | [diff] [blame] | 560 | PCI_VEND_DEV(INTEL, 7205_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0, |
| 561 | E7205}, |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 562 | { |
Dave Jiang | 849a4c3 | 2007-07-19 01:50:03 -0700 | [diff] [blame] | 563 | PCI_VEND_DEV(INTEL, 7500_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0, |
| 564 | E7500}, |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 565 | { |
Dave Jiang | 849a4c3 | 2007-07-19 01:50:03 -0700 | [diff] [blame] | 566 | PCI_VEND_DEV(INTEL, 7501_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0, |
| 567 | E7501}, |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 568 | { |
Dave Jiang | 849a4c3 | 2007-07-19 01:50:03 -0700 | [diff] [blame] | 569 | PCI_VEND_DEV(INTEL, 7505_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0, |
| 570 | E7505}, |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 571 | { |
Dave Jiang | 849a4c3 | 2007-07-19 01:50:03 -0700 | [diff] [blame] | 572 | 0, |
| 573 | } /* 0 terminated list. */ |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 574 | }; |
| 575 | |
| 576 | MODULE_DEVICE_TABLE(pci, e7xxx_pci_tbl); |
| 577 | |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 578 | static struct pci_driver e7xxx_driver = { |
Dave Peterson | 680cbbb | 2006-03-26 01:38:41 -0800 | [diff] [blame] | 579 | .name = EDAC_MOD_STR, |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 580 | .probe = e7xxx_init_one, |
Greg Kroah-Hartman | 9b3c6e8 | 2012-12-21 13:23:51 -0800 | [diff] [blame] | 581 | .remove = e7xxx_remove_one, |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 582 | .id_table = e7xxx_pci_tbl, |
| 583 | }; |
| 584 | |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 585 | static int __init e7xxx_init(void) |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 586 | { |
Hitoshi Mitake | c3c52bc | 2008-04-29 01:03:18 -0700 | [diff] [blame] | 587 | /* Ensure that the OPSTATE is set correctly for POLL or NMI */ |
| 588 | opstate_init(); |
| 589 | |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 590 | return pci_register_driver(&e7xxx_driver); |
| 591 | } |
| 592 | |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 593 | static void __exit e7xxx_exit(void) |
| 594 | { |
| 595 | pci_unregister_driver(&e7xxx_driver); |
| 596 | } |
| 597 | |
| 598 | module_init(e7xxx_init); |
| 599 | module_exit(e7xxx_exit); |
| 600 | |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 601 | MODULE_LICENSE("GPL"); |
| 602 | MODULE_AUTHOR("Linux Networx (http://lnxi.com) Thayne Harbaugh et al\n" |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 603 | "Based on.work by Dan Hollis et al"); |
Alan Cox | 806c35f | 2006-01-18 17:44:08 -0800 | [diff] [blame] | 604 | MODULE_DESCRIPTION("MC support for Intel e7xxx memory controllers"); |
Dave Jiang | c0d1217 | 2007-07-19 01:49:46 -0700 | [diff] [blame] | 605 | module_param(edac_op_state, int, 0444); |
| 606 | MODULE_PARM_DESC(edac_op_state, "EDAC Error Reporting state: 0=Poll,1=NMI"); |