blob: a9518d3e4be4f3d46b205e4070685ad995b54002 [file] [log] [blame]
Alan Cox806c35f2006-01-18 17:44:08 -08001/*
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 *
13 * Contributors:
Dave Petersone7ecd892006-03-26 01:38:52 -080014 * Eric Biederman (Linux Networx)
15 * Tom Zimmerman (Linux Networx)
16 * Jim Garlick (Lawrence Livermore National Labs)
Alan Cox806c35f2006-01-18 17:44:08 -080017 * Dave Peterson (Lawrence Livermore National Labs)
18 * That One Guy (Some other place)
19 * Wang Zhenyu (intel.com)
20 *
21 * $Id: edac_e7xxx.c,v 1.5.2.9 2005/10/05 00:43:44 dsp_llnl Exp $
22 *
23 */
24
Alan Cox806c35f2006-01-18 17:44:08 -080025#include <linux/config.h>
26#include <linux/module.h>
27#include <linux/init.h>
28#include <linux/pci.h>
29#include <linux/pci_ids.h>
30#include <linux/slab.h>
31#include "edac_mc.h"
32
Dave Peterson537fba22006-03-26 01:38:40 -080033#define e7xxx_printk(level, fmt, arg...) \
Dave Petersone7ecd892006-03-26 01:38:52 -080034 edac_printk(level, "e7xxx", fmt, ##arg)
Dave Peterson537fba22006-03-26 01:38:40 -080035
36#define e7xxx_mc_printk(mci, level, fmt, arg...) \
Dave Petersone7ecd892006-03-26 01:38:52 -080037 edac_mc_chipset_printk(mci, level, "e7xxx", fmt, ##arg)
Dave Peterson537fba22006-03-26 01:38:40 -080038
Alan Cox806c35f2006-01-18 17:44:08 -080039#ifndef PCI_DEVICE_ID_INTEL_7205_0
40#define PCI_DEVICE_ID_INTEL_7205_0 0x255d
41#endif /* PCI_DEVICE_ID_INTEL_7205_0 */
42
43#ifndef PCI_DEVICE_ID_INTEL_7205_1_ERR
44#define PCI_DEVICE_ID_INTEL_7205_1_ERR 0x2551
45#endif /* PCI_DEVICE_ID_INTEL_7205_1_ERR */
46
47#ifndef PCI_DEVICE_ID_INTEL_7500_0
48#define PCI_DEVICE_ID_INTEL_7500_0 0x2540
49#endif /* PCI_DEVICE_ID_INTEL_7500_0 */
50
51#ifndef PCI_DEVICE_ID_INTEL_7500_1_ERR
52#define PCI_DEVICE_ID_INTEL_7500_1_ERR 0x2541
53#endif /* PCI_DEVICE_ID_INTEL_7500_1_ERR */
54
55#ifndef PCI_DEVICE_ID_INTEL_7501_0
56#define PCI_DEVICE_ID_INTEL_7501_0 0x254c
57#endif /* PCI_DEVICE_ID_INTEL_7501_0 */
58
59#ifndef PCI_DEVICE_ID_INTEL_7501_1_ERR
60#define PCI_DEVICE_ID_INTEL_7501_1_ERR 0x2541
61#endif /* PCI_DEVICE_ID_INTEL_7501_1_ERR */
62
63#ifndef PCI_DEVICE_ID_INTEL_7505_0
64#define PCI_DEVICE_ID_INTEL_7505_0 0x2550
65#endif /* PCI_DEVICE_ID_INTEL_7505_0 */
66
67#ifndef PCI_DEVICE_ID_INTEL_7505_1_ERR
68#define PCI_DEVICE_ID_INTEL_7505_1_ERR 0x2551
69#endif /* PCI_DEVICE_ID_INTEL_7505_1_ERR */
70
Alan Cox806c35f2006-01-18 17:44:08 -080071#define E7XXX_NR_CSROWS 8 /* number of csrows */
72#define E7XXX_NR_DIMMS 8 /* FIXME - is this correct? */
73
Alan Cox806c35f2006-01-18 17:44:08 -080074/* E7XXX register addresses - device 0 function 0 */
75#define E7XXX_DRB 0x60 /* DRAM row boundary register (8b) */
76#define E7XXX_DRA 0x70 /* DRAM row attribute register (8b) */
77 /*
78 * 31 Device width row 7 0=x8 1=x4
79 * 27 Device width row 6
80 * 23 Device width row 5
81 * 19 Device width row 4
82 * 15 Device width row 3
83 * 11 Device width row 2
84 * 7 Device width row 1
85 * 3 Device width row 0
86 */
87#define E7XXX_DRC 0x7C /* DRAM controller mode reg (32b) */
88 /*
89 * 22 Number channels 0=1,1=2
90 * 19:18 DRB Granularity 32/64MB
91 */
92#define E7XXX_TOLM 0xC4 /* DRAM top of low memory reg (16b) */
93#define E7XXX_REMAPBASE 0xC6 /* DRAM remap base address reg (16b) */
94#define E7XXX_REMAPLIMIT 0xC8 /* DRAM remap limit address reg (16b) */
95
96/* E7XXX register addresses - device 0 function 1 */
97#define E7XXX_DRAM_FERR 0x80 /* DRAM first error register (8b) */
98#define E7XXX_DRAM_NERR 0x82 /* DRAM next error register (8b) */
99#define E7XXX_DRAM_CELOG_ADD 0xA0 /* DRAM first correctable memory */
100 /* error address register (32b) */
101 /*
102 * 31:28 Reserved
103 * 27:6 CE address (4k block 33:12)
104 * 5:0 Reserved
105 */
106#define E7XXX_DRAM_UELOG_ADD 0xB0 /* DRAM first uncorrectable memory */
107 /* error address register (32b) */
108 /*
109 * 31:28 Reserved
110 * 27:6 CE address (4k block 33:12)
111 * 5:0 Reserved
112 */
113#define E7XXX_DRAM_CELOG_SYNDROME 0xD0 /* DRAM first correctable memory */
114 /* error syndrome register (16b) */
115
116enum e7xxx_chips {
117 E7500 = 0,
118 E7501,
119 E7505,
120 E7205,
121};
122
Alan Cox806c35f2006-01-18 17:44:08 -0800123struct e7xxx_pvt {
124 struct pci_dev *bridge_ck;
125 u32 tolm;
126 u32 remapbase;
127 u32 remaplimit;
128 const struct e7xxx_dev_info *dev_info;
129};
130
Alan Cox806c35f2006-01-18 17:44:08 -0800131struct e7xxx_dev_info {
132 u16 err_dev;
133 const char *ctl_name;
134};
135
Alan Cox806c35f2006-01-18 17:44:08 -0800136struct e7xxx_error_info {
137 u8 dram_ferr;
138 u8 dram_nerr;
139 u32 dram_celog_add;
140 u16 dram_celog_syndrome;
141 u32 dram_uelog_add;
142};
143
144static const struct e7xxx_dev_info e7xxx_devs[] = {
145 [E7500] = {
Dave Petersone7ecd892006-03-26 01:38:52 -0800146 .err_dev = PCI_DEVICE_ID_INTEL_7500_1_ERR,
147 .ctl_name = "E7500"
148 },
Alan Cox806c35f2006-01-18 17:44:08 -0800149 [E7501] = {
Dave Petersone7ecd892006-03-26 01:38:52 -0800150 .err_dev = PCI_DEVICE_ID_INTEL_7501_1_ERR,
151 .ctl_name = "E7501"
152 },
Alan Cox806c35f2006-01-18 17:44:08 -0800153 [E7505] = {
Dave Petersone7ecd892006-03-26 01:38:52 -0800154 .err_dev = PCI_DEVICE_ID_INTEL_7505_1_ERR,
155 .ctl_name = "E7505"
156 },
Alan Cox806c35f2006-01-18 17:44:08 -0800157 [E7205] = {
Dave Petersone7ecd892006-03-26 01:38:52 -0800158 .err_dev = PCI_DEVICE_ID_INTEL_7205_1_ERR,
159 .ctl_name = "E7205"
160 },
Alan Cox806c35f2006-01-18 17:44:08 -0800161};
162
Alan Cox806c35f2006-01-18 17:44:08 -0800163/* FIXME - is this valid for both SECDED and S4ECD4ED? */
164static inline int e7xxx_find_channel(u16 syndrome)
165{
Dave Peterson537fba22006-03-26 01:38:40 -0800166 debugf3("%s()\n", __func__);
Alan Cox806c35f2006-01-18 17:44:08 -0800167
168 if ((syndrome & 0xff00) == 0)
169 return 0;
Dave Petersone7ecd892006-03-26 01:38:52 -0800170
Alan Cox806c35f2006-01-18 17:44:08 -0800171 if ((syndrome & 0x00ff) == 0)
172 return 1;
Dave Petersone7ecd892006-03-26 01:38:52 -0800173
Alan Cox806c35f2006-01-18 17:44:08 -0800174 if ((syndrome & 0xf000) == 0 || (syndrome & 0x0f00) == 0)
175 return 0;
Dave Petersone7ecd892006-03-26 01:38:52 -0800176
Alan Cox806c35f2006-01-18 17:44:08 -0800177 return 1;
178}
179
Dave Petersone7ecd892006-03-26 01:38:52 -0800180static unsigned long ctl_page_to_phys(struct mem_ctl_info *mci,
181 unsigned long page)
Alan Cox806c35f2006-01-18 17:44:08 -0800182{
183 u32 remap;
184 struct e7xxx_pvt *pvt = (struct e7xxx_pvt *) mci->pvt_info;
185
Dave Peterson537fba22006-03-26 01:38:40 -0800186 debugf3("%s()\n", __func__);
Alan Cox806c35f2006-01-18 17:44:08 -0800187
188 if ((page < pvt->tolm) ||
Dave Petersone7ecd892006-03-26 01:38:52 -0800189 ((page >= 0x100000) && (page < pvt->remapbase)))
Alan Cox806c35f2006-01-18 17:44:08 -0800190 return page;
Dave Petersone7ecd892006-03-26 01:38:52 -0800191
Alan Cox806c35f2006-01-18 17:44:08 -0800192 remap = (page - pvt->tolm) + pvt->remapbase;
Dave Petersone7ecd892006-03-26 01:38:52 -0800193
Alan Cox806c35f2006-01-18 17:44:08 -0800194 if (remap < pvt->remaplimit)
195 return remap;
Dave Petersone7ecd892006-03-26 01:38:52 -0800196
Dave Peterson537fba22006-03-26 01:38:40 -0800197 e7xxx_printk(KERN_ERR, "Invalid page %lx - out of range\n", page);
Alan Cox806c35f2006-01-18 17:44:08 -0800198 return pvt->tolm - 1;
199}
200
Dave Petersone7ecd892006-03-26 01:38:52 -0800201static void process_ce(struct mem_ctl_info *mci,
202 struct e7xxx_error_info *info)
Alan Cox806c35f2006-01-18 17:44:08 -0800203{
204 u32 error_1b, page;
205 u16 syndrome;
206 int row;
207 int channel;
208
Dave Peterson537fba22006-03-26 01:38:40 -0800209 debugf3("%s()\n", __func__);
Alan Cox806c35f2006-01-18 17:44:08 -0800210 /* read the error address */
211 error_1b = info->dram_celog_add;
212 /* FIXME - should use PAGE_SHIFT */
Dave Petersone7ecd892006-03-26 01:38:52 -0800213 page = error_1b >> 6; /* convert the address to 4k page */
Alan Cox806c35f2006-01-18 17:44:08 -0800214 /* read the syndrome */
215 syndrome = info->dram_celog_syndrome;
216 /* FIXME - check for -1 */
217 row = edac_mc_find_csrow_by_page(mci, page);
218 /* convert syndrome to channel */
219 channel = e7xxx_find_channel(syndrome);
Dave Petersone7ecd892006-03-26 01:38:52 -0800220 edac_mc_handle_ce(mci, page, 0, syndrome, row, channel, "e7xxx CE");
Alan Cox806c35f2006-01-18 17:44:08 -0800221}
222
Alan Cox806c35f2006-01-18 17:44:08 -0800223static void process_ce_no_info(struct mem_ctl_info *mci)
224{
Dave Peterson537fba22006-03-26 01:38:40 -0800225 debugf3("%s()\n", __func__);
Alan Cox806c35f2006-01-18 17:44:08 -0800226 edac_mc_handle_ce_no_info(mci, "e7xxx CE log register overflow");
227}
228
Dave Petersone7ecd892006-03-26 01:38:52 -0800229static void process_ue(struct mem_ctl_info *mci,
230 struct e7xxx_error_info *info)
Alan Cox806c35f2006-01-18 17:44:08 -0800231{
232 u32 error_2b, block_page;
233 int row;
234
Dave Peterson537fba22006-03-26 01:38:40 -0800235 debugf3("%s()\n", __func__);
Alan Cox806c35f2006-01-18 17:44:08 -0800236 /* read the error address */
237 error_2b = info->dram_uelog_add;
238 /* FIXME - should use PAGE_SHIFT */
Dave Petersone7ecd892006-03-26 01:38:52 -0800239 block_page = error_2b >> 6; /* convert to 4k address */
Alan Cox806c35f2006-01-18 17:44:08 -0800240 row = edac_mc_find_csrow_by_page(mci, block_page);
241 edac_mc_handle_ue(mci, block_page, 0, row, "e7xxx UE");
242}
243
Alan Cox806c35f2006-01-18 17:44:08 -0800244static void process_ue_no_info(struct mem_ctl_info *mci)
245{
Dave Peterson537fba22006-03-26 01:38:40 -0800246 debugf3("%s()\n", __func__);
Alan Cox806c35f2006-01-18 17:44:08 -0800247 edac_mc_handle_ue_no_info(mci, "e7xxx UE log register overflow");
248}
249
Alan Cox806c35f2006-01-18 17:44:08 -0800250static void e7xxx_get_error_info (struct mem_ctl_info *mci,
251 struct e7xxx_error_info *info)
252{
253 struct e7xxx_pvt *pvt;
254
255 pvt = (struct e7xxx_pvt *) mci->pvt_info;
256 pci_read_config_byte(pvt->bridge_ck, E7XXX_DRAM_FERR,
Dave Petersone7ecd892006-03-26 01:38:52 -0800257 &info->dram_ferr);
Alan Cox806c35f2006-01-18 17:44:08 -0800258 pci_read_config_byte(pvt->bridge_ck, E7XXX_DRAM_NERR,
Dave Petersone7ecd892006-03-26 01:38:52 -0800259 &info->dram_nerr);
Alan Cox806c35f2006-01-18 17:44:08 -0800260
261 if ((info->dram_ferr & 1) || (info->dram_nerr & 1)) {
262 pci_read_config_dword(pvt->bridge_ck, E7XXX_DRAM_CELOG_ADD,
Dave Petersone7ecd892006-03-26 01:38:52 -0800263 &info->dram_celog_add);
Alan Cox806c35f2006-01-18 17:44:08 -0800264 pci_read_config_word(pvt->bridge_ck,
Dave Petersone7ecd892006-03-26 01:38:52 -0800265 E7XXX_DRAM_CELOG_SYNDROME,
266 &info->dram_celog_syndrome);
Alan Cox806c35f2006-01-18 17:44:08 -0800267 }
268
269 if ((info->dram_ferr & 2) || (info->dram_nerr & 2))
270 pci_read_config_dword(pvt->bridge_ck, E7XXX_DRAM_UELOG_ADD,
Dave Petersone7ecd892006-03-26 01:38:52 -0800271 &info->dram_uelog_add);
Alan Cox806c35f2006-01-18 17:44:08 -0800272
273 if (info->dram_ferr & 3)
Dave Petersone7ecd892006-03-26 01:38:52 -0800274 pci_write_bits8(pvt->bridge_ck, E7XXX_DRAM_FERR, 0x03, 0x03);
Alan Cox806c35f2006-01-18 17:44:08 -0800275
276 if (info->dram_nerr & 3)
Dave Petersone7ecd892006-03-26 01:38:52 -0800277 pci_write_bits8(pvt->bridge_ck, E7XXX_DRAM_NERR, 0x03, 0x03);
Alan Cox806c35f2006-01-18 17:44:08 -0800278}
279
Alan Cox806c35f2006-01-18 17:44:08 -0800280static int e7xxx_process_error_info (struct mem_ctl_info *mci,
281 struct e7xxx_error_info *info, int handle_errors)
282{
283 int error_found;
284
285 error_found = 0;
286
287 /* decode and report errors */
288 if (info->dram_ferr & 1) { /* check first error correctable */
289 error_found = 1;
290
291 if (handle_errors)
292 process_ce(mci, info);
293 }
294
295 if (info->dram_ferr & 2) { /* check first error uncorrectable */
296 error_found = 1;
297
298 if (handle_errors)
299 process_ue(mci, info);
300 }
301
302 if (info->dram_nerr & 1) { /* check next error correctable */
303 error_found = 1;
304
305 if (handle_errors) {
306 if (info->dram_ferr & 1)
307 process_ce_no_info(mci);
308 else
309 process_ce(mci, info);
310 }
311 }
312
313 if (info->dram_nerr & 2) { /* check next error uncorrectable */
314 error_found = 1;
315
316 if (handle_errors) {
317 if (info->dram_ferr & 2)
318 process_ue_no_info(mci);
319 else
320 process_ue(mci, info);
321 }
322 }
323
324 return error_found;
325}
326
Alan Cox806c35f2006-01-18 17:44:08 -0800327static void e7xxx_check(struct mem_ctl_info *mci)
328{
329 struct e7xxx_error_info info;
330
Dave Peterson537fba22006-03-26 01:38:40 -0800331 debugf3("%s()\n", __func__);
Alan Cox806c35f2006-01-18 17:44:08 -0800332 e7xxx_get_error_info(mci, &info);
333 e7xxx_process_error_info(mci, &info, 1);
334}
335
Alan Cox806c35f2006-01-18 17:44:08 -0800336static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx)
337{
338 int rc = -ENODEV;
339 int index;
340 u16 pci_data;
341 struct mem_ctl_info *mci = NULL;
342 struct e7xxx_pvt *pvt = NULL;
343 u32 drc;
344 int drc_chan = 1; /* Number of channels 0=1chan,1=2chan */
345 int drc_drbg = 1; /* DRB granularity 0=32mb,1=64mb */
346 int drc_ddim; /* DRAM Data Integrity Mode 0=none,2=edac */
347 u32 dra;
348 unsigned long last_cumul_size;
Dave Peterson749ede52006-03-26 01:38:45 -0800349 struct e7xxx_error_info discard;
Alan Cox806c35f2006-01-18 17:44:08 -0800350
Dave Peterson537fba22006-03-26 01:38:40 -0800351 debugf0("%s(): mci\n", __func__);
Alan Cox806c35f2006-01-18 17:44:08 -0800352
353 /* need to find out the number of channels */
354 pci_read_config_dword(pdev, E7XXX_DRC, &drc);
Dave Petersone7ecd892006-03-26 01:38:52 -0800355
Alan Cox806c35f2006-01-18 17:44:08 -0800356 /* only e7501 can be single channel */
357 if (dev_idx == E7501) {
358 drc_chan = ((drc >> 22) & 0x1);
359 drc_drbg = (drc >> 18) & 0x3;
360 }
Alan Cox806c35f2006-01-18 17:44:08 -0800361
Dave Petersone7ecd892006-03-26 01:38:52 -0800362 drc_ddim = (drc >> 20) & 0x3;
Alan Cox806c35f2006-01-18 17:44:08 -0800363 mci = edac_mc_alloc(sizeof(*pvt), E7XXX_NR_CSROWS, drc_chan + 1);
364
365 if (mci == NULL) {
366 rc = -ENOMEM;
367 goto fail;
368 }
369
Dave Peterson537fba22006-03-26 01:38:40 -0800370 debugf3("%s(): init mci\n", __func__);
Alan Cox806c35f2006-01-18 17:44:08 -0800371 mci->mtype_cap = MEM_FLAG_RDDR;
Dave Petersone7ecd892006-03-26 01:38:52 -0800372 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED |
373 EDAC_FLAG_S4ECD4ED;
Alan Cox806c35f2006-01-18 17:44:08 -0800374 /* FIXME - what if different memory types are in different csrows? */
Dave Peterson680cbbb2006-03-26 01:38:41 -0800375 mci->mod_name = EDAC_MOD_STR;
Alan Cox806c35f2006-01-18 17:44:08 -0800376 mci->mod_ver = "$Revision: 1.5.2.9 $";
377 mci->pdev = pdev;
378
Dave Peterson537fba22006-03-26 01:38:40 -0800379 debugf3("%s(): init pvt\n", __func__);
Alan Cox806c35f2006-01-18 17:44:08 -0800380 pvt = (struct e7xxx_pvt *) mci->pvt_info;
381 pvt->dev_info = &e7xxx_devs[dev_idx];
382 pvt->bridge_ck = pci_get_device(PCI_VENDOR_ID_INTEL,
Dave Petersone7ecd892006-03-26 01:38:52 -0800383 pvt->dev_info->err_dev,
384 pvt->bridge_ck);
385
Alan Cox806c35f2006-01-18 17:44:08 -0800386 if (!pvt->bridge_ck) {
Dave Peterson537fba22006-03-26 01:38:40 -0800387 e7xxx_printk(KERN_ERR, "error reporting device not found:"
Dave Petersone7ecd892006-03-26 01:38:52 -0800388 "vendor %x device 0x%x (broken BIOS?)\n",
389 PCI_VENDOR_ID_INTEL, e7xxx_devs[dev_idx].err_dev);
Alan Cox806c35f2006-01-18 17:44:08 -0800390 goto fail;
391 }
392
Dave Peterson537fba22006-03-26 01:38:40 -0800393 debugf3("%s(): more mci init\n", __func__);
Alan Cox806c35f2006-01-18 17:44:08 -0800394 mci->ctl_name = pvt->dev_info->ctl_name;
Alan Cox806c35f2006-01-18 17:44:08 -0800395 mci->edac_check = e7xxx_check;
396 mci->ctl_page_to_phys = ctl_page_to_phys;
397
398 /* find out the device types */
399 pci_read_config_dword(pdev, E7XXX_DRA, &dra);
400
401 /*
402 * The dram row boundary (DRB) reg values are boundary address
403 * for each DRAM row with a granularity of 32 or 64MB (single/dual
404 * channel operation). DRB regs are cumulative; therefore DRB7 will
405 * contain the total memory contained in all eight rows.
406 */
407 for (last_cumul_size = index = 0; index < mci->nr_csrows; index++) {
408 u8 value;
409 u32 cumul_size;
410 /* mem_dev 0=x8, 1=x4 */
411 int mem_dev = (dra >> (index * 4 + 3)) & 0x1;
412 struct csrow_info *csrow = &mci->csrows[index];
413
414 pci_read_config_byte(mci->pdev, E7XXX_DRB + index, &value);
415 /* convert a 64 or 32 MiB DRB to a page size. */
416 cumul_size = value << (25 + drc_drbg - PAGE_SHIFT);
Dave Peterson537fba22006-03-26 01:38:40 -0800417 debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index,
418 cumul_size);
Dave Petersone7ecd892006-03-26 01:38:52 -0800419
Alan Cox806c35f2006-01-18 17:44:08 -0800420 if (cumul_size == last_cumul_size)
Dave Petersone7ecd892006-03-26 01:38:52 -0800421 continue; /* not populated */
Alan Cox806c35f2006-01-18 17:44:08 -0800422
423 csrow->first_page = last_cumul_size;
424 csrow->last_page = cumul_size - 1;
425 csrow->nr_pages = cumul_size - last_cumul_size;
426 last_cumul_size = cumul_size;
Dave Petersone7ecd892006-03-26 01:38:52 -0800427 csrow->grain = 1 << 12; /* 4KiB - resolution of CELOG */
428 csrow->mtype = MEM_RDDR; /* only one type supported */
Alan Cox806c35f2006-01-18 17:44:08 -0800429 csrow->dtype = mem_dev ? DEV_X4 : DEV_X8;
430
431 /*
432 * if single channel or x8 devices then SECDED
433 * if dual channel and x4 then S4ECD4ED
434 */
435 if (drc_ddim) {
436 if (drc_chan && mem_dev) {
437 csrow->edac_mode = EDAC_S4ECD4ED;
438 mci->edac_cap |= EDAC_FLAG_S4ECD4ED;
439 } else {
440 csrow->edac_mode = EDAC_SECDED;
441 mci->edac_cap |= EDAC_FLAG_SECDED;
442 }
443 } else
444 csrow->edac_mode = EDAC_NONE;
445 }
446
447 mci->edac_cap |= EDAC_FLAG_NONE;
448
Dave Peterson537fba22006-03-26 01:38:40 -0800449 debugf3("%s(): tolm, remapbase, remaplimit\n", __func__);
Alan Cox806c35f2006-01-18 17:44:08 -0800450 /* load the top of low memory, remap base, and remap limit vars */
451 pci_read_config_word(mci->pdev, E7XXX_TOLM, &pci_data);
452 pvt->tolm = ((u32) pci_data) << 4;
453 pci_read_config_word(mci->pdev, E7XXX_REMAPBASE, &pci_data);
454 pvt->remapbase = ((u32) pci_data) << 14;
455 pci_read_config_word(mci->pdev, E7XXX_REMAPLIMIT, &pci_data);
456 pvt->remaplimit = ((u32) pci_data) << 14;
Dave Peterson537fba22006-03-26 01:38:40 -0800457 e7xxx_printk(KERN_INFO,
Dave Petersone7ecd892006-03-26 01:38:52 -0800458 "tolm = %x, remapbase = %x, remaplimit = %x\n", pvt->tolm,
459 pvt->remapbase, pvt->remaplimit);
Alan Cox806c35f2006-01-18 17:44:08 -0800460
461 /* clear any pending errors, or initial state bits */
Dave Peterson749ede52006-03-26 01:38:45 -0800462 e7xxx_get_error_info(mci, &discard);
Alan Cox806c35f2006-01-18 17:44:08 -0800463
464 if (edac_mc_add_mc(mci) != 0) {
Dave Peterson537fba22006-03-26 01:38:40 -0800465 debugf3("%s(): failed edac_mc_add_mc()\n", __func__);
Alan Cox806c35f2006-01-18 17:44:08 -0800466 goto fail;
467 }
468
469 /* get this far and it's successful */
Dave Peterson537fba22006-03-26 01:38:40 -0800470 debugf3("%s(): success\n", __func__);
Alan Cox806c35f2006-01-18 17:44:08 -0800471 return 0;
472
473fail:
474 if (mci != NULL) {
475 if(pvt != NULL && pvt->bridge_ck)
476 pci_dev_put(pvt->bridge_ck);
477 edac_mc_free(mci);
478 }
479
480 return rc;
481}
482
483/* returns count (>= 0), or negative on error */
Dave Petersone7ecd892006-03-26 01:38:52 -0800484static int __devinit e7xxx_init_one(struct pci_dev *pdev,
485 const struct pci_device_id *ent)
Alan Cox806c35f2006-01-18 17:44:08 -0800486{
Dave Peterson537fba22006-03-26 01:38:40 -0800487 debugf0("%s()\n", __func__);
Alan Cox806c35f2006-01-18 17:44:08 -0800488
489 /* wake up and enable device */
490 return pci_enable_device(pdev) ?
Dave Petersone7ecd892006-03-26 01:38:52 -0800491 -EIO : e7xxx_probe1(pdev, ent->driver_data);
Alan Cox806c35f2006-01-18 17:44:08 -0800492}
493
Alan Cox806c35f2006-01-18 17:44:08 -0800494static void __devexit e7xxx_remove_one(struct pci_dev *pdev)
495{
496 struct mem_ctl_info *mci;
497 struct e7xxx_pvt *pvt;
498
Dave Peterson537fba22006-03-26 01:38:40 -0800499 debugf0("%s()\n", __func__);
Alan Cox806c35f2006-01-18 17:44:08 -0800500
Dave Peterson18dbc332006-03-26 01:38:50 -0800501 if ((mci = edac_mc_del_mc(pdev)) == NULL)
502 return;
503
504 pvt = (struct e7xxx_pvt *) mci->pvt_info;
505 pci_dev_put(pvt->bridge_ck);
506 edac_mc_free(mci);
Alan Cox806c35f2006-01-18 17:44:08 -0800507}
508
Alan Cox806c35f2006-01-18 17:44:08 -0800509static const struct pci_device_id e7xxx_pci_tbl[] __devinitdata = {
Dave Petersone7ecd892006-03-26 01:38:52 -0800510 {
511 PCI_VEND_DEV(INTEL, 7205_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
512 E7205
513 },
514 {
515 PCI_VEND_DEV(INTEL, 7500_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
516 E7500
517 },
518 {
519 PCI_VEND_DEV(INTEL, 7501_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
520 E7501
521 },
522 {
523 PCI_VEND_DEV(INTEL, 7505_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
524 E7505
525 },
526 {
527 0,
528 } /* 0 terminated list. */
Alan Cox806c35f2006-01-18 17:44:08 -0800529};
530
531MODULE_DEVICE_TABLE(pci, e7xxx_pci_tbl);
532
Alan Cox806c35f2006-01-18 17:44:08 -0800533static struct pci_driver e7xxx_driver = {
Dave Peterson680cbbb2006-03-26 01:38:41 -0800534 .name = EDAC_MOD_STR,
Alan Cox806c35f2006-01-18 17:44:08 -0800535 .probe = e7xxx_init_one,
536 .remove = __devexit_p(e7xxx_remove_one),
537 .id_table = e7xxx_pci_tbl,
538};
539
Alan Coxda9bb1d2006-01-18 17:44:13 -0800540static int __init e7xxx_init(void)
Alan Cox806c35f2006-01-18 17:44:08 -0800541{
542 return pci_register_driver(&e7xxx_driver);
543}
544
Alan Cox806c35f2006-01-18 17:44:08 -0800545static void __exit e7xxx_exit(void)
546{
547 pci_unregister_driver(&e7xxx_driver);
548}
549
550module_init(e7xxx_init);
551module_exit(e7xxx_exit);
552
Alan Cox806c35f2006-01-18 17:44:08 -0800553MODULE_LICENSE("GPL");
554MODULE_AUTHOR("Linux Networx (http://lnxi.com) Thayne Harbaugh et al\n"
Dave Petersone7ecd892006-03-26 01:38:52 -0800555 "Based on.work by Dan Hollis et al");
Alan Cox806c35f2006-01-18 17:44:08 -0800556MODULE_DESCRIPTION("MC support for Intel e7xxx memory controllers");