i7300_edac.c 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157
  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. struct i7300_error_info {
  277. int dummy; /* FIXME */
  278. };
  279. const char *get_err_from_table(const char *table[], int size, int pos)
  280. {
  281. if (pos >= size)
  282. return "Reserved";
  283. return table[pos];
  284. }
  285. #define GET_ERR_FROM_TABLE(table, pos) \
  286. get_err_from_table(table, ARRAY_SIZE(table), pos)
  287. /*
  288. * i7300_get_error_info Retrieve the hardware error information from
  289. * the hardware and cache it in the 'info'
  290. * structure
  291. */
  292. static void i7300_get_error_info(struct mem_ctl_info *mci,
  293. struct i7300_error_info *info)
  294. {
  295. }
  296. /*
  297. * i7300_process_error_global Retrieve the hardware error information from
  298. * the hardware and cache it in the 'info'
  299. * structure
  300. */
  301. static void i7300_process_error_global(struct mem_ctl_info *mci,
  302. struct i7300_error_info *info)
  303. {
  304. struct i7300_pvt *pvt;
  305. u32 errnum, value;
  306. unsigned long errors;
  307. const char *specific;
  308. bool is_fatal;
  309. pvt = mci->pvt_info;
  310. /* read in the 1st FATAL error register */
  311. pci_read_config_dword(pvt->pci_dev_16_2_fsb_err_regs,
  312. FERR_GLOBAL_HI, &value);
  313. if (unlikely(value)) {
  314. errors = value;
  315. errnum = find_first_bit(&errors,
  316. ARRAY_SIZE(ferr_global_hi_name));
  317. specific = GET_ERR_FROM_TABLE(ferr_global_hi_name, errnum);
  318. is_fatal = ferr_global_hi_is_fatal(errnum);
  319. /* Clear the error bit */
  320. pci_write_config_dword(pvt->pci_dev_16_2_fsb_err_regs,
  321. FERR_GLOBAL_HI, value);
  322. goto error_global;
  323. }
  324. pci_read_config_dword(pvt->pci_dev_16_2_fsb_err_regs,
  325. FERR_GLOBAL_LO, &value);
  326. if (unlikely(value)) {
  327. errors = value;
  328. errnum = find_first_bit(&errors,
  329. ARRAY_SIZE(ferr_global_lo_name));
  330. specific = GET_ERR_FROM_TABLE(ferr_global_lo_name, errnum);
  331. is_fatal = ferr_global_lo_is_fatal(errnum);
  332. /* Clear the error bit */
  333. pci_write_config_dword(pvt->pci_dev_16_2_fsb_err_regs,
  334. FERR_GLOBAL_LO, value);
  335. goto error_global;
  336. }
  337. return;
  338. error_global:
  339. i7300_mc_printk(mci, KERN_EMERG, "%s misc error: %s\n",
  340. is_fatal ? "Fatal" : "NOT fatal", specific);
  341. }
  342. /*
  343. * i7300_process_fbd_error Retrieve the hardware error information from
  344. * the hardware and cache it in the 'info'
  345. * structure
  346. */
  347. static void i7300_process_fbd_error(struct mem_ctl_info *mci,
  348. struct i7300_error_info *info)
  349. {
  350. struct i7300_pvt *pvt;
  351. u32 errnum, value;
  352. int branch;
  353. unsigned long errors;
  354. const char *specific;
  355. bool is_fatal;
  356. pvt = mci->pvt_info;
  357. /* read in the 1st FATAL error register */
  358. pci_read_config_dword(pvt->pci_dev_16_1_fsb_addr_map,
  359. FERR_FAT_FBD, &value);
  360. if (unlikely(value & FERR_FAT_FBD_ERR_MASK)) {
  361. errors = value & FERR_FAT_FBD_ERR_MASK ;
  362. errnum = find_first_bit(&errors,
  363. ARRAY_SIZE(ferr_fat_fbd_name));
  364. specific = GET_ERR_FROM_TABLE(ferr_fat_fbd_name, errnum);
  365. is_fatal = 1;
  366. branch = (GET_FBD_FAT_IDX(value) == 2) ? 1 : 0;
  367. goto error_fbd;
  368. }
  369. /* read in the 1st NON-FATAL error register */
  370. pci_read_config_dword(pvt->pci_dev_16_1_fsb_addr_map,
  371. FERR_NF_FBD, &value);
  372. if (unlikely(value & FERR_NF_FBD_ERR_MASK)) {
  373. errors = value & FERR_NF_FBD_ERR_MASK;
  374. errnum = find_first_bit(&errors,
  375. ARRAY_SIZE(ferr_nf_fbd_name));
  376. specific = GET_ERR_FROM_TABLE(ferr_nf_fbd_name, errnum);
  377. is_fatal = 0;
  378. /* Clear the error bit */
  379. pci_write_config_dword(pvt->pci_dev_16_2_fsb_err_regs,
  380. FERR_GLOBAL_LO, value);
  381. goto error_fbd;
  382. }
  383. return;
  384. error_fbd:
  385. i7300_mc_printk(mci, KERN_EMERG, "%s FBD error on branch %d: %s\n",
  386. is_fatal ? "Fatal" : "NOT fatal", branch, specific);
  387. }
  388. /*
  389. * i7300_process_error_info Retrieve the hardware error information from
  390. * the hardware and cache it in the 'info'
  391. * structure
  392. */
  393. static void i7300_process_error_info(struct mem_ctl_info *mci,
  394. struct i7300_error_info *info)
  395. {
  396. i7300_process_error_global(mci, info);
  397. i7300_process_fbd_error(mci, info);
  398. };
  399. /*
  400. * i7300_clear_error Retrieve any error from the hardware
  401. * but do NOT process that error.
  402. * Used for 'clearing' out of previous errors
  403. * Called by the Core module.
  404. */
  405. static void i7300_clear_error(struct mem_ctl_info *mci)
  406. {
  407. struct i7300_error_info info;
  408. i7300_get_error_info(mci, &info);
  409. }
  410. /*
  411. * i7300_check_error Retrieve and process errors reported by the
  412. * hardware. Called by the Core module.
  413. */
  414. static void i7300_check_error(struct mem_ctl_info *mci)
  415. {
  416. struct i7300_error_info info;
  417. debugf4("MC%d: " __FILE__ ": %s()\n", mci->mc_idx, __func__);
  418. i7300_get_error_info(mci, &info);
  419. i7300_process_error_info(mci, &info);
  420. }
  421. /*
  422. * i7300_enable_error_reporting
  423. * Turn on the memory reporting features of the hardware
  424. */
  425. static void i7300_enable_error_reporting(struct mem_ctl_info *mci)
  426. {
  427. struct i7300_pvt *pvt = mci->pvt_info;
  428. u32 fbd_error_mask;
  429. /* Read the FBD Error Mask Register */
  430. pci_read_config_dword(pvt->pci_dev_16_1_fsb_addr_map,
  431. EMASK_FBD, &fbd_error_mask);
  432. /* Enable with a '0' */
  433. fbd_error_mask &= ~(EMASK_FBD_ERR_MASK);
  434. pci_write_config_dword(pvt->pci_dev_16_1_fsb_addr_map,
  435. EMASK_FBD, fbd_error_mask);
  436. }
  437. /************************************************
  438. * i7300 Functions related to memory enumberation
  439. ************************************************/
  440. /*
  441. * determine_mtr(pvt, csrow, channel)
  442. *
  443. * return the proper MTR register as determine by the csrow and desired channel
  444. */
  445. static int decode_mtr(struct i7300_pvt *pvt,
  446. int slot, int ch, int branch,
  447. struct i7300_dimm_info *dinfo,
  448. struct csrow_info *p_csrow)
  449. {
  450. int mtr, ans, addrBits, channel;
  451. channel = to_channel(ch, branch);
  452. mtr = pvt->mtr[slot][branch];
  453. ans = MTR_DIMMS_PRESENT(mtr) ? 1 : 0;
  454. debugf2("\tMTR%d CH%d: DIMMs are %s (mtr)\n",
  455. slot, channel,
  456. ans ? "Present" : "NOT Present");
  457. /* Determine if there is a DIMM present in this DIMM slot */
  458. #if 0
  459. if (!amb_present || !ans)
  460. return 0;
  461. #else
  462. if (!ans)
  463. return 0;
  464. #endif
  465. /* Start with the number of bits for a Bank
  466. * on the DRAM */
  467. addrBits = MTR_DRAM_BANKS_ADDR_BITS;
  468. /* Add thenumber of ROW bits */
  469. addrBits += MTR_DIMM_ROWS_ADDR_BITS(mtr);
  470. /* add the number of COLUMN bits */
  471. addrBits += MTR_DIMM_COLS_ADDR_BITS(mtr);
  472. /* add the number of RANK bits */
  473. addrBits += MTR_DIMM_RANKS(mtr);
  474. addrBits += 6; /* add 64 bits per DIMM */
  475. addrBits -= 20; /* divide by 2^^20 */
  476. addrBits -= 3; /* 8 bits per bytes */
  477. dinfo->megabytes = 1 << addrBits;
  478. debugf2("\t\tWIDTH: x%d\n", MTR_DRAM_WIDTH(mtr));
  479. debugf2("\t\tELECTRICAL THROTTLING is %s\n",
  480. MTR_DIMMS_ETHROTTLE(mtr) ? "enabled" : "disabled");
  481. debugf2("\t\tNUMBANK: %d bank(s)\n", MTR_DRAM_BANKS(mtr));
  482. debugf2("\t\tNUMRANK: %s\n", MTR_DIMM_RANKS(mtr) ? "double" : "single");
  483. debugf2("\t\tNUMROW: %s\n", numrow_toString[MTR_DIMM_ROWS(mtr)]);
  484. debugf2("\t\tNUMCOL: %s\n", numcol_toString[MTR_DIMM_COLS(mtr)]);
  485. debugf2("\t\tSIZE: %d MB\n", dinfo->megabytes);
  486. p_csrow->grain = 8;
  487. p_csrow->nr_pages = dinfo->megabytes << 8;
  488. p_csrow->mtype = MEM_FB_DDR2;
  489. /*
  490. * The type of error detection actually depends of the
  491. * mode of operation. When it is just one single memory chip, at
  492. * socket 0, channel 0, it uses 8-byte-over-32-byte SECDED+ code.
  493. * In normal or mirrored mode, it uses Lockstep mode,
  494. * with the possibility of using an extended algorithm for x8 memories
  495. * See datasheet Sections 7.3.6 to 7.3.8
  496. */
  497. if (IS_SINGLE_MODE(pvt->mc_settings_a)) {
  498. p_csrow->edac_mode = EDAC_SECDED;
  499. debugf0("ECC code is 8-byte-over-32-byte SECDED+ code\n");
  500. } else {
  501. debugf0("ECC code is on Lockstep mode\n");
  502. if (MTR_DRAM_WIDTH(mtr))
  503. p_csrow->edac_mode = EDAC_S8ECD8ED;
  504. else
  505. p_csrow->edac_mode = EDAC_S4ECD4ED;
  506. }
  507. /* ask what device type on this row */
  508. if (MTR_DRAM_WIDTH(mtr)) {
  509. debugf0("Scrub algorithm for x8 is on %s mode\n",
  510. IS_SCRBALGO_ENHANCED(pvt->mc_settings) ?
  511. "enhanced" : "normal");
  512. p_csrow->dtype = DEV_X8;
  513. } else
  514. p_csrow->dtype = DEV_X4;
  515. return mtr;
  516. }
  517. /*
  518. * print_dimm_size
  519. *
  520. * also will output a DIMM matrix map, if debug is enabled, for viewing
  521. * how the DIMMs are populated
  522. */
  523. static void print_dimm_size(struct i7300_pvt *pvt)
  524. {
  525. struct i7300_dimm_info *dinfo;
  526. char *p, *mem_buffer;
  527. int space, n;
  528. int channel, slot;
  529. space = PAGE_SIZE;
  530. mem_buffer = p = kmalloc(space, GFP_KERNEL);
  531. if (p == NULL) {
  532. i7300_printk(KERN_ERR, "MC: %s:%s() kmalloc() failed\n",
  533. __FILE__, __func__);
  534. return;
  535. }
  536. n = snprintf(p, space, " ");
  537. p += n;
  538. space -= n;
  539. for (channel = 0; channel < MAX_CHANNELS; channel++) {
  540. n = snprintf(p, space, "channel %d | ", channel);
  541. p += n;
  542. space -= n;
  543. }
  544. debugf2("%s\n", mem_buffer);
  545. p = mem_buffer;
  546. space = PAGE_SIZE;
  547. n = snprintf(p, space, "-------------------------------"
  548. "------------------------------");
  549. p += n;
  550. space -= n;
  551. debugf2("%s\n", mem_buffer);
  552. p = mem_buffer;
  553. space = PAGE_SIZE;
  554. for (slot = 0; slot < MAX_SLOTS; slot++) {
  555. n = snprintf(p, space, "csrow/SLOT %d ", slot);
  556. p += n;
  557. space -= n;
  558. for (channel = 0; channel < MAX_CHANNELS; channel++) {
  559. dinfo = &pvt->dimm_info[slot][channel];
  560. n = snprintf(p, space, "%4d MB | ", dinfo->megabytes);
  561. p += n;
  562. space -= n;
  563. }
  564. debugf2("%s\n", mem_buffer);
  565. p = mem_buffer;
  566. space = PAGE_SIZE;
  567. }
  568. n = snprintf(p, space, "-------------------------------"
  569. "------------------------------");
  570. p += n;
  571. space -= n;
  572. debugf2("%s\n", mem_buffer);
  573. p = mem_buffer;
  574. space = PAGE_SIZE;
  575. kfree(mem_buffer);
  576. }
  577. /*
  578. * i7300_init_csrows Initialize the 'csrows' table within
  579. * the mci control structure with the
  580. * addressing of memory.
  581. *
  582. * return:
  583. * 0 success
  584. * 1 no actual memory found on this MC
  585. */
  586. static int i7300_init_csrows(struct mem_ctl_info *mci)
  587. {
  588. struct i7300_pvt *pvt;
  589. struct i7300_dimm_info *dinfo;
  590. struct csrow_info *p_csrow;
  591. int empty;
  592. int mtr;
  593. int ch, branch, slot, channel;
  594. pvt = mci->pvt_info;
  595. empty = 1; /* Assume NO memory */
  596. debugf2("Memory Technology Registers:\n");
  597. /* Get the AMB present registers for the four channels */
  598. for (branch = 0; branch < MAX_BRANCHES; branch++) {
  599. /* Read and dump branch 0's MTRs */
  600. channel = to_channel(0, branch);
  601. pci_read_config_word(pvt->pci_dev_2x_0_fbd_branch[branch], AMBPRESENT_0,
  602. &pvt->ambpresent[channel]);
  603. debugf2("\t\tAMB-present CH%d = 0x%x:\n",
  604. channel, pvt->ambpresent[channel]);
  605. channel = to_channel(1, branch);
  606. pci_read_config_word(pvt->pci_dev_2x_0_fbd_branch[branch], AMBPRESENT_1,
  607. &pvt->ambpresent[channel]);
  608. debugf2("\t\tAMB-present CH%d = 0x%x:\n",
  609. channel, pvt->ambpresent[channel]);
  610. }
  611. /* Get the set of MTR[0-7] regs by each branch */
  612. for (slot = 0; slot < MAX_SLOTS; slot++) {
  613. int where = mtr_regs[slot];
  614. for (branch = 0; branch < MAX_BRANCHES; branch++) {
  615. pci_read_config_word(pvt->pci_dev_2x_0_fbd_branch[branch],
  616. where,
  617. &pvt->mtr[slot][branch]);
  618. for (ch = 0; ch < MAX_BRANCHES; ch++) {
  619. int channel = to_channel(ch, branch);
  620. dinfo = &pvt->dimm_info[slot][channel];
  621. p_csrow = &mci->csrows[slot];
  622. mtr = decode_mtr(pvt, slot, ch, branch,
  623. dinfo, p_csrow);
  624. /* if no DIMMS on this row, continue */
  625. if (!MTR_DIMMS_PRESENT(mtr))
  626. continue;
  627. p_csrow->csrow_idx = slot;
  628. /* FAKE OUT VALUES, FIXME */
  629. p_csrow->first_page = 0 + slot * 20;
  630. p_csrow->last_page = 9 + slot * 20;
  631. p_csrow->page_mask = 0xfff;
  632. empty = 0;
  633. }
  634. }
  635. }
  636. return empty;
  637. }
  638. static void decode_mir(int mir_no, u16 mir[MAX_MIR])
  639. {
  640. if (mir[mir_no] & 3)
  641. debugf2("MIR%d: limit= 0x%x Branch(es) that participate: %s %s\n",
  642. mir_no,
  643. (mir[mir_no] >> 4) & 0xfff,
  644. (mir[mir_no] & 1) ? "B0" : "",
  645. (mir[mir_no] & 2) ? "B1": "");
  646. }
  647. /*
  648. * i7300_get_mc_regs read in the necessary registers and
  649. * cache locally
  650. *
  651. * Fills in the private data members
  652. */
  653. static int i7300_get_mc_regs(struct mem_ctl_info *mci)
  654. {
  655. struct i7300_pvt *pvt;
  656. u32 actual_tolm;
  657. int i, rc;
  658. pvt = mci->pvt_info;
  659. pci_read_config_dword(pvt->pci_dev_16_0_fsb_ctlr, AMBASE,
  660. (u32 *) &pvt->ambase);
  661. debugf2("AMBASE= 0x%lx\n", (long unsigned int)pvt->ambase);
  662. /* Get the Branch Map regs */
  663. pci_read_config_word(pvt->pci_dev_16_1_fsb_addr_map, TOLM, &pvt->tolm);
  664. pvt->tolm >>= 12;
  665. debugf2("TOLM (number of 256M regions) =%u (0x%x)\n", pvt->tolm,
  666. pvt->tolm);
  667. actual_tolm = (u32) ((1000l * pvt->tolm) >> (30 - 28));
  668. debugf2("Actual TOLM byte addr=%u.%03u GB (0x%x)\n",
  669. actual_tolm/1000, actual_tolm % 1000, pvt->tolm << 28);
  670. /* Get memory controller settings */
  671. pci_read_config_dword(pvt->pci_dev_16_1_fsb_addr_map, MC_SETTINGS,
  672. &pvt->mc_settings);
  673. pci_read_config_dword(pvt->pci_dev_16_1_fsb_addr_map, MC_SETTINGS_A,
  674. &pvt->mc_settings_a);
  675. if (IS_SINGLE_MODE(pvt->mc_settings_a))
  676. debugf0("Memory controller operating on single mode\n");
  677. else
  678. debugf0("Memory controller operating on %s mode\n",
  679. IS_MIRRORED(pvt->mc_settings) ? "mirrored" : "non-mirrored");
  680. debugf0("Error detection is %s\n",
  681. IS_ECC_ENABLED(pvt->mc_settings) ? "enabled" : "disabled");
  682. debugf0("Retry is %s\n",
  683. IS_RETRY_ENABLED(pvt->mc_settings) ? "enabled" : "disabled");
  684. /* Get Memory Interleave Range registers */
  685. pci_read_config_word(pvt->pci_dev_16_1_fsb_addr_map, MIR0, &pvt->mir[0]);
  686. pci_read_config_word(pvt->pci_dev_16_1_fsb_addr_map, MIR1, &pvt->mir[1]);
  687. pci_read_config_word(pvt->pci_dev_16_1_fsb_addr_map, MIR2, &pvt->mir[2]);
  688. /* Decode the MIR regs */
  689. for (i = 0; i < MAX_MIR; i++)
  690. decode_mir(i, pvt->mir);
  691. rc = i7300_init_csrows(mci);
  692. if (rc < 0)
  693. return rc;
  694. /* Go and determine the size of each DIMM and place in an
  695. * orderly matrix */
  696. print_dimm_size(pvt);
  697. return 0;
  698. }
  699. /*************************************************
  700. * i7300 Functions related to device probe/release
  701. *************************************************/
  702. /*
  703. * i7300_put_devices 'put' all the devices that we have
  704. * reserved via 'get'
  705. */
  706. static void i7300_put_devices(struct mem_ctl_info *mci)
  707. {
  708. struct i7300_pvt *pvt;
  709. int branch;
  710. pvt = mci->pvt_info;
  711. /* Decrement usage count for devices */
  712. for (branch = 0; branch < MAX_CH_PER_BRANCH; branch++)
  713. pci_dev_put(pvt->pci_dev_2x_0_fbd_branch[branch]);
  714. pci_dev_put(pvt->pci_dev_16_2_fsb_err_regs);
  715. pci_dev_put(pvt->pci_dev_16_1_fsb_addr_map);
  716. }
  717. /*
  718. * i7300_get_devices Find and perform 'get' operation on the MCH's
  719. * device/functions we want to reference for this driver
  720. *
  721. * Need to 'get' device 16 func 1 and func 2
  722. */
  723. static int i7300_get_devices(struct mem_ctl_info *mci, int dev_idx)
  724. {
  725. struct i7300_pvt *pvt;
  726. struct pci_dev *pdev;
  727. pvt = mci->pvt_info;
  728. /* Attempt to 'get' the MCH register we want */
  729. pdev = NULL;
  730. while (!pvt->pci_dev_16_1_fsb_addr_map || !pvt->pci_dev_16_2_fsb_err_regs) {
  731. pdev = pci_get_device(PCI_VENDOR_ID_INTEL,
  732. PCI_DEVICE_ID_INTEL_I7300_MCH_ERR, pdev);
  733. if (!pdev) {
  734. /* End of list, leave */
  735. i7300_printk(KERN_ERR,
  736. "'system address,Process Bus' "
  737. "device not found:"
  738. "vendor 0x%x device 0x%x ERR funcs "
  739. "(broken BIOS?)\n",
  740. PCI_VENDOR_ID_INTEL,
  741. PCI_DEVICE_ID_INTEL_I7300_MCH_ERR);
  742. goto error;
  743. }
  744. /* Store device 16 funcs 1 and 2 */
  745. switch (PCI_FUNC(pdev->devfn)) {
  746. case 1:
  747. pvt->pci_dev_16_1_fsb_addr_map = pdev;
  748. break;
  749. case 2:
  750. pvt->pci_dev_16_2_fsb_err_regs = pdev;
  751. break;
  752. }
  753. }
  754. debugf1("System Address, processor bus- PCI Bus ID: %s %x:%x\n",
  755. pci_name(pvt->pci_dev_16_0_fsb_ctlr),
  756. pvt->pci_dev_16_0_fsb_ctlr->vendor, pvt->pci_dev_16_0_fsb_ctlr->device);
  757. debugf1("Branchmap, control and errors - PCI Bus ID: %s %x:%x\n",
  758. pci_name(pvt->pci_dev_16_1_fsb_addr_map),
  759. pvt->pci_dev_16_1_fsb_addr_map->vendor, pvt->pci_dev_16_1_fsb_addr_map->device);
  760. debugf1("FSB Error Regs - PCI Bus ID: %s %x:%x\n",
  761. pci_name(pvt->pci_dev_16_2_fsb_err_regs),
  762. pvt->pci_dev_16_2_fsb_err_regs->vendor, pvt->pci_dev_16_2_fsb_err_regs->device);
  763. pvt->pci_dev_2x_0_fbd_branch[0] = pci_get_device(PCI_VENDOR_ID_INTEL,
  764. PCI_DEVICE_ID_INTEL_I7300_MCH_FB0,
  765. NULL);
  766. if (!pvt->pci_dev_2x_0_fbd_branch[0]) {
  767. i7300_printk(KERN_ERR,
  768. "MC: 'BRANCH 0' device not found:"
  769. "vendor 0x%x device 0x%x Func 0 (broken BIOS?)\n",
  770. PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_I7300_MCH_FB0);
  771. goto error;
  772. }
  773. pvt->pci_dev_2x_0_fbd_branch[1] = pci_get_device(PCI_VENDOR_ID_INTEL,
  774. PCI_DEVICE_ID_INTEL_I7300_MCH_FB1,
  775. NULL);
  776. if (!pvt->pci_dev_2x_0_fbd_branch[1]) {
  777. i7300_printk(KERN_ERR,
  778. "MC: 'BRANCH 1' device not found:"
  779. "vendor 0x%x device 0x%x Func 0 "
  780. "(broken BIOS?)\n",
  781. PCI_VENDOR_ID_INTEL,
  782. PCI_DEVICE_ID_INTEL_I7300_MCH_FB1);
  783. goto error;
  784. }
  785. return 0;
  786. error:
  787. i7300_put_devices(mci);
  788. return -ENODEV;
  789. }
  790. /*
  791. * i7300_probe1 Probe for ONE instance of device to see if it is
  792. * present.
  793. * return:
  794. * 0 for FOUND a device
  795. * < 0 for error code
  796. */
  797. static int i7300_probe1(struct pci_dev *pdev, int dev_idx)
  798. {
  799. struct mem_ctl_info *mci;
  800. struct i7300_pvt *pvt;
  801. int num_channels;
  802. int num_dimms_per_channel;
  803. int num_csrows;
  804. if (dev_idx >= ARRAY_SIZE(i7300_devs))
  805. return -EINVAL;
  806. debugf0("MC: " __FILE__ ": %s(), pdev bus %u dev=0x%x fn=0x%x\n",
  807. __func__,
  808. pdev->bus->number,
  809. PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
  810. /* We only are looking for func 0 of the set */
  811. if (PCI_FUNC(pdev->devfn) != 0)
  812. return -ENODEV;
  813. /* As we don't have a motherboard identification routine to determine
  814. * actual number of slots/dimms per channel, we thus utilize the
  815. * resource as specified by the chipset. Thus, we might have
  816. * have more DIMMs per channel than actually on the mobo, but this
  817. * allows the driver to support upto the chipset max, without
  818. * some fancy mobo determination.
  819. */
  820. num_dimms_per_channel = MAX_SLOTS;
  821. num_channels = MAX_CHANNELS;
  822. num_csrows = MAX_SLOTS * MAX_CHANNELS;
  823. debugf0("MC: %s(): Number of - Channels= %d DIMMS= %d CSROWS= %d\n",
  824. __func__, num_channels, num_dimms_per_channel, num_csrows);
  825. /* allocate a new MC control structure */
  826. mci = edac_mc_alloc(sizeof(*pvt), num_csrows, num_channels, 0);
  827. if (mci == NULL)
  828. return -ENOMEM;
  829. debugf0("MC: " __FILE__ ": %s(): mci = %p\n", __func__, mci);
  830. mci->dev = &pdev->dev; /* record ptr to the generic device */
  831. pvt = mci->pvt_info;
  832. pvt->pci_dev_16_0_fsb_ctlr = pdev; /* Record this device in our private */
  833. /* 'get' the pci devices we want to reserve for our use */
  834. if (i7300_get_devices(mci, dev_idx))
  835. goto fail0;
  836. mci->mc_idx = 0;
  837. mci->mtype_cap = MEM_FLAG_FB_DDR2;
  838. mci->edac_ctl_cap = EDAC_FLAG_NONE;
  839. mci->edac_cap = EDAC_FLAG_NONE;
  840. mci->mod_name = "i7300_edac.c";
  841. mci->mod_ver = I7300_REVISION;
  842. mci->ctl_name = i7300_devs[dev_idx].ctl_name;
  843. mci->dev_name = pci_name(pdev);
  844. mci->ctl_page_to_phys = NULL;
  845. /* Set the function pointer to an actual operation function */
  846. mci->edac_check = i7300_check_error;
  847. /* initialize the MC control structure 'csrows' table
  848. * with the mapping and control information */
  849. if (i7300_get_mc_regs(mci)) {
  850. debugf0("MC: Setting mci->edac_cap to EDAC_FLAG_NONE\n"
  851. " because i7300_init_csrows() returned nonzero "
  852. "value\n");
  853. mci->edac_cap = EDAC_FLAG_NONE; /* no csrows found */
  854. } else {
  855. debugf1("MC: Enable error reporting now\n");
  856. i7300_enable_error_reporting(mci);
  857. }
  858. /* add this new MC control structure to EDAC's list of MCs */
  859. if (edac_mc_add_mc(mci)) {
  860. debugf0("MC: " __FILE__
  861. ": %s(): failed edac_mc_add_mc()\n", __func__);
  862. /* FIXME: perhaps some code should go here that disables error
  863. * reporting if we just enabled it
  864. */
  865. goto fail1;
  866. }
  867. i7300_clear_error(mci);
  868. /* allocating generic PCI control info */
  869. i7300_pci = edac_pci_create_generic_ctl(&pdev->dev, EDAC_MOD_STR);
  870. if (!i7300_pci) {
  871. printk(KERN_WARNING
  872. "%s(): Unable to create PCI control\n",
  873. __func__);
  874. printk(KERN_WARNING
  875. "%s(): PCI error report via EDAC not setup\n",
  876. __func__);
  877. }
  878. return 0;
  879. /* Error exit unwinding stack */
  880. fail1:
  881. i7300_put_devices(mci);
  882. fail0:
  883. edac_mc_free(mci);
  884. return -ENODEV;
  885. }
  886. /*
  887. * i7300_init_one constructor for one instance of device
  888. *
  889. * returns:
  890. * negative on error
  891. * count (>= 0)
  892. */
  893. static int __devinit i7300_init_one(struct pci_dev *pdev,
  894. const struct pci_device_id *id)
  895. {
  896. int rc;
  897. debugf0("MC: " __FILE__ ": %s()\n", __func__);
  898. /* wake up device */
  899. rc = pci_enable_device(pdev);
  900. if (rc == -EIO)
  901. return rc;
  902. /* now probe and enable the device */
  903. return i7300_probe1(pdev, id->driver_data);
  904. }
  905. /*
  906. * i7300_remove_one destructor for one instance of device
  907. *
  908. */
  909. static void __devexit i7300_remove_one(struct pci_dev *pdev)
  910. {
  911. struct mem_ctl_info *mci;
  912. debugf0(__FILE__ ": %s()\n", __func__);
  913. if (i7300_pci)
  914. edac_pci_release_generic_ctl(i7300_pci);
  915. mci = edac_mc_del_mc(&pdev->dev);
  916. if (!mci)
  917. return;
  918. /* retrieve references to resources, and free those resources */
  919. i7300_put_devices(mci);
  920. edac_mc_free(mci);
  921. }
  922. /*
  923. * pci_device_id table for which devices we are looking for
  924. *
  925. * The "E500P" device is the first device supported.
  926. */
  927. static const struct pci_device_id i7300_pci_tbl[] __devinitdata = {
  928. {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_I7300_MCH_ERR)},
  929. {0,} /* 0 terminated list. */
  930. };
  931. MODULE_DEVICE_TABLE(pci, i7300_pci_tbl);
  932. /*
  933. * i7300_driver pci_driver structure for this module
  934. *
  935. */
  936. static struct pci_driver i7300_driver = {
  937. .name = "i7300_edac",
  938. .probe = i7300_init_one,
  939. .remove = __devexit_p(i7300_remove_one),
  940. .id_table = i7300_pci_tbl,
  941. };
  942. /*
  943. * i7300_init Module entry function
  944. * Try to initialize this module for its devices
  945. */
  946. static int __init i7300_init(void)
  947. {
  948. int pci_rc;
  949. debugf2("MC: " __FILE__ ": %s()\n", __func__);
  950. /* Ensure that the OPSTATE is set correctly for POLL or NMI */
  951. opstate_init();
  952. pci_rc = pci_register_driver(&i7300_driver);
  953. return (pci_rc < 0) ? pci_rc : 0;
  954. }
  955. /*
  956. * i7300_exit() Module exit function
  957. * Unregister the driver
  958. */
  959. static void __exit i7300_exit(void)
  960. {
  961. debugf2("MC: " __FILE__ ": %s()\n", __func__);
  962. pci_unregister_driver(&i7300_driver);
  963. }
  964. module_init(i7300_init);
  965. module_exit(i7300_exit);
  966. MODULE_LICENSE("GPL");
  967. MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>");
  968. MODULE_AUTHOR("Red Hat Inc. (http://www.redhat.com)");
  969. MODULE_DESCRIPTION("MC Driver for Intel I7300 memory controllers - "
  970. I7300_REVISION);
  971. module_param(edac_op_state, int, 0444);
  972. MODULE_PARM_DESC(edac_op_state, "EDAC Error Reporting state: 0=Poll,1=NMI");