fsl_ddr_edac.c 15 KB

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