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/interrupt.h>
17 #include <linux/edac.h>
18 #include <linux/gfp.h>
20 #include "edac_module.h"
21 #include "mv64x60_edac.h"
23 static const char *mv64x60_ctl_name
= "MV64x60";
24 static int edac_dev_idx
;
25 static int edac_pci_idx
;
26 static int edac_mc_idx
;
28 /*********************** PCI err device **********************************/
30 static void mv64x60_pci_check(struct edac_pci_ctl_info
*pci
)
32 struct mv64x60_pci_pdata
*pdata
= pci
->pvt_info
;
35 cause
= in_le32(pdata
->pci_vbase
+ MV64X60_PCI_ERROR_CAUSE
);
39 printk(KERN_ERR
"Error in PCI %d Interface\n", pdata
->pci_hose
);
40 printk(KERN_ERR
"Cause register: 0x%08x\n", cause
);
41 printk(KERN_ERR
"Address Low: 0x%08x\n",
42 in_le32(pdata
->pci_vbase
+ MV64X60_PCI_ERROR_ADDR_LO
));
43 printk(KERN_ERR
"Address High: 0x%08x\n",
44 in_le32(pdata
->pci_vbase
+ MV64X60_PCI_ERROR_ADDR_HI
));
45 printk(KERN_ERR
"Attribute: 0x%08x\n",
46 in_le32(pdata
->pci_vbase
+ MV64X60_PCI_ERROR_ATTR
));
47 printk(KERN_ERR
"Command: 0x%08x\n",
48 in_le32(pdata
->pci_vbase
+ MV64X60_PCI_ERROR_CMD
));
49 out_le32(pdata
->pci_vbase
+ MV64X60_PCI_ERROR_CAUSE
, ~cause
);
51 if (cause
& MV64X60_PCI_PE_MASK
)
52 edac_pci_handle_pe(pci
, pci
->ctl_name
);
54 if (!(cause
& MV64X60_PCI_PE_MASK
))
55 edac_pci_handle_npe(pci
, pci
->ctl_name
);
58 static irqreturn_t
mv64x60_pci_isr(int irq
, void *dev_id
)
60 struct edac_pci_ctl_info
*pci
= dev_id
;
61 struct mv64x60_pci_pdata
*pdata
= pci
->pvt_info
;
64 val
= in_le32(pdata
->pci_vbase
+ MV64X60_PCI_ERROR_CAUSE
);
68 mv64x60_pci_check(pci
);
74 * Bit 0 of MV64x60_PCIx_ERR_MASK does not exist on the 64360 and because of
75 * errata FEr-#11 and FEr-##16 for the 64460, it should be 0 on that chip as
76 * well. IOW, don't set bit 0.
79 /* Erratum FEr PCI-#16: clear bit 0 of PCI SERRn Mask reg. */
80 static int __init
mv64x60_pci_fixup(struct platform_device
*pdev
)
83 void __iomem
*pci_serr
;
85 r
= platform_get_resource(pdev
, IORESOURCE_MEM
, 1);
87 printk(KERN_ERR
"%s: Unable to get resource for "
88 "PCI err regs\n", __func__
);
92 pci_serr
= ioremap(r
->start
, resource_size(r
));
96 out_le32(pci_serr
, in_le32(pci_serr
) & ~0x1);
102 static int mv64x60_pci_err_probe(struct platform_device
*pdev
)
104 struct edac_pci_ctl_info
*pci
;
105 struct mv64x60_pci_pdata
*pdata
;
109 if (!devres_open_group(&pdev
->dev
, mv64x60_pci_err_probe
, GFP_KERNEL
))
112 pci
= edac_pci_alloc_ctl_info(sizeof(*pdata
), "mv64x60_pci_err");
116 pdata
= pci
->pvt_info
;
118 pdata
->pci_hose
= pdev
->id
;
119 pdata
->name
= "mpc85xx_pci_err";
120 platform_set_drvdata(pdev
, pci
);
121 pci
->dev
= &pdev
->dev
;
122 pci
->dev_name
= dev_name(&pdev
->dev
);
123 pci
->mod_name
= EDAC_MOD_STR
;
124 pci
->ctl_name
= pdata
->name
;
126 if (edac_op_state
== EDAC_OPSTATE_POLL
)
127 pci
->edac_check
= mv64x60_pci_check
;
129 pdata
->edac_idx
= edac_pci_idx
++;
131 r
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
133 printk(KERN_ERR
"%s: Unable to get resource for "
134 "PCI err regs\n", __func__
);
139 if (!devm_request_mem_region(&pdev
->dev
,
143 printk(KERN_ERR
"%s: Error while requesting mem region\n",
149 pdata
->pci_vbase
= devm_ioremap(&pdev
->dev
,
152 if (!pdata
->pci_vbase
) {
153 printk(KERN_ERR
"%s: Unable to setup PCI err regs\n", __func__
);
158 res
= mv64x60_pci_fixup(pdev
);
160 printk(KERN_ERR
"%s: PCI fixup failed\n", __func__
);
164 out_le32(pdata
->pci_vbase
+ MV64X60_PCI_ERROR_CAUSE
, 0);
165 out_le32(pdata
->pci_vbase
+ MV64X60_PCI_ERROR_MASK
, 0);
166 out_le32(pdata
->pci_vbase
+ MV64X60_PCI_ERROR_MASK
,
167 MV64X60_PCIx_ERR_MASK_VAL
);
169 if (edac_pci_add_device(pci
, pdata
->edac_idx
) > 0) {
170 edac_dbg(3, "failed edac_pci_add_device()\n");
174 if (edac_op_state
== EDAC_OPSTATE_INT
) {
175 pdata
->irq
= platform_get_irq(pdev
, 0);
176 res
= devm_request_irq(&pdev
->dev
,
183 printk(KERN_ERR
"%s: Unable to request irq %d for "
184 "MV64x60 PCI ERR\n", __func__
, pdata
->irq
);
188 printk(KERN_INFO EDAC_MOD_STR
" acquired irq %d for PCI Err\n",
192 devres_remove_group(&pdev
->dev
, mv64x60_pci_err_probe
);
194 /* get this far and it's successful */
195 edac_dbg(3, "success\n");
200 edac_pci_del_device(&pdev
->dev
);
202 edac_pci_free_ctl_info(pci
);
203 devres_release_group(&pdev
->dev
, mv64x60_pci_err_probe
);
207 static int mv64x60_pci_err_remove(struct platform_device
*pdev
)
209 struct edac_pci_ctl_info
*pci
= platform_get_drvdata(pdev
);
213 edac_pci_del_device(&pdev
->dev
);
215 edac_pci_free_ctl_info(pci
);
220 static struct platform_driver mv64x60_pci_err_driver
= {
221 .probe
= mv64x60_pci_err_probe
,
222 .remove
= mv64x60_pci_err_remove
,
224 .name
= "mv64x60_pci_err",
228 #endif /* CONFIG_PCI */
230 /*********************** SRAM err device **********************************/
231 static void mv64x60_sram_check(struct edac_device_ctl_info
*edac_dev
)
233 struct mv64x60_sram_pdata
*pdata
= edac_dev
->pvt_info
;
236 cause
= in_le32(pdata
->sram_vbase
+ MV64X60_SRAM_ERR_CAUSE
);
240 printk(KERN_ERR
"Error in internal SRAM\n");
241 printk(KERN_ERR
"Cause register: 0x%08x\n", cause
);
242 printk(KERN_ERR
"Address Low: 0x%08x\n",
243 in_le32(pdata
->sram_vbase
+ MV64X60_SRAM_ERR_ADDR_LO
));
244 printk(KERN_ERR
"Address High: 0x%08x\n",
245 in_le32(pdata
->sram_vbase
+ MV64X60_SRAM_ERR_ADDR_HI
));
246 printk(KERN_ERR
"Data Low: 0x%08x\n",
247 in_le32(pdata
->sram_vbase
+ MV64X60_SRAM_ERR_DATA_LO
));
248 printk(KERN_ERR
"Data High: 0x%08x\n",
249 in_le32(pdata
->sram_vbase
+ MV64X60_SRAM_ERR_DATA_HI
));
250 printk(KERN_ERR
"Parity: 0x%08x\n",
251 in_le32(pdata
->sram_vbase
+ MV64X60_SRAM_ERR_PARITY
));
252 out_le32(pdata
->sram_vbase
+ MV64X60_SRAM_ERR_CAUSE
, 0);
254 edac_device_handle_ue(edac_dev
, 0, 0, edac_dev
->ctl_name
);
257 static irqreturn_t
mv64x60_sram_isr(int irq
, void *dev_id
)
259 struct edac_device_ctl_info
*edac_dev
= dev_id
;
260 struct mv64x60_sram_pdata
*pdata
= edac_dev
->pvt_info
;
263 cause
= in_le32(pdata
->sram_vbase
+ MV64X60_SRAM_ERR_CAUSE
);
267 mv64x60_sram_check(edac_dev
);
272 static int mv64x60_sram_err_probe(struct platform_device
*pdev
)
274 struct edac_device_ctl_info
*edac_dev
;
275 struct mv64x60_sram_pdata
*pdata
;
279 if (!devres_open_group(&pdev
->dev
, mv64x60_sram_err_probe
, GFP_KERNEL
))
282 edac_dev
= edac_device_alloc_ctl_info(sizeof(*pdata
),
283 "sram", 1, NULL
, 0, 0, NULL
, 0,
286 devres_release_group(&pdev
->dev
, mv64x60_sram_err_probe
);
290 pdata
= edac_dev
->pvt_info
;
291 pdata
->name
= "mv64x60_sram_err";
292 edac_dev
->dev
= &pdev
->dev
;
293 platform_set_drvdata(pdev
, edac_dev
);
294 edac_dev
->dev_name
= dev_name(&pdev
->dev
);
296 r
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
298 printk(KERN_ERR
"%s: Unable to get resource for "
299 "SRAM err regs\n", __func__
);
304 if (!devm_request_mem_region(&pdev
->dev
,
308 printk(KERN_ERR
"%s: Error while request mem region\n",
314 pdata
->sram_vbase
= devm_ioremap(&pdev
->dev
,
317 if (!pdata
->sram_vbase
) {
318 printk(KERN_ERR
"%s: Unable to setup SRAM err regs\n",
324 /* setup SRAM err registers */
325 out_le32(pdata
->sram_vbase
+ MV64X60_SRAM_ERR_CAUSE
, 0);
327 edac_dev
->mod_name
= EDAC_MOD_STR
;
328 edac_dev
->ctl_name
= pdata
->name
;
330 if (edac_op_state
== EDAC_OPSTATE_POLL
)
331 edac_dev
->edac_check
= mv64x60_sram_check
;
333 pdata
->edac_idx
= edac_dev_idx
++;
335 if (edac_device_add_device(edac_dev
) > 0) {
336 edac_dbg(3, "failed edac_device_add_device()\n");
340 if (edac_op_state
== EDAC_OPSTATE_INT
) {
341 pdata
->irq
= platform_get_irq(pdev
, 0);
342 res
= devm_request_irq(&pdev
->dev
,
350 "%s: Unable to request irq %d for "
351 "MV64x60 SRAM ERR\n", __func__
, pdata
->irq
);
356 printk(KERN_INFO EDAC_MOD_STR
" acquired irq %d for SRAM Err\n",
360 devres_remove_group(&pdev
->dev
, mv64x60_sram_err_probe
);
362 /* get this far and it's successful */
363 edac_dbg(3, "success\n");
368 edac_device_del_device(&pdev
->dev
);
370 devres_release_group(&pdev
->dev
, mv64x60_sram_err_probe
);
371 edac_device_free_ctl_info(edac_dev
);
375 static int mv64x60_sram_err_remove(struct platform_device
*pdev
)
377 struct edac_device_ctl_info
*edac_dev
= platform_get_drvdata(pdev
);
381 edac_device_del_device(&pdev
->dev
);
382 edac_device_free_ctl_info(edac_dev
);
387 static struct platform_driver mv64x60_sram_err_driver
= {
388 .probe
= mv64x60_sram_err_probe
,
389 .remove
= mv64x60_sram_err_remove
,
391 .name
= "mv64x60_sram_err",
395 /*********************** CPU err device **********************************/
396 static void mv64x60_cpu_check(struct edac_device_ctl_info
*edac_dev
)
398 struct mv64x60_cpu_pdata
*pdata
= edac_dev
->pvt_info
;
401 cause
= in_le32(pdata
->cpu_vbase
[1] + MV64x60_CPU_ERR_CAUSE
) &
402 MV64x60_CPU_CAUSE_MASK
;
406 printk(KERN_ERR
"Error on CPU interface\n");
407 printk(KERN_ERR
"Cause register: 0x%08x\n", cause
);
408 printk(KERN_ERR
"Address Low: 0x%08x\n",
409 in_le32(pdata
->cpu_vbase
[0] + MV64x60_CPU_ERR_ADDR_LO
));
410 printk(KERN_ERR
"Address High: 0x%08x\n",
411 in_le32(pdata
->cpu_vbase
[0] + MV64x60_CPU_ERR_ADDR_HI
));
412 printk(KERN_ERR
"Data Low: 0x%08x\n",
413 in_le32(pdata
->cpu_vbase
[1] + MV64x60_CPU_ERR_DATA_LO
));
414 printk(KERN_ERR
"Data High: 0x%08x\n",
415 in_le32(pdata
->cpu_vbase
[1] + MV64x60_CPU_ERR_DATA_HI
));
416 printk(KERN_ERR
"Parity: 0x%08x\n",
417 in_le32(pdata
->cpu_vbase
[1] + MV64x60_CPU_ERR_PARITY
));
418 out_le32(pdata
->cpu_vbase
[1] + MV64x60_CPU_ERR_CAUSE
, 0);
420 edac_device_handle_ue(edac_dev
, 0, 0, edac_dev
->ctl_name
);
423 static irqreturn_t
mv64x60_cpu_isr(int irq
, void *dev_id
)
425 struct edac_device_ctl_info
*edac_dev
= dev_id
;
426 struct mv64x60_cpu_pdata
*pdata
= edac_dev
->pvt_info
;
429 cause
= in_le32(pdata
->cpu_vbase
[1] + MV64x60_CPU_ERR_CAUSE
) &
430 MV64x60_CPU_CAUSE_MASK
;
434 mv64x60_cpu_check(edac_dev
);
439 static int mv64x60_cpu_err_probe(struct platform_device
*pdev
)
441 struct edac_device_ctl_info
*edac_dev
;
443 struct mv64x60_cpu_pdata
*pdata
;
446 if (!devres_open_group(&pdev
->dev
, mv64x60_cpu_err_probe
, GFP_KERNEL
))
449 edac_dev
= edac_device_alloc_ctl_info(sizeof(*pdata
),
450 "cpu", 1, NULL
, 0, 0, NULL
, 0,
453 devres_release_group(&pdev
->dev
, mv64x60_cpu_err_probe
);
457 pdata
= edac_dev
->pvt_info
;
458 pdata
->name
= "mv64x60_cpu_err";
459 edac_dev
->dev
= &pdev
->dev
;
460 platform_set_drvdata(pdev
, edac_dev
);
461 edac_dev
->dev_name
= dev_name(&pdev
->dev
);
463 r
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
465 printk(KERN_ERR
"%s: Unable to get resource for "
466 "CPU err regs\n", __func__
);
471 if (!devm_request_mem_region(&pdev
->dev
,
475 printk(KERN_ERR
"%s: Error while requesting mem region\n",
481 pdata
->cpu_vbase
[0] = devm_ioremap(&pdev
->dev
,
484 if (!pdata
->cpu_vbase
[0]) {
485 printk(KERN_ERR
"%s: Unable to setup CPU err regs\n", __func__
);
490 r
= platform_get_resource(pdev
, IORESOURCE_MEM
, 1);
492 printk(KERN_ERR
"%s: Unable to get resource for "
493 "CPU err regs\n", __func__
);
498 if (!devm_request_mem_region(&pdev
->dev
,
502 printk(KERN_ERR
"%s: Error while requesting mem region\n",
508 pdata
->cpu_vbase
[1] = devm_ioremap(&pdev
->dev
,
511 if (!pdata
->cpu_vbase
[1]) {
512 printk(KERN_ERR
"%s: Unable to setup CPU err regs\n", __func__
);
517 /* setup CPU err registers */
518 out_le32(pdata
->cpu_vbase
[1] + MV64x60_CPU_ERR_CAUSE
, 0);
519 out_le32(pdata
->cpu_vbase
[1] + MV64x60_CPU_ERR_MASK
, 0);
520 out_le32(pdata
->cpu_vbase
[1] + MV64x60_CPU_ERR_MASK
, 0x000000ff);
522 edac_dev
->mod_name
= EDAC_MOD_STR
;
523 edac_dev
->ctl_name
= pdata
->name
;
524 if (edac_op_state
== EDAC_OPSTATE_POLL
)
525 edac_dev
->edac_check
= mv64x60_cpu_check
;
527 pdata
->edac_idx
= edac_dev_idx
++;
529 if (edac_device_add_device(edac_dev
) > 0) {
530 edac_dbg(3, "failed edac_device_add_device()\n");
534 if (edac_op_state
== EDAC_OPSTATE_INT
) {
535 pdata
->irq
= platform_get_irq(pdev
, 0);
536 res
= devm_request_irq(&pdev
->dev
,
544 "%s: Unable to request irq %d for MV64x60 "
545 "CPU ERR\n", __func__
, pdata
->irq
);
550 printk(KERN_INFO EDAC_MOD_STR
551 " acquired irq %d for CPU Err\n", pdata
->irq
);
554 devres_remove_group(&pdev
->dev
, mv64x60_cpu_err_probe
);
556 /* get this far and it's successful */
557 edac_dbg(3, "success\n");
562 edac_device_del_device(&pdev
->dev
);
564 devres_release_group(&pdev
->dev
, mv64x60_cpu_err_probe
);
565 edac_device_free_ctl_info(edac_dev
);
569 static int mv64x60_cpu_err_remove(struct platform_device
*pdev
)
571 struct edac_device_ctl_info
*edac_dev
= platform_get_drvdata(pdev
);
575 edac_device_del_device(&pdev
->dev
);
576 edac_device_free_ctl_info(edac_dev
);
580 static struct platform_driver mv64x60_cpu_err_driver
= {
581 .probe
= mv64x60_cpu_err_probe
,
582 .remove
= mv64x60_cpu_err_remove
,
584 .name
= "mv64x60_cpu_err",
588 /*********************** DRAM err device **********************************/
590 static void mv64x60_mc_check(struct mem_ctl_info
*mci
)
592 struct mv64x60_mc_pdata
*pdata
= mci
->pvt_info
;
599 reg
= in_le32(pdata
->mc_vbase
+ MV64X60_SDRAM_ERR_ADDR
);
603 err_addr
= reg
& ~0x3;
604 sdram_ecc
= in_le32(pdata
->mc_vbase
+ MV64X60_SDRAM_ERR_ECC_RCVD
);
605 comp_ecc
= in_le32(pdata
->mc_vbase
+ MV64X60_SDRAM_ERR_ECC_CALC
);
606 syndrome
= sdram_ecc
^ comp_ecc
;
608 /* first bit clear in ECC Err Reg, 1 bit error, correctable by HW */
610 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED
, mci
, 1,
611 err_addr
>> PAGE_SHIFT
,
612 err_addr
& PAGE_MASK
, syndrome
,
615 else /* 2 bit error, UE */
616 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED
, mci
, 1,
617 err_addr
>> PAGE_SHIFT
,
618 err_addr
& PAGE_MASK
, 0,
622 /* clear the error */
623 out_le32(pdata
->mc_vbase
+ MV64X60_SDRAM_ERR_ADDR
, 0);
626 static irqreturn_t
mv64x60_mc_isr(int irq
, void *dev_id
)
628 struct mem_ctl_info
*mci
= dev_id
;
629 struct mv64x60_mc_pdata
*pdata
= mci
->pvt_info
;
632 reg
= in_le32(pdata
->mc_vbase
+ MV64X60_SDRAM_ERR_ADDR
);
636 /* writing 0's to the ECC err addr in check function clears irq */
637 mv64x60_mc_check(mci
);
642 static void get_total_mem(struct mv64x60_mc_pdata
*pdata
)
644 struct device_node
*np
= NULL
;
645 const unsigned int *reg
;
647 np
= of_find_node_by_type(NULL
, "memory");
651 reg
= of_get_property(np
, "reg", NULL
);
653 pdata
->total_mem
= reg
[1];
656 static void mv64x60_init_csrows(struct mem_ctl_info
*mci
,
657 struct mv64x60_mc_pdata
*pdata
)
659 struct csrow_info
*csrow
;
660 struct dimm_info
*dimm
;
665 get_total_mem(pdata
);
667 ctl
= in_le32(pdata
->mc_vbase
+ MV64X60_SDRAM_CONFIG
);
669 csrow
= mci
->csrows
[0];
670 dimm
= csrow
->channels
[0]->dimm
;
672 dimm
->nr_pages
= pdata
->total_mem
>> PAGE_SHIFT
;
675 dimm
->mtype
= (ctl
& MV64X60_SDRAM_REGISTERED
) ? MEM_RDDR
: MEM_DDR
;
677 devtype
= (ctl
>> 20) & 0x3;
680 dimm
->dtype
= DEV_X32
;
682 case 0x2: /* could be X8 too, but no way to tell */
683 dimm
->dtype
= DEV_X16
;
686 dimm
->dtype
= DEV_X4
;
689 dimm
->dtype
= DEV_UNKNOWN
;
693 dimm
->edac_mode
= EDAC_SECDED
;
696 static int mv64x60_mc_err_probe(struct platform_device
*pdev
)
698 struct mem_ctl_info
*mci
;
699 struct edac_mc_layer layers
[2];
700 struct mv64x60_mc_pdata
*pdata
;
705 if (!devres_open_group(&pdev
->dev
, mv64x60_mc_err_probe
, GFP_KERNEL
))
708 layers
[0].type
= EDAC_MC_LAYER_CHIP_SELECT
;
710 layers
[0].is_virt_csrow
= true;
711 layers
[1].type
= EDAC_MC_LAYER_CHANNEL
;
713 layers
[1].is_virt_csrow
= false;
714 mci
= edac_mc_alloc(edac_mc_idx
, ARRAY_SIZE(layers
), layers
,
715 sizeof(struct mv64x60_mc_pdata
));
717 printk(KERN_ERR
"%s: No memory for CPU err\n", __func__
);
718 devres_release_group(&pdev
->dev
, mv64x60_mc_err_probe
);
722 pdata
= mci
->pvt_info
;
723 mci
->pdev
= &pdev
->dev
;
724 platform_set_drvdata(pdev
, mci
);
725 pdata
->name
= "mv64x60_mc_err";
726 mci
->dev_name
= dev_name(&pdev
->dev
);
727 pdata
->edac_idx
= edac_mc_idx
++;
729 r
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
731 printk(KERN_ERR
"%s: Unable to get resource for "
732 "MC err regs\n", __func__
);
737 if (!devm_request_mem_region(&pdev
->dev
,
741 printk(KERN_ERR
"%s: Error while requesting mem region\n",
747 pdata
->mc_vbase
= devm_ioremap(&pdev
->dev
,
750 if (!pdata
->mc_vbase
) {
751 printk(KERN_ERR
"%s: Unable to setup MC err regs\n", __func__
);
756 ctl
= in_le32(pdata
->mc_vbase
+ MV64X60_SDRAM_CONFIG
);
757 if (!(ctl
& MV64X60_SDRAM_ECC
)) {
759 printk(KERN_WARNING
"%s: No ECC DIMMs discovered\n", __func__
);
764 edac_dbg(3, "init mci\n");
765 mci
->mtype_cap
= MEM_FLAG_RDDR
| MEM_FLAG_DDR
;
766 mci
->edac_ctl_cap
= EDAC_FLAG_NONE
| EDAC_FLAG_SECDED
;
767 mci
->edac_cap
= EDAC_FLAG_SECDED
;
768 mci
->mod_name
= EDAC_MOD_STR
;
769 mci
->mod_ver
= MV64x60_REVISION
;
770 mci
->ctl_name
= mv64x60_ctl_name
;
772 if (edac_op_state
== EDAC_OPSTATE_POLL
)
773 mci
->edac_check
= mv64x60_mc_check
;
775 mci
->ctl_page_to_phys
= NULL
;
777 mci
->scrub_mode
= SCRUB_SW_SRC
;
779 mv64x60_init_csrows(mci
, pdata
);
781 /* setup MC registers */
782 out_le32(pdata
->mc_vbase
+ MV64X60_SDRAM_ERR_ADDR
, 0);
783 ctl
= in_le32(pdata
->mc_vbase
+ MV64X60_SDRAM_ERR_ECC_CNTL
);
784 ctl
= (ctl
& 0xff00ffff) | 0x10000;
785 out_le32(pdata
->mc_vbase
+ MV64X60_SDRAM_ERR_ECC_CNTL
, ctl
);
787 res
= edac_mc_add_mc(mci
);
789 edac_dbg(3, "failed edac_mc_add_mc()\n");
793 if (edac_op_state
== EDAC_OPSTATE_INT
) {
794 /* acquire interrupt that reports errors */
795 pdata
->irq
= platform_get_irq(pdev
, 0);
796 res
= devm_request_irq(&pdev
->dev
,
803 printk(KERN_ERR
"%s: Unable to request irq %d for "
804 "MV64x60 DRAM ERR\n", __func__
, pdata
->irq
);
809 printk(KERN_INFO EDAC_MOD_STR
" acquired irq %d for MC Err\n",
813 /* get this far and it's successful */
814 edac_dbg(3, "success\n");
819 edac_mc_del_mc(&pdev
->dev
);
821 devres_release_group(&pdev
->dev
, mv64x60_mc_err_probe
);
826 static int mv64x60_mc_err_remove(struct platform_device
*pdev
)
828 struct mem_ctl_info
*mci
= platform_get_drvdata(pdev
);
832 edac_mc_del_mc(&pdev
->dev
);
837 static struct platform_driver mv64x60_mc_err_driver
= {
838 .probe
= mv64x60_mc_err_probe
,
839 .remove
= mv64x60_mc_err_remove
,
841 .name
= "mv64x60_mc_err",
845 static struct platform_driver
* const drivers
[] = {
846 &mv64x60_mc_err_driver
,
847 &mv64x60_cpu_err_driver
,
848 &mv64x60_sram_err_driver
,
850 &mv64x60_pci_err_driver
,
854 static int __init
mv64x60_edac_init(void)
858 printk(KERN_INFO
"Marvell MV64x60 EDAC driver " MV64x60_REVISION
"\n");
859 printk(KERN_INFO
"\t(C) 2006-2007 MontaVista Software\n");
860 /* make sure error reporting method is sane */
861 switch (edac_op_state
) {
862 case EDAC_OPSTATE_POLL
:
863 case EDAC_OPSTATE_INT
:
866 edac_op_state
= EDAC_OPSTATE_INT
;
870 return platform_register_drivers(drivers
, ARRAY_SIZE(drivers
));
872 module_init(mv64x60_edac_init
);
874 static void __exit
mv64x60_edac_exit(void)
876 platform_unregister_drivers(drivers
, ARRAY_SIZE(drivers
));
878 module_exit(mv64x60_edac_exit
);
880 MODULE_LICENSE("GPL");
881 MODULE_AUTHOR("Montavista Software, Inc.");
882 module_param(edac_op_state
, int, 0444);
883 MODULE_PARM_DESC(edac_op_state
,
884 "EDAC Error Reporting state: 0=Poll, 2=Interrupt");