i7300_edac.c 32 KB

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