2 * Marvell MV64x60 Memory Controller kernel module for PPC platforms
4 * Author: Dave Jiang <djiang@mvista.com>
6 * 2006-2007 (c) MontaVista Software, Inc. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
13 #include <linux/module.h>
14 #include <linux/init.h>
15 #include <linux/slab.h>
16 #include <linux/interrupt.h>
18 #include <linux/edac.h>
20 #include "edac_core.h"
21 #include "edac_module.h"
22 #include "mv64x60_edac.h"
24 static const char *mv64x60_ctl_name
= "MV64x60";
25 static int edac_dev_idx
;
26 static int edac_pci_idx
;
27 static int edac_mc_idx
;
29 /*********************** PCI err device **********************************/
31 static void mv64x60_pci_check(struct edac_pci_ctl_info
*pci
)
33 struct mv64x60_pci_pdata
*pdata
= pci
->pvt_info
;
36 cause
= in_le32(pdata
->pci_vbase
+ MV64X60_PCI_ERROR_CAUSE
);
40 printk(KERN_ERR
"Error in PCI %d Interface\n", pdata
->pci_hose
);
41 printk(KERN_ERR
"Cause register: 0x%08x\n", cause
);
42 printk(KERN_ERR
"Address Low: 0x%08x\n",
43 in_le32(pdata
->pci_vbase
+ MV64X60_PCI_ERROR_ADDR_LO
));
44 printk(KERN_ERR
"Address High: 0x%08x\n",
45 in_le32(pdata
->pci_vbase
+ MV64X60_PCI_ERROR_ADDR_HI
));
46 printk(KERN_ERR
"Attribute: 0x%08x\n",
47 in_le32(pdata
->pci_vbase
+ MV64X60_PCI_ERROR_ATTR
));
48 printk(KERN_ERR
"Command: 0x%08x\n",
49 in_le32(pdata
->pci_vbase
+ MV64X60_PCI_ERROR_CMD
));
50 out_le32(pdata
->pci_vbase
+ MV64X60_PCI_ERROR_CAUSE
, ~cause
);
52 if (cause
& MV64X60_PCI_PE_MASK
)
53 edac_pci_handle_pe(pci
, pci
->ctl_name
);
55 if (!(cause
& MV64X60_PCI_PE_MASK
))
56 edac_pci_handle_npe(pci
, pci
->ctl_name
);
59 static irqreturn_t
mv64x60_pci_isr(int irq
, void *dev_id
)
61 struct edac_pci_ctl_info
*pci
= dev_id
;
62 struct mv64x60_pci_pdata
*pdata
= pci
->pvt_info
;
65 val
= in_le32(pdata
->pci_vbase
+ MV64X60_PCI_ERROR_CAUSE
);
69 mv64x60_pci_check(pci
);
74 static int __devinit
mv64x60_pci_err_probe(struct platform_device
*pdev
)
76 struct edac_pci_ctl_info
*pci
;
77 struct mv64x60_pci_pdata
*pdata
;
81 if (!devres_open_group(&pdev
->dev
, mv64x60_pci_err_probe
, GFP_KERNEL
))
84 pci
= edac_pci_alloc_ctl_info(sizeof(*pdata
), "mv64x60_pci_err");
88 pdata
= pci
->pvt_info
;
90 pdata
->pci_hose
= pdev
->id
;
91 pdata
->name
= "mpc85xx_pci_err";
93 platform_set_drvdata(pdev
, pci
);
94 pci
->dev
= &pdev
->dev
;
95 pci
->dev_name
= pdev
->dev
.bus_id
;
96 pci
->mod_name
= EDAC_MOD_STR
;
97 pci
->ctl_name
= pdata
->name
;
99 if (edac_op_state
== EDAC_OPSTATE_POLL
)
100 pci
->edac_check
= mv64x60_pci_check
;
102 pdata
->edac_idx
= edac_pci_idx
++;
104 r
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
106 printk(KERN_ERR
"%s: Unable to get resource for "
107 "PCI err regs\n", __func__
);
112 if (!devm_request_mem_region(&pdev
->dev
,
114 r
->end
- r
->start
+ 1,
116 printk(KERN_ERR
"%s: Error while requesting mem region\n",
122 pdata
->pci_vbase
= devm_ioremap(&pdev
->dev
,
124 r
->end
- r
->start
+ 1);
125 if (!pdata
->pci_vbase
) {
126 printk(KERN_ERR
"%s: Unable to setup PCI err regs\n", __func__
);
131 out_le32(pdata
->pci_vbase
+ MV64X60_PCI_ERROR_CAUSE
, 0);
132 out_le32(pdata
->pci_vbase
+ MV64X60_PCI_ERROR_MASK
, 0);
133 out_le32(pdata
->pci_vbase
+ MV64X60_PCI_ERROR_MASK
,
134 MV64X60_PCIx_ERR_MASK_VAL
);
136 if (edac_pci_add_device(pci
, pdata
->edac_idx
) > 0) {
137 debugf3("%s(): failed edac_pci_add_device()\n", __func__
);
141 if (edac_op_state
== EDAC_OPSTATE_INT
) {
142 pdata
->irq
= platform_get_irq(pdev
, 0);
143 res
= devm_request_irq(&pdev
->dev
,
150 printk(KERN_ERR
"%s: Unable to request irq %d for "
151 "MV64x60 PCI ERR\n", __func__
, pdata
->irq
);
155 printk(KERN_INFO EDAC_MOD_STR
" acquired irq %d for PCI Err\n",
159 devres_remove_group(&pdev
->dev
, mv64x60_pci_err_probe
);
161 /* get this far and it's successful */
162 debugf3("%s(): success\n", __func__
);
167 edac_pci_del_device(&pdev
->dev
);
169 edac_pci_free_ctl_info(pci
);
170 devres_release_group(&pdev
->dev
, mv64x60_pci_err_probe
);
174 static int mv64x60_pci_err_remove(struct platform_device
*pdev
)
176 struct edac_pci_ctl_info
*pci
= platform_get_drvdata(pdev
);
178 debugf0("%s()\n", __func__
);
180 edac_pci_del_device(&pdev
->dev
);
182 edac_pci_free_ctl_info(pci
);
187 static struct platform_driver mv64x60_pci_err_driver
= {
188 .probe
= mv64x60_pci_err_probe
,
189 .remove
= __devexit_p(mv64x60_pci_err_remove
),
191 .name
= "mv64x60_pci_err",
195 #endif /* CONFIG_PCI */
197 /*********************** SRAM err device **********************************/
198 static void mv64x60_sram_check(struct edac_device_ctl_info
*edac_dev
)
200 struct mv64x60_sram_pdata
*pdata
= edac_dev
->pvt_info
;
203 cause
= in_le32(pdata
->sram_vbase
+ MV64X60_SRAM_ERR_CAUSE
);
207 printk(KERN_ERR
"Error in internal SRAM\n");
208 printk(KERN_ERR
"Cause register: 0x%08x\n", cause
);
209 printk(KERN_ERR
"Address Low: 0x%08x\n",
210 in_le32(pdata
->sram_vbase
+ MV64X60_SRAM_ERR_ADDR_LO
));
211 printk(KERN_ERR
"Address High: 0x%08x\n",
212 in_le32(pdata
->sram_vbase
+ MV64X60_SRAM_ERR_ADDR_HI
));
213 printk(KERN_ERR
"Data Low: 0x%08x\n",
214 in_le32(pdata
->sram_vbase
+ MV64X60_SRAM_ERR_DATA_LO
));
215 printk(KERN_ERR
"Data High: 0x%08x\n",
216 in_le32(pdata
->sram_vbase
+ MV64X60_SRAM_ERR_DATA_HI
));
217 printk(KERN_ERR
"Parity: 0x%08x\n",
218 in_le32(pdata
->sram_vbase
+ MV64X60_SRAM_ERR_PARITY
));
219 out_le32(pdata
->sram_vbase
+ MV64X60_SRAM_ERR_CAUSE
, 0);
221 edac_device_handle_ue(edac_dev
, 0, 0, edac_dev
->ctl_name
);
224 static irqreturn_t
mv64x60_sram_isr(int irq
, void *dev_id
)
226 struct edac_device_ctl_info
*edac_dev
= dev_id
;
227 struct mv64x60_sram_pdata
*pdata
= edac_dev
->pvt_info
;
230 cause
= in_le32(pdata
->sram_vbase
+ MV64X60_SRAM_ERR_CAUSE
);
234 mv64x60_sram_check(edac_dev
);
239 static int __devinit
mv64x60_sram_err_probe(struct platform_device
*pdev
)
241 struct edac_device_ctl_info
*edac_dev
;
242 struct mv64x60_sram_pdata
*pdata
;
246 if (!devres_open_group(&pdev
->dev
, mv64x60_sram_err_probe
, GFP_KERNEL
))
249 edac_dev
= edac_device_alloc_ctl_info(sizeof(*pdata
),
250 "sram", 1, NULL
, 0, 0, NULL
, 0,
253 devres_release_group(&pdev
->dev
, mv64x60_sram_err_probe
);
257 pdata
= edac_dev
->pvt_info
;
258 pdata
->name
= "mv64x60_sram_err";
260 edac_dev
->dev
= &pdev
->dev
;
261 platform_set_drvdata(pdev
, edac_dev
);
262 edac_dev
->dev_name
= pdev
->dev
.bus_id
;
264 r
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
266 printk(KERN_ERR
"%s: Unable to get resource for "
267 "SRAM err regs\n", __func__
);
272 if (!devm_request_mem_region(&pdev
->dev
,
274 r
->end
- r
->start
+ 1,
276 printk(KERN_ERR
"%s: Error while request mem region\n",
282 pdata
->sram_vbase
= devm_ioremap(&pdev
->dev
,
284 r
->end
- r
->start
+ 1);
285 if (!pdata
->sram_vbase
) {
286 printk(KERN_ERR
"%s: Unable to setup SRAM err regs\n",
292 /* setup SRAM err registers */
293 out_le32(pdata
->sram_vbase
+ MV64X60_SRAM_ERR_CAUSE
, 0);
295 edac_dev
->mod_name
= EDAC_MOD_STR
;
296 edac_dev
->ctl_name
= pdata
->name
;
298 if (edac_op_state
== EDAC_OPSTATE_POLL
)
299 edac_dev
->edac_check
= mv64x60_sram_check
;
301 pdata
->edac_idx
= edac_dev_idx
++;
303 if (edac_device_add_device(edac_dev
) > 0) {
304 debugf3("%s(): failed edac_device_add_device()\n", __func__
);
308 if (edac_op_state
== EDAC_OPSTATE_INT
) {
309 pdata
->irq
= platform_get_irq(pdev
, 0);
310 res
= devm_request_irq(&pdev
->dev
,
318 "%s: Unable to request irq %d for "
319 "MV64x60 SRAM ERR\n", __func__
, pdata
->irq
);
324 printk(KERN_INFO EDAC_MOD_STR
" acquired irq %d for SRAM Err\n",
328 devres_remove_group(&pdev
->dev
, mv64x60_sram_err_probe
);
330 /* get this far and it's successful */
331 debugf3("%s(): success\n", __func__
);
336 edac_device_del_device(&pdev
->dev
);
338 devres_release_group(&pdev
->dev
, mv64x60_sram_err_probe
);
339 edac_device_free_ctl_info(edac_dev
);
343 static int mv64x60_sram_err_remove(struct platform_device
*pdev
)
345 struct edac_device_ctl_info
*edac_dev
= platform_get_drvdata(pdev
);
347 debugf0("%s()\n", __func__
);
349 edac_device_del_device(&pdev
->dev
);
350 edac_device_free_ctl_info(edac_dev
);
355 static struct platform_driver mv64x60_sram_err_driver
= {
356 .probe
= mv64x60_sram_err_probe
,
357 .remove
= mv64x60_sram_err_remove
,
359 .name
= "mv64x60_sram_err",
363 /*********************** CPU err device **********************************/
364 static void mv64x60_cpu_check(struct edac_device_ctl_info
*edac_dev
)
366 struct mv64x60_cpu_pdata
*pdata
= edac_dev
->pvt_info
;
369 cause
= in_le32(pdata
->cpu_vbase
[1] + MV64x60_CPU_ERR_CAUSE
) &
370 MV64x60_CPU_CAUSE_MASK
;
374 printk(KERN_ERR
"Error on CPU interface\n");
375 printk(KERN_ERR
"Cause register: 0x%08x\n", cause
);
376 printk(KERN_ERR
"Address Low: 0x%08x\n",
377 in_le32(pdata
->cpu_vbase
[0] + MV64x60_CPU_ERR_ADDR_LO
));
378 printk(KERN_ERR
"Address High: 0x%08x\n",
379 in_le32(pdata
->cpu_vbase
[0] + MV64x60_CPU_ERR_ADDR_HI
));
380 printk(KERN_ERR
"Data Low: 0x%08x\n",
381 in_le32(pdata
->cpu_vbase
[1] + MV64x60_CPU_ERR_DATA_LO
));
382 printk(KERN_ERR
"Data High: 0x%08x\n",
383 in_le32(pdata
->cpu_vbase
[1] + MV64x60_CPU_ERR_DATA_HI
));
384 printk(KERN_ERR
"Parity: 0x%08x\n",
385 in_le32(pdata
->cpu_vbase
[1] + MV64x60_CPU_ERR_PARITY
));
386 out_le32(pdata
->cpu_vbase
[1] + MV64x60_CPU_ERR_CAUSE
, 0);
388 edac_device_handle_ue(edac_dev
, 0, 0, edac_dev
->ctl_name
);
391 static irqreturn_t
mv64x60_cpu_isr(int irq
, void *dev_id
)
393 struct edac_device_ctl_info
*edac_dev
= dev_id
;
394 struct mv64x60_cpu_pdata
*pdata
= edac_dev
->pvt_info
;
397 cause
= in_le32(pdata
->cpu_vbase
[1] + MV64x60_CPU_ERR_CAUSE
) &
398 MV64x60_CPU_CAUSE_MASK
;
402 mv64x60_cpu_check(edac_dev
);
407 static int __devinit
mv64x60_cpu_err_probe(struct platform_device
*pdev
)
409 struct edac_device_ctl_info
*edac_dev
;
411 struct mv64x60_cpu_pdata
*pdata
;
414 if (!devres_open_group(&pdev
->dev
, mv64x60_cpu_err_probe
, GFP_KERNEL
))
417 edac_dev
= edac_device_alloc_ctl_info(sizeof(*pdata
),
418 "cpu", 1, NULL
, 0, 0, NULL
, 0,
421 devres_release_group(&pdev
->dev
, mv64x60_cpu_err_probe
);
425 pdata
= edac_dev
->pvt_info
;
426 pdata
->name
= "mv64x60_cpu_err";
428 edac_dev
->dev
= &pdev
->dev
;
429 platform_set_drvdata(pdev
, edac_dev
);
430 edac_dev
->dev_name
= pdev
->dev
.bus_id
;
432 r
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
434 printk(KERN_ERR
"%s: Unable to get resource for "
435 "CPU err regs\n", __func__
);
440 if (!devm_request_mem_region(&pdev
->dev
,
442 r
->end
- r
->start
+ 1,
444 printk(KERN_ERR
"%s: Error while requesting mem region\n",
450 pdata
->cpu_vbase
[0] = devm_ioremap(&pdev
->dev
,
452 r
->end
- r
->start
+ 1);
453 if (!pdata
->cpu_vbase
[0]) {
454 printk(KERN_ERR
"%s: Unable to setup CPU err regs\n", __func__
);
459 r
= platform_get_resource(pdev
, IORESOURCE_MEM
, 1);
461 printk(KERN_ERR
"%s: Unable to get resource for "
462 "CPU err regs\n", __func__
);
467 if (!devm_request_mem_region(&pdev
->dev
,
469 r
->end
- r
->start
+ 1,
471 printk(KERN_ERR
"%s: Error while requesting mem region\n",
477 pdata
->cpu_vbase
[1] = devm_ioremap(&pdev
->dev
,
479 r
->end
- r
->start
+ 1);
480 if (!pdata
->cpu_vbase
[1]) {
481 printk(KERN_ERR
"%s: Unable to setup CPU err regs\n", __func__
);
486 /* setup CPU err registers */
487 out_le32(pdata
->cpu_vbase
[1] + MV64x60_CPU_ERR_CAUSE
, 0);
488 out_le32(pdata
->cpu_vbase
[1] + MV64x60_CPU_ERR_MASK
, 0);
489 out_le32(pdata
->cpu_vbase
[1] + MV64x60_CPU_ERR_MASK
, 0x000000ff);
491 edac_dev
->mod_name
= EDAC_MOD_STR
;
492 edac_dev
->ctl_name
= pdata
->name
;
493 if (edac_op_state
== EDAC_OPSTATE_POLL
)
494 edac_dev
->edac_check
= mv64x60_cpu_check
;
496 pdata
->edac_idx
= edac_dev_idx
++;
498 if (edac_device_add_device(edac_dev
) > 0) {
499 debugf3("%s(): failed edac_device_add_device()\n", __func__
);
503 if (edac_op_state
== EDAC_OPSTATE_INT
) {
504 pdata
->irq
= platform_get_irq(pdev
, 0);
505 res
= devm_request_irq(&pdev
->dev
,
513 "%s: Unable to request irq %d for MV64x60 "
514 "CPU ERR\n", __func__
, pdata
->irq
);
519 printk(KERN_INFO EDAC_MOD_STR
520 " acquired irq %d for CPU Err\n", pdata
->irq
);
523 devres_remove_group(&pdev
->dev
, mv64x60_cpu_err_probe
);
525 /* get this far and it's successful */
526 debugf3("%s(): success\n", __func__
);
531 edac_device_del_device(&pdev
->dev
);
533 devres_release_group(&pdev
->dev
, mv64x60_cpu_err_probe
);
534 edac_device_free_ctl_info(edac_dev
);
538 static int mv64x60_cpu_err_remove(struct platform_device
*pdev
)
540 struct edac_device_ctl_info
*edac_dev
= platform_get_drvdata(pdev
);
542 debugf0("%s()\n", __func__
);
544 edac_device_del_device(&pdev
->dev
);
545 edac_device_free_ctl_info(edac_dev
);
549 static struct platform_driver mv64x60_cpu_err_driver
= {
550 .probe
= mv64x60_cpu_err_probe
,
551 .remove
= mv64x60_cpu_err_remove
,
553 .name
= "mv64x60_cpu_err",
557 /*********************** DRAM err device **********************************/
559 static void mv64x60_mc_check(struct mem_ctl_info
*mci
)
561 struct mv64x60_mc_pdata
*pdata
= mci
->pvt_info
;
568 reg
= in_le32(pdata
->mc_vbase
+ MV64X60_SDRAM_ERR_ADDR
);
572 err_addr
= reg
& ~0x3;
573 sdram_ecc
= in_le32(pdata
->mc_vbase
+ MV64X60_SDRAM_ERR_ECC_RCVD
);
574 comp_ecc
= in_le32(pdata
->mc_vbase
+ MV64X60_SDRAM_ERR_ECC_CALC
);
575 syndrome
= sdram_ecc
^ comp_ecc
;
577 /* first bit clear in ECC Err Reg, 1 bit error, correctable by HW */
579 edac_mc_handle_ce(mci
, err_addr
>> PAGE_SHIFT
,
580 err_addr
& PAGE_MASK
, syndrome
, 0, 0,
582 else /* 2 bit error, UE */
583 edac_mc_handle_ue(mci
, err_addr
>> PAGE_SHIFT
,
584 err_addr
& PAGE_MASK
, 0, mci
->ctl_name
);
586 /* clear the error */
587 out_le32(pdata
->mc_vbase
+ MV64X60_SDRAM_ERR_ADDR
, 0);
590 static irqreturn_t
mv64x60_mc_isr(int irq
, void *dev_id
)
592 struct mem_ctl_info
*mci
= dev_id
;
593 struct mv64x60_mc_pdata
*pdata
= mci
->pvt_info
;
596 reg
= in_le32(pdata
->mc_vbase
+ MV64X60_SDRAM_ERR_ADDR
);
600 /* writing 0's to the ECC err addr in check function clears irq */
601 mv64x60_mc_check(mci
);
606 static void get_total_mem(struct mv64x60_mc_pdata
*pdata
)
608 struct device_node
*np
= NULL
;
609 const unsigned int *reg
;
611 np
= of_find_node_by_type(NULL
, "memory");
615 reg
= get_property(np
, "reg", NULL
);
617 pdata
->total_mem
= reg
[1];
620 static void mv64x60_init_csrows(struct mem_ctl_info
*mci
,
621 struct mv64x60_mc_pdata
*pdata
)
623 struct csrow_info
*csrow
;
627 get_total_mem(pdata
);
629 ctl
= in_le32(pdata
->mc_vbase
+ MV64X60_SDRAM_CONFIG
);
631 csrow
= &mci
->csrows
[0];
632 csrow
->first_page
= 0;
633 csrow
->nr_pages
= pdata
->total_mem
>> PAGE_SHIFT
;
634 csrow
->last_page
= csrow
->first_page
+ csrow
->nr_pages
- 1;
637 csrow
->mtype
= (ctl
& MV64X60_SDRAM_REGISTERED
) ? MEM_RDDR
: MEM_DDR
;
639 devtype
= (ctl
>> 20) & 0x3;
642 csrow
->dtype
= DEV_X32
;
644 case 0x2: /* could be X8 too, but no way to tell */
645 csrow
->dtype
= DEV_X16
;
648 csrow
->dtype
= DEV_X4
;
651 csrow
->dtype
= DEV_UNKNOWN
;
655 csrow
->edac_mode
= EDAC_SECDED
;
658 static int __devinit
mv64x60_mc_err_probe(struct platform_device
*pdev
)
660 struct mem_ctl_info
*mci
;
661 struct mv64x60_mc_pdata
*pdata
;
666 if (!devres_open_group(&pdev
->dev
, mv64x60_mc_err_probe
, GFP_KERNEL
))
669 mci
= edac_mc_alloc(sizeof(struct mv64x60_mc_pdata
), 1, 1, edac_mc_idx
);
671 printk(KERN_ERR
"%s: No memory for CPU err\n", __func__
);
672 devres_release_group(&pdev
->dev
, mv64x60_mc_err_probe
);
676 pdata
= mci
->pvt_info
;
677 mci
->dev
= &pdev
->dev
;
678 platform_set_drvdata(pdev
, mci
);
679 pdata
->name
= "mv64x60_mc_err";
681 mci
->dev_name
= pdev
->dev
.bus_id
;
682 pdata
->edac_idx
= edac_mc_idx
++;
684 r
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
686 printk(KERN_ERR
"%s: Unable to get resource for "
687 "MC err regs\n", __func__
);
692 if (!devm_request_mem_region(&pdev
->dev
,
694 r
->end
- r
->start
+ 1,
696 printk(KERN_ERR
"%s: Error while requesting mem region\n",
702 pdata
->mc_vbase
= devm_ioremap(&pdev
->dev
,
704 r
->end
- r
->start
+ 1);
705 if (!pdata
->mc_vbase
) {
706 printk(KERN_ERR
"%s: Unable to setup MC err regs\n", __func__
);
711 ctl
= in_le32(pdata
->mc_vbase
+ MV64X60_SDRAM_CONFIG
);
712 if (!(ctl
& MV64X60_SDRAM_ECC
)) {
714 printk(KERN_WARNING
"%s: No ECC DIMMs discovered\n", __func__
);
719 debugf3("%s(): init mci\n", __func__
);
720 mci
->mtype_cap
= MEM_FLAG_RDDR
| MEM_FLAG_DDR
;
721 mci
->edac_ctl_cap
= EDAC_FLAG_NONE
| EDAC_FLAG_SECDED
;
722 mci
->edac_cap
= EDAC_FLAG_SECDED
;
723 mci
->mod_name
= EDAC_MOD_STR
;
724 mci
->mod_ver
= MV64x60_REVISION
;
725 mci
->ctl_name
= mv64x60_ctl_name
;
727 if (edac_op_state
== EDAC_OPSTATE_POLL
)
728 mci
->edac_check
= mv64x60_mc_check
;
730 mci
->ctl_page_to_phys
= NULL
;
732 mci
->scrub_mode
= SCRUB_SW_SRC
;
734 mv64x60_init_csrows(mci
, pdata
);
736 /* setup MC registers */
737 out_le32(pdata
->mc_vbase
+ MV64X60_SDRAM_ERR_ADDR
, 0);
738 ctl
= in_le32(pdata
->mc_vbase
+ MV64X60_SDRAM_ERR_ECC_CNTL
);
739 ctl
= (ctl
& 0xff00ffff) | 0x10000;
740 out_le32(pdata
->mc_vbase
+ MV64X60_SDRAM_ERR_ECC_CNTL
, ctl
);
742 if (edac_mc_add_mc(mci
)) {
743 debugf3("%s(): failed edac_mc_add_mc()\n", __func__
);
747 if (edac_op_state
== EDAC_OPSTATE_INT
) {
748 /* acquire interrupt that reports errors */
749 pdata
->irq
= platform_get_irq(pdev
, 0);
750 res
= devm_request_irq(&pdev
->dev
,
757 printk(KERN_ERR
"%s: Unable to request irq %d for "
758 "MV64x60 DRAM ERR\n", __func__
, pdata
->irq
);
763 printk(KERN_INFO EDAC_MOD_STR
" acquired irq %d for MC Err\n",
767 /* get this far and it's successful */
768 debugf3("%s(): success\n", __func__
);
773 edac_mc_del_mc(&pdev
->dev
);
775 devres_release_group(&pdev
->dev
, mv64x60_mc_err_probe
);
780 static int mv64x60_mc_err_remove(struct platform_device
*pdev
)
782 struct mem_ctl_info
*mci
= platform_get_drvdata(pdev
);
784 debugf0("%s()\n", __func__
);
786 edac_mc_del_mc(&pdev
->dev
);
791 static struct platform_driver mv64x60_mc_err_driver
= {
792 .probe
= mv64x60_mc_err_probe
,
793 .remove
= mv64x60_mc_err_remove
,
795 .name
= "mv64x60_mc_err",
799 static int __init
mv64x60_edac_init(void)
803 printk(KERN_INFO
"Marvell MV64x60 EDAC driver " MV64x60_REVISION
"\n");
804 printk(KERN_INFO
"\t(C) 2006-2007 MontaVista Software\n");
805 /* make sure error reporting method is sane */
806 switch (edac_op_state
) {
807 case EDAC_OPSTATE_POLL
:
808 case EDAC_OPSTATE_INT
:
811 edac_op_state
= EDAC_OPSTATE_INT
;
815 ret
= platform_driver_register(&mv64x60_mc_err_driver
);
817 printk(KERN_WARNING EDAC_MOD_STR
"MC err failed to register\n");
819 ret
= platform_driver_register(&mv64x60_cpu_err_driver
);
821 printk(KERN_WARNING EDAC_MOD_STR
822 "CPU err failed to register\n");
824 ret
= platform_driver_register(&mv64x60_sram_err_driver
);
826 printk(KERN_WARNING EDAC_MOD_STR
827 "SRAM err failed to register\n");
830 ret
= platform_driver_register(&mv64x60_pci_err_driver
);
832 printk(KERN_WARNING EDAC_MOD_STR
833 "PCI err failed to register\n");
838 module_init(mv64x60_edac_init
);
840 static void __exit
mv64x60_edac_exit(void)
843 platform_driver_unregister(&mv64x60_pci_err_driver
);
845 platform_driver_unregister(&mv64x60_sram_err_driver
);
846 platform_driver_unregister(&mv64x60_cpu_err_driver
);
847 platform_driver_unregister(&mv64x60_mc_err_driver
);
849 module_exit(mv64x60_edac_exit
);
851 MODULE_LICENSE("GPL");
852 MODULE_AUTHOR("Montavista Software, Inc.");
853 module_param(edac_op_state
, int, 0444);
854 MODULE_PARM_DESC(edac_op_state
,
855 "EDAC Error Reporting state: 0=Poll, 2=Interrupt");