xref: /openbmc/linux/drivers/edac/r82600_edac.c (revision 2f768af73fea4c70f9046388a7ff648ad11f028e)
1*2f768af7SAlan Cox /*
2*2f768af7SAlan Cox  * Radisys 82600 Embedded chipset Memory Controller kernel module
3*2f768af7SAlan Cox  * (C) 2005 EADS Astrium
4*2f768af7SAlan Cox  * This file may be distributed under the terms of the
5*2f768af7SAlan Cox  * GNU General Public License.
6*2f768af7SAlan Cox  *
7*2f768af7SAlan Cox  * Written by Tim Small <tim@buttersideup.com>, based on work by Thayne
8*2f768af7SAlan Cox  * Harbaugh, Dan Hollis <goemon at anime dot net> and others.
9*2f768af7SAlan Cox  *
10*2f768af7SAlan Cox  * $Id: edac_r82600.c,v 1.1.2.6 2005/10/05 00:43:44 dsp_llnl Exp $
11*2f768af7SAlan Cox  *
12*2f768af7SAlan Cox  * Written with reference to 82600 High Integration Dual PCI System
13*2f768af7SAlan Cox  * Controller Data Book:
14*2f768af7SAlan Cox  * http://www.radisys.com/files/support_downloads/007-01277-0002.82600DataBook.pdf
15*2f768af7SAlan Cox  * references to this document given in []
16*2f768af7SAlan Cox  */
17*2f768af7SAlan Cox 
18*2f768af7SAlan Cox #include <linux/config.h>
19*2f768af7SAlan Cox #include <linux/module.h>
20*2f768af7SAlan Cox #include <linux/init.h>
21*2f768af7SAlan Cox 
22*2f768af7SAlan Cox #include <linux/pci.h>
23*2f768af7SAlan Cox #include <linux/pci_ids.h>
24*2f768af7SAlan Cox 
25*2f768af7SAlan Cox #include <linux/slab.h>
26*2f768af7SAlan Cox 
27*2f768af7SAlan Cox #include "edac_mc.h"
28*2f768af7SAlan Cox 
29*2f768af7SAlan Cox /* Radisys say "The 82600 integrates a main memory SDRAM controller that
30*2f768af7SAlan Cox  * supports up to four banks of memory. The four banks can support a mix of
31*2f768af7SAlan Cox  * sizes of 64 bit wide (72 bits with ECC) Synchronous DRAM (SDRAM) DIMMs,
32*2f768af7SAlan Cox  * each of which can be any size from 16MB to 512MB. Both registered (control
33*2f768af7SAlan Cox  * signals buffered) and unbuffered DIMM types are supported. Mixing of
34*2f768af7SAlan Cox  * registered and unbuffered DIMMs as well as mixing of ECC and non-ECC DIMMs
35*2f768af7SAlan Cox  * is not allowed. The 82600 SDRAM interface operates at the same frequency as
36*2f768af7SAlan Cox  * the CPU bus, 66MHz, 100MHz or 133MHz."
37*2f768af7SAlan Cox  */
38*2f768af7SAlan Cox 
39*2f768af7SAlan Cox #define R82600_NR_CSROWS 4
40*2f768af7SAlan Cox #define R82600_NR_CHANS  1
41*2f768af7SAlan Cox #define R82600_NR_DIMMS  4
42*2f768af7SAlan Cox 
43*2f768af7SAlan Cox #define R82600_BRIDGE_ID  0x8200
44*2f768af7SAlan Cox 
45*2f768af7SAlan Cox /* Radisys 82600 register addresses - device 0 function 0 - PCI bridge */
46*2f768af7SAlan Cox #define R82600_DRAMC	0x57	/* Various SDRAM related control bits
47*2f768af7SAlan Cox 				 * all bits are R/W
48*2f768af7SAlan Cox 				 *
49*2f768af7SAlan Cox 				 * 7    SDRAM ISA Hole Enable
50*2f768af7SAlan Cox 				 * 6    Flash Page Mode Enable
51*2f768af7SAlan Cox 				 * 5    ECC Enable: 1=ECC 0=noECC
52*2f768af7SAlan Cox 				 * 4    DRAM DIMM Type: 1=
53*2f768af7SAlan Cox 				 * 3    BIOS Alias Disable
54*2f768af7SAlan Cox 				 * 2    SDRAM BIOS Flash Write Enable
55*2f768af7SAlan Cox 				 * 1:0  SDRAM Refresh Rate: 00=Disabled
56*2f768af7SAlan Cox 				 *          01=7.8usec (256Mbit SDRAMs)
57*2f768af7SAlan Cox 				 *          10=15.6us 11=125usec
58*2f768af7SAlan Cox 				 */
59*2f768af7SAlan Cox 
60*2f768af7SAlan Cox #define R82600_SDRAMC	0x76	/* "SDRAM Control Register"
61*2f768af7SAlan Cox 				 * More SDRAM related control bits
62*2f768af7SAlan Cox 				 * all bits are R/W
63*2f768af7SAlan Cox 				 *
64*2f768af7SAlan Cox 				 * 15:8 Reserved.
65*2f768af7SAlan Cox 				 *
66*2f768af7SAlan Cox 				 * 7:5  Special SDRAM Mode Select
67*2f768af7SAlan Cox 				 *
68*2f768af7SAlan Cox 				 * 4    Force ECC
69*2f768af7SAlan Cox 				 *
70*2f768af7SAlan Cox 				 *        1=Drive ECC bits to 0 during
71*2f768af7SAlan Cox 				 *          write cycles (i.e. ECC test mode)
72*2f768af7SAlan Cox 				 *
73*2f768af7SAlan Cox 				 *        0=Normal ECC functioning
74*2f768af7SAlan Cox 				 *
75*2f768af7SAlan Cox 				 * 3    Enhanced Paging Enable
76*2f768af7SAlan Cox 				 *
77*2f768af7SAlan Cox 				 * 2    CAS# Latency 0=3clks 1=2clks
78*2f768af7SAlan Cox 				 *
79*2f768af7SAlan Cox 				 * 1    RAS# to CAS# Delay 0=3 1=2
80*2f768af7SAlan Cox 				 *
81*2f768af7SAlan Cox 				 * 0    RAS# Precharge     0=3 1=2
82*2f768af7SAlan Cox 				 */
83*2f768af7SAlan Cox 
84*2f768af7SAlan Cox #define R82600_EAP	0x80	/* ECC Error Address Pointer Register
85*2f768af7SAlan Cox 				 *
86*2f768af7SAlan Cox 				 * 31    Disable Hardware Scrubbing (RW)
87*2f768af7SAlan Cox 				 *        0=Scrub on corrected read
88*2f768af7SAlan Cox 				 *        1=Don't scrub on corrected read
89*2f768af7SAlan Cox 				 *
90*2f768af7SAlan Cox 				 * 30:12 Error Address Pointer (RO)
91*2f768af7SAlan Cox 				 *        Upper 19 bits of error address
92*2f768af7SAlan Cox 				 *
93*2f768af7SAlan Cox 				 * 11:4  Syndrome Bits (RO)
94*2f768af7SAlan Cox 				 *
95*2f768af7SAlan Cox 				 * 3     BSERR# on multibit error (RW)
96*2f768af7SAlan Cox 				 *        1=enable 0=disable
97*2f768af7SAlan Cox 				 *
98*2f768af7SAlan Cox 				 * 2     NMI on Single Bit Eror (RW)
99*2f768af7SAlan Cox 				 *        1=NMI triggered by SBE n.b. other
100*2f768af7SAlan Cox 				 *          prerequeists
101*2f768af7SAlan Cox 				 *        0=NMI not triggered
102*2f768af7SAlan Cox 				 *
103*2f768af7SAlan Cox 				 * 1     MBE (R/WC)
104*2f768af7SAlan Cox 				 *        read 1=MBE at EAP (see above)
105*2f768af7SAlan Cox 				 *        read 0=no MBE, or SBE occurred first
106*2f768af7SAlan Cox 				 *        write 1=Clear MBE status (must also
107*2f768af7SAlan Cox 				 *          clear SBE)
108*2f768af7SAlan Cox 				 *        write 0=NOP
109*2f768af7SAlan Cox 				 *
110*2f768af7SAlan Cox 				 * 1     SBE (R/WC)
111*2f768af7SAlan Cox 				 *        read 1=SBE at EAP (see above)
112*2f768af7SAlan Cox 				 *        read 0=no SBE, or MBE occurred first
113*2f768af7SAlan Cox 				 *        write 1=Clear SBE status (must also
114*2f768af7SAlan Cox 				 *          clear MBE)
115*2f768af7SAlan Cox 				 *        write 0=NOP
116*2f768af7SAlan Cox 				 */
117*2f768af7SAlan Cox 
118*2f768af7SAlan Cox #define R82600_DRBA	0x60	/* + 0x60..0x63 SDRAM Row Boundry Address
119*2f768af7SAlan Cox 				 *  Registers
120*2f768af7SAlan Cox 				 *
121*2f768af7SAlan Cox 				 * 7:0  Address lines 30:24 - upper limit of
122*2f768af7SAlan Cox 				 * each row [p57]
123*2f768af7SAlan Cox 				 */
124*2f768af7SAlan Cox 
125*2f768af7SAlan Cox struct r82600_error_info {
126*2f768af7SAlan Cox 	u32 eapr;
127*2f768af7SAlan Cox };
128*2f768af7SAlan Cox 
129*2f768af7SAlan Cox 
130*2f768af7SAlan Cox static unsigned int disable_hardware_scrub = 0;
131*2f768af7SAlan Cox 
132*2f768af7SAlan Cox 
133*2f768af7SAlan Cox static void r82600_get_error_info (struct mem_ctl_info *mci,
134*2f768af7SAlan Cox 		struct r82600_error_info *info)
135*2f768af7SAlan Cox {
136*2f768af7SAlan Cox 	pci_read_config_dword(mci->pdev, R82600_EAP, &info->eapr);
137*2f768af7SAlan Cox 
138*2f768af7SAlan Cox 	if (info->eapr & BIT(0))
139*2f768af7SAlan Cox 		/* Clear error to allow next error to be reported [p.62] */
140*2f768af7SAlan Cox 		pci_write_bits32(mci->pdev, R82600_EAP,
141*2f768af7SAlan Cox 				   ((u32) BIT(0) & (u32) BIT(1)),
142*2f768af7SAlan Cox 				   ((u32) BIT(0) & (u32) BIT(1)));
143*2f768af7SAlan Cox 
144*2f768af7SAlan Cox 	if (info->eapr & BIT(1))
145*2f768af7SAlan Cox 		/* Clear error to allow next error to be reported [p.62] */
146*2f768af7SAlan Cox 		pci_write_bits32(mci->pdev, R82600_EAP,
147*2f768af7SAlan Cox 				   ((u32) BIT(0) & (u32) BIT(1)),
148*2f768af7SAlan Cox 				   ((u32) BIT(0) & (u32) BIT(1)));
149*2f768af7SAlan Cox }
150*2f768af7SAlan Cox 
151*2f768af7SAlan Cox 
152*2f768af7SAlan Cox static int r82600_process_error_info (struct mem_ctl_info *mci,
153*2f768af7SAlan Cox 		struct r82600_error_info *info, int handle_errors)
154*2f768af7SAlan Cox {
155*2f768af7SAlan Cox 	int error_found;
156*2f768af7SAlan Cox 	u32 eapaddr, page;
157*2f768af7SAlan Cox 	u32 syndrome;
158*2f768af7SAlan Cox 
159*2f768af7SAlan Cox 	error_found = 0;
160*2f768af7SAlan Cox 
161*2f768af7SAlan Cox 	/* bits 30:12 store the upper 19 bits of the 32 bit error address */
162*2f768af7SAlan Cox 	eapaddr = ((info->eapr >> 12) & 0x7FFF) << 13;
163*2f768af7SAlan Cox 	/* Syndrome in bits 11:4 [p.62]       */
164*2f768af7SAlan Cox 	syndrome = (info->eapr >> 4) & 0xFF;
165*2f768af7SAlan Cox 
166*2f768af7SAlan Cox 	/* the R82600 reports at less than page *
167*2f768af7SAlan Cox 	 * granularity (upper 19 bits only)     */
168*2f768af7SAlan Cox 	page = eapaddr >> PAGE_SHIFT;
169*2f768af7SAlan Cox 
170*2f768af7SAlan Cox 	if (info->eapr & BIT(0)) { 	/* CE? */
171*2f768af7SAlan Cox 		error_found = 1;
172*2f768af7SAlan Cox 
173*2f768af7SAlan Cox 		if (handle_errors)
174*2f768af7SAlan Cox 			edac_mc_handle_ce(
175*2f768af7SAlan Cox 			    mci, page, 0,	/* not avail */
176*2f768af7SAlan Cox 			    syndrome,
177*2f768af7SAlan Cox 			    edac_mc_find_csrow_by_page(mci, page),
178*2f768af7SAlan Cox 			    0,	/* channel */
179*2f768af7SAlan Cox 			    mci->ctl_name);
180*2f768af7SAlan Cox 	}
181*2f768af7SAlan Cox 
182*2f768af7SAlan Cox 	if (info->eapr & BIT(1)) { 	/* UE? */
183*2f768af7SAlan Cox 		error_found = 1;
184*2f768af7SAlan Cox 
185*2f768af7SAlan Cox 		if (handle_errors)
186*2f768af7SAlan Cox 			/* 82600 doesn't give enough info */
187*2f768af7SAlan Cox 			edac_mc_handle_ue(mci, page, 0,
188*2f768af7SAlan Cox 			    edac_mc_find_csrow_by_page(mci, page),
189*2f768af7SAlan Cox 			    mci->ctl_name);
190*2f768af7SAlan Cox 	}
191*2f768af7SAlan Cox 
192*2f768af7SAlan Cox 	return error_found;
193*2f768af7SAlan Cox }
194*2f768af7SAlan Cox 
195*2f768af7SAlan Cox static void r82600_check(struct mem_ctl_info *mci)
196*2f768af7SAlan Cox {
197*2f768af7SAlan Cox 	struct r82600_error_info info;
198*2f768af7SAlan Cox 
199*2f768af7SAlan Cox 	debugf1("MC%d: " __FILE__ ": %s()\n", mci->mc_idx, __func__);
200*2f768af7SAlan Cox 	r82600_get_error_info(mci, &info);
201*2f768af7SAlan Cox 	r82600_process_error_info(mci, &info, 1);
202*2f768af7SAlan Cox }
203*2f768af7SAlan Cox 
204*2f768af7SAlan Cox static int r82600_probe1(struct pci_dev *pdev, int dev_idx)
205*2f768af7SAlan Cox {
206*2f768af7SAlan Cox 	int rc = -ENODEV;
207*2f768af7SAlan Cox 	int index;
208*2f768af7SAlan Cox 	struct mem_ctl_info *mci = NULL;
209*2f768af7SAlan Cox 	u8 dramcr;
210*2f768af7SAlan Cox 	u32 ecc_on;
211*2f768af7SAlan Cox 	u32 reg_sdram;
212*2f768af7SAlan Cox 	u32 eapr;
213*2f768af7SAlan Cox 	u32 scrub_disabled;
214*2f768af7SAlan Cox 	u32 sdram_refresh_rate;
215*2f768af7SAlan Cox 	u32 row_high_limit_last = 0;
216*2f768af7SAlan Cox 	u32 eap_init_bits;
217*2f768af7SAlan Cox 
218*2f768af7SAlan Cox 	debugf0("MC: " __FILE__ ": %s()\n", __func__);
219*2f768af7SAlan Cox 
220*2f768af7SAlan Cox 
221*2f768af7SAlan Cox 	pci_read_config_byte(pdev, R82600_DRAMC, &dramcr);
222*2f768af7SAlan Cox 	pci_read_config_dword(pdev, R82600_EAP, &eapr);
223*2f768af7SAlan Cox 
224*2f768af7SAlan Cox 	ecc_on = dramcr & BIT(5);
225*2f768af7SAlan Cox 	reg_sdram = dramcr & BIT(4);
226*2f768af7SAlan Cox 	scrub_disabled = eapr & BIT(31);
227*2f768af7SAlan Cox 	sdram_refresh_rate = dramcr & (BIT(0) | BIT(1));
228*2f768af7SAlan Cox 
229*2f768af7SAlan Cox 	debugf2("MC: " __FILE__ ": %s(): sdram refresh rate = %#0x\n",
230*2f768af7SAlan Cox 		__func__, sdram_refresh_rate);
231*2f768af7SAlan Cox 
232*2f768af7SAlan Cox 	debugf2("MC: " __FILE__ ": %s(): DRAMC register = %#0x\n", __func__,
233*2f768af7SAlan Cox 		dramcr);
234*2f768af7SAlan Cox 
235*2f768af7SAlan Cox 	mci = edac_mc_alloc(0, R82600_NR_CSROWS, R82600_NR_CHANS);
236*2f768af7SAlan Cox 
237*2f768af7SAlan Cox 	if (mci == NULL) {
238*2f768af7SAlan Cox 		rc = -ENOMEM;
239*2f768af7SAlan Cox 		goto fail;
240*2f768af7SAlan Cox 	}
241*2f768af7SAlan Cox 
242*2f768af7SAlan Cox 	debugf0("MC: " __FILE__ ": %s(): mci = %p\n", __func__, mci);
243*2f768af7SAlan Cox 
244*2f768af7SAlan Cox 	mci->pdev = pdev;
245*2f768af7SAlan Cox 	mci->mtype_cap = MEM_FLAG_RDDR | MEM_FLAG_DDR;
246*2f768af7SAlan Cox 
247*2f768af7SAlan Cox 	mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_EC | EDAC_FLAG_SECDED;
248*2f768af7SAlan Cox 	/* FIXME try to work out if the chip leads have been                 *
249*2f768af7SAlan Cox 	 * used for COM2 instead on this board? [MA6?]       MAYBE:          */
250*2f768af7SAlan Cox 
251*2f768af7SAlan Cox 	/* On the R82600, the pins for memory bits 72:65 - i.e. the   *
252*2f768af7SAlan Cox 	 * EC bits are shared with the pins for COM2 (!), so if COM2  *
253*2f768af7SAlan Cox 	 * is enabled, we assume COM2 is wired up, and thus no EDAC   *
254*2f768af7SAlan Cox 	 * is possible.                                               */
255*2f768af7SAlan Cox 	mci->edac_cap = EDAC_FLAG_NONE | EDAC_FLAG_EC | EDAC_FLAG_SECDED;
256*2f768af7SAlan Cox 	if (ecc_on) {
257*2f768af7SAlan Cox 		if (scrub_disabled)
258*2f768af7SAlan Cox 			debugf3("MC: " __FILE__ ": %s(): mci = %p - "
259*2f768af7SAlan Cox 				"Scrubbing disabled! EAP: %#0x\n", __func__,
260*2f768af7SAlan Cox 				mci, eapr);
261*2f768af7SAlan Cox 	} else
262*2f768af7SAlan Cox 		mci->edac_cap = EDAC_FLAG_NONE;
263*2f768af7SAlan Cox 
264*2f768af7SAlan Cox 	mci->mod_name = BS_MOD_STR;
265*2f768af7SAlan Cox 	mci->mod_ver = "$Revision: 1.1.2.6 $";
266*2f768af7SAlan Cox 	mci->ctl_name = "R82600";
267*2f768af7SAlan Cox 	mci->edac_check = r82600_check;
268*2f768af7SAlan Cox 	mci->ctl_page_to_phys = NULL;
269*2f768af7SAlan Cox 
270*2f768af7SAlan Cox 	for (index = 0; index < mci->nr_csrows; index++) {
271*2f768af7SAlan Cox 		struct csrow_info *csrow = &mci->csrows[index];
272*2f768af7SAlan Cox 		u8 drbar;	/* sDram Row Boundry Address Register */
273*2f768af7SAlan Cox 		u32 row_high_limit;
274*2f768af7SAlan Cox 		u32 row_base;
275*2f768af7SAlan Cox 
276*2f768af7SAlan Cox 		/* find the DRAM Chip Select Base address and mask */
277*2f768af7SAlan Cox 		pci_read_config_byte(mci->pdev, R82600_DRBA + index, &drbar);
278*2f768af7SAlan Cox 
279*2f768af7SAlan Cox 		debugf1("MC%d: " __FILE__ ": %s() Row=%d DRBA = %#0x\n",
280*2f768af7SAlan Cox 			mci->mc_idx, __func__, index, drbar);
281*2f768af7SAlan Cox 
282*2f768af7SAlan Cox 		row_high_limit = ((u32) drbar << 24);
283*2f768af7SAlan Cox /*		row_high_limit = ((u32)drbar << 24) | 0xffffffUL; */
284*2f768af7SAlan Cox 
285*2f768af7SAlan Cox 		debugf1("MC%d: " __FILE__ ": %s() Row=%d, "
286*2f768af7SAlan Cox 			"Boundry Address=%#0x, Last = %#0x \n",
287*2f768af7SAlan Cox 			mci->mc_idx, __func__, index, row_high_limit,
288*2f768af7SAlan Cox 			row_high_limit_last);
289*2f768af7SAlan Cox 
290*2f768af7SAlan Cox 		/* Empty row [p.57] */
291*2f768af7SAlan Cox 		if (row_high_limit == row_high_limit_last)
292*2f768af7SAlan Cox 			continue;
293*2f768af7SAlan Cox 
294*2f768af7SAlan Cox 		row_base = row_high_limit_last;
295*2f768af7SAlan Cox 
296*2f768af7SAlan Cox 		csrow->first_page = row_base >> PAGE_SHIFT;
297*2f768af7SAlan Cox 		csrow->last_page = (row_high_limit >> PAGE_SHIFT) - 1;
298*2f768af7SAlan Cox 		csrow->nr_pages = csrow->last_page - csrow->first_page + 1;
299*2f768af7SAlan Cox 		/* Error address is top 19 bits - so granularity is      *
300*2f768af7SAlan Cox 		 * 14 bits                                               */
301*2f768af7SAlan Cox 		csrow->grain = 1 << 14;
302*2f768af7SAlan Cox 		csrow->mtype = reg_sdram ? MEM_RDDR : MEM_DDR;
303*2f768af7SAlan Cox 		/* FIXME - check that this is unknowable with this chipset */
304*2f768af7SAlan Cox 		csrow->dtype = DEV_UNKNOWN;
305*2f768af7SAlan Cox 
306*2f768af7SAlan Cox 		/* Mode is global on 82600 */
307*2f768af7SAlan Cox 		csrow->edac_mode = ecc_on ? EDAC_SECDED : EDAC_NONE;
308*2f768af7SAlan Cox 		row_high_limit_last = row_high_limit;
309*2f768af7SAlan Cox 	}
310*2f768af7SAlan Cox 
311*2f768af7SAlan Cox 	/* clear counters */
312*2f768af7SAlan Cox 	/* FIXME should we? */
313*2f768af7SAlan Cox 
314*2f768af7SAlan Cox 	if (edac_mc_add_mc(mci)) {
315*2f768af7SAlan Cox 		debugf3("MC: " __FILE__
316*2f768af7SAlan Cox 			": %s(): failed edac_mc_add_mc()\n", __func__);
317*2f768af7SAlan Cox 		goto fail;
318*2f768af7SAlan Cox 	}
319*2f768af7SAlan Cox 
320*2f768af7SAlan Cox 	/* get this far and it's successful */
321*2f768af7SAlan Cox 
322*2f768af7SAlan Cox 	/* Clear error flags to allow next error to be reported [p.62] */
323*2f768af7SAlan Cox 	/* Test systems seem to always have the UE flag raised on boot */
324*2f768af7SAlan Cox 
325*2f768af7SAlan Cox 	eap_init_bits = BIT(0) & BIT(1);
326*2f768af7SAlan Cox 	if (disable_hardware_scrub) {
327*2f768af7SAlan Cox 		eap_init_bits |= BIT(31);
328*2f768af7SAlan Cox 		debugf3("MC: " __FILE__ ": %s(): Disabling Hardware Scrub "
329*2f768af7SAlan Cox 			"(scrub on error)\n", __func__);
330*2f768af7SAlan Cox 	}
331*2f768af7SAlan Cox 
332*2f768af7SAlan Cox 	pci_write_bits32(mci->pdev, R82600_EAP, eap_init_bits,
333*2f768af7SAlan Cox 			 eap_init_bits);
334*2f768af7SAlan Cox 
335*2f768af7SAlan Cox 	debugf3("MC: " __FILE__ ": %s(): success\n", __func__);
336*2f768af7SAlan Cox 	return 0;
337*2f768af7SAlan Cox 
338*2f768af7SAlan Cox fail:
339*2f768af7SAlan Cox 	if (mci)
340*2f768af7SAlan Cox 		edac_mc_free(mci);
341*2f768af7SAlan Cox 
342*2f768af7SAlan Cox 	return rc;
343*2f768af7SAlan Cox }
344*2f768af7SAlan Cox 
345*2f768af7SAlan Cox /* returns count (>= 0), or negative on error */
346*2f768af7SAlan Cox static int __devinit r82600_init_one(struct pci_dev *pdev,
347*2f768af7SAlan Cox 				     const struct pci_device_id *ent)
348*2f768af7SAlan Cox {
349*2f768af7SAlan Cox 	debugf0("MC: " __FILE__ ": %s()\n", __func__);
350*2f768af7SAlan Cox 
351*2f768af7SAlan Cox 	/* don't need to call pci_device_enable() */
352*2f768af7SAlan Cox 	return r82600_probe1(pdev, ent->driver_data);
353*2f768af7SAlan Cox }
354*2f768af7SAlan Cox 
355*2f768af7SAlan Cox 
356*2f768af7SAlan Cox static void __devexit r82600_remove_one(struct pci_dev *pdev)
357*2f768af7SAlan Cox {
358*2f768af7SAlan Cox 	struct mem_ctl_info *mci;
359*2f768af7SAlan Cox 
360*2f768af7SAlan Cox 	debugf0(__FILE__ ": %s()\n", __func__);
361*2f768af7SAlan Cox 
362*2f768af7SAlan Cox 	if (((mci = edac_mc_find_mci_by_pdev(pdev)) != NULL) &&
363*2f768af7SAlan Cox 	    !edac_mc_del_mc(mci))
364*2f768af7SAlan Cox 		edac_mc_free(mci);
365*2f768af7SAlan Cox }
366*2f768af7SAlan Cox 
367*2f768af7SAlan Cox 
368*2f768af7SAlan Cox static const struct pci_device_id r82600_pci_tbl[] __devinitdata = {
369*2f768af7SAlan Cox 	{PCI_DEVICE(PCI_VENDOR_ID_RADISYS, R82600_BRIDGE_ID)},
370*2f768af7SAlan Cox 	{0,}			/* 0 terminated list. */
371*2f768af7SAlan Cox };
372*2f768af7SAlan Cox 
373*2f768af7SAlan Cox MODULE_DEVICE_TABLE(pci, r82600_pci_tbl);
374*2f768af7SAlan Cox 
375*2f768af7SAlan Cox 
376*2f768af7SAlan Cox static struct pci_driver r82600_driver = {
377*2f768af7SAlan Cox 	.name = BS_MOD_STR,
378*2f768af7SAlan Cox 	.probe = r82600_init_one,
379*2f768af7SAlan Cox 	.remove = __devexit_p(r82600_remove_one),
380*2f768af7SAlan Cox 	.id_table = r82600_pci_tbl,
381*2f768af7SAlan Cox };
382*2f768af7SAlan Cox 
383*2f768af7SAlan Cox 
384*2f768af7SAlan Cox int __init r82600_init(void)
385*2f768af7SAlan Cox {
386*2f768af7SAlan Cox 	return pci_register_driver(&r82600_driver);
387*2f768af7SAlan Cox }
388*2f768af7SAlan Cox 
389*2f768af7SAlan Cox 
390*2f768af7SAlan Cox static void __exit r82600_exit(void)
391*2f768af7SAlan Cox {
392*2f768af7SAlan Cox 	pci_unregister_driver(&r82600_driver);
393*2f768af7SAlan Cox }
394*2f768af7SAlan Cox 
395*2f768af7SAlan Cox 
396*2f768af7SAlan Cox module_init(r82600_init);
397*2f768af7SAlan Cox module_exit(r82600_exit);
398*2f768af7SAlan Cox 
399*2f768af7SAlan Cox 
400*2f768af7SAlan Cox MODULE_LICENSE("GPL");
401*2f768af7SAlan Cox MODULE_AUTHOR("Tim Small <tim@buttersideup.com> - WPAD Ltd. "
402*2f768af7SAlan Cox 	      "on behalf of EADS Astrium");
403*2f768af7SAlan Cox MODULE_DESCRIPTION("MC support for Radisys 82600 memory controllers");
404*2f768af7SAlan Cox 
405*2f768af7SAlan Cox module_param(disable_hardware_scrub, bool, 0644);
406*2f768af7SAlan Cox MODULE_PARM_DESC(disable_hardware_scrub,
407*2f768af7SAlan Cox 		 "If set, disable the chipset's automatic scrub for CEs");
408