i7300_edac: pre-allocate a buffer used to prepare err messages
[deliverable/linux.git] / drivers / edac / i7300_edac.c
CommitLineData
fcaf780b
MCC
1/*
2 * Intel 7300 class Memory Controllers kernel module (Clarksboro)
3 *
4 * This file may be distributed under the terms of the
5 * GNU General Public License version 2 only.
6 *
7 * Copyright (c) 2010 by:
8 * Mauro Carvalho Chehab <mchehab@redhat.com>
9 *
10 * Red Hat Inc. http://www.redhat.com
11 *
12 * Intel 7300 Chipset Memory Controller Hub (MCH) - Datasheet
13 * http://www.intel.com/Assets/PDF/datasheet/318082.pdf
14 *
15 * TODO: The chipset allow checking for PCI Express errors also. Currently,
16 * the driver covers only memory error errors
17 *
18 * This driver uses "csrows" EDAC attribute to represent DIMM slot#
19 */
20
21#include <linux/module.h>
22#include <linux/init.h>
23#include <linux/pci.h>
24#include <linux/pci_ids.h>
25#include <linux/slab.h>
26#include <linux/edac.h>
27#include <linux/mmzone.h>
28
29#include "edac_core.h"
30
31/*
32 * Alter this version for the I7300 module when modifications are made
33 */
34#define I7300_REVISION " Ver: 1.0.0 " __DATE__
35
36#define EDAC_MOD_STR "i7300_edac"
37
38#define i7300_printk(level, fmt, arg...) \
39 edac_printk(level, "i7300", fmt, ##arg)
40
41#define i7300_mc_printk(mci, level, fmt, arg...) \
42 edac_mc_chipset_printk(mci, level, "i7300", fmt, ##arg)
43
44/*
45 * Memory topology is organized as:
46 * Branch 0 - 2 channels: channels 0 and 1 (FDB0 PCI dev 21.0)
47 * Branch 1 - 2 channels: channels 2 and 3 (FDB1 PCI dev 22.0)
48 * Each channel can have to 8 DIMM sets (called as SLOTS)
49 * Slots should generally be filled in pairs
50 * Except on Single Channel mode of operation
51 * just slot 0/channel0 filled on this mode
52 * On normal operation mode, the two channels on a branch should be
c3af2eaf 53 * filled together for the same SLOT#
fcaf780b
MCC
54 * When in mirrored mode, Branch 1 replicate memory at Branch 0, so, the four
55 * channels on both branches should be filled
56 */
57
58/* Limits for i7300 */
59#define MAX_SLOTS 8
60#define MAX_BRANCHES 2
61#define MAX_CH_PER_BRANCH 2
62#define MAX_CHANNELS (MAX_CH_PER_BRANCH * MAX_BRANCHES)
63#define MAX_MIR 3
64
65#define to_channel(ch, branch) ((((branch)) << 1) | (ch))
66
67#define to_csrow(slot, ch, branch) \
68 (to_channel(ch, branch) | ((slot) << 2))
69
c3af2eaf
MCC
70/*
71 * I7300 devices
fcaf780b
MCC
72 * All 3 functions of Device 16 (0,1,2) share the SAME DID and
73 * uses PCI_DEVICE_ID_INTEL_I7300_MCH_ERR for device 16 (0,1,2),
74 * PCI_DEVICE_ID_INTEL_I7300_MCH_FB0 and PCI_DEVICE_ID_INTEL_I7300_MCH_FB1
75 * for device 21 (0,1).
c3af2eaf
MCC
76 */
77
78/****************************************************
79 * i7300 Register definitions for memory enumberation
80 ****************************************************/
81
82/*
83 * Device 16,
84 * Function 0: System Address (not documented)
85 * Function 1: Memory Branch Map, Control, Errors Register
fcaf780b
MCC
86 */
87
88 /* OFFSETS for Function 0 */
af3d8831
MCC
89#define AMBASE 0x48 /* AMB Mem Mapped Reg Region Base */
90#define MAXCH 0x56 /* Max Channel Number */
91#define MAXDIMMPERCH 0x57 /* Max DIMM PER Channel Number */
fcaf780b
MCC
92
93 /* OFFSETS for Function 1 */
af3d8831 94#define MC_SETTINGS 0x40
bb81a216
MCC
95 #define IS_MIRRORED(mc) ((mc) & (1 << 16))
96 #define IS_ECC_ENABLED(mc) ((mc) & (1 << 5))
97 #define IS_RETRY_ENABLED(mc) ((mc) & (1 << 31))
98 #define IS_SCRBALGO_ENHANCED(mc) ((mc) & (1 << 8))
fcaf780b 99
bb81a216
MCC
100#define MC_SETTINGS_A 0x58
101 #define IS_SINGLE_MODE(mca) ((mca) & (1 << 14))
d7de2bdb 102
af3d8831
MCC
103#define TOLM 0x6C
104#define REDMEMB 0x7C
105
106#define MIR0 0x80
107#define MIR1 0x84
108#define MIR2 0x88
fcaf780b 109
fcaf780b
MCC
110/*
111 * Note: Other Intel EDAC drivers use AMBPRESENT to identify if the available
112 * memory. From datasheet item 7.3.1 (FB-DIMM technology & organization), it
113 * seems that we cannot use this information directly for the same usage.
114 * Each memory slot may have up to 2 AMB interfaces, one for income and another
115 * for outcome interface to the next slot.
116 * For now, the driver just stores the AMB present registers, but rely only at
117 * the MTR info to detect memory.
118 * Datasheet is also not clear about how to map each AMBPRESENT registers to
119 * one of the 4 available channels.
120 */
121#define AMBPRESENT_0 0x64
122#define AMBPRESENT_1 0x66
123
124const static u16 mtr_regs [MAX_SLOTS] = {
125 0x80, 0x84, 0x88, 0x8c,
126 0x82, 0x86, 0x8a, 0x8e
127};
128
129/* Defines to extract the vaious fields from the
130 * MTRx - Memory Technology Registers
131 */
132#define MTR_DIMMS_PRESENT(mtr) ((mtr) & (1 << 8))
133#define MTR_DIMMS_ETHROTTLE(mtr) ((mtr) & (1 << 7))
134#define MTR_DRAM_WIDTH(mtr) (((mtr) & (1 << 6)) ? 8 : 4)
135#define MTR_DRAM_BANKS(mtr) (((mtr) & (1 << 5)) ? 8 : 4)
136#define MTR_DIMM_RANKS(mtr) (((mtr) & (1 << 4)) ? 1 : 0)
137#define MTR_DIMM_ROWS(mtr) (((mtr) >> 2) & 0x3)
138#define MTR_DRAM_BANKS_ADDR_BITS 2
139#define MTR_DIMM_ROWS_ADDR_BITS(mtr) (MTR_DIMM_ROWS(mtr) + 13)
140#define MTR_DIMM_COLS(mtr) ((mtr) & 0x3)
141#define MTR_DIMM_COLS_ADDR_BITS(mtr) (MTR_DIMM_COLS(mtr) + 10)
142
fcaf780b
MCC
143#ifdef CONFIG_EDAC_DEBUG
144/* MTR NUMROW */
145static const char *numrow_toString[] = {
146 "8,192 - 13 rows",
147 "16,384 - 14 rows",
148 "32,768 - 15 rows",
149 "65,536 - 16 rows"
150};
151
152/* MTR NUMCOL */
153static const char *numcol_toString[] = {
154 "1,024 - 10 columns",
155 "2,048 - 11 columns",
156 "4,096 - 12 columns",
157 "reserved"
158};
159#endif
160
c3af2eaf
MCC
161/************************************************
162 * i7300 Register definitions for error detection
163 ************************************************/
57021918
MCC
164
165/*
166 * Device 16.1: FBD Error Registers
167 */
168#define FERR_FAT_FBD 0x98
169static const char *ferr_fat_fbd_name[] = {
170 [22] = "Non-Redundant Fast Reset Timeout",
171 [2] = ">Tmid Thermal event with intelligent throttling disabled",
172 [1] = "Memory or FBD configuration CRC read error",
173 [0] = "Memory Write error on non-redundant retry or "
174 "FBD configuration Write error on retry",
175};
176#define GET_FBD_FAT_IDX(fbderr) (fbderr & (3 << 28))
177#define FERR_FAT_FBD_ERR_MASK ((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3))
178
179#define FERR_NF_FBD 0xa0
180static const char *ferr_nf_fbd_name[] = {
181 [24] = "DIMM-Spare Copy Completed",
182 [23] = "DIMM-Spare Copy Initiated",
183 [22] = "Redundant Fast Reset Timeout",
184 [21] = "Memory Write error on redundant retry",
185 [18] = "SPD protocol Error",
186 [17] = "FBD Northbound parity error on FBD Sync Status",
187 [16] = "Correctable Patrol Data ECC",
188 [15] = "Correctable Resilver- or Spare-Copy Data ECC",
189 [14] = "Correctable Mirrored Demand Data ECC",
190 [13] = "Correctable Non-Mirrored Demand Data ECC",
191 [11] = "Memory or FBD configuration CRC read error",
192 [10] = "FBD Configuration Write error on first attempt",
193 [9] = "Memory Write error on first attempt",
194 [8] = "Non-Aliased Uncorrectable Patrol Data ECC",
195 [7] = "Non-Aliased Uncorrectable Resilver- or Spare-Copy Data ECC",
196 [6] = "Non-Aliased Uncorrectable Mirrored Demand Data ECC",
197 [5] = "Non-Aliased Uncorrectable Non-Mirrored Demand Data ECC",
198 [4] = "Aliased Uncorrectable Patrol Data ECC",
199 [3] = "Aliased Uncorrectable Resilver- or Spare-Copy Data ECC",
200 [2] = "Aliased Uncorrectable Mirrored Demand Data ECC",
201 [1] = "Aliased Uncorrectable Non-Mirrored Demand Data ECC",
202 [0] = "Uncorrectable Data ECC on Replay",
203};
204#define GET_FBD_NF_IDX(fbderr) (fbderr & (3 << 28))
205#define FERR_NF_FBD_ERR_MASK ((1 << 24) | (1 << 23) | (1 << 22) | (1 << 21) |\
206 (1 << 18) | (1 << 17) | (1 << 16) | (1 << 15) |\
207 (1 << 14) | (1 << 13) | (1 << 11) | (1 << 10) |\
208 (1 << 9) | (1 << 8) | (1 << 7) | (1 << 6) |\
209 (1 << 5) | (1 << 4) | (1 << 3) | (1 << 2) |\
210 (1 << 1) | (1 << 0))
211
212#define EMASK_FBD 0xa8
213#define EMASK_FBD_ERR_MASK ((1 << 27) | (1 << 26) | (1 << 25) | (1 << 24) |\
214 (1 << 22) | (1 << 21) | (1 << 20) | (1 << 19) |\
215 (1 << 18) | (1 << 17) | (1 << 16) | (1 << 14) |\
216 (1 << 13) | (1 << 12) | (1 << 11) | (1 << 10) |\
217 (1 << 9) | (1 << 8) | (1 << 7) | (1 << 6) |\
218 (1 << 5) | (1 << 4) | (1 << 3) | (1 << 2) |\
219 (1 << 1) | (1 << 0))
220
c3af2eaf
MCC
221/*
222 * Device 16.2: Global Error Registers
223 */
224
5de6e07e
MCC
225#define FERR_GLOBAL_HI 0x48
226static const char *ferr_global_hi_name[] = {
227 [3] = "FSB 3 Fatal Error",
228 [2] = "FSB 2 Fatal Error",
229 [1] = "FSB 1 Fatal Error",
230 [0] = "FSB 0 Fatal Error",
231};
232#define ferr_global_hi_is_fatal(errno) 1
233
c3af2eaf 234#define FERR_GLOBAL_LO 0x40
5de6e07e 235static const char *ferr_global_lo_name[] = {
c3af2eaf
MCC
236 [31] = "Internal MCH Fatal Error",
237 [30] = "Intel QuickData Technology Device Fatal Error",
238 [29] = "FSB1 Fatal Error",
239 [28] = "FSB0 Fatal Error",
240 [27] = "FBD Channel 3 Fatal Error",
241 [26] = "FBD Channel 2 Fatal Error",
242 [25] = "FBD Channel 1 Fatal Error",
243 [24] = "FBD Channel 0 Fatal Error",
244 [23] = "PCI Express Device 7Fatal Error",
245 [22] = "PCI Express Device 6 Fatal Error",
246 [21] = "PCI Express Device 5 Fatal Error",
247 [20] = "PCI Express Device 4 Fatal Error",
248 [19] = "PCI Express Device 3 Fatal Error",
249 [18] = "PCI Express Device 2 Fatal Error",
250 [17] = "PCI Express Device 1 Fatal Error",
251 [16] = "ESI Fatal Error",
252 [15] = "Internal MCH Non-Fatal Error",
253 [14] = "Intel QuickData Technology Device Non Fatal Error",
254 [13] = "FSB1 Non-Fatal Error",
255 [12] = "FSB 0 Non-Fatal Error",
256 [11] = "FBD Channel 3 Non-Fatal Error",
257 [10] = "FBD Channel 2 Non-Fatal Error",
258 [9] = "FBD Channel 1 Non-Fatal Error",
259 [8] = "FBD Channel 0 Non-Fatal Error",
260 [7] = "PCI Express Device 7 Non-Fatal Error",
261 [6] = "PCI Express Device 6 Non-Fatal Error",
262 [5] = "PCI Express Device 5 Non-Fatal Error",
263 [4] = "PCI Express Device 4 Non-Fatal Error",
264 [3] = "PCI Express Device 3 Non-Fatal Error",
265 [2] = "PCI Express Device 2 Non-Fatal Error",
266 [1] = "PCI Express Device 1 Non-Fatal Error",
267 [0] = "ESI Non-Fatal Error",
268};
5de6e07e 269#define ferr_global_lo_is_fatal(errno) ((errno < 16) ? 0 : 1)
fcaf780b
MCC
270
271/* Device name and register DID (Device ID) */
272struct i7300_dev_info {
273 const char *ctl_name; /* name for this device */
274 u16 fsb_mapping_errors; /* DID for the branchmap,control */
275};
276
277/* Table of devices attributes supported by this driver */
278static const struct i7300_dev_info i7300_devs[] = {
279 {
280 .ctl_name = "I7300",
281 .fsb_mapping_errors = PCI_DEVICE_ID_INTEL_I7300_MCH_ERR,
282 },
283};
284
285struct i7300_dimm_info {
286 int megabytes; /* size, 0 means not present */
287};
288
289/* driver private data structure */
290struct i7300_pvt {
3e57eef6
MCC
291 struct pci_dev *pci_dev_16_0_fsb_ctlr; /* 16.0 */
292 struct pci_dev *pci_dev_16_1_fsb_addr_map; /* 16.1 */
293 struct pci_dev *pci_dev_16_2_fsb_err_regs; /* 16.2 */
294 struct pci_dev *pci_dev_2x_0_fbd_branch[MAX_BRANCHES]; /* 21.0 and 22.0 */
fcaf780b
MCC
295
296 u16 tolm; /* top of low memory */
297 u64 ambase; /* AMB BAR */
298
bb81a216
MCC
299 u32 mc_settings; /* Report several settings */
300 u32 mc_settings_a;
301
302 u16 mir[MAX_MIR]; /* Memory Interleave Reg*/
fcaf780b
MCC
303
304 u16 mtr[MAX_SLOTS][MAX_BRANCHES]; /* Memory Technlogy Reg */
305 u16 ambpresent[MAX_CHANNELS]; /* AMB present regs */
306
307 /* DIMM information matrix, allocating architecture maximums */
308 struct i7300_dimm_info dimm_info[MAX_SLOTS][MAX_CHANNELS];
85580ea4
MCC
309
310 /* Temporary buffer for use when preparing error messages */
311 char *tmp_prt_buffer;
fcaf780b
MCC
312};
313
fcaf780b
MCC
314/* FIXME: Why do we need to have this static? */
315static struct edac_pci_ctl_info *i7300_pci;
316
5de6e07e
MCC
317/********************************************
318 * i7300 Functions related to error detection
319 ********************************************/
fcaf780b 320
5de6e07e 321const char *get_err_from_table(const char *table[], int size, int pos)
fcaf780b 322{
5de6e07e
MCC
323 if (pos >= size)
324 return "Reserved";
325
326 return table[pos];
fcaf780b
MCC
327}
328
5de6e07e
MCC
329#define GET_ERR_FROM_TABLE(table, pos) \
330 get_err_from_table(table, ARRAY_SIZE(table), pos)
331
fcaf780b 332/*
5de6e07e
MCC
333 * i7300_process_error_global Retrieve the hardware error information from
334 * the hardware and cache it in the 'info'
335 * structure
fcaf780b 336 */
f4277422 337static void i7300_process_error_global(struct mem_ctl_info *mci)
fcaf780b 338{
5de6e07e
MCC
339 struct i7300_pvt *pvt;
340 u32 errnum, value;
341 unsigned long errors;
342 const char *specific;
343 bool is_fatal;
fcaf780b 344
5de6e07e 345 pvt = mci->pvt_info;
fcaf780b 346
5de6e07e
MCC
347 /* read in the 1st FATAL error register */
348 pci_read_config_dword(pvt->pci_dev_16_2_fsb_err_regs,
349 FERR_GLOBAL_HI, &value);
350 if (unlikely(value)) {
351 errors = value;
352 errnum = find_first_bit(&errors,
353 ARRAY_SIZE(ferr_global_hi_name));
354 specific = GET_ERR_FROM_TABLE(ferr_global_hi_name, errnum);
355 is_fatal = ferr_global_hi_is_fatal(errnum);
86002324
MCC
356
357 /* Clear the error bit */
358 pci_write_config_dword(pvt->pci_dev_16_2_fsb_err_regs,
359 FERR_GLOBAL_HI, value);
360
5de6e07e 361 goto error_global;
fcaf780b
MCC
362 }
363
5de6e07e
MCC
364 pci_read_config_dword(pvt->pci_dev_16_2_fsb_err_regs,
365 FERR_GLOBAL_LO, &value);
366 if (unlikely(value)) {
367 errors = value;
368 errnum = find_first_bit(&errors,
369 ARRAY_SIZE(ferr_global_lo_name));
370 specific = GET_ERR_FROM_TABLE(ferr_global_lo_name, errnum);
371 is_fatal = ferr_global_lo_is_fatal(errnum);
86002324
MCC
372
373 /* Clear the error bit */
374 pci_write_config_dword(pvt->pci_dev_16_2_fsb_err_regs,
375 FERR_GLOBAL_LO, value);
376
5de6e07e
MCC
377 goto error_global;
378 }
379 return;
fcaf780b 380
5de6e07e
MCC
381error_global:
382 i7300_mc_printk(mci, KERN_EMERG, "%s misc error: %s\n",
383 is_fatal ? "Fatal" : "NOT fatal", specific);
fcaf780b
MCC
384}
385
57021918
MCC
386/*
387 * i7300_process_fbd_error Retrieve the hardware error information from
388 * the hardware and cache it in the 'info'
389 * structure
390 */
f4277422 391static void i7300_process_fbd_error(struct mem_ctl_info *mci)
57021918
MCC
392{
393 struct i7300_pvt *pvt;
394 u32 errnum, value;
395 int branch;
396 unsigned long errors;
397 const char *specific;
398 bool is_fatal;
399
400 pvt = mci->pvt_info;
401
402 /* read in the 1st FATAL error register */
403 pci_read_config_dword(pvt->pci_dev_16_1_fsb_addr_map,
404 FERR_FAT_FBD, &value);
405 if (unlikely(value & FERR_FAT_FBD_ERR_MASK)) {
406 errors = value & FERR_FAT_FBD_ERR_MASK ;
407 errnum = find_first_bit(&errors,
408 ARRAY_SIZE(ferr_fat_fbd_name));
409 specific = GET_ERR_FROM_TABLE(ferr_fat_fbd_name, errnum);
410 is_fatal = 1;
411
412 branch = (GET_FBD_FAT_IDX(value) == 2) ? 1 : 0;
413
414 goto error_fbd;
415 }
416
417 /* read in the 1st NON-FATAL error register */
418 pci_read_config_dword(pvt->pci_dev_16_1_fsb_addr_map,
419 FERR_NF_FBD, &value);
420 if (unlikely(value & FERR_NF_FBD_ERR_MASK)) {
421 errors = value & FERR_NF_FBD_ERR_MASK;
422 errnum = find_first_bit(&errors,
423 ARRAY_SIZE(ferr_nf_fbd_name));
424 specific = GET_ERR_FROM_TABLE(ferr_nf_fbd_name, errnum);
425 is_fatal = 0;
426
427 /* Clear the error bit */
428 pci_write_config_dword(pvt->pci_dev_16_2_fsb_err_regs,
429 FERR_GLOBAL_LO, value);
430
431 goto error_fbd;
432 }
433 return;
434
435error_fbd:
436 i7300_mc_printk(mci, KERN_EMERG, "%s FBD error on branch %d: %s\n",
437 is_fatal ? "Fatal" : "NOT fatal", branch, specific);
438}
439
fcaf780b 440/*
f4277422 441 * i7300_check_error Retrieve the hardware error information from
5de6e07e
MCC
442 * the hardware and cache it in the 'info'
443 * structure
fcaf780b 444 */
f4277422 445static void i7300_check_error(struct mem_ctl_info *mci)
5de6e07e 446{
f4277422
MCC
447 i7300_process_error_global(mci);
448 i7300_process_fbd_error(mci);
5de6e07e 449};
fcaf780b
MCC
450
451/*
452 * i7300_clear_error Retrieve any error from the hardware
453 * but do NOT process that error.
454 * Used for 'clearing' out of previous errors
455 * Called by the Core module.
456 */
457static void i7300_clear_error(struct mem_ctl_info *mci)
458{
e4327605
MCC
459 struct i7300_pvt *pvt = mci->pvt_info;
460 u32 value;
461 /*
462 * All error values are RWC - we need to read and write 1 to the
463 * bit that we want to cleanup
464 */
fcaf780b 465
e4327605
MCC
466 /* Clear global error registers */
467 pci_read_config_dword(pvt->pci_dev_16_2_fsb_err_regs,
468 FERR_GLOBAL_HI, &value);
469 pci_write_config_dword(pvt->pci_dev_16_2_fsb_err_regs,
470 FERR_GLOBAL_HI, value);
471
472 pci_read_config_dword(pvt->pci_dev_16_2_fsb_err_regs,
473 FERR_GLOBAL_LO, &value);
474 pci_write_config_dword(pvt->pci_dev_16_2_fsb_err_regs,
475 FERR_GLOBAL_LO, value);
476
477 /* Clear FBD error registers */
478 pci_read_config_dword(pvt->pci_dev_16_1_fsb_addr_map,
479 FERR_FAT_FBD, &value);
480 pci_write_config_dword(pvt->pci_dev_16_1_fsb_addr_map,
481 FERR_FAT_FBD, value);
482
483 pci_read_config_dword(pvt->pci_dev_16_1_fsb_addr_map,
484 FERR_NF_FBD, &value);
485 pci_write_config_dword(pvt->pci_dev_16_1_fsb_addr_map,
486 FERR_NF_FBD, value);
fcaf780b
MCC
487}
488
fcaf780b
MCC
489/*
490 * i7300_enable_error_reporting
491 * Turn on the memory reporting features of the hardware
492 */
493static void i7300_enable_error_reporting(struct mem_ctl_info *mci)
494{
57021918
MCC
495 struct i7300_pvt *pvt = mci->pvt_info;
496 u32 fbd_error_mask;
497
498 /* Read the FBD Error Mask Register */
499 pci_read_config_dword(pvt->pci_dev_16_1_fsb_addr_map,
500 EMASK_FBD, &fbd_error_mask);
501
502 /* Enable with a '0' */
503 fbd_error_mask &= ~(EMASK_FBD_ERR_MASK);
504
505 pci_write_config_dword(pvt->pci_dev_16_1_fsb_addr_map,
506 EMASK_FBD, fbd_error_mask);
fcaf780b 507}
5de6e07e
MCC
508
509/************************************************
510 * i7300 Functions related to memory enumberation
511 ************************************************/
fcaf780b
MCC
512
513/*
514 * determine_mtr(pvt, csrow, channel)
515 *
516 * return the proper MTR register as determine by the csrow and desired channel
517 */
518static int decode_mtr(struct i7300_pvt *pvt,
519 int slot, int ch, int branch,
520 struct i7300_dimm_info *dinfo,
521 struct csrow_info *p_csrow)
522{
523 int mtr, ans, addrBits, channel;
524
525 channel = to_channel(ch, branch);
526
527 mtr = pvt->mtr[slot][branch];
528 ans = MTR_DIMMS_PRESENT(mtr) ? 1 : 0;
529
530 debugf2("\tMTR%d CH%d: DIMMs are %s (mtr)\n",
531 slot, channel,
532 ans ? "Present" : "NOT Present");
533
534 /* Determine if there is a DIMM present in this DIMM slot */
535
536#if 0
537 if (!amb_present || !ans)
538 return 0;
539#else
540 if (!ans)
541 return 0;
542#endif
543
544 /* Start with the number of bits for a Bank
545 * on the DRAM */
546 addrBits = MTR_DRAM_BANKS_ADDR_BITS;
547 /* Add thenumber of ROW bits */
548 addrBits += MTR_DIMM_ROWS_ADDR_BITS(mtr);
549 /* add the number of COLUMN bits */
550 addrBits += MTR_DIMM_COLS_ADDR_BITS(mtr);
551 /* add the number of RANK bits */
552 addrBits += MTR_DIMM_RANKS(mtr);
553
554 addrBits += 6; /* add 64 bits per DIMM */
555 addrBits -= 20; /* divide by 2^^20 */
556 addrBits -= 3; /* 8 bits per bytes */
557
558 dinfo->megabytes = 1 << addrBits;
559
560 debugf2("\t\tWIDTH: x%d\n", MTR_DRAM_WIDTH(mtr));
561
562 debugf2("\t\tELECTRICAL THROTTLING is %s\n",
563 MTR_DIMMS_ETHROTTLE(mtr) ? "enabled" : "disabled");
564
565 debugf2("\t\tNUMBANK: %d bank(s)\n", MTR_DRAM_BANKS(mtr));
566 debugf2("\t\tNUMRANK: %s\n", MTR_DIMM_RANKS(mtr) ? "double" : "single");
567 debugf2("\t\tNUMROW: %s\n", numrow_toString[MTR_DIMM_ROWS(mtr)]);
568 debugf2("\t\tNUMCOL: %s\n", numcol_toString[MTR_DIMM_COLS(mtr)]);
569 debugf2("\t\tSIZE: %d MB\n", dinfo->megabytes);
570
571 p_csrow->grain = 8;
572 p_csrow->nr_pages = dinfo->megabytes << 8;
573 p_csrow->mtype = MEM_FB_DDR2;
116389ed
MCC
574
575 /*
15154c57 576 * The type of error detection actually depends of the
116389ed 577 * mode of operation. When it is just one single memory chip, at
15154c57
MCC
578 * socket 0, channel 0, it uses 8-byte-over-32-byte SECDED+ code.
579 * In normal or mirrored mode, it uses Lockstep mode,
116389ed
MCC
580 * with the possibility of using an extended algorithm for x8 memories
581 * See datasheet Sections 7.3.6 to 7.3.8
582 */
15154c57
MCC
583
584 if (IS_SINGLE_MODE(pvt->mc_settings_a)) {
585 p_csrow->edac_mode = EDAC_SECDED;
3b330f67 586 debugf2("\t\tECC code is 8-byte-over-32-byte SECDED+ code\n");
15154c57 587 } else {
3b330f67 588 debugf2("\t\tECC code is on Lockstep mode\n");
28c2ce7c 589 if (MTR_DRAM_WIDTH(mtr) == 8)
15154c57
MCC
590 p_csrow->edac_mode = EDAC_S8ECD8ED;
591 else
592 p_csrow->edac_mode = EDAC_S4ECD4ED;
593 }
fcaf780b
MCC
594
595 /* ask what device type on this row */
28c2ce7c 596 if (MTR_DRAM_WIDTH(mtr) == 8) {
3b330f67 597 debugf2("\t\tScrub algorithm for x8 is on %s mode\n",
d7de2bdb
MCC
598 IS_SCRBALGO_ENHANCED(pvt->mc_settings) ?
599 "enhanced" : "normal");
600
fcaf780b 601 p_csrow->dtype = DEV_X8;
d7de2bdb 602 } else
fcaf780b
MCC
603 p_csrow->dtype = DEV_X4;
604
605 return mtr;
606}
607
608/*
609 * print_dimm_size
610 *
611 * also will output a DIMM matrix map, if debug is enabled, for viewing
612 * how the DIMMs are populated
613 */
614static void print_dimm_size(struct i7300_pvt *pvt)
615{
616 struct i7300_dimm_info *dinfo;
85580ea4 617 char *p;
fcaf780b
MCC
618 int space, n;
619 int channel, slot;
620
621 space = PAGE_SIZE;
85580ea4 622 p = pvt->tmp_prt_buffer;
fcaf780b
MCC
623
624 n = snprintf(p, space, " ");
625 p += n;
626 space -= n;
627 for (channel = 0; channel < MAX_CHANNELS; channel++) {
628 n = snprintf(p, space, "channel %d | ", channel);
629 p += n;
630 space -= n;
631 }
85580ea4
MCC
632 debugf2("%s\n", pvt->tmp_prt_buffer);
633 p = pvt->tmp_prt_buffer;
fcaf780b
MCC
634 space = PAGE_SIZE;
635 n = snprintf(p, space, "-------------------------------"
636 "------------------------------");
637 p += n;
638 space -= n;
85580ea4
MCC
639 debugf2("%s\n", pvt->tmp_prt_buffer);
640 p = pvt->tmp_prt_buffer;
fcaf780b
MCC
641 space = PAGE_SIZE;
642
643 for (slot = 0; slot < MAX_SLOTS; slot++) {
644 n = snprintf(p, space, "csrow/SLOT %d ", slot);
645 p += n;
646 space -= n;
647
648 for (channel = 0; channel < MAX_CHANNELS; channel++) {
649 dinfo = &pvt->dimm_info[slot][channel];
650 n = snprintf(p, space, "%4d MB | ", dinfo->megabytes);
651 p += n;
652 space -= n;
653 }
654
85580ea4
MCC
655 debugf2("%s\n", pvt->tmp_prt_buffer);
656 p = pvt->tmp_prt_buffer;
fcaf780b
MCC
657 space = PAGE_SIZE;
658 }
659
660 n = snprintf(p, space, "-------------------------------"
661 "------------------------------");
662 p += n;
663 space -= n;
85580ea4
MCC
664 debugf2("%s\n", pvt->tmp_prt_buffer);
665 p = pvt->tmp_prt_buffer;
fcaf780b 666 space = PAGE_SIZE;
fcaf780b
MCC
667}
668
669/*
670 * i7300_init_csrows Initialize the 'csrows' table within
671 * the mci control structure with the
672 * addressing of memory.
673 *
674 * return:
675 * 0 success
676 * 1 no actual memory found on this MC
677 */
678static int i7300_init_csrows(struct mem_ctl_info *mci)
679{
680 struct i7300_pvt *pvt;
681 struct i7300_dimm_info *dinfo;
682 struct csrow_info *p_csrow;
683 int empty;
684 int mtr;
685 int ch, branch, slot, channel;
686
687 pvt = mci->pvt_info;
688
689 empty = 1; /* Assume NO memory */
690
691 debugf2("Memory Technology Registers:\n");
692
693 /* Get the AMB present registers for the four channels */
694 for (branch = 0; branch < MAX_BRANCHES; branch++) {
695 /* Read and dump branch 0's MTRs */
696 channel = to_channel(0, branch);
3e57eef6 697 pci_read_config_word(pvt->pci_dev_2x_0_fbd_branch[branch], AMBPRESENT_0,
fcaf780b
MCC
698 &pvt->ambpresent[channel]);
699 debugf2("\t\tAMB-present CH%d = 0x%x:\n",
700 channel, pvt->ambpresent[channel]);
701
702 channel = to_channel(1, branch);
3e57eef6 703 pci_read_config_word(pvt->pci_dev_2x_0_fbd_branch[branch], AMBPRESENT_1,
fcaf780b
MCC
704 &pvt->ambpresent[channel]);
705 debugf2("\t\tAMB-present CH%d = 0x%x:\n",
706 channel, pvt->ambpresent[channel]);
707 }
708
709 /* Get the set of MTR[0-7] regs by each branch */
710 for (slot = 0; slot < MAX_SLOTS; slot++) {
711 int where = mtr_regs[slot];
712 for (branch = 0; branch < MAX_BRANCHES; branch++) {
3e57eef6 713 pci_read_config_word(pvt->pci_dev_2x_0_fbd_branch[branch],
fcaf780b
MCC
714 where,
715 &pvt->mtr[slot][branch]);
716 for (ch = 0; ch < MAX_BRANCHES; ch++) {
717 int channel = to_channel(ch, branch);
718
719 dinfo = &pvt->dimm_info[slot][channel];
720 p_csrow = &mci->csrows[slot];
721
722 mtr = decode_mtr(pvt, slot, ch, branch,
723 dinfo, p_csrow);
724 /* if no DIMMS on this row, continue */
725 if (!MTR_DIMMS_PRESENT(mtr))
726 continue;
727
728 p_csrow->csrow_idx = slot;
729
730 /* FAKE OUT VALUES, FIXME */
731 p_csrow->first_page = 0 + slot * 20;
732 p_csrow->last_page = 9 + slot * 20;
733 p_csrow->page_mask = 0xfff;
734
735 empty = 0;
736 }
737 }
738 }
739
740 return empty;
741}
742
743static void decode_mir(int mir_no, u16 mir[MAX_MIR])
744{
745 if (mir[mir_no] & 3)
746 debugf2("MIR%d: limit= 0x%x Branch(es) that participate: %s %s\n",
747 mir_no,
748 (mir[mir_no] >> 4) & 0xfff,
749 (mir[mir_no] & 1) ? "B0" : "",
750 (mir[mir_no] & 2) ? "B1": "");
751}
752
753/*
754 * i7300_get_mc_regs read in the necessary registers and
755 * cache locally
756 *
757 * Fills in the private data members
758 */
759static int i7300_get_mc_regs(struct mem_ctl_info *mci)
760{
761 struct i7300_pvt *pvt;
762 u32 actual_tolm;
763 int i, rc;
764
765 pvt = mci->pvt_info;
766
3e57eef6 767 pci_read_config_dword(pvt->pci_dev_16_0_fsb_ctlr, AMBASE,
fcaf780b
MCC
768 (u32 *) &pvt->ambase);
769
770 debugf2("AMBASE= 0x%lx\n", (long unsigned int)pvt->ambase);
771
772 /* Get the Branch Map regs */
3e57eef6 773 pci_read_config_word(pvt->pci_dev_16_1_fsb_addr_map, TOLM, &pvt->tolm);
fcaf780b
MCC
774 pvt->tolm >>= 12;
775 debugf2("TOLM (number of 256M regions) =%u (0x%x)\n", pvt->tolm,
776 pvt->tolm);
777
778 actual_tolm = (u32) ((1000l * pvt->tolm) >> (30 - 28));
779 debugf2("Actual TOLM byte addr=%u.%03u GB (0x%x)\n",
780 actual_tolm/1000, actual_tolm % 1000, pvt->tolm << 28);
781
af3d8831 782 /* Get memory controller settings */
3e57eef6 783 pci_read_config_dword(pvt->pci_dev_16_1_fsb_addr_map, MC_SETTINGS,
af3d8831 784 &pvt->mc_settings);
bb81a216
MCC
785 pci_read_config_dword(pvt->pci_dev_16_1_fsb_addr_map, MC_SETTINGS_A,
786 &pvt->mc_settings_a);
d7de2bdb 787
bb81a216
MCC
788 if (IS_SINGLE_MODE(pvt->mc_settings_a))
789 debugf0("Memory controller operating on single mode\n");
790 else
791 debugf0("Memory controller operating on %s mode\n",
d7de2bdb 792 IS_MIRRORED(pvt->mc_settings) ? "mirrored" : "non-mirrored");
bb81a216 793
af3d8831 794 debugf0("Error detection is %s\n",
d7de2bdb
MCC
795 IS_ECC_ENABLED(pvt->mc_settings) ? "enabled" : "disabled");
796 debugf0("Retry is %s\n",
797 IS_RETRY_ENABLED(pvt->mc_settings) ? "enabled" : "disabled");
af3d8831
MCC
798
799 /* Get Memory Interleave Range registers */
3e57eef6
MCC
800 pci_read_config_word(pvt->pci_dev_16_1_fsb_addr_map, MIR0, &pvt->mir[0]);
801 pci_read_config_word(pvt->pci_dev_16_1_fsb_addr_map, MIR1, &pvt->mir[1]);
802 pci_read_config_word(pvt->pci_dev_16_1_fsb_addr_map, MIR2, &pvt->mir[2]);
fcaf780b
MCC
803
804 /* Decode the MIR regs */
805 for (i = 0; i < MAX_MIR; i++)
806 decode_mir(i, pvt->mir);
807
808 rc = i7300_init_csrows(mci);
809 if (rc < 0)
810 return rc;
811
812 /* Go and determine the size of each DIMM and place in an
813 * orderly matrix */
814 print_dimm_size(pvt);
815
816 return 0;
817}
818
5de6e07e
MCC
819/*************************************************
820 * i7300 Functions related to device probe/release
821 *************************************************/
822
fcaf780b
MCC
823/*
824 * i7300_put_devices 'put' all the devices that we have
825 * reserved via 'get'
826 */
827static void i7300_put_devices(struct mem_ctl_info *mci)
828{
829 struct i7300_pvt *pvt;
830 int branch;
831
832 pvt = mci->pvt_info;
833
834 /* Decrement usage count for devices */
835 for (branch = 0; branch < MAX_CH_PER_BRANCH; branch++)
3e57eef6
MCC
836 pci_dev_put(pvt->pci_dev_2x_0_fbd_branch[branch]);
837 pci_dev_put(pvt->pci_dev_16_2_fsb_err_regs);
838 pci_dev_put(pvt->pci_dev_16_1_fsb_addr_map);
fcaf780b
MCC
839}
840
841/*
842 * i7300_get_devices Find and perform 'get' operation on the MCH's
843 * device/functions we want to reference for this driver
844 *
845 * Need to 'get' device 16 func 1 and func 2
846 */
847static int i7300_get_devices(struct mem_ctl_info *mci, int dev_idx)
848{
849 struct i7300_pvt *pvt;
850 struct pci_dev *pdev;
851
852 pvt = mci->pvt_info;
853
854 /* Attempt to 'get' the MCH register we want */
855 pdev = NULL;
3e57eef6 856 while (!pvt->pci_dev_16_1_fsb_addr_map || !pvt->pci_dev_16_2_fsb_err_regs) {
fcaf780b
MCC
857 pdev = pci_get_device(PCI_VENDOR_ID_INTEL,
858 PCI_DEVICE_ID_INTEL_I7300_MCH_ERR, pdev);
859 if (!pdev) {
860 /* End of list, leave */
861 i7300_printk(KERN_ERR,
862 "'system address,Process Bus' "
863 "device not found:"
864 "vendor 0x%x device 0x%x ERR funcs "
865 "(broken BIOS?)\n",
866 PCI_VENDOR_ID_INTEL,
867 PCI_DEVICE_ID_INTEL_I7300_MCH_ERR);
868 goto error;
869 }
870
871 /* Store device 16 funcs 1 and 2 */
872 switch (PCI_FUNC(pdev->devfn)) {
873 case 1:
3e57eef6 874 pvt->pci_dev_16_1_fsb_addr_map = pdev;
fcaf780b
MCC
875 break;
876 case 2:
3e57eef6 877 pvt->pci_dev_16_2_fsb_err_regs = pdev;
fcaf780b
MCC
878 break;
879 }
880 }
881
882 debugf1("System Address, processor bus- PCI Bus ID: %s %x:%x\n",
3e57eef6
MCC
883 pci_name(pvt->pci_dev_16_0_fsb_ctlr),
884 pvt->pci_dev_16_0_fsb_ctlr->vendor, pvt->pci_dev_16_0_fsb_ctlr->device);
fcaf780b 885 debugf1("Branchmap, control and errors - PCI Bus ID: %s %x:%x\n",
3e57eef6
MCC
886 pci_name(pvt->pci_dev_16_1_fsb_addr_map),
887 pvt->pci_dev_16_1_fsb_addr_map->vendor, pvt->pci_dev_16_1_fsb_addr_map->device);
fcaf780b 888 debugf1("FSB Error Regs - PCI Bus ID: %s %x:%x\n",
3e57eef6
MCC
889 pci_name(pvt->pci_dev_16_2_fsb_err_regs),
890 pvt->pci_dev_16_2_fsb_err_regs->vendor, pvt->pci_dev_16_2_fsb_err_regs->device);
fcaf780b 891
3e57eef6 892 pvt->pci_dev_2x_0_fbd_branch[0] = pci_get_device(PCI_VENDOR_ID_INTEL,
fcaf780b
MCC
893 PCI_DEVICE_ID_INTEL_I7300_MCH_FB0,
894 NULL);
3e57eef6 895 if (!pvt->pci_dev_2x_0_fbd_branch[0]) {
fcaf780b
MCC
896 i7300_printk(KERN_ERR,
897 "MC: 'BRANCH 0' device not found:"
898 "vendor 0x%x device 0x%x Func 0 (broken BIOS?)\n",
899 PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_I7300_MCH_FB0);
900 goto error;
901 }
902
3e57eef6 903 pvt->pci_dev_2x_0_fbd_branch[1] = pci_get_device(PCI_VENDOR_ID_INTEL,
fcaf780b
MCC
904 PCI_DEVICE_ID_INTEL_I7300_MCH_FB1,
905 NULL);
3e57eef6 906 if (!pvt->pci_dev_2x_0_fbd_branch[1]) {
fcaf780b
MCC
907 i7300_printk(KERN_ERR,
908 "MC: 'BRANCH 1' device not found:"
909 "vendor 0x%x device 0x%x Func 0 "
910 "(broken BIOS?)\n",
911 PCI_VENDOR_ID_INTEL,
912 PCI_DEVICE_ID_INTEL_I7300_MCH_FB1);
913 goto error;
914 }
915
916 return 0;
917
918error:
919 i7300_put_devices(mci);
920 return -ENODEV;
921}
922
923/*
924 * i7300_probe1 Probe for ONE instance of device to see if it is
925 * present.
926 * return:
927 * 0 for FOUND a device
928 * < 0 for error code
929 */
930static int i7300_probe1(struct pci_dev *pdev, int dev_idx)
931{
932 struct mem_ctl_info *mci;
933 struct i7300_pvt *pvt;
934 int num_channels;
935 int num_dimms_per_channel;
936 int num_csrows;
937
938 if (dev_idx >= ARRAY_SIZE(i7300_devs))
939 return -EINVAL;
940
941 debugf0("MC: " __FILE__ ": %s(), pdev bus %u dev=0x%x fn=0x%x\n",
942 __func__,
943 pdev->bus->number,
944 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
945
946 /* We only are looking for func 0 of the set */
947 if (PCI_FUNC(pdev->devfn) != 0)
948 return -ENODEV;
949
950 /* As we don't have a motherboard identification routine to determine
951 * actual number of slots/dimms per channel, we thus utilize the
952 * resource as specified by the chipset. Thus, we might have
953 * have more DIMMs per channel than actually on the mobo, but this
954 * allows the driver to support upto the chipset max, without
955 * some fancy mobo determination.
956 */
957 num_dimms_per_channel = MAX_SLOTS;
958 num_channels = MAX_CHANNELS;
959 num_csrows = MAX_SLOTS * MAX_CHANNELS;
960
961 debugf0("MC: %s(): Number of - Channels= %d DIMMS= %d CSROWS= %d\n",
962 __func__, num_channels, num_dimms_per_channel, num_csrows);
963
964 /* allocate a new MC control structure */
965 mci = edac_mc_alloc(sizeof(*pvt), num_csrows, num_channels, 0);
966
967 if (mci == NULL)
968 return -ENOMEM;
969
970 debugf0("MC: " __FILE__ ": %s(): mci = %p\n", __func__, mci);
971
972 mci->dev = &pdev->dev; /* record ptr to the generic device */
973
974 pvt = mci->pvt_info;
3e57eef6 975 pvt->pci_dev_16_0_fsb_ctlr = pdev; /* Record this device in our private */
fcaf780b 976
85580ea4
MCC
977 pvt->tmp_prt_buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
978 if (!pvt->tmp_prt_buffer) {
979 edac_mc_free(mci);
980 return -ENOMEM;
981 }
982
fcaf780b
MCC
983 /* 'get' the pci devices we want to reserve for our use */
984 if (i7300_get_devices(mci, dev_idx))
985 goto fail0;
986
987 mci->mc_idx = 0;
988 mci->mtype_cap = MEM_FLAG_FB_DDR2;
989 mci->edac_ctl_cap = EDAC_FLAG_NONE;
990 mci->edac_cap = EDAC_FLAG_NONE;
991 mci->mod_name = "i7300_edac.c";
992 mci->mod_ver = I7300_REVISION;
993 mci->ctl_name = i7300_devs[dev_idx].ctl_name;
994 mci->dev_name = pci_name(pdev);
995 mci->ctl_page_to_phys = NULL;
996
fcaf780b
MCC
997 /* Set the function pointer to an actual operation function */
998 mci->edac_check = i7300_check_error;
fcaf780b
MCC
999
1000 /* initialize the MC control structure 'csrows' table
1001 * with the mapping and control information */
1002 if (i7300_get_mc_regs(mci)) {
1003 debugf0("MC: Setting mci->edac_cap to EDAC_FLAG_NONE\n"
1004 " because i7300_init_csrows() returned nonzero "
1005 "value\n");
1006 mci->edac_cap = EDAC_FLAG_NONE; /* no csrows found */
1007 } else {
fcaf780b
MCC
1008 debugf1("MC: Enable error reporting now\n");
1009 i7300_enable_error_reporting(mci);
fcaf780b
MCC
1010 }
1011
1012 /* add this new MC control structure to EDAC's list of MCs */
1013 if (edac_mc_add_mc(mci)) {
1014 debugf0("MC: " __FILE__
1015 ": %s(): failed edac_mc_add_mc()\n", __func__);
1016 /* FIXME: perhaps some code should go here that disables error
1017 * reporting if we just enabled it
1018 */
1019 goto fail1;
1020 }
1021
fcaf780b 1022 i7300_clear_error(mci);
fcaf780b
MCC
1023
1024 /* allocating generic PCI control info */
1025 i7300_pci = edac_pci_create_generic_ctl(&pdev->dev, EDAC_MOD_STR);
1026 if (!i7300_pci) {
1027 printk(KERN_WARNING
1028 "%s(): Unable to create PCI control\n",
1029 __func__);
1030 printk(KERN_WARNING
1031 "%s(): PCI error report via EDAC not setup\n",
1032 __func__);
1033 }
1034
1035 return 0;
1036
1037 /* Error exit unwinding stack */
1038fail1:
1039
1040 i7300_put_devices(mci);
1041
1042fail0:
85580ea4 1043 kfree(pvt->tmp_prt_buffer);
fcaf780b
MCC
1044 edac_mc_free(mci);
1045 return -ENODEV;
1046}
1047
1048/*
1049 * i7300_init_one constructor for one instance of device
1050 *
1051 * returns:
1052 * negative on error
1053 * count (>= 0)
1054 */
1055static int __devinit i7300_init_one(struct pci_dev *pdev,
1056 const struct pci_device_id *id)
1057{
1058 int rc;
1059
1060 debugf0("MC: " __FILE__ ": %s()\n", __func__);
1061
1062 /* wake up device */
1063 rc = pci_enable_device(pdev);
1064 if (rc == -EIO)
1065 return rc;
1066
1067 /* now probe and enable the device */
1068 return i7300_probe1(pdev, id->driver_data);
1069}
1070
1071/*
1072 * i7300_remove_one destructor for one instance of device
1073 *
1074 */
1075static void __devexit i7300_remove_one(struct pci_dev *pdev)
1076{
1077 struct mem_ctl_info *mci;
85580ea4 1078 char *tmp;
fcaf780b
MCC
1079
1080 debugf0(__FILE__ ": %s()\n", __func__);
1081
1082 if (i7300_pci)
1083 edac_pci_release_generic_ctl(i7300_pci);
1084
1085 mci = edac_mc_del_mc(&pdev->dev);
1086 if (!mci)
1087 return;
1088
85580ea4
MCC
1089 tmp = ((struct i7300_pvt *)mci->pvt_info)->tmp_prt_buffer;
1090
fcaf780b
MCC
1091 /* retrieve references to resources, and free those resources */
1092 i7300_put_devices(mci);
1093
85580ea4 1094 kfree(tmp);
fcaf780b
MCC
1095 edac_mc_free(mci);
1096}
1097
1098/*
1099 * pci_device_id table for which devices we are looking for
1100 *
1101 * The "E500P" device is the first device supported.
1102 */
1103static const struct pci_device_id i7300_pci_tbl[] __devinitdata = {
1104 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_I7300_MCH_ERR)},
1105 {0,} /* 0 terminated list. */
1106};
1107
1108MODULE_DEVICE_TABLE(pci, i7300_pci_tbl);
1109
1110/*
1111 * i7300_driver pci_driver structure for this module
1112 *
1113 */
1114static struct pci_driver i7300_driver = {
1115 .name = "i7300_edac",
1116 .probe = i7300_init_one,
1117 .remove = __devexit_p(i7300_remove_one),
1118 .id_table = i7300_pci_tbl,
1119};
1120
1121/*
1122 * i7300_init Module entry function
1123 * Try to initialize this module for its devices
1124 */
1125static int __init i7300_init(void)
1126{
1127 int pci_rc;
1128
1129 debugf2("MC: " __FILE__ ": %s()\n", __func__);
1130
1131 /* Ensure that the OPSTATE is set correctly for POLL or NMI */
1132 opstate_init();
1133
1134 pci_rc = pci_register_driver(&i7300_driver);
1135
1136 return (pci_rc < 0) ? pci_rc : 0;
1137}
1138
1139/*
1140 * i7300_exit() Module exit function
1141 * Unregister the driver
1142 */
1143static void __exit i7300_exit(void)
1144{
1145 debugf2("MC: " __FILE__ ": %s()\n", __func__);
1146 pci_unregister_driver(&i7300_driver);
1147}
1148
1149module_init(i7300_init);
1150module_exit(i7300_exit);
1151
1152MODULE_LICENSE("GPL");
1153MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>");
1154MODULE_AUTHOR("Red Hat Inc. (http://www.redhat.com)");
1155MODULE_DESCRIPTION("MC Driver for Intel I7300 memory controllers - "
1156 I7300_REVISION);
1157
1158module_param(edac_op_state, int, 0444);
1159MODULE_PARM_DESC(edac_op_state, "EDAC Error Reporting state: 0=Poll,1=NMI");
This page took 0.074229 seconds and 5 git commands to generate.