fsl_ddr_edac.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. /*
  2. * Freescale Memory Controller kernel module
  3. *
  4. * Support Power-based SoCs including MPC85xx, MPC86xx, MPC83xx and
  5. * ARM-based Layerscape SoCs including LS2xxx. Originally split
  6. * out from mpc85xx_edac EDAC driver.
  7. *
  8. * Parts Copyrighted (c) 2013 by Freescale Semiconductor, Inc.
  9. *
  10. * Author: Dave Jiang <djiang@mvista.com>
  11. *
  12. * 2006-2007 (c) MontaVista Software, Inc. This file is licensed under
  13. * the terms of the GNU General Public License version 2. This program
  14. * is licensed "as is" without any warranty of any kind, whether express
  15. * or implied.
  16. */
  17. #include <linux/module.h>
  18. #include <linux/init.h>
  19. #include <linux/interrupt.h>
  20. #include <linux/ctype.h>
  21. #include <linux/io.h>
  22. #include <linux/mod_devicetable.h>
  23. #include <linux/edac.h>
  24. #include <linux/smp.h>
  25. #include <linux/gfp.h>
  26. #include <linux/of_platform.h>
  27. #include <linux/of_device.h>
  28. #include <linux/of_address.h>
  29. #include "edac_module.h"
  30. #include "fsl_ddr_edac.h"
  31. #define EDAC_MOD_STR "fsl_ddr_edac"
  32. static int edac_mc_idx;
  33. static u32 orig_ddr_err_disable;
  34. static u32 orig_ddr_err_sbe;
  35. static bool little_endian;
  36. static inline u32 ddr_in32(void __iomem *addr)
  37. {
  38. return little_endian ? ioread32(addr) : ioread32be(addr);
  39. }
  40. static inline void ddr_out32(void __iomem *addr, u32 value)
  41. {
  42. if (little_endian)
  43. iowrite32(value, addr);
  44. else
  45. iowrite32be(value, addr);
  46. }
  47. /************************ MC SYSFS parts ***********************************/
  48. #define to_mci(k) container_of(k, struct mem_ctl_info, dev)
  49. static ssize_t fsl_mc_inject_data_hi_show(struct device *dev,
  50. struct device_attribute *mattr,
  51. char *data)
  52. {
  53. struct mem_ctl_info *mci = to_mci(dev);
  54. struct fsl_mc_pdata *pdata = mci->pvt_info;
  55. return sprintf(data, "0x%08x",
  56. ddr_in32(pdata->mc_vbase + FSL_MC_DATA_ERR_INJECT_HI));
  57. }
  58. static ssize_t fsl_mc_inject_data_lo_show(struct device *dev,
  59. struct device_attribute *mattr,
  60. char *data)
  61. {
  62. struct mem_ctl_info *mci = to_mci(dev);
  63. struct fsl_mc_pdata *pdata = mci->pvt_info;
  64. return sprintf(data, "0x%08x",
  65. ddr_in32(pdata->mc_vbase + FSL_MC_DATA_ERR_INJECT_LO));
  66. }
  67. static ssize_t fsl_mc_inject_ctrl_show(struct device *dev,
  68. struct device_attribute *mattr,
  69. char *data)
  70. {
  71. struct mem_ctl_info *mci = to_mci(dev);
  72. struct fsl_mc_pdata *pdata = mci->pvt_info;
  73. return sprintf(data, "0x%08x",
  74. ddr_in32(pdata->mc_vbase + FSL_MC_ECC_ERR_INJECT));
  75. }
  76. static ssize_t fsl_mc_inject_data_hi_store(struct device *dev,
  77. struct device_attribute *mattr,
  78. const char *data, size_t count)
  79. {
  80. struct mem_ctl_info *mci = to_mci(dev);
  81. struct fsl_mc_pdata *pdata = mci->pvt_info;
  82. unsigned long val;
  83. int rc;
  84. if (isdigit(*data)) {
  85. rc = kstrtoul(data, 0, &val);
  86. if (rc)
  87. return rc;
  88. ddr_out32(pdata->mc_vbase + FSL_MC_DATA_ERR_INJECT_HI, val);
  89. return count;
  90. }
  91. return 0;
  92. }
  93. static ssize_t fsl_mc_inject_data_lo_store(struct device *dev,
  94. struct device_attribute *mattr,
  95. const char *data, size_t count)
  96. {
  97. struct mem_ctl_info *mci = to_mci(dev);
  98. struct fsl_mc_pdata *pdata = mci->pvt_info;
  99. unsigned long val;
  100. int rc;
  101. if (isdigit(*data)) {
  102. rc = kstrtoul(data, 0, &val);
  103. if (rc)
  104. return rc;
  105. ddr_out32(pdata->mc_vbase + FSL_MC_DATA_ERR_INJECT_LO, val);
  106. return count;
  107. }
  108. return 0;
  109. }
  110. static ssize_t fsl_mc_inject_ctrl_store(struct device *dev,
  111. struct device_attribute *mattr,
  112. const char *data, size_t count)
  113. {
  114. struct mem_ctl_info *mci = to_mci(dev);
  115. struct fsl_mc_pdata *pdata = mci->pvt_info;
  116. unsigned long val;
  117. int rc;
  118. if (isdigit(*data)) {
  119. rc = kstrtoul(data, 0, &val);
  120. if (rc)
  121. return rc;
  122. ddr_out32(pdata->mc_vbase + FSL_MC_ECC_ERR_INJECT, val);
  123. return count;
  124. }
  125. return 0;
  126. }
  127. static DEVICE_ATTR(inject_data_hi, S_IRUGO | S_IWUSR,
  128. fsl_mc_inject_data_hi_show, fsl_mc_inject_data_hi_store);
  129. static DEVICE_ATTR(inject_data_lo, S_IRUGO | S_IWUSR,
  130. fsl_mc_inject_data_lo_show, fsl_mc_inject_data_lo_store);
  131. static DEVICE_ATTR(inject_ctrl, S_IRUGO | S_IWUSR,
  132. fsl_mc_inject_ctrl_show, fsl_mc_inject_ctrl_store);
  133. static struct attribute *fsl_ddr_dev_attrs[] = {
  134. &dev_attr_inject_data_hi.attr,
  135. &dev_attr_inject_data_lo.attr,
  136. &dev_attr_inject_ctrl.attr,
  137. NULL
  138. };
  139. ATTRIBUTE_GROUPS(fsl_ddr_dev);
  140. /**************************** MC Err device ***************************/
  141. /*
  142. * Taken from table 8-55 in the MPC8641 User's Manual and/or 9-61 in the
  143. * MPC8572 User's Manual. Each line represents a syndrome bit column as a
  144. * 64-bit value, but split into an upper and lower 32-bit chunk. The labels
  145. * below correspond to Freescale's manuals.
  146. */
  147. static unsigned int ecc_table[16] = {
  148. /* MSB LSB */
  149. /* [0:31] [32:63] */
  150. 0xf00fe11e, 0xc33c0ff7, /* Syndrome bit 7 */
  151. 0x00ff00ff, 0x00fff0ff,
  152. 0x0f0f0f0f, 0x0f0fff00,
  153. 0x11113333, 0x7777000f,
  154. 0x22224444, 0x8888222f,
  155. 0x44448888, 0xffff4441,
  156. 0x8888ffff, 0x11118882,
  157. 0xffff1111, 0x22221114, /* Syndrome bit 0 */
  158. };
  159. /*
  160. * Calculate the correct ECC value for a 64-bit value specified by high:low
  161. */
  162. static u8 calculate_ecc(u32 high, u32 low)
  163. {
  164. u32 mask_low;
  165. u32 mask_high;
  166. int bit_cnt;
  167. u8 ecc = 0;
  168. int i;
  169. int j;
  170. for (i = 0; i < 8; i++) {
  171. mask_high = ecc_table[i * 2];
  172. mask_low = ecc_table[i * 2 + 1];
  173. bit_cnt = 0;
  174. for (j = 0; j < 32; j++) {
  175. if ((mask_high >> j) & 1)
  176. bit_cnt ^= (high >> j) & 1;
  177. if ((mask_low >> j) & 1)
  178. bit_cnt ^= (low >> j) & 1;
  179. }
  180. ecc |= bit_cnt << i;
  181. }
  182. return ecc;
  183. }
  184. /*
  185. * Create the syndrome code which is generated if the data line specified by
  186. * 'bit' failed. Eg generate an 8-bit codes seen in Table 8-55 in the MPC8641
  187. * User's Manual and 9-61 in the MPC8572 User's Manual.
  188. */
  189. static u8 syndrome_from_bit(unsigned int bit) {
  190. int i;
  191. u8 syndrome = 0;
  192. /*
  193. * Cycle through the upper or lower 32-bit portion of each value in
  194. * ecc_table depending on if 'bit' is in the upper or lower half of
  195. * 64-bit data.
  196. */
  197. for (i = bit < 32; i < 16; i += 2)
  198. syndrome |= ((ecc_table[i] >> (bit % 32)) & 1) << (i / 2);
  199. return syndrome;
  200. }
  201. /*
  202. * Decode data and ecc syndrome to determine what went wrong
  203. * Note: This can only decode single-bit errors
  204. */
  205. static void sbe_ecc_decode(u32 cap_high, u32 cap_low, u32 cap_ecc,
  206. int *bad_data_bit, int *bad_ecc_bit)
  207. {
  208. int i;
  209. u8 syndrome;
  210. *bad_data_bit = -1;
  211. *bad_ecc_bit = -1;
  212. /*
  213. * Calculate the ECC of the captured data and XOR it with the captured
  214. * ECC to find an ECC syndrome value we can search for
  215. */
  216. syndrome = calculate_ecc(cap_high, cap_low) ^ cap_ecc;
  217. /* Check if a data line is stuck... */
  218. for (i = 0; i < 64; i++) {
  219. if (syndrome == syndrome_from_bit(i)) {
  220. *bad_data_bit = i;
  221. return;
  222. }
  223. }
  224. /* If data is correct, check ECC bits for errors... */
  225. for (i = 0; i < 8; i++) {
  226. if ((syndrome >> i) & 0x1) {
  227. *bad_ecc_bit = i;
  228. return;
  229. }
  230. }
  231. }
  232. #define make64(high, low) (((u64)(high) << 32) | (low))
  233. static void fsl_mc_check(struct mem_ctl_info *mci)
  234. {
  235. struct fsl_mc_pdata *pdata = mci->pvt_info;
  236. struct csrow_info *csrow;
  237. u32 bus_width;
  238. u32 err_detect;
  239. u32 syndrome;
  240. u64 err_addr;
  241. u32 pfn;
  242. int row_index;
  243. u32 cap_high;
  244. u32 cap_low;
  245. int bad_data_bit;
  246. int bad_ecc_bit;
  247. err_detect = ddr_in32(pdata->mc_vbase + FSL_MC_ERR_DETECT);
  248. if (!err_detect)
  249. return;
  250. fsl_mc_printk(mci, KERN_ERR, "Err Detect Register: %#8.8x\n",
  251. err_detect);
  252. /* no more processing if not ECC bit errors */
  253. if (!(err_detect & (DDR_EDE_SBE | DDR_EDE_MBE))) {
  254. ddr_out32(pdata->mc_vbase + FSL_MC_ERR_DETECT, err_detect);
  255. return;
  256. }
  257. syndrome = ddr_in32(pdata->mc_vbase + FSL_MC_CAPTURE_ECC);
  258. /* Mask off appropriate bits of syndrome based on bus width */
  259. bus_width = (ddr_in32(pdata->mc_vbase + FSL_MC_DDR_SDRAM_CFG) &
  260. DSC_DBW_MASK) ? 32 : 64;
  261. if (bus_width == 64)
  262. syndrome &= 0xff;
  263. else
  264. syndrome &= 0xffff;
  265. err_addr = make64(
  266. ddr_in32(pdata->mc_vbase + FSL_MC_CAPTURE_EXT_ADDRESS),
  267. ddr_in32(pdata->mc_vbase + FSL_MC_CAPTURE_ADDRESS));
  268. pfn = err_addr >> PAGE_SHIFT;
  269. for (row_index = 0; row_index < mci->nr_csrows; row_index++) {
  270. csrow = mci->csrows[row_index];
  271. if ((pfn >= csrow->first_page) && (pfn <= csrow->last_page))
  272. break;
  273. }
  274. cap_high = ddr_in32(pdata->mc_vbase + FSL_MC_CAPTURE_DATA_HI);
  275. cap_low = ddr_in32(pdata->mc_vbase + FSL_MC_CAPTURE_DATA_LO);
  276. /*
  277. * Analyze single-bit errors on 64-bit wide buses
  278. * TODO: Add support for 32-bit wide buses
  279. */
  280. if ((err_detect & DDR_EDE_SBE) && (bus_width == 64)) {
  281. sbe_ecc_decode(cap_high, cap_low, syndrome,
  282. &bad_data_bit, &bad_ecc_bit);
  283. if (bad_data_bit != -1)
  284. fsl_mc_printk(mci, KERN_ERR,
  285. "Faulty Data bit: %d\n", bad_data_bit);
  286. if (bad_ecc_bit != -1)
  287. fsl_mc_printk(mci, KERN_ERR,
  288. "Faulty ECC bit: %d\n", bad_ecc_bit);
  289. fsl_mc_printk(mci, KERN_ERR,
  290. "Expected Data / ECC:\t%#8.8x_%08x / %#2.2x\n",
  291. cap_high ^ (1 << (bad_data_bit - 32)),
  292. cap_low ^ (1 << bad_data_bit),
  293. syndrome ^ (1 << bad_ecc_bit));
  294. }
  295. fsl_mc_printk(mci, KERN_ERR,
  296. "Captured Data / ECC:\t%#8.8x_%08x / %#2.2x\n",
  297. cap_high, cap_low, syndrome);
  298. fsl_mc_printk(mci, KERN_ERR, "Err addr: %#8.8llx\n", err_addr);
  299. fsl_mc_printk(mci, KERN_ERR, "PFN: %#8.8x\n", pfn);
  300. /* we are out of range */
  301. if (row_index == mci->nr_csrows)
  302. fsl_mc_printk(mci, KERN_ERR, "PFN out of range!\n");
  303. if (err_detect & DDR_EDE_SBE)
  304. edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1,
  305. pfn, err_addr & ~PAGE_MASK, syndrome,
  306. row_index, 0, -1,
  307. mci->ctl_name, "");
  308. if (err_detect & DDR_EDE_MBE)
  309. edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1,
  310. pfn, err_addr & ~PAGE_MASK, syndrome,
  311. row_index, 0, -1,
  312. mci->ctl_name, "");
  313. ddr_out32(pdata->mc_vbase + FSL_MC_ERR_DETECT, err_detect);
  314. }
  315. static irqreturn_t fsl_mc_isr(int irq, void *dev_id)
  316. {
  317. struct mem_ctl_info *mci = dev_id;
  318. struct fsl_mc_pdata *pdata = mci->pvt_info;
  319. u32 err_detect;
  320. err_detect = ddr_in32(pdata->mc_vbase + FSL_MC_ERR_DETECT);
  321. if (!err_detect)
  322. return IRQ_NONE;
  323. fsl_mc_check(mci);
  324. return IRQ_HANDLED;
  325. }
  326. static void fsl_ddr_init_csrows(struct mem_ctl_info *mci)
  327. {
  328. struct fsl_mc_pdata *pdata = mci->pvt_info;
  329. struct csrow_info *csrow;
  330. struct dimm_info *dimm;
  331. u32 sdram_ctl;
  332. u32 sdtype;
  333. enum mem_type mtype;
  334. u32 cs_bnds;
  335. int index;
  336. sdram_ctl = ddr_in32(pdata->mc_vbase + FSL_MC_DDR_SDRAM_CFG);
  337. sdtype = sdram_ctl & DSC_SDTYPE_MASK;
  338. if (sdram_ctl & DSC_RD_EN) {
  339. switch (sdtype) {
  340. case 0x02000000:
  341. mtype = MEM_RDDR;
  342. break;
  343. case 0x03000000:
  344. mtype = MEM_RDDR2;
  345. break;
  346. case 0x07000000:
  347. mtype = MEM_RDDR3;
  348. break;
  349. case 0x05000000:
  350. mtype = MEM_RDDR4;
  351. break;
  352. default:
  353. mtype = MEM_UNKNOWN;
  354. break;
  355. }
  356. } else {
  357. switch (sdtype) {
  358. case 0x02000000:
  359. mtype = MEM_DDR;
  360. break;
  361. case 0x03000000:
  362. mtype = MEM_DDR2;
  363. break;
  364. case 0x07000000:
  365. mtype = MEM_DDR3;
  366. break;
  367. case 0x05000000:
  368. mtype = MEM_DDR4;
  369. break;
  370. default:
  371. mtype = MEM_UNKNOWN;
  372. break;
  373. }
  374. }
  375. for (index = 0; index < mci->nr_csrows; index++) {
  376. u32 start;
  377. u32 end;
  378. csrow = mci->csrows[index];
  379. dimm = csrow->channels[0]->dimm;
  380. cs_bnds = ddr_in32(pdata->mc_vbase + FSL_MC_CS_BNDS_0 +
  381. (index * FSL_MC_CS_BNDS_OFS));
  382. start = (cs_bnds & 0xffff0000) >> 16;
  383. end = (cs_bnds & 0x0000ffff);
  384. if (start == end)
  385. continue; /* not populated */
  386. start <<= (24 - PAGE_SHIFT);
  387. end <<= (24 - PAGE_SHIFT);
  388. end |= (1 << (24 - PAGE_SHIFT)) - 1;
  389. csrow->first_page = start;
  390. csrow->last_page = end;
  391. dimm->nr_pages = end + 1 - start;
  392. dimm->grain = 8;
  393. dimm->mtype = mtype;
  394. dimm->dtype = DEV_UNKNOWN;
  395. if (sdram_ctl & DSC_X32_EN)
  396. dimm->dtype = DEV_X32;
  397. dimm->edac_mode = EDAC_SECDED;
  398. }
  399. }
  400. int fsl_mc_err_probe(struct platform_device *op)
  401. {
  402. struct mem_ctl_info *mci;
  403. struct edac_mc_layer layers[2];
  404. struct fsl_mc_pdata *pdata;
  405. struct resource r;
  406. u32 sdram_ctl;
  407. int res;
  408. if (!devres_open_group(&op->dev, fsl_mc_err_probe, GFP_KERNEL))
  409. return -ENOMEM;
  410. layers[0].type = EDAC_MC_LAYER_CHIP_SELECT;
  411. layers[0].size = 4;
  412. layers[0].is_virt_csrow = true;
  413. layers[1].type = EDAC_MC_LAYER_CHANNEL;
  414. layers[1].size = 1;
  415. layers[1].is_virt_csrow = false;
  416. mci = edac_mc_alloc(edac_mc_idx, ARRAY_SIZE(layers), layers,
  417. sizeof(*pdata));
  418. if (!mci) {
  419. devres_release_group(&op->dev, fsl_mc_err_probe);
  420. return -ENOMEM;
  421. }
  422. pdata = mci->pvt_info;
  423. pdata->name = "fsl_mc_err";
  424. mci->pdev = &op->dev;
  425. pdata->edac_idx = edac_mc_idx++;
  426. dev_set_drvdata(mci->pdev, mci);
  427. mci->ctl_name = pdata->name;
  428. mci->dev_name = pdata->name;
  429. /*
  430. * Get the endianness of DDR controller registers.
  431. * Default is big endian.
  432. */
  433. little_endian = of_property_read_bool(op->dev.of_node, "little-endian");
  434. res = of_address_to_resource(op->dev.of_node, 0, &r);
  435. if (res) {
  436. pr_err("%s: Unable to get resource for MC err regs\n",
  437. __func__);
  438. goto err;
  439. }
  440. if (!devm_request_mem_region(&op->dev, r.start, resource_size(&r),
  441. pdata->name)) {
  442. pr_err("%s: Error while requesting mem region\n",
  443. __func__);
  444. res = -EBUSY;
  445. goto err;
  446. }
  447. pdata->mc_vbase = devm_ioremap(&op->dev, r.start, resource_size(&r));
  448. if (!pdata->mc_vbase) {
  449. pr_err("%s: Unable to setup MC err regs\n", __func__);
  450. res = -ENOMEM;
  451. goto err;
  452. }
  453. sdram_ctl = ddr_in32(pdata->mc_vbase + FSL_MC_DDR_SDRAM_CFG);
  454. if (!(sdram_ctl & DSC_ECC_EN)) {
  455. /* no ECC */
  456. pr_warn("%s: No ECC DIMMs discovered\n", __func__);
  457. res = -ENODEV;
  458. goto err;
  459. }
  460. edac_dbg(3, "init mci\n");
  461. mci->mtype_cap = MEM_FLAG_DDR | MEM_FLAG_RDDR |
  462. MEM_FLAG_DDR2 | MEM_FLAG_RDDR2 |
  463. MEM_FLAG_DDR3 | MEM_FLAG_RDDR3 |
  464. MEM_FLAG_DDR4 | MEM_FLAG_RDDR4;
  465. mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED;
  466. mci->edac_cap = EDAC_FLAG_SECDED;
  467. mci->mod_name = EDAC_MOD_STR;
  468. if (edac_op_state == EDAC_OPSTATE_POLL)
  469. mci->edac_check = fsl_mc_check;
  470. mci->ctl_page_to_phys = NULL;
  471. mci->scrub_mode = SCRUB_SW_SRC;
  472. fsl_ddr_init_csrows(mci);
  473. /* store the original error disable bits */
  474. orig_ddr_err_disable = ddr_in32(pdata->mc_vbase + FSL_MC_ERR_DISABLE);
  475. ddr_out32(pdata->mc_vbase + FSL_MC_ERR_DISABLE, 0);
  476. /* clear all error bits */
  477. ddr_out32(pdata->mc_vbase + FSL_MC_ERR_DETECT, ~0);
  478. res = edac_mc_add_mc_with_groups(mci, fsl_ddr_dev_groups);
  479. if (res) {
  480. edac_dbg(3, "failed edac_mc_add_mc()\n");
  481. goto err;
  482. }
  483. if (edac_op_state == EDAC_OPSTATE_INT) {
  484. ddr_out32(pdata->mc_vbase + FSL_MC_ERR_INT_EN,
  485. DDR_EIE_MBEE | DDR_EIE_SBEE);
  486. /* store the original error management threshold */
  487. orig_ddr_err_sbe = ddr_in32(pdata->mc_vbase +
  488. FSL_MC_ERR_SBE) & 0xff0000;
  489. /* set threshold to 1 error per interrupt */
  490. ddr_out32(pdata->mc_vbase + FSL_MC_ERR_SBE, 0x10000);
  491. /* register interrupts */
  492. pdata->irq = platform_get_irq(op, 0);
  493. res = devm_request_irq(&op->dev, pdata->irq,
  494. fsl_mc_isr,
  495. IRQF_SHARED,
  496. "[EDAC] MC err", mci);
  497. if (res < 0) {
  498. pr_err("%s: Unable to request irq %d for FSL DDR DRAM ERR\n",
  499. __func__, pdata->irq);
  500. res = -ENODEV;
  501. goto err2;
  502. }
  503. pr_info(EDAC_MOD_STR " acquired irq %d for MC\n",
  504. pdata->irq);
  505. }
  506. devres_remove_group(&op->dev, fsl_mc_err_probe);
  507. edac_dbg(3, "success\n");
  508. pr_info(EDAC_MOD_STR " MC err registered\n");
  509. return 0;
  510. err2:
  511. edac_mc_del_mc(&op->dev);
  512. err:
  513. devres_release_group(&op->dev, fsl_mc_err_probe);
  514. edac_mc_free(mci);
  515. return res;
  516. }
  517. int fsl_mc_err_remove(struct platform_device *op)
  518. {
  519. struct mem_ctl_info *mci = dev_get_drvdata(&op->dev);
  520. struct fsl_mc_pdata *pdata = mci->pvt_info;
  521. edac_dbg(0, "\n");
  522. if (edac_op_state == EDAC_OPSTATE_INT) {
  523. ddr_out32(pdata->mc_vbase + FSL_MC_ERR_INT_EN, 0);
  524. }
  525. ddr_out32(pdata->mc_vbase + FSL_MC_ERR_DISABLE,
  526. orig_ddr_err_disable);
  527. ddr_out32(pdata->mc_vbase + FSL_MC_ERR_SBE, orig_ddr_err_sbe);
  528. edac_mc_del_mc(&op->dev);
  529. edac_mc_free(mci);
  530. return 0;
  531. }