xref: /openbmc/linux/drivers/edac/i82443bxgx_edac.c (revision 11116601092c42364892d3f59c8f4a8a30916867)
15a2c675cSTim Small /*
25a2c675cSTim Small  * Intel 82443BX/GX (440BX/GX chipset) Memory Controller EDAC kernel
35a2c675cSTim Small  * module (C) 2006 Tim Small
45a2c675cSTim Small  *
55a2c675cSTim Small  * This file may be distributed under the terms of the GNU General
65a2c675cSTim Small  * Public License.
75a2c675cSTim Small  *
85a2c675cSTim Small  * Written by Tim Small <tim@buttersideup.com>, based on work by Linux
95a2c675cSTim Small  * Networx, Thayne Harbaugh, Dan Hollis <goemon at anime dot net> and
105a2c675cSTim Small  * others.
115a2c675cSTim Small  *
125a2c675cSTim Small  * 440GX fix by Jason Uhlenkott <juhlenko@akamai.com>.
135a2c675cSTim Small  *
145a2c675cSTim Small  * Written with reference to 82443BX Host Bridge Datasheet:
155a2c675cSTim Small  * http://www.intel.com/design/chipsets/440/documentation.htm
165a2c675cSTim Small  * references to this document given in [].
175a2c675cSTim Small  *
185a2c675cSTim Small  * This module doesn't support the 440LX, but it may be possible to
195a2c675cSTim Small  * make it do so (the 440LX's register definitions are different, but
205a2c675cSTim Small  * not completely so - I haven't studied them in enough detail to know
215a2c675cSTim Small  * how easy this would be).
225a2c675cSTim Small  */
235a2c675cSTim Small 
245a2c675cSTim Small #include <linux/module.h>
255a2c675cSTim Small #include <linux/init.h>
265a2c675cSTim Small 
275a2c675cSTim Small #include <linux/pci.h>
285a2c675cSTim Small #include <linux/pci_ids.h>
295a2c675cSTim Small 
305a2c675cSTim Small #include <linux/slab.h>
315a2c675cSTim Small 
3220bcb7a8SDouglas Thompson #include "edac_core.h"
335a2c675cSTim Small 
345a2c675cSTim Small #define I82443_REVISION	"0.1"
355a2c675cSTim Small 
365a2c675cSTim Small #define EDAC_MOD_STR    "i82443bxgx_edac"
375a2c675cSTim Small 
385a2c675cSTim Small /* The 82443BX supports SDRAM, or EDO (EDO for mobile only), "Memory
395a2c675cSTim Small  * Size: 8 MB to 512 MB (1GB with Registered DIMMs) with eight memory
405a2c675cSTim Small  * rows" "The 82443BX supports multiple-bit error detection and
415a2c675cSTim Small  * single-bit error correction when ECC mode is enabled and
425a2c675cSTim Small  * single/multi-bit error detection when correction is disabled.
435a2c675cSTim Small  * During writes to the DRAM, the 82443BX generates ECC for the data
445a2c675cSTim Small  * on a QWord basis. Partial QWord writes require a read-modify-write
455a2c675cSTim Small  * cycle when ECC is enabled."
465a2c675cSTim Small */
475a2c675cSTim Small 
485a2c675cSTim Small /* "Additionally, the 82443BX ensures that the data is corrected in
495a2c675cSTim Small  * main memory so that accumulation of errors is prevented. Another
505a2c675cSTim Small  * error within the same QWord would result in a double-bit error
515a2c675cSTim Small  * which is unrecoverable. This is known as hardware scrubbing since
525a2c675cSTim Small  * it requires no software intervention to correct the data in memory."
535a2c675cSTim Small  */
545a2c675cSTim Small 
555a2c675cSTim Small /* [Also see page 100 (section 4.3), "DRAM Interface"]
565a2c675cSTim Small  * [Also see page 112 (section 4.6.1.4), ECC]
575a2c675cSTim Small  */
585a2c675cSTim Small 
595a2c675cSTim Small #define I82443BXGX_NR_CSROWS 8
605a2c675cSTim Small #define I82443BXGX_NR_CHANS  1
615a2c675cSTim Small #define I82443BXGX_NR_DIMMS  4
625a2c675cSTim Small 
635a2c675cSTim Small /* 82443 PCI Device 0 */
645a2c675cSTim Small #define I82443BXGX_NBXCFG 0x50	/* 32bit register starting at this PCI
655a2c675cSTim Small 				 * config space offset */
665a2c675cSTim Small #define I82443BXGX_NBXCFG_OFFSET_NON_ECCROW 24	/* Array of bits, zero if
675a2c675cSTim Small 						 * row is non-ECC */
685a2c675cSTim Small #define I82443BXGX_NBXCFG_OFFSET_DRAM_FREQ 12	/* 2 bits,00=100MHz,10=66 MHz */
695a2c675cSTim Small 
705a2c675cSTim Small #define I82443BXGX_NBXCFG_OFFSET_DRAM_INTEGRITY 7	/* 2 bits:       */
715a2c675cSTim Small #define I82443BXGX_NBXCFG_INTEGRITY_NONE   0x0	/* 00 = Non-ECC */
725a2c675cSTim Small #define I82443BXGX_NBXCFG_INTEGRITY_EC     0x1	/* 01 = EC (only) */
735a2c675cSTim Small #define I82443BXGX_NBXCFG_INTEGRITY_ECC    0x2	/* 10 = ECC */
745a2c675cSTim Small #define I82443BXGX_NBXCFG_INTEGRITY_SCRUB  0x3	/* 11 = ECC + HW Scrub */
755a2c675cSTim Small 
765a2c675cSTim Small #define I82443BXGX_NBXCFG_OFFSET_ECC_DIAG_ENABLE  6
775a2c675cSTim Small 
785a2c675cSTim Small /* 82443 PCI Device 0 */
795a2c675cSTim Small #define I82443BXGX_EAP   0x80	/* 32bit register starting at this PCI
805a2c675cSTim Small 				 * config space offset, Error Address
815a2c675cSTim Small 				 * Pointer Register */
825a2c675cSTim Small #define I82443BXGX_EAP_OFFSET_EAP  12	/* High 20 bits of error address */
835a2c675cSTim Small #define I82443BXGX_EAP_OFFSET_MBE  BIT(1)	/* Err at EAP was multi-bit (W1TC) */
845a2c675cSTim Small #define I82443BXGX_EAP_OFFSET_SBE  BIT(0)	/* Err at EAP was single-bit (W1TC) */
855a2c675cSTim Small 
865a2c675cSTim Small #define I82443BXGX_ERRCMD  0x90	/* 8bit register starting at this PCI
875a2c675cSTim Small 				 * config space offset. */
885a2c675cSTim Small #define I82443BXGX_ERRCMD_OFFSET_SERR_ON_MBE BIT(1)	/* 1 = enable */
895a2c675cSTim Small #define I82443BXGX_ERRCMD_OFFSET_SERR_ON_SBE BIT(0)	/* 1 = enable */
905a2c675cSTim Small 
915a2c675cSTim Small #define I82443BXGX_ERRSTS  0x91	/* 16bit register starting at this PCI
925a2c675cSTim Small 				 * config space offset. */
935a2c675cSTim Small #define I82443BXGX_ERRSTS_OFFSET_MBFRE 5	/* 3 bits - first err row multibit */
945a2c675cSTim Small #define I82443BXGX_ERRSTS_OFFSET_MEF   BIT(4)	/* 1 = MBE occurred */
955a2c675cSTim Small #define I82443BXGX_ERRSTS_OFFSET_SBFRE 1	/* 3 bits - first err row singlebit */
965a2c675cSTim Small #define I82443BXGX_ERRSTS_OFFSET_SEF   BIT(0)	/* 1 = SBE occurred */
975a2c675cSTim Small 
985a2c675cSTim Small #define I82443BXGX_DRAMC 0x57	/* 8bit register starting at this PCI
995a2c675cSTim Small 				 * config space offset. */
1005a2c675cSTim Small #define I82443BXGX_DRAMC_OFFSET_DT 3	/* 2 bits, DRAM Type */
1015a2c675cSTim Small #define I82443BXGX_DRAMC_DRAM_IS_EDO 0	/* 00 = EDO */
1025a2c675cSTim Small #define I82443BXGX_DRAMC_DRAM_IS_SDRAM 1	/* 01 = SDRAM */
1035a2c675cSTim Small #define I82443BXGX_DRAMC_DRAM_IS_RSDRAM 2	/* 10 = Registered SDRAM */
1045a2c675cSTim Small 
1055a2c675cSTim Small #define I82443BXGX_DRB 0x60	/* 8x 8bit registers starting at this PCI
1065a2c675cSTim Small 				 * config space offset. */
1075a2c675cSTim Small 
1085a2c675cSTim Small /* FIXME - don't poll when ECC disabled? */
1095a2c675cSTim Small 
1105a2c675cSTim Small struct i82443bxgx_edacmc_error_info {
1115a2c675cSTim Small 	u32 eap;
1125a2c675cSTim Small };
1135a2c675cSTim Small 
1145a2c675cSTim Small static void i82443bxgx_edacmc_get_error_info(struct mem_ctl_info *mci,
115*11116601SDouglas Thompson 					     struct i82443bxgx_edacmc_error_info
116*11116601SDouglas Thompson 					     *info)
1175a2c675cSTim Small {
1185a2c675cSTim Small 	struct pci_dev *pdev;
1195a2c675cSTim Small 	pdev = to_pci_dev(mci->dev);
1205a2c675cSTim Small 	pci_read_config_dword(pdev, I82443BXGX_EAP, &info->eap);
1215a2c675cSTim Small 	if (info->eap & I82443BXGX_EAP_OFFSET_SBE)
1225a2c675cSTim Small 		/* Clear error to allow next error to be reported [p.61] */
1235a2c675cSTim Small 		pci_write_bits32(pdev, I82443BXGX_EAP,
1245a2c675cSTim Small 				 I82443BXGX_EAP_OFFSET_SBE,
1255a2c675cSTim Small 				 I82443BXGX_EAP_OFFSET_SBE);
1265a2c675cSTim Small 
1275a2c675cSTim Small 	if (info->eap & I82443BXGX_EAP_OFFSET_MBE)
1285a2c675cSTim Small 		/* Clear error to allow next error to be reported [p.61] */
1295a2c675cSTim Small 		pci_write_bits32(pdev, I82443BXGX_EAP,
1305a2c675cSTim Small 				 I82443BXGX_EAP_OFFSET_MBE,
1315a2c675cSTim Small 				 I82443BXGX_EAP_OFFSET_MBE);
1325a2c675cSTim Small }
1335a2c675cSTim Small 
1345a2c675cSTim Small static int i82443bxgx_edacmc_process_error_info(struct mem_ctl_info *mci,
135*11116601SDouglas Thompson 						struct
136*11116601SDouglas Thompson 						i82443bxgx_edacmc_error_info
137*11116601SDouglas Thompson 						*info, int handle_errors)
1385a2c675cSTim Small {
1395a2c675cSTim Small 	int error_found = 0;
1405a2c675cSTim Small 	u32 eapaddr, page, pageoffset;
1415a2c675cSTim Small 
1425a2c675cSTim Small 	/* bits 30:12 hold the 4kb block in which the error occurred
1435a2c675cSTim Small 	 * [p.61] */
1445a2c675cSTim Small 	eapaddr = (info->eap & 0xfffff000);
1455a2c675cSTim Small 	page = eapaddr >> PAGE_SHIFT;
1465a2c675cSTim Small 	pageoffset = eapaddr - (page << PAGE_SHIFT);
1475a2c675cSTim Small 
1485a2c675cSTim Small 	if (info->eap & I82443BXGX_EAP_OFFSET_SBE) {
1495a2c675cSTim Small 		error_found = 1;
1505a2c675cSTim Small 		if (handle_errors)
151*11116601SDouglas Thompson 			edac_mc_handle_ce(mci, page, pageoffset,
1525a2c675cSTim Small 					  /* 440BX/GX don't make syndrome information available */
153*11116601SDouglas Thompson 					  0, edac_mc_find_csrow_by_page(mci, page), 0,	/* channel */
1545a2c675cSTim Small 					  mci->ctl_name);
1555a2c675cSTim Small 	}
1565a2c675cSTim Small 
1575a2c675cSTim Small 	if (info->eap & I82443BXGX_EAP_OFFSET_MBE) {
1585a2c675cSTim Small 		error_found = 1;
1595a2c675cSTim Small 		if (handle_errors)
160*11116601SDouglas Thompson 			edac_mc_handle_ue(mci, page, pageoffset,
1615a2c675cSTim Small 					  edac_mc_find_csrow_by_page(mci, page),
1625a2c675cSTim Small 					  mci->ctl_name);
1635a2c675cSTim Small 	}
1645a2c675cSTim Small 
1655a2c675cSTim Small 	return error_found;
1665a2c675cSTim Small }
1675a2c675cSTim Small 
1685a2c675cSTim Small static void i82443bxgx_edacmc_check(struct mem_ctl_info *mci)
1695a2c675cSTim Small {
1705a2c675cSTim Small 	struct i82443bxgx_edacmc_error_info info;
1715a2c675cSTim Small 
1725a2c675cSTim Small 	debugf1("MC%d: " __FILE__ ": %s()\n", mci->mc_idx, __func__);
1735a2c675cSTim Small 	i82443bxgx_edacmc_get_error_info(mci, &info);
1745a2c675cSTim Small 	i82443bxgx_edacmc_process_error_info(mci, &info, 1);
1755a2c675cSTim Small }
1765a2c675cSTim Small 
1775a2c675cSTim Small static void i82443bxgx_init_csrows(struct mem_ctl_info *mci,
1785a2c675cSTim Small 				   struct pci_dev *pdev,
1795a2c675cSTim Small 				   enum edac_type edac_mode,
1805a2c675cSTim Small 				   enum mem_type mtype)
1815a2c675cSTim Small {
1825a2c675cSTim Small 	struct csrow_info *csrow;
1835a2c675cSTim Small 	int index;
1845a2c675cSTim Small 	u8 drbar, dramc;
1855a2c675cSTim Small 	u32 row_base, row_high_limit, row_high_limit_last;
1865a2c675cSTim Small 
1875a2c675cSTim Small 	pci_read_config_byte(pdev, I82443BXGX_DRAMC, &dramc);
1885a2c675cSTim Small 	row_high_limit_last = 0;
1895a2c675cSTim Small 	for (index = 0; index < mci->nr_csrows; index++) {
1905a2c675cSTim Small 		csrow = &mci->csrows[index];
1915a2c675cSTim Small 		pci_read_config_byte(pdev, I82443BXGX_DRB + index, &drbar);
1925a2c675cSTim Small 		debugf1("MC%d: " __FILE__ ": %s() Row=%d DRB = %#0x\n",
1935a2c675cSTim Small 			mci->mc_idx, __func__, index, drbar);
1945a2c675cSTim Small 		row_high_limit = ((u32) drbar << 23);
1955a2c675cSTim Small 		/* find the DRAM Chip Select Base address and mask */
1965a2c675cSTim Small 		debugf1("MC%d: " __FILE__ ": %s() Row=%d, "
1975a2c675cSTim Small 			"Boundry Address=%#0x, Last = %#0x \n",
1985a2c675cSTim Small 			mci->mc_idx, __func__, index, row_high_limit,
1995a2c675cSTim Small 			row_high_limit_last);
2005a2c675cSTim Small 
2015a2c675cSTim Small 		/* 440GX goes to 2GB, represented with a DRB of 0. */
2025a2c675cSTim Small 		if (row_high_limit_last && !row_high_limit)
2035a2c675cSTim Small 			row_high_limit = 1UL << 31;
2045a2c675cSTim Small 
2055a2c675cSTim Small 		/* This row is empty [p.49] */
2065a2c675cSTim Small 		if (row_high_limit == row_high_limit_last)
2075a2c675cSTim Small 			continue;
2085a2c675cSTim Small 		row_base = row_high_limit_last;
2095a2c675cSTim Small 		csrow->first_page = row_base >> PAGE_SHIFT;
2105a2c675cSTim Small 		csrow->last_page = (row_high_limit >> PAGE_SHIFT) - 1;
2115a2c675cSTim Small 		csrow->nr_pages = csrow->last_page - csrow->first_page + 1;
2125a2c675cSTim Small 		/* EAP reports in 4kilobyte granularity [61] */
2135a2c675cSTim Small 		csrow->grain = 1 << 12;
2145a2c675cSTim Small 		csrow->mtype = mtype;
2155a2c675cSTim Small 		/* I don't think 440BX can tell you device type? FIXME? */
2165a2c675cSTim Small 		csrow->dtype = DEV_UNKNOWN;
2175a2c675cSTim Small 		/* Mode is global to all rows on 440BX */
2185a2c675cSTim Small 		csrow->edac_mode = edac_mode;
2195a2c675cSTim Small 		row_high_limit_last = row_high_limit;
2205a2c675cSTim Small 	}
2215a2c675cSTim Small }
2225a2c675cSTim Small 
2235a2c675cSTim Small static int i82443bxgx_edacmc_probe1(struct pci_dev *pdev, int dev_idx)
2245a2c675cSTim Small {
2255a2c675cSTim Small 	struct mem_ctl_info *mci;
2265a2c675cSTim Small 	u8 dramc;
2275a2c675cSTim Small 	u32 nbxcfg, ecc_mode;
2285a2c675cSTim Small 	enum mem_type mtype;
2295a2c675cSTim Small 	enum edac_type edac_mode;
2305a2c675cSTim Small 
2315a2c675cSTim Small 	debugf0("MC: " __FILE__ ": %s()\n", __func__);
2325a2c675cSTim Small 
2335a2c675cSTim Small 	/* Something is really hosed if PCI config space reads from
2345a2c675cSTim Small 	   the MC aren't working.  */
2355a2c675cSTim Small 	if (pci_read_config_dword(pdev, I82443BXGX_NBXCFG, &nbxcfg))
2365a2c675cSTim Small 		return -EIO;
2375a2c675cSTim Small 
2385a2c675cSTim Small 	mci = edac_mc_alloc(0, I82443BXGX_NR_CSROWS, I82443BXGX_NR_CHANS);
2395a2c675cSTim Small 
2405a2c675cSTim Small 	if (mci == NULL)
2415a2c675cSTim Small 		return -ENOMEM;
2425a2c675cSTim Small 
2435a2c675cSTim Small 	debugf0("MC: " __FILE__ ": %s(): mci = %p\n", __func__, mci);
2445a2c675cSTim Small 	mci->dev = &pdev->dev;
2455a2c675cSTim Small 	mci->mtype_cap = MEM_FLAG_EDO | MEM_FLAG_SDR | MEM_FLAG_RDR;
2465a2c675cSTim Small 	mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_EC | EDAC_FLAG_SECDED;
2475a2c675cSTim Small 	pci_read_config_byte(pdev, I82443BXGX_DRAMC, &dramc);
2485a2c675cSTim Small 	switch ((dramc >> I82443BXGX_DRAMC_OFFSET_DT) & (BIT(0) | BIT(1))) {
2495a2c675cSTim Small 	case I82443BXGX_DRAMC_DRAM_IS_EDO:
2505a2c675cSTim Small 		mtype = MEM_EDO;
2515a2c675cSTim Small 		break;
2525a2c675cSTim Small 	case I82443BXGX_DRAMC_DRAM_IS_SDRAM:
2535a2c675cSTim Small 		mtype = MEM_SDR;
2545a2c675cSTim Small 		break;
2555a2c675cSTim Small 	case I82443BXGX_DRAMC_DRAM_IS_RSDRAM:
2565a2c675cSTim Small 		mtype = MEM_RDR;
2575a2c675cSTim Small 		break;
2585a2c675cSTim Small 	default:
259*11116601SDouglas Thompson 		debugf0
260*11116601SDouglas Thompson 		    ("Unknown/reserved DRAM type value in DRAMC register!\n");
2615a2c675cSTim Small 		mtype = -MEM_UNKNOWN;
2625a2c675cSTim Small 	}
2635a2c675cSTim Small 
2645a2c675cSTim Small 	if ((mtype == MEM_SDR) || (mtype == MEM_RDR))
2655a2c675cSTim Small 		mci->edac_cap = mci->edac_ctl_cap;
2665a2c675cSTim Small 	else
2675a2c675cSTim Small 		mci->edac_cap = EDAC_FLAG_NONE;
2685a2c675cSTim Small 
2695a2c675cSTim Small 	mci->scrub_cap = SCRUB_FLAG_HW_SRC;
2705a2c675cSTim Small 	pci_read_config_dword(pdev, I82443BXGX_NBXCFG, &nbxcfg);
2715a2c675cSTim Small 	ecc_mode = ((nbxcfg >> I82443BXGX_NBXCFG_OFFSET_DRAM_INTEGRITY) &
2725a2c675cSTim Small 		    (BIT(0) | BIT(1)));
2735a2c675cSTim Small 
2745a2c675cSTim Small 	mci->scrub_mode = (ecc_mode == I82443BXGX_NBXCFG_INTEGRITY_SCRUB)
275*11116601SDouglas Thompson 	    ? SCRUB_HW_SRC : SCRUB_NONE;
2765a2c675cSTim Small 
2775a2c675cSTim Small 	switch (ecc_mode) {
2785a2c675cSTim Small 	case I82443BXGX_NBXCFG_INTEGRITY_NONE:
2795a2c675cSTim Small 		edac_mode = EDAC_NONE;
2805a2c675cSTim Small 		break;
2815a2c675cSTim Small 	case I82443BXGX_NBXCFG_INTEGRITY_EC:
2825a2c675cSTim Small 		edac_mode = EDAC_EC;
2835a2c675cSTim Small 		break;
2845a2c675cSTim Small 	case I82443BXGX_NBXCFG_INTEGRITY_ECC:
2855a2c675cSTim Small 	case I82443BXGX_NBXCFG_INTEGRITY_SCRUB:
2865a2c675cSTim Small 		edac_mode = EDAC_SECDED;
2875a2c675cSTim Small 		break;
2885a2c675cSTim Small 	default:
289*11116601SDouglas Thompson 		debugf0
290*11116601SDouglas Thompson 		    ("%s(): Unknown/reserved ECC state in NBXCFG register!\n",
2915a2c675cSTim Small 		     __func__);
2925a2c675cSTim Small 		edac_mode = EDAC_UNKNOWN;
2935a2c675cSTim Small 		break;
2945a2c675cSTim Small 	}
2955a2c675cSTim Small 
2965a2c675cSTim Small 	i82443bxgx_init_csrows(mci, pdev, edac_mode, mtype);
2975a2c675cSTim Small 
2985a2c675cSTim Small 	/* Many BIOSes don't clear error flags on boot, so do this
2995a2c675cSTim Small 	 * here, or we get "phantom" errors occuring at module-load
3005a2c675cSTim Small 	 * time. */
3015a2c675cSTim Small 	pci_write_bits32(pdev, I82443BXGX_EAP,
302*11116601SDouglas Thompson 			 (I82443BXGX_EAP_OFFSET_SBE |
303*11116601SDouglas Thompson 			  I82443BXGX_EAP_OFFSET_MBE),
304*11116601SDouglas Thompson 			 (I82443BXGX_EAP_OFFSET_SBE |
305*11116601SDouglas Thompson 			  I82443BXGX_EAP_OFFSET_MBE));
3065a2c675cSTim Small 
3075a2c675cSTim Small 	mci->mod_name = EDAC_MOD_STR;
3085a2c675cSTim Small 	mci->mod_ver = I82443_REVISION;
3095a2c675cSTim Small 	mci->ctl_name = "I82443BXGX";
310c4192705SDave Jiang 	mci->dev_name = pci_name(pdev);
3115a2c675cSTim Small 	mci->edac_check = i82443bxgx_edacmc_check;
3125a2c675cSTim Small 	mci->ctl_page_to_phys = NULL;
3135a2c675cSTim Small 
3145a2c675cSTim Small 	if (edac_mc_add_mc(mci, 0)) {
3155a2c675cSTim Small 		debugf3("%s(): failed edac_mc_add_mc()\n", __func__);
3165a2c675cSTim Small 		goto fail;
3175a2c675cSTim Small 	}
3185a2c675cSTim Small 
3195a2c675cSTim Small 	debugf3("MC: " __FILE__ ": %s(): success\n", __func__);
3205a2c675cSTim Small 	return 0;
3215a2c675cSTim Small 
3225a2c675cSTim Small       fail:
3235a2c675cSTim Small 	edac_mc_free(mci);
3245a2c675cSTim Small 	return -ENODEV;
3255a2c675cSTim Small }
326*11116601SDouglas Thompson 
3275a2c675cSTim Small EXPORT_SYMBOL_GPL(i82443bxgx_edacmc_probe1);
3285a2c675cSTim Small 
3295a2c675cSTim Small /* returns count (>= 0), or negative on error */
3305a2c675cSTim Small static int __devinit i82443bxgx_edacmc_init_one(struct pci_dev *pdev,
3315a2c675cSTim Small 						const struct pci_device_id *ent)
3325a2c675cSTim Small {
3335a2c675cSTim Small 	debugf0("MC: " __FILE__ ": %s()\n", __func__);
3345a2c675cSTim Small 
3355a2c675cSTim Small 	/* don't need to call pci_device_enable() */
3365a2c675cSTim Small 	return i82443bxgx_edacmc_probe1(pdev, ent->driver_data);
3375a2c675cSTim Small }
3385a2c675cSTim Small 
3395a2c675cSTim Small static void __devexit i82443bxgx_edacmc_remove_one(struct pci_dev *pdev)
3405a2c675cSTim Small {
3415a2c675cSTim Small 	struct mem_ctl_info *mci;
3425a2c675cSTim Small 
3435a2c675cSTim Small 	debugf0(__FILE__ ": %s()\n", __func__);
3445a2c675cSTim Small 
3455a2c675cSTim Small 	if ((mci = edac_mc_del_mc(&pdev->dev)) == NULL)
3465a2c675cSTim Small 		return;
3475a2c675cSTim Small 
3485a2c675cSTim Small 	edac_mc_free(mci);
3495a2c675cSTim Small }
3505a2c675cSTim Small 
351*11116601SDouglas Thompson EXPORT_SYMBOL_GPL(i82443bxgx_edacmc_remove_one);
3525a2c675cSTim Small 
3535a2c675cSTim Small static const struct pci_device_id i82443bxgx_pci_tbl[] __devinitdata = {
3545a2c675cSTim Small 	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443BX_0)},
3555a2c675cSTim Small 	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443BX_2)},
3565a2c675cSTim Small 	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443GX_0)},
3575a2c675cSTim Small 	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443GX_2)},
3585a2c675cSTim Small 	{0,}			/* 0 terminated list. */
3595a2c675cSTim Small };
3605a2c675cSTim Small 
3615a2c675cSTim Small MODULE_DEVICE_TABLE(pci, i82443bxgx_pci_tbl);
3625a2c675cSTim Small 
3635a2c675cSTim Small static struct pci_driver i82443bxgx_edacmc_driver = {
3645a2c675cSTim Small 	.name = EDAC_MOD_STR,
3655a2c675cSTim Small 	.probe = i82443bxgx_edacmc_init_one,
3665a2c675cSTim Small 	.remove = __devexit_p(i82443bxgx_edacmc_remove_one),
3675a2c675cSTim Small 	.id_table = i82443bxgx_pci_tbl,
3685a2c675cSTim Small };
3695a2c675cSTim Small 
3705a2c675cSTim Small static int __init i82443bxgx_edacmc_init(void)
3715a2c675cSTim Small {
3725a2c675cSTim Small 	return pci_register_driver(&i82443bxgx_edacmc_driver);
3735a2c675cSTim Small }
3745a2c675cSTim Small 
3755a2c675cSTim Small static void __exit i82443bxgx_edacmc_exit(void)
3765a2c675cSTim Small {
3775a2c675cSTim Small 	pci_unregister_driver(&i82443bxgx_edacmc_driver);
3785a2c675cSTim Small }
3795a2c675cSTim Small 
3805a2c675cSTim Small module_init(i82443bxgx_edacmc_init);
3815a2c675cSTim Small module_exit(i82443bxgx_edacmc_exit);
3825a2c675cSTim Small 
3835a2c675cSTim Small MODULE_LICENSE("GPL");
3845a2c675cSTim Small MODULE_AUTHOR("Tim Small <tim@buttersideup.com> - WPAD");
3855a2c675cSTim Small MODULE_DESCRIPTION("EDAC MC support for Intel 82443BX/GX memory controllers");
386