1fcaf780bSMauro Carvalho Chehab /* 2fcaf780bSMauro Carvalho Chehab * Intel 7300 class Memory Controllers kernel module (Clarksboro) 3fcaf780bSMauro Carvalho Chehab * 4fcaf780bSMauro Carvalho Chehab * This file may be distributed under the terms of the 5fcaf780bSMauro Carvalho Chehab * GNU General Public License version 2 only. 6fcaf780bSMauro Carvalho Chehab * 7fcaf780bSMauro Carvalho Chehab * Copyright (c) 2010 by: 8fcaf780bSMauro Carvalho Chehab * Mauro Carvalho Chehab <mchehab@redhat.com> 9fcaf780bSMauro Carvalho Chehab * 10fcaf780bSMauro Carvalho Chehab * Red Hat Inc. http://www.redhat.com 11fcaf780bSMauro Carvalho Chehab * 12fcaf780bSMauro Carvalho Chehab * Intel 7300 Chipset Memory Controller Hub (MCH) - Datasheet 13fcaf780bSMauro Carvalho Chehab * http://www.intel.com/Assets/PDF/datasheet/318082.pdf 14fcaf780bSMauro Carvalho Chehab * 15fcaf780bSMauro Carvalho Chehab * TODO: The chipset allow checking for PCI Express errors also. Currently, 16fcaf780bSMauro Carvalho Chehab * the driver covers only memory error errors 17fcaf780bSMauro Carvalho Chehab * 18fcaf780bSMauro Carvalho Chehab * This driver uses "csrows" EDAC attribute to represent DIMM slot# 19fcaf780bSMauro Carvalho Chehab */ 20fcaf780bSMauro Carvalho Chehab 21fcaf780bSMauro Carvalho Chehab #include <linux/module.h> 22fcaf780bSMauro Carvalho Chehab #include <linux/init.h> 23fcaf780bSMauro Carvalho Chehab #include <linux/pci.h> 24fcaf780bSMauro Carvalho Chehab #include <linux/pci_ids.h> 25fcaf780bSMauro Carvalho Chehab #include <linux/slab.h> 26fcaf780bSMauro Carvalho Chehab #include <linux/edac.h> 27fcaf780bSMauro Carvalho Chehab #include <linux/mmzone.h> 28fcaf780bSMauro Carvalho Chehab 29fcaf780bSMauro Carvalho Chehab #include "edac_core.h" 30fcaf780bSMauro Carvalho Chehab 31fcaf780bSMauro Carvalho Chehab /* 32fcaf780bSMauro Carvalho Chehab * Alter this version for the I7300 module when modifications are made 33fcaf780bSMauro Carvalho Chehab */ 34152ba394SMichal Marek #define I7300_REVISION " Ver: 1.0.0" 35fcaf780bSMauro Carvalho Chehab 36fcaf780bSMauro Carvalho Chehab #define EDAC_MOD_STR "i7300_edac" 37fcaf780bSMauro Carvalho Chehab 38fcaf780bSMauro Carvalho Chehab #define i7300_printk(level, fmt, arg...) \ 39fcaf780bSMauro Carvalho Chehab edac_printk(level, "i7300", fmt, ##arg) 40fcaf780bSMauro Carvalho Chehab 41fcaf780bSMauro Carvalho Chehab #define i7300_mc_printk(mci, level, fmt, arg...) \ 42fcaf780bSMauro Carvalho Chehab edac_mc_chipset_printk(mci, level, "i7300", fmt, ##arg) 43fcaf780bSMauro Carvalho Chehab 44b4552aceSMauro Carvalho Chehab /*********************************************** 45b4552aceSMauro Carvalho Chehab * i7300 Limit constants Structs and static vars 46b4552aceSMauro Carvalho Chehab ***********************************************/ 47b4552aceSMauro Carvalho Chehab 48fcaf780bSMauro Carvalho Chehab /* 49fcaf780bSMauro Carvalho Chehab * Memory topology is organized as: 50fcaf780bSMauro Carvalho Chehab * Branch 0 - 2 channels: channels 0 and 1 (FDB0 PCI dev 21.0) 51fcaf780bSMauro Carvalho Chehab * Branch 1 - 2 channels: channels 2 and 3 (FDB1 PCI dev 22.0) 52fcaf780bSMauro Carvalho Chehab * Each channel can have to 8 DIMM sets (called as SLOTS) 53fcaf780bSMauro Carvalho Chehab * Slots should generally be filled in pairs 54fcaf780bSMauro Carvalho Chehab * Except on Single Channel mode of operation 55fcaf780bSMauro Carvalho Chehab * just slot 0/channel0 filled on this mode 56fcaf780bSMauro Carvalho Chehab * On normal operation mode, the two channels on a branch should be 57c3af2eafSMauro Carvalho Chehab * filled together for the same SLOT# 58fcaf780bSMauro Carvalho Chehab * When in mirrored mode, Branch 1 replicate memory at Branch 0, so, the four 59fcaf780bSMauro Carvalho Chehab * channels on both branches should be filled 60fcaf780bSMauro Carvalho Chehab */ 61fcaf780bSMauro Carvalho Chehab 62fcaf780bSMauro Carvalho Chehab /* Limits for i7300 */ 63fcaf780bSMauro Carvalho Chehab #define MAX_SLOTS 8 64fcaf780bSMauro Carvalho Chehab #define MAX_BRANCHES 2 65fcaf780bSMauro Carvalho Chehab #define MAX_CH_PER_BRANCH 2 66fcaf780bSMauro Carvalho Chehab #define MAX_CHANNELS (MAX_CH_PER_BRANCH * MAX_BRANCHES) 67fcaf780bSMauro Carvalho Chehab #define MAX_MIR 3 68fcaf780bSMauro Carvalho Chehab 69fcaf780bSMauro Carvalho Chehab #define to_channel(ch, branch) ((((branch)) << 1) | (ch)) 70fcaf780bSMauro Carvalho Chehab 71fcaf780bSMauro Carvalho Chehab #define to_csrow(slot, ch, branch) \ 72fcaf780bSMauro Carvalho Chehab (to_channel(ch, branch) | ((slot) << 2)) 73fcaf780bSMauro Carvalho Chehab 74b4552aceSMauro Carvalho Chehab /* Device name and register DID (Device ID) */ 75b4552aceSMauro Carvalho Chehab struct i7300_dev_info { 76b4552aceSMauro Carvalho Chehab const char *ctl_name; /* name for this device */ 77b4552aceSMauro Carvalho Chehab u16 fsb_mapping_errors; /* DID for the branchmap,control */ 78b4552aceSMauro Carvalho Chehab }; 79fcaf780bSMauro Carvalho Chehab 80b4552aceSMauro Carvalho Chehab /* Table of devices attributes supported by this driver */ 81b4552aceSMauro Carvalho Chehab static const struct i7300_dev_info i7300_devs[] = { 82b4552aceSMauro Carvalho Chehab { 83b4552aceSMauro Carvalho Chehab .ctl_name = "I7300", 84b4552aceSMauro Carvalho Chehab .fsb_mapping_errors = PCI_DEVICE_ID_INTEL_I7300_MCH_ERR, 85b4552aceSMauro Carvalho Chehab }, 86b4552aceSMauro Carvalho Chehab }; 87b4552aceSMauro Carvalho Chehab 88b4552aceSMauro Carvalho Chehab struct i7300_dimm_info { 89b4552aceSMauro Carvalho Chehab int megabytes; /* size, 0 means not present */ 90b4552aceSMauro Carvalho Chehab }; 91b4552aceSMauro Carvalho Chehab 92b4552aceSMauro Carvalho Chehab /* driver private data structure */ 93b4552aceSMauro Carvalho Chehab struct i7300_pvt { 94b4552aceSMauro Carvalho Chehab struct pci_dev *pci_dev_16_0_fsb_ctlr; /* 16.0 */ 95b4552aceSMauro Carvalho Chehab struct pci_dev *pci_dev_16_1_fsb_addr_map; /* 16.1 */ 96b4552aceSMauro Carvalho Chehab struct pci_dev *pci_dev_16_2_fsb_err_regs; /* 16.2 */ 97b4552aceSMauro Carvalho Chehab struct pci_dev *pci_dev_2x_0_fbd_branch[MAX_BRANCHES]; /* 21.0 and 22.0 */ 98b4552aceSMauro Carvalho Chehab 99b4552aceSMauro Carvalho Chehab u16 tolm; /* top of low memory */ 100b4552aceSMauro Carvalho Chehab u64 ambase; /* AMB BAR */ 101b4552aceSMauro Carvalho Chehab 102b4552aceSMauro Carvalho Chehab u32 mc_settings; /* Report several settings */ 103b4552aceSMauro Carvalho Chehab u32 mc_settings_a; 104b4552aceSMauro Carvalho Chehab 105b4552aceSMauro Carvalho Chehab u16 mir[MAX_MIR]; /* Memory Interleave Reg*/ 106b4552aceSMauro Carvalho Chehab 107b4552aceSMauro Carvalho Chehab u16 mtr[MAX_SLOTS][MAX_BRANCHES]; /* Memory Technlogy Reg */ 108b4552aceSMauro Carvalho Chehab u16 ambpresent[MAX_CHANNELS]; /* AMB present regs */ 109b4552aceSMauro Carvalho Chehab 110b4552aceSMauro Carvalho Chehab /* DIMM information matrix, allocating architecture maximums */ 111b4552aceSMauro Carvalho Chehab struct i7300_dimm_info dimm_info[MAX_SLOTS][MAX_CHANNELS]; 112b4552aceSMauro Carvalho Chehab 113b4552aceSMauro Carvalho Chehab /* Temporary buffer for use when preparing error messages */ 114b4552aceSMauro Carvalho Chehab char *tmp_prt_buffer; 115b4552aceSMauro Carvalho Chehab }; 116b4552aceSMauro Carvalho Chehab 117b4552aceSMauro Carvalho Chehab /* FIXME: Why do we need to have this static? */ 118b4552aceSMauro Carvalho Chehab static struct edac_pci_ctl_info *i7300_pci; 119b4552aceSMauro Carvalho Chehab 120b4552aceSMauro Carvalho Chehab /*************************************************** 121b4552aceSMauro Carvalho Chehab * i7300 Register definitions for memory enumeration 122b4552aceSMauro Carvalho Chehab ***************************************************/ 123b4552aceSMauro Carvalho Chehab 124b4552aceSMauro Carvalho Chehab /* 125c3af2eafSMauro Carvalho Chehab * Device 16, 126c3af2eafSMauro Carvalho Chehab * Function 0: System Address (not documented) 127c3af2eafSMauro Carvalho Chehab * Function 1: Memory Branch Map, Control, Errors Register 128c3af2eafSMauro Carvalho Chehab */ 129c3af2eafSMauro Carvalho Chehab 130fcaf780bSMauro Carvalho Chehab /* OFFSETS for Function 0 */ 131fcaf780bSMauro Carvalho Chehab #define AMBASE 0x48 /* AMB Mem Mapped Reg Region Base */ 132fcaf780bSMauro Carvalho Chehab #define MAXCH 0x56 /* Max Channel Number */ 133fcaf780bSMauro Carvalho Chehab #define MAXDIMMPERCH 0x57 /* Max DIMM PER Channel Number */ 134fcaf780bSMauro Carvalho Chehab 135fcaf780bSMauro Carvalho Chehab /* OFFSETS for Function 1 */ 136af3d8831SMauro Carvalho Chehab #define MC_SETTINGS 0x40 137d7de2bdbSMauro Carvalho Chehab #define IS_MIRRORED(mc) ((mc) & (1 << 16)) 138d7de2bdbSMauro Carvalho Chehab #define IS_ECC_ENABLED(mc) ((mc) & (1 << 5)) 139d7de2bdbSMauro Carvalho Chehab #define IS_RETRY_ENABLED(mc) ((mc) & (1 << 31)) 140d7de2bdbSMauro Carvalho Chehab #define IS_SCRBALGO_ENHANCED(mc) ((mc) & (1 << 8)) 141d7de2bdbSMauro Carvalho Chehab 142bb81a216SMauro Carvalho Chehab #define MC_SETTINGS_A 0x58 143bb81a216SMauro Carvalho Chehab #define IS_SINGLE_MODE(mca) ((mca) & (1 << 14)) 144d7de2bdbSMauro Carvalho Chehab 145fcaf780bSMauro Carvalho Chehab #define TOLM 0x6C 146fcaf780bSMauro Carvalho Chehab 147fcaf780bSMauro Carvalho Chehab #define MIR0 0x80 148fcaf780bSMauro Carvalho Chehab #define MIR1 0x84 149fcaf780bSMauro Carvalho Chehab #define MIR2 0x88 150fcaf780bSMauro Carvalho Chehab 151fcaf780bSMauro Carvalho Chehab /* 152fcaf780bSMauro Carvalho Chehab * Note: Other Intel EDAC drivers use AMBPRESENT to identify if the available 153fcaf780bSMauro Carvalho Chehab * memory. From datasheet item 7.3.1 (FB-DIMM technology & organization), it 154fcaf780bSMauro Carvalho Chehab * seems that we cannot use this information directly for the same usage. 155fcaf780bSMauro Carvalho Chehab * Each memory slot may have up to 2 AMB interfaces, one for income and another 156fcaf780bSMauro Carvalho Chehab * for outcome interface to the next slot. 157fcaf780bSMauro Carvalho Chehab * For now, the driver just stores the AMB present registers, but rely only at 158fcaf780bSMauro Carvalho Chehab * the MTR info to detect memory. 159fcaf780bSMauro Carvalho Chehab * Datasheet is also not clear about how to map each AMBPRESENT registers to 160fcaf780bSMauro Carvalho Chehab * one of the 4 available channels. 161fcaf780bSMauro Carvalho Chehab */ 162fcaf780bSMauro Carvalho Chehab #define AMBPRESENT_0 0x64 163fcaf780bSMauro Carvalho Chehab #define AMBPRESENT_1 0x66 164fcaf780bSMauro Carvalho Chehab 16542b16b3fSJesper Juhl static const u16 mtr_regs[MAX_SLOTS] = { 166fcaf780bSMauro Carvalho Chehab 0x80, 0x84, 0x88, 0x8c, 167fcaf780bSMauro Carvalho Chehab 0x82, 0x86, 0x8a, 0x8e 168fcaf780bSMauro Carvalho Chehab }; 169fcaf780bSMauro Carvalho Chehab 170b4552aceSMauro Carvalho Chehab /* 171b4552aceSMauro Carvalho Chehab * Defines to extract the vaious fields from the 172fcaf780bSMauro Carvalho Chehab * MTRx - Memory Technology Registers 173fcaf780bSMauro Carvalho Chehab */ 174fcaf780bSMauro Carvalho Chehab #define MTR_DIMMS_PRESENT(mtr) ((mtr) & (1 << 8)) 175fcaf780bSMauro Carvalho Chehab #define MTR_DIMMS_ETHROTTLE(mtr) ((mtr) & (1 << 7)) 176fcaf780bSMauro Carvalho Chehab #define MTR_DRAM_WIDTH(mtr) (((mtr) & (1 << 6)) ? 8 : 4) 177fcaf780bSMauro Carvalho Chehab #define MTR_DRAM_BANKS(mtr) (((mtr) & (1 << 5)) ? 8 : 4) 178fcaf780bSMauro Carvalho Chehab #define MTR_DIMM_RANKS(mtr) (((mtr) & (1 << 4)) ? 1 : 0) 179fcaf780bSMauro Carvalho Chehab #define MTR_DIMM_ROWS(mtr) (((mtr) >> 2) & 0x3) 180fcaf780bSMauro Carvalho Chehab #define MTR_DRAM_BANKS_ADDR_BITS 2 181fcaf780bSMauro Carvalho Chehab #define MTR_DIMM_ROWS_ADDR_BITS(mtr) (MTR_DIMM_ROWS(mtr) + 13) 182fcaf780bSMauro Carvalho Chehab #define MTR_DIMM_COLS(mtr) ((mtr) & 0x3) 183fcaf780bSMauro Carvalho Chehab #define MTR_DIMM_COLS_ADDR_BITS(mtr) (MTR_DIMM_COLS(mtr) + 10) 184fcaf780bSMauro Carvalho Chehab 185c3af2eafSMauro Carvalho Chehab /************************************************ 186c3af2eafSMauro Carvalho Chehab * i7300 Register definitions for error detection 187c3af2eafSMauro Carvalho Chehab ************************************************/ 18857021918SMauro Carvalho Chehab 18957021918SMauro Carvalho Chehab /* 19057021918SMauro Carvalho Chehab * Device 16.1: FBD Error Registers 19157021918SMauro Carvalho Chehab */ 19257021918SMauro Carvalho Chehab #define FERR_FAT_FBD 0x98 19357021918SMauro Carvalho Chehab static const char *ferr_fat_fbd_name[] = { 19457021918SMauro Carvalho Chehab [22] = "Non-Redundant Fast Reset Timeout", 19557021918SMauro Carvalho Chehab [2] = ">Tmid Thermal event with intelligent throttling disabled", 19657021918SMauro Carvalho Chehab [1] = "Memory or FBD configuration CRC read error", 19757021918SMauro Carvalho Chehab [0] = "Memory Write error on non-redundant retry or " 19857021918SMauro Carvalho Chehab "FBD configuration Write error on retry", 19957021918SMauro Carvalho Chehab }; 2007e06b7a3SJean Delvare #define GET_FBD_FAT_IDX(fbderr) (((fbderr) >> 28) & 3) 2017e06b7a3SJean Delvare #define FERR_FAT_FBD_ERR_MASK ((1 << 0) | (1 << 1) | (1 << 2) | (1 << 22)) 20257021918SMauro Carvalho Chehab 20357021918SMauro Carvalho Chehab #define FERR_NF_FBD 0xa0 20457021918SMauro Carvalho Chehab static const char *ferr_nf_fbd_name[] = { 20557021918SMauro Carvalho Chehab [24] = "DIMM-Spare Copy Completed", 20657021918SMauro Carvalho Chehab [23] = "DIMM-Spare Copy Initiated", 20757021918SMauro Carvalho Chehab [22] = "Redundant Fast Reset Timeout", 20857021918SMauro Carvalho Chehab [21] = "Memory Write error on redundant retry", 20957021918SMauro Carvalho Chehab [18] = "SPD protocol Error", 21057021918SMauro Carvalho Chehab [17] = "FBD Northbound parity error on FBD Sync Status", 21157021918SMauro Carvalho Chehab [16] = "Correctable Patrol Data ECC", 21257021918SMauro Carvalho Chehab [15] = "Correctable Resilver- or Spare-Copy Data ECC", 21357021918SMauro Carvalho Chehab [14] = "Correctable Mirrored Demand Data ECC", 21457021918SMauro Carvalho Chehab [13] = "Correctable Non-Mirrored Demand Data ECC", 21557021918SMauro Carvalho Chehab [11] = "Memory or FBD configuration CRC read error", 21657021918SMauro Carvalho Chehab [10] = "FBD Configuration Write error on first attempt", 21757021918SMauro Carvalho Chehab [9] = "Memory Write error on first attempt", 21857021918SMauro Carvalho Chehab [8] = "Non-Aliased Uncorrectable Patrol Data ECC", 21957021918SMauro Carvalho Chehab [7] = "Non-Aliased Uncorrectable Resilver- or Spare-Copy Data ECC", 22057021918SMauro Carvalho Chehab [6] = "Non-Aliased Uncorrectable Mirrored Demand Data ECC", 22157021918SMauro Carvalho Chehab [5] = "Non-Aliased Uncorrectable Non-Mirrored Demand Data ECC", 22257021918SMauro Carvalho Chehab [4] = "Aliased Uncorrectable Patrol Data ECC", 22357021918SMauro Carvalho Chehab [3] = "Aliased Uncorrectable Resilver- or Spare-Copy Data ECC", 22457021918SMauro Carvalho Chehab [2] = "Aliased Uncorrectable Mirrored Demand Data ECC", 22557021918SMauro Carvalho Chehab [1] = "Aliased Uncorrectable Non-Mirrored Demand Data ECC", 22657021918SMauro Carvalho Chehab [0] = "Uncorrectable Data ECC on Replay", 22757021918SMauro Carvalho Chehab }; 2287e06b7a3SJean Delvare #define GET_FBD_NF_IDX(fbderr) (((fbderr) >> 28) & 3) 22957021918SMauro Carvalho Chehab #define FERR_NF_FBD_ERR_MASK ((1 << 24) | (1 << 23) | (1 << 22) | (1 << 21) |\ 23057021918SMauro Carvalho Chehab (1 << 18) | (1 << 17) | (1 << 16) | (1 << 15) |\ 23157021918SMauro Carvalho Chehab (1 << 14) | (1 << 13) | (1 << 11) | (1 << 10) |\ 23257021918SMauro Carvalho Chehab (1 << 9) | (1 << 8) | (1 << 7) | (1 << 6) |\ 23357021918SMauro Carvalho Chehab (1 << 5) | (1 << 4) | (1 << 3) | (1 << 2) |\ 23457021918SMauro Carvalho Chehab (1 << 1) | (1 << 0)) 23557021918SMauro Carvalho Chehab 23657021918SMauro Carvalho Chehab #define EMASK_FBD 0xa8 23757021918SMauro Carvalho Chehab #define EMASK_FBD_ERR_MASK ((1 << 27) | (1 << 26) | (1 << 25) | (1 << 24) |\ 23857021918SMauro Carvalho Chehab (1 << 22) | (1 << 21) | (1 << 20) | (1 << 19) |\ 23957021918SMauro Carvalho Chehab (1 << 18) | (1 << 17) | (1 << 16) | (1 << 14) |\ 24057021918SMauro Carvalho Chehab (1 << 13) | (1 << 12) | (1 << 11) | (1 << 10) |\ 24157021918SMauro Carvalho Chehab (1 << 9) | (1 << 8) | (1 << 7) | (1 << 6) |\ 24257021918SMauro Carvalho Chehab (1 << 5) | (1 << 4) | (1 << 3) | (1 << 2) |\ 24357021918SMauro Carvalho Chehab (1 << 1) | (1 << 0)) 24457021918SMauro Carvalho Chehab 245c3af2eafSMauro Carvalho Chehab /* 246c3af2eafSMauro Carvalho Chehab * Device 16.2: Global Error Registers 247c3af2eafSMauro Carvalho Chehab */ 248c3af2eafSMauro Carvalho Chehab 2495de6e07eSMauro Carvalho Chehab #define FERR_GLOBAL_HI 0x48 2505de6e07eSMauro Carvalho Chehab static const char *ferr_global_hi_name[] = { 2515de6e07eSMauro Carvalho Chehab [3] = "FSB 3 Fatal Error", 2525de6e07eSMauro Carvalho Chehab [2] = "FSB 2 Fatal Error", 2535de6e07eSMauro Carvalho Chehab [1] = "FSB 1 Fatal Error", 2545de6e07eSMauro Carvalho Chehab [0] = "FSB 0 Fatal Error", 2555de6e07eSMauro Carvalho Chehab }; 2565de6e07eSMauro Carvalho Chehab #define ferr_global_hi_is_fatal(errno) 1 2575de6e07eSMauro Carvalho Chehab 258c3af2eafSMauro Carvalho Chehab #define FERR_GLOBAL_LO 0x40 2595de6e07eSMauro Carvalho Chehab static const char *ferr_global_lo_name[] = { 260c3af2eafSMauro Carvalho Chehab [31] = "Internal MCH Fatal Error", 261c3af2eafSMauro Carvalho Chehab [30] = "Intel QuickData Technology Device Fatal Error", 262c3af2eafSMauro Carvalho Chehab [29] = "FSB1 Fatal Error", 263c3af2eafSMauro Carvalho Chehab [28] = "FSB0 Fatal Error", 264c3af2eafSMauro Carvalho Chehab [27] = "FBD Channel 3 Fatal Error", 265c3af2eafSMauro Carvalho Chehab [26] = "FBD Channel 2 Fatal Error", 266c3af2eafSMauro Carvalho Chehab [25] = "FBD Channel 1 Fatal Error", 267c3af2eafSMauro Carvalho Chehab [24] = "FBD Channel 0 Fatal Error", 268c3af2eafSMauro Carvalho Chehab [23] = "PCI Express Device 7Fatal Error", 269c3af2eafSMauro Carvalho Chehab [22] = "PCI Express Device 6 Fatal Error", 270c3af2eafSMauro Carvalho Chehab [21] = "PCI Express Device 5 Fatal Error", 271c3af2eafSMauro Carvalho Chehab [20] = "PCI Express Device 4 Fatal Error", 272c3af2eafSMauro Carvalho Chehab [19] = "PCI Express Device 3 Fatal Error", 273c3af2eafSMauro Carvalho Chehab [18] = "PCI Express Device 2 Fatal Error", 274c3af2eafSMauro Carvalho Chehab [17] = "PCI Express Device 1 Fatal Error", 275c3af2eafSMauro Carvalho Chehab [16] = "ESI Fatal Error", 276c3af2eafSMauro Carvalho Chehab [15] = "Internal MCH Non-Fatal Error", 277c3af2eafSMauro Carvalho Chehab [14] = "Intel QuickData Technology Device Non Fatal Error", 278c3af2eafSMauro Carvalho Chehab [13] = "FSB1 Non-Fatal Error", 279c3af2eafSMauro Carvalho Chehab [12] = "FSB 0 Non-Fatal Error", 280c3af2eafSMauro Carvalho Chehab [11] = "FBD Channel 3 Non-Fatal Error", 281c3af2eafSMauro Carvalho Chehab [10] = "FBD Channel 2 Non-Fatal Error", 282c3af2eafSMauro Carvalho Chehab [9] = "FBD Channel 1 Non-Fatal Error", 283c3af2eafSMauro Carvalho Chehab [8] = "FBD Channel 0 Non-Fatal Error", 284c3af2eafSMauro Carvalho Chehab [7] = "PCI Express Device 7 Non-Fatal Error", 285c3af2eafSMauro Carvalho Chehab [6] = "PCI Express Device 6 Non-Fatal Error", 286c3af2eafSMauro Carvalho Chehab [5] = "PCI Express Device 5 Non-Fatal Error", 287c3af2eafSMauro Carvalho Chehab [4] = "PCI Express Device 4 Non-Fatal Error", 288c3af2eafSMauro Carvalho Chehab [3] = "PCI Express Device 3 Non-Fatal Error", 289c3af2eafSMauro Carvalho Chehab [2] = "PCI Express Device 2 Non-Fatal Error", 290c3af2eafSMauro Carvalho Chehab [1] = "PCI Express Device 1 Non-Fatal Error", 291c3af2eafSMauro Carvalho Chehab [0] = "ESI Non-Fatal Error", 292c3af2eafSMauro Carvalho Chehab }; 2935de6e07eSMauro Carvalho Chehab #define ferr_global_lo_is_fatal(errno) ((errno < 16) ? 0 : 1) 294fcaf780bSMauro Carvalho Chehab 2958199d8ccSMauro Carvalho Chehab #define NRECMEMA 0xbe 2968199d8ccSMauro Carvalho Chehab #define NRECMEMA_BANK(v) (((v) >> 12) & 7) 2978199d8ccSMauro Carvalho Chehab #define NRECMEMA_RANK(v) (((v) >> 8) & 15) 2988199d8ccSMauro Carvalho Chehab 2998199d8ccSMauro Carvalho Chehab #define NRECMEMB 0xc0 3008199d8ccSMauro Carvalho Chehab #define NRECMEMB_IS_WR(v) ((v) & (1 << 31)) 3018199d8ccSMauro Carvalho Chehab #define NRECMEMB_CAS(v) (((v) >> 16) & 0x1fff) 3028199d8ccSMauro Carvalho Chehab #define NRECMEMB_RAS(v) ((v) & 0xffff) 3038199d8ccSMauro Carvalho Chehab 30432f94726SMauro Carvalho Chehab #define REDMEMA 0xdc 30532f94726SMauro Carvalho Chehab 30637b69cf9SMauro Carvalho Chehab #define REDMEMB 0x7c 30737b69cf9SMauro Carvalho Chehab #define IS_SECOND_CH(v) ((v) * (1 << 17)) 30837b69cf9SMauro Carvalho Chehab 30932f94726SMauro Carvalho Chehab #define RECMEMA 0xe0 31032f94726SMauro Carvalho Chehab #define RECMEMA_BANK(v) (((v) >> 12) & 7) 31132f94726SMauro Carvalho Chehab #define RECMEMA_RANK(v) (((v) >> 8) & 15) 31232f94726SMauro Carvalho Chehab 31332f94726SMauro Carvalho Chehab #define RECMEMB 0xe4 31432f94726SMauro Carvalho Chehab #define RECMEMB_IS_WR(v) ((v) & (1 << 31)) 31532f94726SMauro Carvalho Chehab #define RECMEMB_CAS(v) (((v) >> 16) & 0x1fff) 31632f94726SMauro Carvalho Chehab #define RECMEMB_RAS(v) ((v) & 0xffff) 31732f94726SMauro Carvalho Chehab 3185de6e07eSMauro Carvalho Chehab /******************************************** 3195de6e07eSMauro Carvalho Chehab * i7300 Functions related to error detection 3205de6e07eSMauro Carvalho Chehab ********************************************/ 321fcaf780bSMauro Carvalho Chehab 322d091a6ebSMauro Carvalho Chehab /** 323d091a6ebSMauro Carvalho Chehab * get_err_from_table() - Gets the error message from a table 324d091a6ebSMauro Carvalho Chehab * @table: table name (array of char *) 325d091a6ebSMauro Carvalho Chehab * @size: number of elements at the table 326d091a6ebSMauro Carvalho Chehab * @pos: position of the element to be returned 327d091a6ebSMauro Carvalho Chehab * 328d091a6ebSMauro Carvalho Chehab * This is a small routine that gets the pos-th element of a table. If the 329d091a6ebSMauro Carvalho Chehab * element doesn't exist (or it is empty), it returns "reserved". 330d091a6ebSMauro Carvalho Chehab * Instead of calling it directly, the better is to call via the macro 331d091a6ebSMauro Carvalho Chehab * GET_ERR_FROM_TABLE(), that automatically checks the table size via 332d091a6ebSMauro Carvalho Chehab * ARRAY_SIZE() macro 333d091a6ebSMauro Carvalho Chehab */ 334d091a6ebSMauro Carvalho Chehab static const char *get_err_from_table(const char *table[], int size, int pos) 335fcaf780bSMauro Carvalho Chehab { 336d091a6ebSMauro Carvalho Chehab if (unlikely(pos >= size)) 337d091a6ebSMauro Carvalho Chehab return "Reserved"; 338d091a6ebSMauro Carvalho Chehab 339d091a6ebSMauro Carvalho Chehab if (unlikely(!table[pos])) 3405de6e07eSMauro Carvalho Chehab return "Reserved"; 3415de6e07eSMauro Carvalho Chehab 3425de6e07eSMauro Carvalho Chehab return table[pos]; 343fcaf780bSMauro Carvalho Chehab } 3445de6e07eSMauro Carvalho Chehab 3455de6e07eSMauro Carvalho Chehab #define GET_ERR_FROM_TABLE(table, pos) \ 3465de6e07eSMauro Carvalho Chehab get_err_from_table(table, ARRAY_SIZE(table), pos) 347fcaf780bSMauro Carvalho Chehab 348d091a6ebSMauro Carvalho Chehab /** 349d091a6ebSMauro Carvalho Chehab * i7300_process_error_global() - Retrieve the hardware error information from 350d091a6ebSMauro Carvalho Chehab * the hardware global error registers and 351d091a6ebSMauro Carvalho Chehab * sends it to dmesg 352d091a6ebSMauro Carvalho Chehab * @mci: struct mem_ctl_info pointer 3535de6e07eSMauro Carvalho Chehab */ 354f4277422SMauro Carvalho Chehab static void i7300_process_error_global(struct mem_ctl_info *mci) 3555de6e07eSMauro Carvalho Chehab { 356fcaf780bSMauro Carvalho Chehab struct i7300_pvt *pvt; 3575f032119SMauro Carvalho Chehab u32 errnum, error_reg; 3585de6e07eSMauro Carvalho Chehab unsigned long errors; 3595de6e07eSMauro Carvalho Chehab const char *specific; 3605de6e07eSMauro Carvalho Chehab bool is_fatal; 361fcaf780bSMauro Carvalho Chehab 362fcaf780bSMauro Carvalho Chehab pvt = mci->pvt_info; 363fcaf780bSMauro Carvalho Chehab 364fcaf780bSMauro Carvalho Chehab /* read in the 1st FATAL error register */ 3655de6e07eSMauro Carvalho Chehab pci_read_config_dword(pvt->pci_dev_16_2_fsb_err_regs, 3665f032119SMauro Carvalho Chehab FERR_GLOBAL_HI, &error_reg); 3675f032119SMauro Carvalho Chehab if (unlikely(error_reg)) { 3685f032119SMauro Carvalho Chehab errors = error_reg; 3695de6e07eSMauro Carvalho Chehab errnum = find_first_bit(&errors, 3705de6e07eSMauro Carvalho Chehab ARRAY_SIZE(ferr_global_hi_name)); 3715de6e07eSMauro Carvalho Chehab specific = GET_ERR_FROM_TABLE(ferr_global_hi_name, errnum); 3725de6e07eSMauro Carvalho Chehab is_fatal = ferr_global_hi_is_fatal(errnum); 37386002324SMauro Carvalho Chehab 37486002324SMauro Carvalho Chehab /* Clear the error bit */ 37586002324SMauro Carvalho Chehab pci_write_config_dword(pvt->pci_dev_16_2_fsb_err_regs, 3765f032119SMauro Carvalho Chehab FERR_GLOBAL_HI, error_reg); 37786002324SMauro Carvalho Chehab 3785de6e07eSMauro Carvalho Chehab goto error_global; 379fcaf780bSMauro Carvalho Chehab } 380fcaf780bSMauro Carvalho Chehab 3815de6e07eSMauro Carvalho Chehab pci_read_config_dword(pvt->pci_dev_16_2_fsb_err_regs, 3825f032119SMauro Carvalho Chehab FERR_GLOBAL_LO, &error_reg); 3835f032119SMauro Carvalho Chehab if (unlikely(error_reg)) { 3845f032119SMauro Carvalho Chehab errors = error_reg; 3855de6e07eSMauro Carvalho Chehab errnum = find_first_bit(&errors, 3865de6e07eSMauro Carvalho Chehab ARRAY_SIZE(ferr_global_lo_name)); 3875de6e07eSMauro Carvalho Chehab specific = GET_ERR_FROM_TABLE(ferr_global_lo_name, errnum); 3885de6e07eSMauro Carvalho Chehab is_fatal = ferr_global_lo_is_fatal(errnum); 38986002324SMauro Carvalho Chehab 39086002324SMauro Carvalho Chehab /* Clear the error bit */ 39186002324SMauro Carvalho Chehab pci_write_config_dword(pvt->pci_dev_16_2_fsb_err_regs, 3925f032119SMauro Carvalho Chehab FERR_GLOBAL_LO, error_reg); 39386002324SMauro Carvalho Chehab 3945de6e07eSMauro Carvalho Chehab goto error_global; 395fcaf780bSMauro Carvalho Chehab } 396fcaf780bSMauro Carvalho Chehab return; 397fcaf780bSMauro Carvalho Chehab 3985de6e07eSMauro Carvalho Chehab error_global: 3995de6e07eSMauro Carvalho Chehab i7300_mc_printk(mci, KERN_EMERG, "%s misc error: %s\n", 4005de6e07eSMauro Carvalho Chehab is_fatal ? "Fatal" : "NOT fatal", specific); 401fcaf780bSMauro Carvalho Chehab } 402fcaf780bSMauro Carvalho Chehab 403d091a6ebSMauro Carvalho Chehab /** 404d091a6ebSMauro Carvalho Chehab * i7300_process_fbd_error() - Retrieve the hardware error information from 405d091a6ebSMauro Carvalho Chehab * the FBD error registers and sends it via 406d091a6ebSMauro Carvalho Chehab * EDAC error API calls 407d091a6ebSMauro Carvalho Chehab * @mci: struct mem_ctl_info pointer 40857021918SMauro Carvalho Chehab */ 409f4277422SMauro Carvalho Chehab static void i7300_process_fbd_error(struct mem_ctl_info *mci) 41057021918SMauro Carvalho Chehab { 41157021918SMauro Carvalho Chehab struct i7300_pvt *pvt; 4125f032119SMauro Carvalho Chehab u32 errnum, value, error_reg; 4138199d8ccSMauro Carvalho Chehab u16 val16; 41437b69cf9SMauro Carvalho Chehab unsigned branch, channel, bank, rank, cas, ras; 41532f94726SMauro Carvalho Chehab u32 syndrome; 41632f94726SMauro Carvalho Chehab 41757021918SMauro Carvalho Chehab unsigned long errors; 41857021918SMauro Carvalho Chehab const char *specific; 41932f94726SMauro Carvalho Chehab bool is_wr; 42057021918SMauro Carvalho Chehab 42157021918SMauro Carvalho Chehab pvt = mci->pvt_info; 42257021918SMauro Carvalho Chehab 42357021918SMauro Carvalho Chehab /* read in the 1st FATAL error register */ 42457021918SMauro Carvalho Chehab pci_read_config_dword(pvt->pci_dev_16_1_fsb_addr_map, 4255f032119SMauro Carvalho Chehab FERR_FAT_FBD, &error_reg); 4265f032119SMauro Carvalho Chehab if (unlikely(error_reg & FERR_FAT_FBD_ERR_MASK)) { 4275f032119SMauro Carvalho Chehab errors = error_reg & FERR_FAT_FBD_ERR_MASK ; 42857021918SMauro Carvalho Chehab errnum = find_first_bit(&errors, 42957021918SMauro Carvalho Chehab ARRAY_SIZE(ferr_fat_fbd_name)); 43057021918SMauro Carvalho Chehab specific = GET_ERR_FROM_TABLE(ferr_fat_fbd_name, errnum); 4315f032119SMauro Carvalho Chehab branch = (GET_FBD_FAT_IDX(error_reg) == 2) ? 1 : 0; 43257021918SMauro Carvalho Chehab 4338199d8ccSMauro Carvalho Chehab pci_read_config_word(pvt->pci_dev_16_1_fsb_addr_map, 4348199d8ccSMauro Carvalho Chehab NRECMEMA, &val16); 4358199d8ccSMauro Carvalho Chehab bank = NRECMEMA_BANK(val16); 4368199d8ccSMauro Carvalho Chehab rank = NRECMEMA_RANK(val16); 43757021918SMauro Carvalho Chehab 4388199d8ccSMauro Carvalho Chehab pci_read_config_dword(pvt->pci_dev_16_1_fsb_addr_map, 4398199d8ccSMauro Carvalho Chehab NRECMEMB, &value); 4408199d8ccSMauro Carvalho Chehab is_wr = NRECMEMB_IS_WR(value); 4418199d8ccSMauro Carvalho Chehab cas = NRECMEMB_CAS(value); 4428199d8ccSMauro Carvalho Chehab ras = NRECMEMB_RAS(value); 4438199d8ccSMauro Carvalho Chehab 4445f032119SMauro Carvalho Chehab /* Clean the error register */ 4455f032119SMauro Carvalho Chehab pci_write_config_dword(pvt->pci_dev_16_1_fsb_addr_map, 4465f032119SMauro Carvalho Chehab FERR_FAT_FBD, error_reg); 4475f032119SMauro Carvalho Chehab 4488199d8ccSMauro Carvalho Chehab snprintf(pvt->tmp_prt_buffer, PAGE_SIZE, 44970e2a837SMauro Carvalho Chehab "Bank=%d RAS=%d CAS=%d Err=0x%lx (%s))", 45070e2a837SMauro Carvalho Chehab bank, ras, cas, errors, specific); 4518199d8ccSMauro Carvalho Chehab 4529eb07a7fSMauro Carvalho Chehab edac_mc_handle_error(HW_EVENT_ERR_FATAL, mci, 1, 0, 0, 0, 45370e2a837SMauro Carvalho Chehab branch, -1, rank, 45470e2a837SMauro Carvalho Chehab is_wr ? "Write error" : "Read error", 45503f7eae8SMauro Carvalho Chehab pvt->tmp_prt_buffer); 45670e2a837SMauro Carvalho Chehab 45757021918SMauro Carvalho Chehab } 45857021918SMauro Carvalho Chehab 45957021918SMauro Carvalho Chehab /* read in the 1st NON-FATAL error register */ 46057021918SMauro Carvalho Chehab pci_read_config_dword(pvt->pci_dev_16_1_fsb_addr_map, 4615f032119SMauro Carvalho Chehab FERR_NF_FBD, &error_reg); 4625f032119SMauro Carvalho Chehab if (unlikely(error_reg & FERR_NF_FBD_ERR_MASK)) { 4635f032119SMauro Carvalho Chehab errors = error_reg & FERR_NF_FBD_ERR_MASK; 46457021918SMauro Carvalho Chehab errnum = find_first_bit(&errors, 46557021918SMauro Carvalho Chehab ARRAY_SIZE(ferr_nf_fbd_name)); 46657021918SMauro Carvalho Chehab specific = GET_ERR_FROM_TABLE(ferr_nf_fbd_name, errnum); 4677e06b7a3SJean Delvare branch = (GET_FBD_NF_IDX(error_reg) == 2) ? 1 : 0; 46857021918SMauro Carvalho Chehab 46932f94726SMauro Carvalho Chehab pci_read_config_dword(pvt->pci_dev_16_1_fsb_addr_map, 47032f94726SMauro Carvalho Chehab REDMEMA, &syndrome); 47132f94726SMauro Carvalho Chehab 47232f94726SMauro Carvalho Chehab pci_read_config_word(pvt->pci_dev_16_1_fsb_addr_map, 47332f94726SMauro Carvalho Chehab RECMEMA, &val16); 47432f94726SMauro Carvalho Chehab bank = RECMEMA_BANK(val16); 47532f94726SMauro Carvalho Chehab rank = RECMEMA_RANK(val16); 47632f94726SMauro Carvalho Chehab 47732f94726SMauro Carvalho Chehab pci_read_config_dword(pvt->pci_dev_16_1_fsb_addr_map, 47832f94726SMauro Carvalho Chehab RECMEMB, &value); 47932f94726SMauro Carvalho Chehab is_wr = RECMEMB_IS_WR(value); 48032f94726SMauro Carvalho Chehab cas = RECMEMB_CAS(value); 48132f94726SMauro Carvalho Chehab ras = RECMEMB_RAS(value); 48232f94726SMauro Carvalho Chehab 48337b69cf9SMauro Carvalho Chehab pci_read_config_dword(pvt->pci_dev_16_1_fsb_addr_map, 48437b69cf9SMauro Carvalho Chehab REDMEMB, &value); 48537b69cf9SMauro Carvalho Chehab channel = (branch << 1); 48637b69cf9SMauro Carvalho Chehab if (IS_SECOND_CH(value)) 48737b69cf9SMauro Carvalho Chehab channel++; 48837b69cf9SMauro Carvalho Chehab 4895f032119SMauro Carvalho Chehab /* Clear the error bit */ 4905f032119SMauro Carvalho Chehab pci_write_config_dword(pvt->pci_dev_16_1_fsb_addr_map, 4915f032119SMauro Carvalho Chehab FERR_NF_FBD, error_reg); 4925f032119SMauro Carvalho Chehab 49332f94726SMauro Carvalho Chehab /* Form out message */ 49432f94726SMauro Carvalho Chehab snprintf(pvt->tmp_prt_buffer, PAGE_SIZE, 49570e2a837SMauro Carvalho Chehab "DRAM-Bank=%d RAS=%d CAS=%d, Err=0x%lx (%s))", 49670e2a837SMauro Carvalho Chehab bank, ras, cas, errors, specific); 49732f94726SMauro Carvalho Chehab 4989eb07a7fSMauro Carvalho Chehab edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1, 0, 0, 49970e2a837SMauro Carvalho Chehab syndrome, 50070e2a837SMauro Carvalho Chehab branch >> 1, channel % 2, rank, 50170e2a837SMauro Carvalho Chehab is_wr ? "Write error" : "Read error", 50203f7eae8SMauro Carvalho Chehab pvt->tmp_prt_buffer); 50357021918SMauro Carvalho Chehab } 50457021918SMauro Carvalho Chehab return; 50557021918SMauro Carvalho Chehab } 50657021918SMauro Carvalho Chehab 507d091a6ebSMauro Carvalho Chehab /** 508d091a6ebSMauro Carvalho Chehab * i7300_check_error() - Calls the error checking subroutines 509d091a6ebSMauro Carvalho Chehab * @mci: struct mem_ctl_info pointer 510fcaf780bSMauro Carvalho Chehab */ 511f4277422SMauro Carvalho Chehab static void i7300_check_error(struct mem_ctl_info *mci) 5125de6e07eSMauro Carvalho Chehab { 513f4277422SMauro Carvalho Chehab i7300_process_error_global(mci); 514f4277422SMauro Carvalho Chehab i7300_process_fbd_error(mci); 5155de6e07eSMauro Carvalho Chehab }; 516fcaf780bSMauro Carvalho Chehab 517d091a6ebSMauro Carvalho Chehab /** 518d091a6ebSMauro Carvalho Chehab * i7300_clear_error() - Clears the error registers 519d091a6ebSMauro Carvalho Chehab * @mci: struct mem_ctl_info pointer 520fcaf780bSMauro Carvalho Chehab */ 521fcaf780bSMauro Carvalho Chehab static void i7300_clear_error(struct mem_ctl_info *mci) 522fcaf780bSMauro Carvalho Chehab { 523e4327605SMauro Carvalho Chehab struct i7300_pvt *pvt = mci->pvt_info; 524e4327605SMauro Carvalho Chehab u32 value; 525e4327605SMauro Carvalho Chehab /* 526e4327605SMauro Carvalho Chehab * All error values are RWC - we need to read and write 1 to the 527e4327605SMauro Carvalho Chehab * bit that we want to cleanup 528e4327605SMauro Carvalho Chehab */ 529fcaf780bSMauro Carvalho Chehab 530e4327605SMauro Carvalho Chehab /* Clear global error registers */ 531e4327605SMauro Carvalho Chehab pci_read_config_dword(pvt->pci_dev_16_2_fsb_err_regs, 532e4327605SMauro Carvalho Chehab FERR_GLOBAL_HI, &value); 533e4327605SMauro Carvalho Chehab pci_write_config_dword(pvt->pci_dev_16_2_fsb_err_regs, 534e4327605SMauro Carvalho Chehab FERR_GLOBAL_HI, value); 535e4327605SMauro Carvalho Chehab 536e4327605SMauro Carvalho Chehab pci_read_config_dword(pvt->pci_dev_16_2_fsb_err_regs, 537e4327605SMauro Carvalho Chehab FERR_GLOBAL_LO, &value); 538e4327605SMauro Carvalho Chehab pci_write_config_dword(pvt->pci_dev_16_2_fsb_err_regs, 539e4327605SMauro Carvalho Chehab FERR_GLOBAL_LO, value); 540e4327605SMauro Carvalho Chehab 541e4327605SMauro Carvalho Chehab /* Clear FBD error registers */ 542e4327605SMauro Carvalho Chehab pci_read_config_dword(pvt->pci_dev_16_1_fsb_addr_map, 543e4327605SMauro Carvalho Chehab FERR_FAT_FBD, &value); 544e4327605SMauro Carvalho Chehab pci_write_config_dword(pvt->pci_dev_16_1_fsb_addr_map, 545e4327605SMauro Carvalho Chehab FERR_FAT_FBD, value); 546e4327605SMauro Carvalho Chehab 547e4327605SMauro Carvalho Chehab pci_read_config_dword(pvt->pci_dev_16_1_fsb_addr_map, 548e4327605SMauro Carvalho Chehab FERR_NF_FBD, &value); 549e4327605SMauro Carvalho Chehab pci_write_config_dword(pvt->pci_dev_16_1_fsb_addr_map, 550e4327605SMauro Carvalho Chehab FERR_NF_FBD, value); 551fcaf780bSMauro Carvalho Chehab } 552fcaf780bSMauro Carvalho Chehab 553d091a6ebSMauro Carvalho Chehab /** 554d091a6ebSMauro Carvalho Chehab * i7300_enable_error_reporting() - Enable the memory reporting logic at the 555d091a6ebSMauro Carvalho Chehab * hardware 556d091a6ebSMauro Carvalho Chehab * @mci: struct mem_ctl_info pointer 557fcaf780bSMauro Carvalho Chehab */ 558fcaf780bSMauro Carvalho Chehab static void i7300_enable_error_reporting(struct mem_ctl_info *mci) 559fcaf780bSMauro Carvalho Chehab { 56057021918SMauro Carvalho Chehab struct i7300_pvt *pvt = mci->pvt_info; 56157021918SMauro Carvalho Chehab u32 fbd_error_mask; 56257021918SMauro Carvalho Chehab 56357021918SMauro Carvalho Chehab /* Read the FBD Error Mask Register */ 56457021918SMauro Carvalho Chehab pci_read_config_dword(pvt->pci_dev_16_1_fsb_addr_map, 56557021918SMauro Carvalho Chehab EMASK_FBD, &fbd_error_mask); 56657021918SMauro Carvalho Chehab 56757021918SMauro Carvalho Chehab /* Enable with a '0' */ 56857021918SMauro Carvalho Chehab fbd_error_mask &= ~(EMASK_FBD_ERR_MASK); 56957021918SMauro Carvalho Chehab 57057021918SMauro Carvalho Chehab pci_write_config_dword(pvt->pci_dev_16_1_fsb_addr_map, 57157021918SMauro Carvalho Chehab EMASK_FBD, fbd_error_mask); 572fcaf780bSMauro Carvalho Chehab } 5735de6e07eSMauro Carvalho Chehab 5745de6e07eSMauro Carvalho Chehab /************************************************ 5755de6e07eSMauro Carvalho Chehab * i7300 Functions related to memory enumberation 5765de6e07eSMauro Carvalho Chehab ************************************************/ 577fcaf780bSMauro Carvalho Chehab 578d091a6ebSMauro Carvalho Chehab /** 579d091a6ebSMauro Carvalho Chehab * decode_mtr() - Decodes the MTR descriptor, filling the edac structs 580d091a6ebSMauro Carvalho Chehab * @pvt: pointer to the private data struct used by i7300 driver 581d091a6ebSMauro Carvalho Chehab * @slot: DIMM slot (0 to 7) 582d091a6ebSMauro Carvalho Chehab * @ch: Channel number within the branch (0 or 1) 583d091a6ebSMauro Carvalho Chehab * @branch: Branch number (0 or 1) 584d091a6ebSMauro Carvalho Chehab * @dinfo: Pointer to DIMM info where dimm size is stored 585d091a6ebSMauro Carvalho Chehab * @p_csrow: Pointer to the struct csrow_info that corresponds to that element 586fcaf780bSMauro Carvalho Chehab */ 587fcaf780bSMauro Carvalho Chehab static int decode_mtr(struct i7300_pvt *pvt, 588fcaf780bSMauro Carvalho Chehab int slot, int ch, int branch, 589fcaf780bSMauro Carvalho Chehab struct i7300_dimm_info *dinfo, 590a895bf8bSMauro Carvalho Chehab struct dimm_info *dimm) 591fcaf780bSMauro Carvalho Chehab { 592fcaf780bSMauro Carvalho Chehab int mtr, ans, addrBits, channel; 593fcaf780bSMauro Carvalho Chehab 594fcaf780bSMauro Carvalho Chehab channel = to_channel(ch, branch); 595fcaf780bSMauro Carvalho Chehab 596fcaf780bSMauro Carvalho Chehab mtr = pvt->mtr[slot][branch]; 597fcaf780bSMauro Carvalho Chehab ans = MTR_DIMMS_PRESENT(mtr) ? 1 : 0; 598fcaf780bSMauro Carvalho Chehab 599956b9ba1SJoe Perches edac_dbg(2, "\tMTR%d CH%d: DIMMs are %sPresent (mtr)\n", 600956b9ba1SJoe Perches slot, channel, ans ? "" : "NOT "); 601fcaf780bSMauro Carvalho Chehab 602fcaf780bSMauro Carvalho Chehab /* Determine if there is a DIMM present in this DIMM slot */ 603fcaf780bSMauro Carvalho Chehab if (!ans) 604fcaf780bSMauro Carvalho Chehab return 0; 605fcaf780bSMauro Carvalho Chehab 606fcaf780bSMauro Carvalho Chehab /* Start with the number of bits for a Bank 607fcaf780bSMauro Carvalho Chehab * on the DRAM */ 608fcaf780bSMauro Carvalho Chehab addrBits = MTR_DRAM_BANKS_ADDR_BITS; 609fcaf780bSMauro Carvalho Chehab /* Add thenumber of ROW bits */ 610fcaf780bSMauro Carvalho Chehab addrBits += MTR_DIMM_ROWS_ADDR_BITS(mtr); 611fcaf780bSMauro Carvalho Chehab /* add the number of COLUMN bits */ 612fcaf780bSMauro Carvalho Chehab addrBits += MTR_DIMM_COLS_ADDR_BITS(mtr); 613fcaf780bSMauro Carvalho Chehab /* add the number of RANK bits */ 614fcaf780bSMauro Carvalho Chehab addrBits += MTR_DIMM_RANKS(mtr); 615fcaf780bSMauro Carvalho Chehab 616fcaf780bSMauro Carvalho Chehab addrBits += 6; /* add 64 bits per DIMM */ 617fcaf780bSMauro Carvalho Chehab addrBits -= 20; /* divide by 2^^20 */ 618fcaf780bSMauro Carvalho Chehab addrBits -= 3; /* 8 bits per bytes */ 619fcaf780bSMauro Carvalho Chehab 620fcaf780bSMauro Carvalho Chehab dinfo->megabytes = 1 << addrBits; 621fcaf780bSMauro Carvalho Chehab 622956b9ba1SJoe Perches edac_dbg(2, "\t\tWIDTH: x%d\n", MTR_DRAM_WIDTH(mtr)); 623fcaf780bSMauro Carvalho Chehab 624956b9ba1SJoe Perches edac_dbg(2, "\t\tELECTRICAL THROTTLING is %s\n", 625fcaf780bSMauro Carvalho Chehab MTR_DIMMS_ETHROTTLE(mtr) ? "enabled" : "disabled"); 626fcaf780bSMauro Carvalho Chehab 627956b9ba1SJoe Perches edac_dbg(2, "\t\tNUMBANK: %d bank(s)\n", MTR_DRAM_BANKS(mtr)); 628956b9ba1SJoe Perches edac_dbg(2, "\t\tNUMRANK: %s\n", 629956b9ba1SJoe Perches MTR_DIMM_RANKS(mtr) ? "double" : "single"); 630956b9ba1SJoe Perches edac_dbg(2, "\t\tNUMROW: %s\n", 6317e881856SJoe Perches MTR_DIMM_ROWS(mtr) == 0 ? "8,192 - 13 rows" : 6327e881856SJoe Perches MTR_DIMM_ROWS(mtr) == 1 ? "16,384 - 14 rows" : 6337e881856SJoe Perches MTR_DIMM_ROWS(mtr) == 2 ? "32,768 - 15 rows" : 6347e881856SJoe Perches "65,536 - 16 rows"); 635956b9ba1SJoe Perches edac_dbg(2, "\t\tNUMCOL: %s\n", 6367e881856SJoe Perches MTR_DIMM_COLS(mtr) == 0 ? "1,024 - 10 columns" : 6377e881856SJoe Perches MTR_DIMM_COLS(mtr) == 1 ? "2,048 - 11 columns" : 6387e881856SJoe Perches MTR_DIMM_COLS(mtr) == 2 ? "4,096 - 12 columns" : 6397e881856SJoe Perches "reserved"); 640956b9ba1SJoe Perches edac_dbg(2, "\t\tSIZE: %d MB\n", dinfo->megabytes); 641fcaf780bSMauro Carvalho Chehab 642116389edSMauro Carvalho Chehab /* 64315154c57SMauro Carvalho Chehab * The type of error detection actually depends of the 644116389edSMauro Carvalho Chehab * mode of operation. When it is just one single memory chip, at 645116389edSMauro Carvalho Chehab * socket 0, channel 0, it uses 8-byte-over-32-byte SECDED+ code. 64615154c57SMauro Carvalho Chehab * In normal or mirrored mode, it uses Lockstep mode, 647116389edSMauro Carvalho Chehab * with the possibility of using an extended algorithm for x8 memories 648116389edSMauro Carvalho Chehab * See datasheet Sections 7.3.6 to 7.3.8 649116389edSMauro Carvalho Chehab */ 65015154c57SMauro Carvalho Chehab 651a895bf8bSMauro Carvalho Chehab dimm->nr_pages = MiB_TO_PAGES(dinfo->megabytes); 652084a4fccSMauro Carvalho Chehab dimm->grain = 8; 653084a4fccSMauro Carvalho Chehab dimm->mtype = MEM_FB_DDR2; 65415154c57SMauro Carvalho Chehab if (IS_SINGLE_MODE(pvt->mc_settings_a)) { 655084a4fccSMauro Carvalho Chehab dimm->edac_mode = EDAC_SECDED; 656956b9ba1SJoe Perches edac_dbg(2, "\t\tECC code is 8-byte-over-32-byte SECDED+ code\n"); 65715154c57SMauro Carvalho Chehab } else { 658956b9ba1SJoe Perches edac_dbg(2, "\t\tECC code is on Lockstep mode\n"); 65928c2ce7cSMauro Carvalho Chehab if (MTR_DRAM_WIDTH(mtr) == 8) 660084a4fccSMauro Carvalho Chehab dimm->edac_mode = EDAC_S8ECD8ED; 66115154c57SMauro Carvalho Chehab else 662084a4fccSMauro Carvalho Chehab dimm->edac_mode = EDAC_S4ECD4ED; 66315154c57SMauro Carvalho Chehab } 664fcaf780bSMauro Carvalho Chehab 665fcaf780bSMauro Carvalho Chehab /* ask what device type on this row */ 66628c2ce7cSMauro Carvalho Chehab if (MTR_DRAM_WIDTH(mtr) == 8) { 667956b9ba1SJoe Perches edac_dbg(2, "\t\tScrub algorithm for x8 is on %s mode\n", 668d7de2bdbSMauro Carvalho Chehab IS_SCRBALGO_ENHANCED(pvt->mc_settings) ? 669d7de2bdbSMauro Carvalho Chehab "enhanced" : "normal"); 670d7de2bdbSMauro Carvalho Chehab 671084a4fccSMauro Carvalho Chehab dimm->dtype = DEV_X8; 672d7de2bdbSMauro Carvalho Chehab } else 673084a4fccSMauro Carvalho Chehab dimm->dtype = DEV_X4; 674fcaf780bSMauro Carvalho Chehab 675fcaf780bSMauro Carvalho Chehab return mtr; 676fcaf780bSMauro Carvalho Chehab } 677fcaf780bSMauro Carvalho Chehab 678d091a6ebSMauro Carvalho Chehab /** 679d091a6ebSMauro Carvalho Chehab * print_dimm_size() - Prints dump of the memory organization 680d091a6ebSMauro Carvalho Chehab * @pvt: pointer to the private data struct used by i7300 driver 681fcaf780bSMauro Carvalho Chehab * 682d091a6ebSMauro Carvalho Chehab * Useful for debug. If debug is disabled, this routine do nothing 683fcaf780bSMauro Carvalho Chehab */ 684fcaf780bSMauro Carvalho Chehab static void print_dimm_size(struct i7300_pvt *pvt) 685fcaf780bSMauro Carvalho Chehab { 686d091a6ebSMauro Carvalho Chehab #ifdef CONFIG_EDAC_DEBUG 687fcaf780bSMauro Carvalho Chehab struct i7300_dimm_info *dinfo; 68885580ea4SMauro Carvalho Chehab char *p; 689fcaf780bSMauro Carvalho Chehab int space, n; 690fcaf780bSMauro Carvalho Chehab int channel, slot; 691fcaf780bSMauro Carvalho Chehab 692fcaf780bSMauro Carvalho Chehab space = PAGE_SIZE; 69385580ea4SMauro Carvalho Chehab p = pvt->tmp_prt_buffer; 694fcaf780bSMauro Carvalho Chehab 695fcaf780bSMauro Carvalho Chehab n = snprintf(p, space, " "); 696fcaf780bSMauro Carvalho Chehab p += n; 697fcaf780bSMauro Carvalho Chehab space -= n; 698fcaf780bSMauro Carvalho Chehab for (channel = 0; channel < MAX_CHANNELS; channel++) { 699fcaf780bSMauro Carvalho Chehab n = snprintf(p, space, "channel %d | ", channel); 700fcaf780bSMauro Carvalho Chehab p += n; 701fcaf780bSMauro Carvalho Chehab space -= n; 702fcaf780bSMauro Carvalho Chehab } 703956b9ba1SJoe Perches edac_dbg(2, "%s\n", pvt->tmp_prt_buffer); 70485580ea4SMauro Carvalho Chehab p = pvt->tmp_prt_buffer; 705fcaf780bSMauro Carvalho Chehab space = PAGE_SIZE; 706fcaf780bSMauro Carvalho Chehab n = snprintf(p, space, "-------------------------------" 707fcaf780bSMauro Carvalho Chehab "------------------------------"); 708fcaf780bSMauro Carvalho Chehab p += n; 709fcaf780bSMauro Carvalho Chehab space -= n; 710956b9ba1SJoe Perches edac_dbg(2, "%s\n", pvt->tmp_prt_buffer); 71185580ea4SMauro Carvalho Chehab p = pvt->tmp_prt_buffer; 712fcaf780bSMauro Carvalho Chehab space = PAGE_SIZE; 713fcaf780bSMauro Carvalho Chehab 714fcaf780bSMauro Carvalho Chehab for (slot = 0; slot < MAX_SLOTS; slot++) { 715fcaf780bSMauro Carvalho Chehab n = snprintf(p, space, "csrow/SLOT %d ", slot); 716fcaf780bSMauro Carvalho Chehab p += n; 717fcaf780bSMauro Carvalho Chehab space -= n; 718fcaf780bSMauro Carvalho Chehab 719fcaf780bSMauro Carvalho Chehab for (channel = 0; channel < MAX_CHANNELS; channel++) { 720fcaf780bSMauro Carvalho Chehab dinfo = &pvt->dimm_info[slot][channel]; 721fcaf780bSMauro Carvalho Chehab n = snprintf(p, space, "%4d MB | ", dinfo->megabytes); 722fcaf780bSMauro Carvalho Chehab p += n; 723fcaf780bSMauro Carvalho Chehab space -= n; 724fcaf780bSMauro Carvalho Chehab } 725fcaf780bSMauro Carvalho Chehab 726956b9ba1SJoe Perches edac_dbg(2, "%s\n", pvt->tmp_prt_buffer); 72785580ea4SMauro Carvalho Chehab p = pvt->tmp_prt_buffer; 728fcaf780bSMauro Carvalho Chehab space = PAGE_SIZE; 729fcaf780bSMauro Carvalho Chehab } 730fcaf780bSMauro Carvalho Chehab 731fcaf780bSMauro Carvalho Chehab n = snprintf(p, space, "-------------------------------" 732fcaf780bSMauro Carvalho Chehab "------------------------------"); 733fcaf780bSMauro Carvalho Chehab p += n; 734fcaf780bSMauro Carvalho Chehab space -= n; 735956b9ba1SJoe Perches edac_dbg(2, "%s\n", pvt->tmp_prt_buffer); 73685580ea4SMauro Carvalho Chehab p = pvt->tmp_prt_buffer; 737fcaf780bSMauro Carvalho Chehab space = PAGE_SIZE; 738d091a6ebSMauro Carvalho Chehab #endif 739fcaf780bSMauro Carvalho Chehab } 740fcaf780bSMauro Carvalho Chehab 741d091a6ebSMauro Carvalho Chehab /** 742d091a6ebSMauro Carvalho Chehab * i7300_init_csrows() - Initialize the 'csrows' table within 743fcaf780bSMauro Carvalho Chehab * the mci control structure with the 744fcaf780bSMauro Carvalho Chehab * addressing of memory. 745d091a6ebSMauro Carvalho Chehab * @mci: struct mem_ctl_info pointer 746fcaf780bSMauro Carvalho Chehab */ 747fcaf780bSMauro Carvalho Chehab static int i7300_init_csrows(struct mem_ctl_info *mci) 748fcaf780bSMauro Carvalho Chehab { 749fcaf780bSMauro Carvalho Chehab struct i7300_pvt *pvt; 750fcaf780bSMauro Carvalho Chehab struct i7300_dimm_info *dinfo; 751d091a6ebSMauro Carvalho Chehab int rc = -ENODEV; 752fcaf780bSMauro Carvalho Chehab int mtr; 75333ad4126SMauro Carvalho Chehab int ch, branch, slot, channel, max_channel, max_branch; 754084a4fccSMauro Carvalho Chehab struct dimm_info *dimm; 755fcaf780bSMauro Carvalho Chehab 756fcaf780bSMauro Carvalho Chehab pvt = mci->pvt_info; 757fcaf780bSMauro Carvalho Chehab 758956b9ba1SJoe Perches edac_dbg(2, "Memory Technology Registers:\n"); 759fcaf780bSMauro Carvalho Chehab 76033ad4126SMauro Carvalho Chehab if (IS_SINGLE_MODE(pvt->mc_settings_a)) { 76133ad4126SMauro Carvalho Chehab max_branch = 1; 76233ad4126SMauro Carvalho Chehab max_channel = 1; 76333ad4126SMauro Carvalho Chehab } else { 76433ad4126SMauro Carvalho Chehab max_branch = MAX_BRANCHES; 76533ad4126SMauro Carvalho Chehab max_channel = MAX_CH_PER_BRANCH; 76633ad4126SMauro Carvalho Chehab } 76733ad4126SMauro Carvalho Chehab 768fcaf780bSMauro Carvalho Chehab /* Get the AMB present registers for the four channels */ 76933ad4126SMauro Carvalho Chehab for (branch = 0; branch < max_branch; branch++) { 770fcaf780bSMauro Carvalho Chehab /* Read and dump branch 0's MTRs */ 771fcaf780bSMauro Carvalho Chehab channel = to_channel(0, branch); 7729c6f6b65SMauro Carvalho Chehab pci_read_config_word(pvt->pci_dev_2x_0_fbd_branch[branch], 7739c6f6b65SMauro Carvalho Chehab AMBPRESENT_0, 774fcaf780bSMauro Carvalho Chehab &pvt->ambpresent[channel]); 775956b9ba1SJoe Perches edac_dbg(2, "\t\tAMB-present CH%d = 0x%x:\n", 776fcaf780bSMauro Carvalho Chehab channel, pvt->ambpresent[channel]); 777fcaf780bSMauro Carvalho Chehab 77833ad4126SMauro Carvalho Chehab if (max_channel == 1) 77933ad4126SMauro Carvalho Chehab continue; 78033ad4126SMauro Carvalho Chehab 781fcaf780bSMauro Carvalho Chehab channel = to_channel(1, branch); 7829c6f6b65SMauro Carvalho Chehab pci_read_config_word(pvt->pci_dev_2x_0_fbd_branch[branch], 7839c6f6b65SMauro Carvalho Chehab AMBPRESENT_1, 784fcaf780bSMauro Carvalho Chehab &pvt->ambpresent[channel]); 785956b9ba1SJoe Perches edac_dbg(2, "\t\tAMB-present CH%d = 0x%x:\n", 786fcaf780bSMauro Carvalho Chehab channel, pvt->ambpresent[channel]); 787fcaf780bSMauro Carvalho Chehab } 788fcaf780bSMauro Carvalho Chehab 789fcaf780bSMauro Carvalho Chehab /* Get the set of MTR[0-7] regs by each branch */ 790fcaf780bSMauro Carvalho Chehab for (slot = 0; slot < MAX_SLOTS; slot++) { 791fcaf780bSMauro Carvalho Chehab int where = mtr_regs[slot]; 79233ad4126SMauro Carvalho Chehab for (branch = 0; branch < max_branch; branch++) { 7933e57eef6SMauro Carvalho Chehab pci_read_config_word(pvt->pci_dev_2x_0_fbd_branch[branch], 794fcaf780bSMauro Carvalho Chehab where, 795fcaf780bSMauro Carvalho Chehab &pvt->mtr[slot][branch]); 79633ad4126SMauro Carvalho Chehab for (ch = 0; ch < max_channel; ch++) { 797fcaf780bSMauro Carvalho Chehab int channel = to_channel(ch, branch); 798fcaf780bSMauro Carvalho Chehab 79970e2a837SMauro Carvalho Chehab dimm = EDAC_DIMM_PTR(mci->layers, mci->dimms, 80070e2a837SMauro Carvalho Chehab mci->n_layers, branch, ch, slot); 801fcaf780bSMauro Carvalho Chehab 80270e2a837SMauro Carvalho Chehab dinfo = &pvt->dimm_info[slot][channel]; 803084a4fccSMauro Carvalho Chehab 804fcaf780bSMauro Carvalho Chehab mtr = decode_mtr(pvt, slot, ch, branch, 805a895bf8bSMauro Carvalho Chehab dinfo, dimm); 806a895bf8bSMauro Carvalho Chehab 807fcaf780bSMauro Carvalho Chehab /* if no DIMMS on this row, continue */ 808fcaf780bSMauro Carvalho Chehab if (!MTR_DIMMS_PRESENT(mtr)) 809fcaf780bSMauro Carvalho Chehab continue; 810fcaf780bSMauro Carvalho Chehab 811d091a6ebSMauro Carvalho Chehab rc = 0; 812a895bf8bSMauro Carvalho Chehab 813fcaf780bSMauro Carvalho Chehab } 814fcaf780bSMauro Carvalho Chehab } 815fcaf780bSMauro Carvalho Chehab } 816fcaf780bSMauro Carvalho Chehab 817d091a6ebSMauro Carvalho Chehab return rc; 818fcaf780bSMauro Carvalho Chehab } 819fcaf780bSMauro Carvalho Chehab 820d091a6ebSMauro Carvalho Chehab /** 821d091a6ebSMauro Carvalho Chehab * decode_mir() - Decodes Memory Interleave Register (MIR) info 822d091a6ebSMauro Carvalho Chehab * @int mir_no: number of the MIR register to decode 823d091a6ebSMauro Carvalho Chehab * @mir: array with the MIR data cached on the driver 824d091a6ebSMauro Carvalho Chehab */ 825fcaf780bSMauro Carvalho Chehab static void decode_mir(int mir_no, u16 mir[MAX_MIR]) 826fcaf780bSMauro Carvalho Chehab { 827fcaf780bSMauro Carvalho Chehab if (mir[mir_no] & 3) 828956b9ba1SJoe Perches edac_dbg(2, "MIR%d: limit= 0x%x Branch(es) that participate: %s %s\n", 829fcaf780bSMauro Carvalho Chehab mir_no, 830fcaf780bSMauro Carvalho Chehab (mir[mir_no] >> 4) & 0xfff, 831fcaf780bSMauro Carvalho Chehab (mir[mir_no] & 1) ? "B0" : "", 832fcaf780bSMauro Carvalho Chehab (mir[mir_no] & 2) ? "B1" : ""); 833fcaf780bSMauro Carvalho Chehab } 834fcaf780bSMauro Carvalho Chehab 835d091a6ebSMauro Carvalho Chehab /** 836d091a6ebSMauro Carvalho Chehab * i7300_get_mc_regs() - Get the contents of the MC enumeration registers 837d091a6ebSMauro Carvalho Chehab * @mci: struct mem_ctl_info pointer 838fcaf780bSMauro Carvalho Chehab * 839d091a6ebSMauro Carvalho Chehab * Data read is cached internally for its usage when needed 840fcaf780bSMauro Carvalho Chehab */ 841fcaf780bSMauro Carvalho Chehab static int i7300_get_mc_regs(struct mem_ctl_info *mci) 842fcaf780bSMauro Carvalho Chehab { 843fcaf780bSMauro Carvalho Chehab struct i7300_pvt *pvt; 844fcaf780bSMauro Carvalho Chehab u32 actual_tolm; 845fcaf780bSMauro Carvalho Chehab int i, rc; 846fcaf780bSMauro Carvalho Chehab 847fcaf780bSMauro Carvalho Chehab pvt = mci->pvt_info; 848fcaf780bSMauro Carvalho Chehab 8493e57eef6SMauro Carvalho Chehab pci_read_config_dword(pvt->pci_dev_16_0_fsb_ctlr, AMBASE, 850fcaf780bSMauro Carvalho Chehab (u32 *) &pvt->ambase); 851fcaf780bSMauro Carvalho Chehab 852956b9ba1SJoe Perches edac_dbg(2, "AMBASE= 0x%lx\n", (long unsigned int)pvt->ambase); 853fcaf780bSMauro Carvalho Chehab 854fcaf780bSMauro Carvalho Chehab /* Get the Branch Map regs */ 8553e57eef6SMauro Carvalho Chehab pci_read_config_word(pvt->pci_dev_16_1_fsb_addr_map, TOLM, &pvt->tolm); 856fcaf780bSMauro Carvalho Chehab pvt->tolm >>= 12; 857956b9ba1SJoe Perches edac_dbg(2, "TOLM (number of 256M regions) =%u (0x%x)\n", 858956b9ba1SJoe Perches pvt->tolm, pvt->tolm); 859fcaf780bSMauro Carvalho Chehab 860fcaf780bSMauro Carvalho Chehab actual_tolm = (u32) ((1000l * pvt->tolm) >> (30 - 28)); 861956b9ba1SJoe Perches edac_dbg(2, "Actual TOLM byte addr=%u.%03u GB (0x%x)\n", 862fcaf780bSMauro Carvalho Chehab actual_tolm/1000, actual_tolm % 1000, pvt->tolm << 28); 863fcaf780bSMauro Carvalho Chehab 864af3d8831SMauro Carvalho Chehab /* Get memory controller settings */ 8653e57eef6SMauro Carvalho Chehab pci_read_config_dword(pvt->pci_dev_16_1_fsb_addr_map, MC_SETTINGS, 866af3d8831SMauro Carvalho Chehab &pvt->mc_settings); 867bb81a216SMauro Carvalho Chehab pci_read_config_dword(pvt->pci_dev_16_1_fsb_addr_map, MC_SETTINGS_A, 868bb81a216SMauro Carvalho Chehab &pvt->mc_settings_a); 869d7de2bdbSMauro Carvalho Chehab 870bb81a216SMauro Carvalho Chehab if (IS_SINGLE_MODE(pvt->mc_settings_a)) 871956b9ba1SJoe Perches edac_dbg(0, "Memory controller operating on single mode\n"); 872bb81a216SMauro Carvalho Chehab else 873956b9ba1SJoe Perches edac_dbg(0, "Memory controller operating on %smirrored mode\n", 874956b9ba1SJoe Perches IS_MIRRORED(pvt->mc_settings) ? "" : "non-"); 875bb81a216SMauro Carvalho Chehab 876956b9ba1SJoe Perches edac_dbg(0, "Error detection is %s\n", 877d7de2bdbSMauro Carvalho Chehab IS_ECC_ENABLED(pvt->mc_settings) ? "enabled" : "disabled"); 878956b9ba1SJoe Perches edac_dbg(0, "Retry is %s\n", 879d7de2bdbSMauro Carvalho Chehab IS_RETRY_ENABLED(pvt->mc_settings) ? "enabled" : "disabled"); 880af3d8831SMauro Carvalho Chehab 881af3d8831SMauro Carvalho Chehab /* Get Memory Interleave Range registers */ 8829c6f6b65SMauro Carvalho Chehab pci_read_config_word(pvt->pci_dev_16_1_fsb_addr_map, MIR0, 8839c6f6b65SMauro Carvalho Chehab &pvt->mir[0]); 8849c6f6b65SMauro Carvalho Chehab pci_read_config_word(pvt->pci_dev_16_1_fsb_addr_map, MIR1, 8859c6f6b65SMauro Carvalho Chehab &pvt->mir[1]); 8869c6f6b65SMauro Carvalho Chehab pci_read_config_word(pvt->pci_dev_16_1_fsb_addr_map, MIR2, 8879c6f6b65SMauro Carvalho Chehab &pvt->mir[2]); 888fcaf780bSMauro Carvalho Chehab 889fcaf780bSMauro Carvalho Chehab /* Decode the MIR regs */ 890fcaf780bSMauro Carvalho Chehab for (i = 0; i < MAX_MIR; i++) 891fcaf780bSMauro Carvalho Chehab decode_mir(i, pvt->mir); 892fcaf780bSMauro Carvalho Chehab 893fcaf780bSMauro Carvalho Chehab rc = i7300_init_csrows(mci); 894fcaf780bSMauro Carvalho Chehab if (rc < 0) 895fcaf780bSMauro Carvalho Chehab return rc; 896fcaf780bSMauro Carvalho Chehab 897fcaf780bSMauro Carvalho Chehab /* Go and determine the size of each DIMM and place in an 898fcaf780bSMauro Carvalho Chehab * orderly matrix */ 899fcaf780bSMauro Carvalho Chehab print_dimm_size(pvt); 900fcaf780bSMauro Carvalho Chehab 901fcaf780bSMauro Carvalho Chehab return 0; 902fcaf780bSMauro Carvalho Chehab } 903fcaf780bSMauro Carvalho Chehab 9045de6e07eSMauro Carvalho Chehab /************************************************* 9055de6e07eSMauro Carvalho Chehab * i7300 Functions related to device probe/release 9065de6e07eSMauro Carvalho Chehab *************************************************/ 9075de6e07eSMauro Carvalho Chehab 908d091a6ebSMauro Carvalho Chehab /** 909d091a6ebSMauro Carvalho Chehab * i7300_put_devices() - Release the PCI devices 910d091a6ebSMauro Carvalho Chehab * @mci: struct mem_ctl_info pointer 911fcaf780bSMauro Carvalho Chehab */ 912fcaf780bSMauro Carvalho Chehab static void i7300_put_devices(struct mem_ctl_info *mci) 913fcaf780bSMauro Carvalho Chehab { 914fcaf780bSMauro Carvalho Chehab struct i7300_pvt *pvt; 915fcaf780bSMauro Carvalho Chehab int branch; 916fcaf780bSMauro Carvalho Chehab 917fcaf780bSMauro Carvalho Chehab pvt = mci->pvt_info; 918fcaf780bSMauro Carvalho Chehab 919fcaf780bSMauro Carvalho Chehab /* Decrement usage count for devices */ 920fcaf780bSMauro Carvalho Chehab for (branch = 0; branch < MAX_CH_PER_BRANCH; branch++) 9213e57eef6SMauro Carvalho Chehab pci_dev_put(pvt->pci_dev_2x_0_fbd_branch[branch]); 9223e57eef6SMauro Carvalho Chehab pci_dev_put(pvt->pci_dev_16_2_fsb_err_regs); 9233e57eef6SMauro Carvalho Chehab pci_dev_put(pvt->pci_dev_16_1_fsb_addr_map); 924fcaf780bSMauro Carvalho Chehab } 925fcaf780bSMauro Carvalho Chehab 926d091a6ebSMauro Carvalho Chehab /** 927d091a6ebSMauro Carvalho Chehab * i7300_get_devices() - Find and perform 'get' operation on the MCH's 928fcaf780bSMauro Carvalho Chehab * device/functions we want to reference for this driver 929d091a6ebSMauro Carvalho Chehab * @mci: struct mem_ctl_info pointer 930fcaf780bSMauro Carvalho Chehab * 931d091a6ebSMauro Carvalho Chehab * Access and prepare the several devices for usage: 932d091a6ebSMauro Carvalho Chehab * I7300 devices used by this driver: 933d091a6ebSMauro Carvalho Chehab * Device 16, functions 0,1 and 2: PCI_DEVICE_ID_INTEL_I7300_MCH_ERR 934d091a6ebSMauro Carvalho Chehab * Device 21 function 0: PCI_DEVICE_ID_INTEL_I7300_MCH_FB0 935d091a6ebSMauro Carvalho Chehab * Device 22 function 0: PCI_DEVICE_ID_INTEL_I7300_MCH_FB1 936fcaf780bSMauro Carvalho Chehab */ 9379b3c6e85SGreg Kroah-Hartman static int i7300_get_devices(struct mem_ctl_info *mci) 938fcaf780bSMauro Carvalho Chehab { 939fcaf780bSMauro Carvalho Chehab struct i7300_pvt *pvt; 940fcaf780bSMauro Carvalho Chehab struct pci_dev *pdev; 941fcaf780bSMauro Carvalho Chehab 942fcaf780bSMauro Carvalho Chehab pvt = mci->pvt_info; 943fcaf780bSMauro Carvalho Chehab 944fcaf780bSMauro Carvalho Chehab /* Attempt to 'get' the MCH register we want */ 945fcaf780bSMauro Carvalho Chehab pdev = NULL; 9469c6f6b65SMauro Carvalho Chehab while (!pvt->pci_dev_16_1_fsb_addr_map || 9479c6f6b65SMauro Carvalho Chehab !pvt->pci_dev_16_2_fsb_err_regs) { 948fcaf780bSMauro Carvalho Chehab pdev = pci_get_device(PCI_VENDOR_ID_INTEL, 949fcaf780bSMauro Carvalho Chehab PCI_DEVICE_ID_INTEL_I7300_MCH_ERR, pdev); 950fcaf780bSMauro Carvalho Chehab if (!pdev) { 951fcaf780bSMauro Carvalho Chehab /* End of list, leave */ 952fcaf780bSMauro Carvalho Chehab i7300_printk(KERN_ERR, 953fcaf780bSMauro Carvalho Chehab "'system address,Process Bus' " 954fcaf780bSMauro Carvalho Chehab "device not found:" 955fcaf780bSMauro Carvalho Chehab "vendor 0x%x device 0x%x ERR funcs " 956fcaf780bSMauro Carvalho Chehab "(broken BIOS?)\n", 957fcaf780bSMauro Carvalho Chehab PCI_VENDOR_ID_INTEL, 958fcaf780bSMauro Carvalho Chehab PCI_DEVICE_ID_INTEL_I7300_MCH_ERR); 959fcaf780bSMauro Carvalho Chehab goto error; 960fcaf780bSMauro Carvalho Chehab } 961fcaf780bSMauro Carvalho Chehab 962fcaf780bSMauro Carvalho Chehab /* Store device 16 funcs 1 and 2 */ 963fcaf780bSMauro Carvalho Chehab switch (PCI_FUNC(pdev->devfn)) { 964fcaf780bSMauro Carvalho Chehab case 1: 9653e57eef6SMauro Carvalho Chehab pvt->pci_dev_16_1_fsb_addr_map = pdev; 966fcaf780bSMauro Carvalho Chehab break; 967fcaf780bSMauro Carvalho Chehab case 2: 9683e57eef6SMauro Carvalho Chehab pvt->pci_dev_16_2_fsb_err_regs = pdev; 969fcaf780bSMauro Carvalho Chehab break; 970fcaf780bSMauro Carvalho Chehab } 971fcaf780bSMauro Carvalho Chehab } 972fcaf780bSMauro Carvalho Chehab 973956b9ba1SJoe Perches edac_dbg(1, "System Address, processor bus- PCI Bus ID: %s %x:%x\n", 9743e57eef6SMauro Carvalho Chehab pci_name(pvt->pci_dev_16_0_fsb_ctlr), 9759c6f6b65SMauro Carvalho Chehab pvt->pci_dev_16_0_fsb_ctlr->vendor, 9769c6f6b65SMauro Carvalho Chehab pvt->pci_dev_16_0_fsb_ctlr->device); 977956b9ba1SJoe Perches edac_dbg(1, "Branchmap, control and errors - PCI Bus ID: %s %x:%x\n", 9783e57eef6SMauro Carvalho Chehab pci_name(pvt->pci_dev_16_1_fsb_addr_map), 9799c6f6b65SMauro Carvalho Chehab pvt->pci_dev_16_1_fsb_addr_map->vendor, 9809c6f6b65SMauro Carvalho Chehab pvt->pci_dev_16_1_fsb_addr_map->device); 981956b9ba1SJoe Perches edac_dbg(1, "FSB Error Regs - PCI Bus ID: %s %x:%x\n", 9823e57eef6SMauro Carvalho Chehab pci_name(pvt->pci_dev_16_2_fsb_err_regs), 9839c6f6b65SMauro Carvalho Chehab pvt->pci_dev_16_2_fsb_err_regs->vendor, 9849c6f6b65SMauro Carvalho Chehab pvt->pci_dev_16_2_fsb_err_regs->device); 985fcaf780bSMauro Carvalho Chehab 9863e57eef6SMauro Carvalho Chehab pvt->pci_dev_2x_0_fbd_branch[0] = pci_get_device(PCI_VENDOR_ID_INTEL, 987fcaf780bSMauro Carvalho Chehab PCI_DEVICE_ID_INTEL_I7300_MCH_FB0, 988fcaf780bSMauro Carvalho Chehab NULL); 9893e57eef6SMauro Carvalho Chehab if (!pvt->pci_dev_2x_0_fbd_branch[0]) { 990fcaf780bSMauro Carvalho Chehab i7300_printk(KERN_ERR, 991fcaf780bSMauro Carvalho Chehab "MC: 'BRANCH 0' device not found:" 992fcaf780bSMauro Carvalho Chehab "vendor 0x%x device 0x%x Func 0 (broken BIOS?)\n", 993fcaf780bSMauro Carvalho Chehab PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_I7300_MCH_FB0); 994fcaf780bSMauro Carvalho Chehab goto error; 995fcaf780bSMauro Carvalho Chehab } 996fcaf780bSMauro Carvalho Chehab 9973e57eef6SMauro Carvalho Chehab pvt->pci_dev_2x_0_fbd_branch[1] = pci_get_device(PCI_VENDOR_ID_INTEL, 998fcaf780bSMauro Carvalho Chehab PCI_DEVICE_ID_INTEL_I7300_MCH_FB1, 999fcaf780bSMauro Carvalho Chehab NULL); 10003e57eef6SMauro Carvalho Chehab if (!pvt->pci_dev_2x_0_fbd_branch[1]) { 1001fcaf780bSMauro Carvalho Chehab i7300_printk(KERN_ERR, 1002fcaf780bSMauro Carvalho Chehab "MC: 'BRANCH 1' device not found:" 1003fcaf780bSMauro Carvalho Chehab "vendor 0x%x device 0x%x Func 0 " 1004fcaf780bSMauro Carvalho Chehab "(broken BIOS?)\n", 1005fcaf780bSMauro Carvalho Chehab PCI_VENDOR_ID_INTEL, 1006fcaf780bSMauro Carvalho Chehab PCI_DEVICE_ID_INTEL_I7300_MCH_FB1); 1007fcaf780bSMauro Carvalho Chehab goto error; 1008fcaf780bSMauro Carvalho Chehab } 1009fcaf780bSMauro Carvalho Chehab 1010fcaf780bSMauro Carvalho Chehab return 0; 1011fcaf780bSMauro Carvalho Chehab 1012fcaf780bSMauro Carvalho Chehab error: 1013fcaf780bSMauro Carvalho Chehab i7300_put_devices(mci); 1014fcaf780bSMauro Carvalho Chehab return -ENODEV; 1015fcaf780bSMauro Carvalho Chehab } 1016fcaf780bSMauro Carvalho Chehab 1017d091a6ebSMauro Carvalho Chehab /** 1018d091a6ebSMauro Carvalho Chehab * i7300_init_one() - Probe for one instance of the device 1019d091a6ebSMauro Carvalho Chehab * @pdev: struct pci_dev pointer 1020d091a6ebSMauro Carvalho Chehab * @id: struct pci_device_id pointer - currently unused 1021fcaf780bSMauro Carvalho Chehab */ 10229b3c6e85SGreg Kroah-Hartman static int i7300_init_one(struct pci_dev *pdev, const struct pci_device_id *id) 1023fcaf780bSMauro Carvalho Chehab { 1024fcaf780bSMauro Carvalho Chehab struct mem_ctl_info *mci; 102570e2a837SMauro Carvalho Chehab struct edac_mc_layer layers[3]; 1026fcaf780bSMauro Carvalho Chehab struct i7300_pvt *pvt; 1027d091a6ebSMauro Carvalho Chehab int rc; 1028fcaf780bSMauro Carvalho Chehab 1029d091a6ebSMauro Carvalho Chehab /* wake up device */ 1030d091a6ebSMauro Carvalho Chehab rc = pci_enable_device(pdev); 1031d091a6ebSMauro Carvalho Chehab if (rc == -EIO) 1032d091a6ebSMauro Carvalho Chehab return rc; 1033fcaf780bSMauro Carvalho Chehab 1034956b9ba1SJoe Perches edac_dbg(0, "MC: pdev bus %u dev=0x%x fn=0x%x\n", 1035fcaf780bSMauro Carvalho Chehab pdev->bus->number, 1036fcaf780bSMauro Carvalho Chehab PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn)); 1037fcaf780bSMauro Carvalho Chehab 1038fcaf780bSMauro Carvalho Chehab /* We only are looking for func 0 of the set */ 1039fcaf780bSMauro Carvalho Chehab if (PCI_FUNC(pdev->devfn) != 0) 1040fcaf780bSMauro Carvalho Chehab return -ENODEV; 1041fcaf780bSMauro Carvalho Chehab 1042fcaf780bSMauro Carvalho Chehab /* allocate a new MC control structure */ 104370e2a837SMauro Carvalho Chehab layers[0].type = EDAC_MC_LAYER_BRANCH; 104470e2a837SMauro Carvalho Chehab layers[0].size = MAX_BRANCHES; 104570e2a837SMauro Carvalho Chehab layers[0].is_virt_csrow = false; 104670e2a837SMauro Carvalho Chehab layers[1].type = EDAC_MC_LAYER_CHANNEL; 104770e2a837SMauro Carvalho Chehab layers[1].size = MAX_CH_PER_BRANCH; 104870e2a837SMauro Carvalho Chehab layers[1].is_virt_csrow = true; 104970e2a837SMauro Carvalho Chehab layers[2].type = EDAC_MC_LAYER_SLOT; 105070e2a837SMauro Carvalho Chehab layers[2].size = MAX_SLOTS; 105170e2a837SMauro Carvalho Chehab layers[2].is_virt_csrow = true; 1052ca0907b9SMauro Carvalho Chehab mci = edac_mc_alloc(0, ARRAY_SIZE(layers), layers, sizeof(*pvt)); 1053fcaf780bSMauro Carvalho Chehab if (mci == NULL) 1054fcaf780bSMauro Carvalho Chehab return -ENOMEM; 1055fcaf780bSMauro Carvalho Chehab 1056956b9ba1SJoe Perches edac_dbg(0, "MC: mci = %p\n", mci); 1057fcaf780bSMauro Carvalho Chehab 1058fd687502SMauro Carvalho Chehab mci->pdev = &pdev->dev; /* record ptr to the generic device */ 1059fcaf780bSMauro Carvalho Chehab 1060fcaf780bSMauro Carvalho Chehab pvt = mci->pvt_info; 10613e57eef6SMauro Carvalho Chehab pvt->pci_dev_16_0_fsb_ctlr = pdev; /* Record this device in our private */ 1062fcaf780bSMauro Carvalho Chehab 106385580ea4SMauro Carvalho Chehab pvt->tmp_prt_buffer = kmalloc(PAGE_SIZE, GFP_KERNEL); 106485580ea4SMauro Carvalho Chehab if (!pvt->tmp_prt_buffer) { 106585580ea4SMauro Carvalho Chehab edac_mc_free(mci); 106685580ea4SMauro Carvalho Chehab return -ENOMEM; 106785580ea4SMauro Carvalho Chehab } 106885580ea4SMauro Carvalho Chehab 1069fcaf780bSMauro Carvalho Chehab /* 'get' the pci devices we want to reserve for our use */ 1070d091a6ebSMauro Carvalho Chehab if (i7300_get_devices(mci)) 1071fcaf780bSMauro Carvalho Chehab goto fail0; 1072fcaf780bSMauro Carvalho Chehab 1073fcaf780bSMauro Carvalho Chehab mci->mc_idx = 0; 1074fcaf780bSMauro Carvalho Chehab mci->mtype_cap = MEM_FLAG_FB_DDR2; 1075fcaf780bSMauro Carvalho Chehab mci->edac_ctl_cap = EDAC_FLAG_NONE; 1076fcaf780bSMauro Carvalho Chehab mci->edac_cap = EDAC_FLAG_NONE; 1077fcaf780bSMauro Carvalho Chehab mci->mod_name = "i7300_edac.c"; 1078fcaf780bSMauro Carvalho Chehab mci->mod_ver = I7300_REVISION; 1079d091a6ebSMauro Carvalho Chehab mci->ctl_name = i7300_devs[0].ctl_name; 1080fcaf780bSMauro Carvalho Chehab mci->dev_name = pci_name(pdev); 1081fcaf780bSMauro Carvalho Chehab mci->ctl_page_to_phys = NULL; 1082fcaf780bSMauro Carvalho Chehab 1083fcaf780bSMauro Carvalho Chehab /* Set the function pointer to an actual operation function */ 1084fcaf780bSMauro Carvalho Chehab mci->edac_check = i7300_check_error; 1085fcaf780bSMauro Carvalho Chehab 1086fcaf780bSMauro Carvalho Chehab /* initialize the MC control structure 'csrows' table 1087fcaf780bSMauro Carvalho Chehab * with the mapping and control information */ 1088fcaf780bSMauro Carvalho Chehab if (i7300_get_mc_regs(mci)) { 1089956b9ba1SJoe Perches edac_dbg(0, "MC: Setting mci->edac_cap to EDAC_FLAG_NONE because i7300_init_csrows() returned nonzero value\n"); 1090fcaf780bSMauro Carvalho Chehab mci->edac_cap = EDAC_FLAG_NONE; /* no csrows found */ 1091fcaf780bSMauro Carvalho Chehab } else { 1092956b9ba1SJoe Perches edac_dbg(1, "MC: Enable error reporting now\n"); 1093fcaf780bSMauro Carvalho Chehab i7300_enable_error_reporting(mci); 1094fcaf780bSMauro Carvalho Chehab } 1095fcaf780bSMauro Carvalho Chehab 1096fcaf780bSMauro Carvalho Chehab /* add this new MC control structure to EDAC's list of MCs */ 1097fcaf780bSMauro Carvalho Chehab if (edac_mc_add_mc(mci)) { 1098956b9ba1SJoe Perches edac_dbg(0, "MC: failed edac_mc_add_mc()\n"); 1099fcaf780bSMauro Carvalho Chehab /* FIXME: perhaps some code should go here that disables error 1100fcaf780bSMauro Carvalho Chehab * reporting if we just enabled it 1101fcaf780bSMauro Carvalho Chehab */ 1102fcaf780bSMauro Carvalho Chehab goto fail1; 1103fcaf780bSMauro Carvalho Chehab } 1104fcaf780bSMauro Carvalho Chehab 1105fcaf780bSMauro Carvalho Chehab i7300_clear_error(mci); 1106fcaf780bSMauro Carvalho Chehab 1107fcaf780bSMauro Carvalho Chehab /* allocating generic PCI control info */ 1108fcaf780bSMauro Carvalho Chehab i7300_pci = edac_pci_create_generic_ctl(&pdev->dev, EDAC_MOD_STR); 1109fcaf780bSMauro Carvalho Chehab if (!i7300_pci) { 1110fcaf780bSMauro Carvalho Chehab printk(KERN_WARNING 1111fcaf780bSMauro Carvalho Chehab "%s(): Unable to create PCI control\n", 1112fcaf780bSMauro Carvalho Chehab __func__); 1113fcaf780bSMauro Carvalho Chehab printk(KERN_WARNING 1114fcaf780bSMauro Carvalho Chehab "%s(): PCI error report via EDAC not setup\n", 1115fcaf780bSMauro Carvalho Chehab __func__); 1116fcaf780bSMauro Carvalho Chehab } 1117fcaf780bSMauro Carvalho Chehab 1118fcaf780bSMauro Carvalho Chehab return 0; 1119fcaf780bSMauro Carvalho Chehab 1120fcaf780bSMauro Carvalho Chehab /* Error exit unwinding stack */ 1121fcaf780bSMauro Carvalho Chehab fail1: 1122fcaf780bSMauro Carvalho Chehab 1123fcaf780bSMauro Carvalho Chehab i7300_put_devices(mci); 1124fcaf780bSMauro Carvalho Chehab 1125fcaf780bSMauro Carvalho Chehab fail0: 112685580ea4SMauro Carvalho Chehab kfree(pvt->tmp_prt_buffer); 1127fcaf780bSMauro Carvalho Chehab edac_mc_free(mci); 1128fcaf780bSMauro Carvalho Chehab return -ENODEV; 1129fcaf780bSMauro Carvalho Chehab } 1130fcaf780bSMauro Carvalho Chehab 1131d091a6ebSMauro Carvalho Chehab /** 1132d091a6ebSMauro Carvalho Chehab * i7300_remove_one() - Remove the driver 1133d091a6ebSMauro Carvalho Chehab * @pdev: struct pci_dev pointer 1134fcaf780bSMauro Carvalho Chehab */ 11359b3c6e85SGreg Kroah-Hartman static void i7300_remove_one(struct pci_dev *pdev) 1136fcaf780bSMauro Carvalho Chehab { 1137fcaf780bSMauro Carvalho Chehab struct mem_ctl_info *mci; 113885580ea4SMauro Carvalho Chehab char *tmp; 1139fcaf780bSMauro Carvalho Chehab 1140956b9ba1SJoe Perches edac_dbg(0, "\n"); 1141fcaf780bSMauro Carvalho Chehab 1142fcaf780bSMauro Carvalho Chehab if (i7300_pci) 1143fcaf780bSMauro Carvalho Chehab edac_pci_release_generic_ctl(i7300_pci); 1144fcaf780bSMauro Carvalho Chehab 1145fcaf780bSMauro Carvalho Chehab mci = edac_mc_del_mc(&pdev->dev); 1146fcaf780bSMauro Carvalho Chehab if (!mci) 1147fcaf780bSMauro Carvalho Chehab return; 1148fcaf780bSMauro Carvalho Chehab 114985580ea4SMauro Carvalho Chehab tmp = ((struct i7300_pvt *)mci->pvt_info)->tmp_prt_buffer; 115085580ea4SMauro Carvalho Chehab 1151fcaf780bSMauro Carvalho Chehab /* retrieve references to resources, and free those resources */ 1152fcaf780bSMauro Carvalho Chehab i7300_put_devices(mci); 1153fcaf780bSMauro Carvalho Chehab 115485580ea4SMauro Carvalho Chehab kfree(tmp); 1155fcaf780bSMauro Carvalho Chehab edac_mc_free(mci); 1156fcaf780bSMauro Carvalho Chehab } 1157fcaf780bSMauro Carvalho Chehab 1158fcaf780bSMauro Carvalho Chehab /* 1159d091a6ebSMauro Carvalho Chehab * pci_device_id: table for which devices we are looking for 1160fcaf780bSMauro Carvalho Chehab * 1161d091a6ebSMauro Carvalho Chehab * Has only 8086:360c PCI ID 1162fcaf780bSMauro Carvalho Chehab */ 1163*ba935f40SJingoo Han static const struct pci_device_id i7300_pci_tbl[] = { 1164fcaf780bSMauro Carvalho Chehab {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_I7300_MCH_ERR)}, 1165fcaf780bSMauro Carvalho Chehab {0,} /* 0 terminated list. */ 1166fcaf780bSMauro Carvalho Chehab }; 1167fcaf780bSMauro Carvalho Chehab 1168fcaf780bSMauro Carvalho Chehab MODULE_DEVICE_TABLE(pci, i7300_pci_tbl); 1169fcaf780bSMauro Carvalho Chehab 1170fcaf780bSMauro Carvalho Chehab /* 1171d091a6ebSMauro Carvalho Chehab * i7300_driver: pci_driver structure for this module 1172fcaf780bSMauro Carvalho Chehab */ 1173fcaf780bSMauro Carvalho Chehab static struct pci_driver i7300_driver = { 1174fcaf780bSMauro Carvalho Chehab .name = "i7300_edac", 1175fcaf780bSMauro Carvalho Chehab .probe = i7300_init_one, 11769b3c6e85SGreg Kroah-Hartman .remove = i7300_remove_one, 1177fcaf780bSMauro Carvalho Chehab .id_table = i7300_pci_tbl, 1178fcaf780bSMauro Carvalho Chehab }; 1179fcaf780bSMauro Carvalho Chehab 1180d091a6ebSMauro Carvalho Chehab /** 1181d091a6ebSMauro Carvalho Chehab * i7300_init() - Registers the driver 1182fcaf780bSMauro Carvalho Chehab */ 1183fcaf780bSMauro Carvalho Chehab static int __init i7300_init(void) 1184fcaf780bSMauro Carvalho Chehab { 1185fcaf780bSMauro Carvalho Chehab int pci_rc; 1186fcaf780bSMauro Carvalho Chehab 1187956b9ba1SJoe Perches edac_dbg(2, "\n"); 1188fcaf780bSMauro Carvalho Chehab 1189fcaf780bSMauro Carvalho Chehab /* Ensure that the OPSTATE is set correctly for POLL or NMI */ 1190fcaf780bSMauro Carvalho Chehab opstate_init(); 1191fcaf780bSMauro Carvalho Chehab 1192fcaf780bSMauro Carvalho Chehab pci_rc = pci_register_driver(&i7300_driver); 1193fcaf780bSMauro Carvalho Chehab 1194fcaf780bSMauro Carvalho Chehab return (pci_rc < 0) ? pci_rc : 0; 1195fcaf780bSMauro Carvalho Chehab } 1196fcaf780bSMauro Carvalho Chehab 1197d091a6ebSMauro Carvalho Chehab /** 1198d091a6ebSMauro Carvalho Chehab * i7300_init() - Unregisters the driver 1199fcaf780bSMauro Carvalho Chehab */ 1200fcaf780bSMauro Carvalho Chehab static void __exit i7300_exit(void) 1201fcaf780bSMauro Carvalho Chehab { 1202956b9ba1SJoe Perches edac_dbg(2, "\n"); 1203fcaf780bSMauro Carvalho Chehab pci_unregister_driver(&i7300_driver); 1204fcaf780bSMauro Carvalho Chehab } 1205fcaf780bSMauro Carvalho Chehab 1206fcaf780bSMauro Carvalho Chehab module_init(i7300_init); 1207fcaf780bSMauro Carvalho Chehab module_exit(i7300_exit); 1208fcaf780bSMauro Carvalho Chehab 1209fcaf780bSMauro Carvalho Chehab MODULE_LICENSE("GPL"); 1210fcaf780bSMauro Carvalho Chehab MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 1211fcaf780bSMauro Carvalho Chehab MODULE_AUTHOR("Red Hat Inc. (http://www.redhat.com)"); 1212fcaf780bSMauro Carvalho Chehab MODULE_DESCRIPTION("MC Driver for Intel I7300 memory controllers - " 1213fcaf780bSMauro Carvalho Chehab I7300_REVISION); 1214fcaf780bSMauro Carvalho Chehab 1215fcaf780bSMauro Carvalho Chehab module_param(edac_op_state, int, 0444); 1216fcaf780bSMauro Carvalho Chehab MODULE_PARM_DESC(edac_op_state, "EDAC Error Reporting state: 0=Poll,1=NMI"); 1217