2008-02-07 16:14:56 +08:00
|
|
|
/*
|
|
|
|
* Marvell MV64x60 Memory Controller kernel module for PPC platforms
|
|
|
|
*
|
|
|
|
* Author: Dave Jiang <djiang@mvista.com>
|
|
|
|
*
|
|
|
|
* 2006-2007 (c) MontaVista Software, Inc. This file is licensed under
|
|
|
|
* the terms of the GNU General Public License version 2. This program
|
|
|
|
* is licensed "as is" without any warranty of any kind, whether express
|
|
|
|
* or implied.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/io.h>
|
|
|
|
#include <linux/edac.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/gfp.h>
|
2008-02-07 16:14:56 +08:00
|
|
|
|
|
|
|
#include "edac_core.h"
|
|
|
|
#include "edac_module.h"
|
|
|
|
#include "mv64x60_edac.h"
|
|
|
|
|
|
|
|
static const char *mv64x60_ctl_name = "MV64x60";
|
|
|
|
static int edac_dev_idx;
|
|
|
|
static int edac_pci_idx;
|
|
|
|
static int edac_mc_idx;
|
|
|
|
|
|
|
|
/*********************** PCI err device **********************************/
|
|
|
|
#ifdef CONFIG_PCI
|
|
|
|
static void mv64x60_pci_check(struct edac_pci_ctl_info *pci)
|
|
|
|
{
|
|
|
|
struct mv64x60_pci_pdata *pdata = pci->pvt_info;
|
|
|
|
u32 cause;
|
|
|
|
|
|
|
|
cause = in_le32(pdata->pci_vbase + MV64X60_PCI_ERROR_CAUSE);
|
|
|
|
if (!cause)
|
|
|
|
return;
|
|
|
|
|
|
|
|
printk(KERN_ERR "Error in PCI %d Interface\n", pdata->pci_hose);
|
|
|
|
printk(KERN_ERR "Cause register: 0x%08x\n", cause);
|
|
|
|
printk(KERN_ERR "Address Low: 0x%08x\n",
|
|
|
|
in_le32(pdata->pci_vbase + MV64X60_PCI_ERROR_ADDR_LO));
|
|
|
|
printk(KERN_ERR "Address High: 0x%08x\n",
|
|
|
|
in_le32(pdata->pci_vbase + MV64X60_PCI_ERROR_ADDR_HI));
|
|
|
|
printk(KERN_ERR "Attribute: 0x%08x\n",
|
|
|
|
in_le32(pdata->pci_vbase + MV64X60_PCI_ERROR_ATTR));
|
|
|
|
printk(KERN_ERR "Command: 0x%08x\n",
|
|
|
|
in_le32(pdata->pci_vbase + MV64X60_PCI_ERROR_CMD));
|
|
|
|
out_le32(pdata->pci_vbase + MV64X60_PCI_ERROR_CAUSE, ~cause);
|
|
|
|
|
|
|
|
if (cause & MV64X60_PCI_PE_MASK)
|
|
|
|
edac_pci_handle_pe(pci, pci->ctl_name);
|
|
|
|
|
|
|
|
if (!(cause & MV64X60_PCI_PE_MASK))
|
|
|
|
edac_pci_handle_npe(pci, pci->ctl_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static irqreturn_t mv64x60_pci_isr(int irq, void *dev_id)
|
|
|
|
{
|
|
|
|
struct edac_pci_ctl_info *pci = dev_id;
|
|
|
|
struct mv64x60_pci_pdata *pdata = pci->pvt_info;
|
|
|
|
u32 val;
|
|
|
|
|
|
|
|
val = in_le32(pdata->pci_vbase + MV64X60_PCI_ERROR_CAUSE);
|
|
|
|
if (!val)
|
|
|
|
return IRQ_NONE;
|
|
|
|
|
|
|
|
mv64x60_pci_check(pci);
|
|
|
|
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
2008-07-25 16:49:14 +08:00
|
|
|
/*
|
|
|
|
* Bit 0 of MV64x60_PCIx_ERR_MASK does not exist on the 64360 and because of
|
|
|
|
* errata FEr-#11 and FEr-##16 for the 64460, it should be 0 on that chip as
|
|
|
|
* well. IOW, don't set bit 0.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Erratum FEr PCI-#16: clear bit 0 of PCI SERRn Mask reg. */
|
|
|
|
static int __init mv64x60_pci_fixup(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
struct resource *r;
|
|
|
|
void __iomem *pci_serr;
|
|
|
|
|
|
|
|
r = platform_get_resource(pdev, IORESOURCE_MEM, 1);
|
|
|
|
if (!r) {
|
|
|
|
printk(KERN_ERR "%s: Unable to get resource for "
|
|
|
|
"PCI err regs\n", __func__);
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
|
2009-09-24 06:57:26 +08:00
|
|
|
pci_serr = ioremap(r->start, resource_size(r));
|
2008-07-25 16:49:14 +08:00
|
|
|
if (!pci_serr)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
out_le32(pci_serr, in_le32(pci_serr) & ~0x1);
|
|
|
|
iounmap(pci_serr);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-12-22 05:23:51 +08:00
|
|
|
static int mv64x60_pci_err_probe(struct platform_device *pdev)
|
2008-02-07 16:14:56 +08:00
|
|
|
{
|
|
|
|
struct edac_pci_ctl_info *pci;
|
|
|
|
struct mv64x60_pci_pdata *pdata;
|
|
|
|
struct resource *r;
|
|
|
|
int res = 0;
|
|
|
|
|
|
|
|
if (!devres_open_group(&pdev->dev, mv64x60_pci_err_probe, GFP_KERNEL))
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
pci = edac_pci_alloc_ctl_info(sizeof(*pdata), "mv64x60_pci_err");
|
|
|
|
if (!pci)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
pdata = pci->pvt_info;
|
|
|
|
|
|
|
|
pdata->pci_hose = pdev->id;
|
|
|
|
pdata->name = "mpc85xx_pci_err";
|
|
|
|
pdata->irq = NO_IRQ;
|
|
|
|
platform_set_drvdata(pdev, pci);
|
|
|
|
pci->dev = &pdev->dev;
|
2009-03-25 07:38:21 +08:00
|
|
|
pci->dev_name = dev_name(&pdev->dev);
|
2008-02-07 16:14:56 +08:00
|
|
|
pci->mod_name = EDAC_MOD_STR;
|
|
|
|
pci->ctl_name = pdata->name;
|
|
|
|
|
|
|
|
if (edac_op_state == EDAC_OPSTATE_POLL)
|
|
|
|
pci->edac_check = mv64x60_pci_check;
|
|
|
|
|
|
|
|
pdata->edac_idx = edac_pci_idx++;
|
|
|
|
|
|
|
|
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
|
|
if (!r) {
|
|
|
|
printk(KERN_ERR "%s: Unable to get resource for "
|
|
|
|
"PCI err regs\n", __func__);
|
|
|
|
res = -ENOENT;
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!devm_request_mem_region(&pdev->dev,
|
|
|
|
r->start,
|
2009-09-24 06:57:26 +08:00
|
|
|
resource_size(r),
|
2008-02-07 16:14:56 +08:00
|
|
|
pdata->name)) {
|
|
|
|
printk(KERN_ERR "%s: Error while requesting mem region\n",
|
|
|
|
__func__);
|
|
|
|
res = -EBUSY;
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
pdata->pci_vbase = devm_ioremap(&pdev->dev,
|
|
|
|
r->start,
|
2009-09-24 06:57:26 +08:00
|
|
|
resource_size(r));
|
2008-02-07 16:14:56 +08:00
|
|
|
if (!pdata->pci_vbase) {
|
|
|
|
printk(KERN_ERR "%s: Unable to setup PCI err regs\n", __func__);
|
|
|
|
res = -ENOMEM;
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2008-07-25 16:49:14 +08:00
|
|
|
res = mv64x60_pci_fixup(pdev);
|
|
|
|
if (res < 0) {
|
|
|
|
printk(KERN_ERR "%s: PCI fixup failed\n", __func__);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2008-02-07 16:14:56 +08:00
|
|
|
out_le32(pdata->pci_vbase + MV64X60_PCI_ERROR_CAUSE, 0);
|
|
|
|
out_le32(pdata->pci_vbase + MV64X60_PCI_ERROR_MASK, 0);
|
|
|
|
out_le32(pdata->pci_vbase + MV64X60_PCI_ERROR_MASK,
|
|
|
|
MV64X60_PCIx_ERR_MASK_VAL);
|
|
|
|
|
|
|
|
if (edac_pci_add_device(pci, pdata->edac_idx) > 0) {
|
2012-04-30 04:08:39 +08:00
|
|
|
edac_dbg(3, "failed edac_pci_add_device()\n");
|
2008-02-07 16:14:56 +08:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (edac_op_state == EDAC_OPSTATE_INT) {
|
|
|
|
pdata->irq = platform_get_irq(pdev, 0);
|
|
|
|
res = devm_request_irq(&pdev->dev,
|
|
|
|
pdata->irq,
|
|
|
|
mv64x60_pci_isr,
|
2014-10-01 18:24:03 +08:00
|
|
|
0,
|
2008-02-07 16:14:56 +08:00
|
|
|
"[EDAC] PCI err",
|
|
|
|
pci);
|
|
|
|
if (res < 0) {
|
|
|
|
printk(KERN_ERR "%s: Unable to request irq %d for "
|
|
|
|
"MV64x60 PCI ERR\n", __func__, pdata->irq);
|
|
|
|
res = -ENODEV;
|
|
|
|
goto err2;
|
|
|
|
}
|
|
|
|
printk(KERN_INFO EDAC_MOD_STR " acquired irq %d for PCI Err\n",
|
|
|
|
pdata->irq);
|
|
|
|
}
|
|
|
|
|
|
|
|
devres_remove_group(&pdev->dev, mv64x60_pci_err_probe);
|
|
|
|
|
|
|
|
/* get this far and it's successful */
|
2012-04-30 04:08:39 +08:00
|
|
|
edac_dbg(3, "success\n");
|
2008-02-07 16:14:56 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err2:
|
|
|
|
edac_pci_del_device(&pdev->dev);
|
|
|
|
err:
|
|
|
|
edac_pci_free_ctl_info(pci);
|
|
|
|
devres_release_group(&pdev->dev, mv64x60_pci_err_probe);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mv64x60_pci_err_remove(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
struct edac_pci_ctl_info *pci = platform_get_drvdata(pdev);
|
|
|
|
|
2012-04-30 04:08:39 +08:00
|
|
|
edac_dbg(0, "\n");
|
2008-02-07 16:14:56 +08:00
|
|
|
|
|
|
|
edac_pci_del_device(&pdev->dev);
|
|
|
|
|
|
|
|
edac_pci_free_ctl_info(pci);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct platform_driver mv64x60_pci_err_driver = {
|
|
|
|
.probe = mv64x60_pci_err_probe,
|
2012-12-22 05:23:51 +08:00
|
|
|
.remove = mv64x60_pci_err_remove,
|
2008-02-07 16:14:56 +08:00
|
|
|
.driver = {
|
|
|
|
.name = "mv64x60_pci_err",
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* CONFIG_PCI */
|
|
|
|
|
|
|
|
/*********************** SRAM err device **********************************/
|
|
|
|
static void mv64x60_sram_check(struct edac_device_ctl_info *edac_dev)
|
|
|
|
{
|
|
|
|
struct mv64x60_sram_pdata *pdata = edac_dev->pvt_info;
|
|
|
|
u32 cause;
|
|
|
|
|
|
|
|
cause = in_le32(pdata->sram_vbase + MV64X60_SRAM_ERR_CAUSE);
|
|
|
|
if (!cause)
|
|
|
|
return;
|
|
|
|
|
|
|
|
printk(KERN_ERR "Error in internal SRAM\n");
|
|
|
|
printk(KERN_ERR "Cause register: 0x%08x\n", cause);
|
|
|
|
printk(KERN_ERR "Address Low: 0x%08x\n",
|
|
|
|
in_le32(pdata->sram_vbase + MV64X60_SRAM_ERR_ADDR_LO));
|
|
|
|
printk(KERN_ERR "Address High: 0x%08x\n",
|
|
|
|
in_le32(pdata->sram_vbase + MV64X60_SRAM_ERR_ADDR_HI));
|
|
|
|
printk(KERN_ERR "Data Low: 0x%08x\n",
|
|
|
|
in_le32(pdata->sram_vbase + MV64X60_SRAM_ERR_DATA_LO));
|
|
|
|
printk(KERN_ERR "Data High: 0x%08x\n",
|
|
|
|
in_le32(pdata->sram_vbase + MV64X60_SRAM_ERR_DATA_HI));
|
|
|
|
printk(KERN_ERR "Parity: 0x%08x\n",
|
|
|
|
in_le32(pdata->sram_vbase + MV64X60_SRAM_ERR_PARITY));
|
|
|
|
out_le32(pdata->sram_vbase + MV64X60_SRAM_ERR_CAUSE, 0);
|
|
|
|
|
|
|
|
edac_device_handle_ue(edac_dev, 0, 0, edac_dev->ctl_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static irqreturn_t mv64x60_sram_isr(int irq, void *dev_id)
|
|
|
|
{
|
|
|
|
struct edac_device_ctl_info *edac_dev = dev_id;
|
|
|
|
struct mv64x60_sram_pdata *pdata = edac_dev->pvt_info;
|
|
|
|
u32 cause;
|
|
|
|
|
|
|
|
cause = in_le32(pdata->sram_vbase + MV64X60_SRAM_ERR_CAUSE);
|
|
|
|
if (!cause)
|
|
|
|
return IRQ_NONE;
|
|
|
|
|
|
|
|
mv64x60_sram_check(edac_dev);
|
|
|
|
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
2012-12-22 05:23:51 +08:00
|
|
|
static int mv64x60_sram_err_probe(struct platform_device *pdev)
|
2008-02-07 16:14:56 +08:00
|
|
|
{
|
|
|
|
struct edac_device_ctl_info *edac_dev;
|
|
|
|
struct mv64x60_sram_pdata *pdata;
|
|
|
|
struct resource *r;
|
|
|
|
int res = 0;
|
|
|
|
|
|
|
|
if (!devres_open_group(&pdev->dev, mv64x60_sram_err_probe, GFP_KERNEL))
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
edac_dev = edac_device_alloc_ctl_info(sizeof(*pdata),
|
|
|
|
"sram", 1, NULL, 0, 0, NULL, 0,
|
|
|
|
edac_dev_idx);
|
|
|
|
if (!edac_dev) {
|
|
|
|
devres_release_group(&pdev->dev, mv64x60_sram_err_probe);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
pdata = edac_dev->pvt_info;
|
|
|
|
pdata->name = "mv64x60_sram_err";
|
|
|
|
pdata->irq = NO_IRQ;
|
|
|
|
edac_dev->dev = &pdev->dev;
|
|
|
|
platform_set_drvdata(pdev, edac_dev);
|
2009-03-25 07:38:21 +08:00
|
|
|
edac_dev->dev_name = dev_name(&pdev->dev);
|
2008-02-07 16:14:56 +08:00
|
|
|
|
|
|
|
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
|
|
if (!r) {
|
|
|
|
printk(KERN_ERR "%s: Unable to get resource for "
|
|
|
|
"SRAM err regs\n", __func__);
|
|
|
|
res = -ENOENT;
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!devm_request_mem_region(&pdev->dev,
|
|
|
|
r->start,
|
2009-09-24 06:57:26 +08:00
|
|
|
resource_size(r),
|
2008-02-07 16:14:56 +08:00
|
|
|
pdata->name)) {
|
|
|
|
printk(KERN_ERR "%s: Error while request mem region\n",
|
|
|
|
__func__);
|
|
|
|
res = -EBUSY;
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
pdata->sram_vbase = devm_ioremap(&pdev->dev,
|
|
|
|
r->start,
|
2009-09-24 06:57:26 +08:00
|
|
|
resource_size(r));
|
2008-02-07 16:14:56 +08:00
|
|
|
if (!pdata->sram_vbase) {
|
|
|
|
printk(KERN_ERR "%s: Unable to setup SRAM err regs\n",
|
|
|
|
__func__);
|
|
|
|
res = -ENOMEM;
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* setup SRAM err registers */
|
|
|
|
out_le32(pdata->sram_vbase + MV64X60_SRAM_ERR_CAUSE, 0);
|
|
|
|
|
|
|
|
edac_dev->mod_name = EDAC_MOD_STR;
|
|
|
|
edac_dev->ctl_name = pdata->name;
|
|
|
|
|
|
|
|
if (edac_op_state == EDAC_OPSTATE_POLL)
|
|
|
|
edac_dev->edac_check = mv64x60_sram_check;
|
|
|
|
|
|
|
|
pdata->edac_idx = edac_dev_idx++;
|
|
|
|
|
|
|
|
if (edac_device_add_device(edac_dev) > 0) {
|
2012-04-30 04:08:39 +08:00
|
|
|
edac_dbg(3, "failed edac_device_add_device()\n");
|
2008-02-07 16:14:56 +08:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (edac_op_state == EDAC_OPSTATE_INT) {
|
|
|
|
pdata->irq = platform_get_irq(pdev, 0);
|
|
|
|
res = devm_request_irq(&pdev->dev,
|
|
|
|
pdata->irq,
|
|
|
|
mv64x60_sram_isr,
|
2014-10-01 18:24:03 +08:00
|
|
|
0,
|
2008-02-07 16:14:56 +08:00
|
|
|
"[EDAC] SRAM err",
|
|
|
|
edac_dev);
|
|
|
|
if (res < 0) {
|
|
|
|
printk(KERN_ERR
|
|
|
|
"%s: Unable to request irq %d for "
|
|
|
|
"MV64x60 SRAM ERR\n", __func__, pdata->irq);
|
|
|
|
res = -ENODEV;
|
|
|
|
goto err2;
|
|
|
|
}
|
|
|
|
|
|
|
|
printk(KERN_INFO EDAC_MOD_STR " acquired irq %d for SRAM Err\n",
|
|
|
|
pdata->irq);
|
|
|
|
}
|
|
|
|
|
|
|
|
devres_remove_group(&pdev->dev, mv64x60_sram_err_probe);
|
|
|
|
|
|
|
|
/* get this far and it's successful */
|
2012-04-30 04:08:39 +08:00
|
|
|
edac_dbg(3, "success\n");
|
2008-02-07 16:14:56 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err2:
|
|
|
|
edac_device_del_device(&pdev->dev);
|
|
|
|
err:
|
|
|
|
devres_release_group(&pdev->dev, mv64x60_sram_err_probe);
|
|
|
|
edac_device_free_ctl_info(edac_dev);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mv64x60_sram_err_remove(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
struct edac_device_ctl_info *edac_dev = platform_get_drvdata(pdev);
|
|
|
|
|
2012-04-30 04:08:39 +08:00
|
|
|
edac_dbg(0, "\n");
|
2008-02-07 16:14:56 +08:00
|
|
|
|
|
|
|
edac_device_del_device(&pdev->dev);
|
|
|
|
edac_device_free_ctl_info(edac_dev);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct platform_driver mv64x60_sram_err_driver = {
|
|
|
|
.probe = mv64x60_sram_err_probe,
|
|
|
|
.remove = mv64x60_sram_err_remove,
|
|
|
|
.driver = {
|
|
|
|
.name = "mv64x60_sram_err",
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/*********************** CPU err device **********************************/
|
|
|
|
static void mv64x60_cpu_check(struct edac_device_ctl_info *edac_dev)
|
|
|
|
{
|
|
|
|
struct mv64x60_cpu_pdata *pdata = edac_dev->pvt_info;
|
|
|
|
u32 cause;
|
|
|
|
|
|
|
|
cause = in_le32(pdata->cpu_vbase[1] + MV64x60_CPU_ERR_CAUSE) &
|
|
|
|
MV64x60_CPU_CAUSE_MASK;
|
|
|
|
if (!cause)
|
|
|
|
return;
|
|
|
|
|
|
|
|
printk(KERN_ERR "Error on CPU interface\n");
|
|
|
|
printk(KERN_ERR "Cause register: 0x%08x\n", cause);
|
|
|
|
printk(KERN_ERR "Address Low: 0x%08x\n",
|
|
|
|
in_le32(pdata->cpu_vbase[0] + MV64x60_CPU_ERR_ADDR_LO));
|
|
|
|
printk(KERN_ERR "Address High: 0x%08x\n",
|
|
|
|
in_le32(pdata->cpu_vbase[0] + MV64x60_CPU_ERR_ADDR_HI));
|
|
|
|
printk(KERN_ERR "Data Low: 0x%08x\n",
|
|
|
|
in_le32(pdata->cpu_vbase[1] + MV64x60_CPU_ERR_DATA_LO));
|
|
|
|
printk(KERN_ERR "Data High: 0x%08x\n",
|
|
|
|
in_le32(pdata->cpu_vbase[1] + MV64x60_CPU_ERR_DATA_HI));
|
|
|
|
printk(KERN_ERR "Parity: 0x%08x\n",
|
|
|
|
in_le32(pdata->cpu_vbase[1] + MV64x60_CPU_ERR_PARITY));
|
|
|
|
out_le32(pdata->cpu_vbase[1] + MV64x60_CPU_ERR_CAUSE, 0);
|
|
|
|
|
|
|
|
edac_device_handle_ue(edac_dev, 0, 0, edac_dev->ctl_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static irqreturn_t mv64x60_cpu_isr(int irq, void *dev_id)
|
|
|
|
{
|
|
|
|
struct edac_device_ctl_info *edac_dev = dev_id;
|
|
|
|
struct mv64x60_cpu_pdata *pdata = edac_dev->pvt_info;
|
|
|
|
u32 cause;
|
|
|
|
|
|
|
|
cause = in_le32(pdata->cpu_vbase[1] + MV64x60_CPU_ERR_CAUSE) &
|
|
|
|
MV64x60_CPU_CAUSE_MASK;
|
|
|
|
if (!cause)
|
|
|
|
return IRQ_NONE;
|
|
|
|
|
|
|
|
mv64x60_cpu_check(edac_dev);
|
|
|
|
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
2012-12-22 05:23:51 +08:00
|
|
|
static int mv64x60_cpu_err_probe(struct platform_device *pdev)
|
2008-02-07 16:14:56 +08:00
|
|
|
{
|
|
|
|
struct edac_device_ctl_info *edac_dev;
|
|
|
|
struct resource *r;
|
|
|
|
struct mv64x60_cpu_pdata *pdata;
|
|
|
|
int res = 0;
|
|
|
|
|
|
|
|
if (!devres_open_group(&pdev->dev, mv64x60_cpu_err_probe, GFP_KERNEL))
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
edac_dev = edac_device_alloc_ctl_info(sizeof(*pdata),
|
|
|
|
"cpu", 1, NULL, 0, 0, NULL, 0,
|
|
|
|
edac_dev_idx);
|
|
|
|
if (!edac_dev) {
|
|
|
|
devres_release_group(&pdev->dev, mv64x60_cpu_err_probe);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
pdata = edac_dev->pvt_info;
|
|
|
|
pdata->name = "mv64x60_cpu_err";
|
|
|
|
pdata->irq = NO_IRQ;
|
|
|
|
edac_dev->dev = &pdev->dev;
|
|
|
|
platform_set_drvdata(pdev, edac_dev);
|
2009-03-25 07:38:21 +08:00
|
|
|
edac_dev->dev_name = dev_name(&pdev->dev);
|
2008-02-07 16:14:56 +08:00
|
|
|
|
|
|
|
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
|
|
if (!r) {
|
|
|
|
printk(KERN_ERR "%s: Unable to get resource for "
|
|
|
|
"CPU err regs\n", __func__);
|
|
|
|
res = -ENOENT;
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!devm_request_mem_region(&pdev->dev,
|
|
|
|
r->start,
|
2009-09-24 06:57:26 +08:00
|
|
|
resource_size(r),
|
2008-02-07 16:14:56 +08:00
|
|
|
pdata->name)) {
|
|
|
|
printk(KERN_ERR "%s: Error while requesting mem region\n",
|
|
|
|
__func__);
|
|
|
|
res = -EBUSY;
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
pdata->cpu_vbase[0] = devm_ioremap(&pdev->dev,
|
|
|
|
r->start,
|
2009-09-24 06:57:26 +08:00
|
|
|
resource_size(r));
|
2008-02-07 16:14:56 +08:00
|
|
|
if (!pdata->cpu_vbase[0]) {
|
|
|
|
printk(KERN_ERR "%s: Unable to setup CPU err regs\n", __func__);
|
|
|
|
res = -ENOMEM;
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
r = platform_get_resource(pdev, IORESOURCE_MEM, 1);
|
|
|
|
if (!r) {
|
|
|
|
printk(KERN_ERR "%s: Unable to get resource for "
|
|
|
|
"CPU err regs\n", __func__);
|
|
|
|
res = -ENOENT;
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!devm_request_mem_region(&pdev->dev,
|
|
|
|
r->start,
|
2009-09-24 06:57:26 +08:00
|
|
|
resource_size(r),
|
2008-02-07 16:14:56 +08:00
|
|
|
pdata->name)) {
|
|
|
|
printk(KERN_ERR "%s: Error while requesting mem region\n",
|
|
|
|
__func__);
|
|
|
|
res = -EBUSY;
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
pdata->cpu_vbase[1] = devm_ioremap(&pdev->dev,
|
|
|
|
r->start,
|
2009-09-24 06:57:26 +08:00
|
|
|
resource_size(r));
|
2008-02-07 16:14:56 +08:00
|
|
|
if (!pdata->cpu_vbase[1]) {
|
|
|
|
printk(KERN_ERR "%s: Unable to setup CPU err regs\n", __func__);
|
|
|
|
res = -ENOMEM;
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* setup CPU err registers */
|
|
|
|
out_le32(pdata->cpu_vbase[1] + MV64x60_CPU_ERR_CAUSE, 0);
|
|
|
|
out_le32(pdata->cpu_vbase[1] + MV64x60_CPU_ERR_MASK, 0);
|
|
|
|
out_le32(pdata->cpu_vbase[1] + MV64x60_CPU_ERR_MASK, 0x000000ff);
|
|
|
|
|
|
|
|
edac_dev->mod_name = EDAC_MOD_STR;
|
|
|
|
edac_dev->ctl_name = pdata->name;
|
|
|
|
if (edac_op_state == EDAC_OPSTATE_POLL)
|
|
|
|
edac_dev->edac_check = mv64x60_cpu_check;
|
|
|
|
|
|
|
|
pdata->edac_idx = edac_dev_idx++;
|
|
|
|
|
|
|
|
if (edac_device_add_device(edac_dev) > 0) {
|
2012-04-30 04:08:39 +08:00
|
|
|
edac_dbg(3, "failed edac_device_add_device()\n");
|
2008-02-07 16:14:56 +08:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (edac_op_state == EDAC_OPSTATE_INT) {
|
|
|
|
pdata->irq = platform_get_irq(pdev, 0);
|
|
|
|
res = devm_request_irq(&pdev->dev,
|
|
|
|
pdata->irq,
|
|
|
|
mv64x60_cpu_isr,
|
2014-10-01 18:24:03 +08:00
|
|
|
0,
|
2008-02-07 16:14:56 +08:00
|
|
|
"[EDAC] CPU err",
|
|
|
|
edac_dev);
|
|
|
|
if (res < 0) {
|
|
|
|
printk(KERN_ERR
|
|
|
|
"%s: Unable to request irq %d for MV64x60 "
|
|
|
|
"CPU ERR\n", __func__, pdata->irq);
|
|
|
|
res = -ENODEV;
|
|
|
|
goto err2;
|
|
|
|
}
|
|
|
|
|
|
|
|
printk(KERN_INFO EDAC_MOD_STR
|
|
|
|
" acquired irq %d for CPU Err\n", pdata->irq);
|
|
|
|
}
|
|
|
|
|
|
|
|
devres_remove_group(&pdev->dev, mv64x60_cpu_err_probe);
|
|
|
|
|
|
|
|
/* get this far and it's successful */
|
2012-04-30 04:08:39 +08:00
|
|
|
edac_dbg(3, "success\n");
|
2008-02-07 16:14:56 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err2:
|
|
|
|
edac_device_del_device(&pdev->dev);
|
|
|
|
err:
|
|
|
|
devres_release_group(&pdev->dev, mv64x60_cpu_err_probe);
|
|
|
|
edac_device_free_ctl_info(edac_dev);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mv64x60_cpu_err_remove(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
struct edac_device_ctl_info *edac_dev = platform_get_drvdata(pdev);
|
|
|
|
|
2012-04-30 04:08:39 +08:00
|
|
|
edac_dbg(0, "\n");
|
2008-02-07 16:14:56 +08:00
|
|
|
|
|
|
|
edac_device_del_device(&pdev->dev);
|
|
|
|
edac_device_free_ctl_info(edac_dev);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct platform_driver mv64x60_cpu_err_driver = {
|
|
|
|
.probe = mv64x60_cpu_err_probe,
|
|
|
|
.remove = mv64x60_cpu_err_remove,
|
|
|
|
.driver = {
|
|
|
|
.name = "mv64x60_cpu_err",
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/*********************** DRAM err device **********************************/
|
|
|
|
|
|
|
|
static void mv64x60_mc_check(struct mem_ctl_info *mci)
|
|
|
|
{
|
|
|
|
struct mv64x60_mc_pdata *pdata = mci->pvt_info;
|
|
|
|
u32 reg;
|
|
|
|
u32 err_addr;
|
|
|
|
u32 sdram_ecc;
|
|
|
|
u32 comp_ecc;
|
|
|
|
u32 syndrome;
|
|
|
|
|
|
|
|
reg = in_le32(pdata->mc_vbase + MV64X60_SDRAM_ERR_ADDR);
|
|
|
|
if (!reg)
|
|
|
|
return;
|
|
|
|
|
|
|
|
err_addr = reg & ~0x3;
|
|
|
|
sdram_ecc = in_le32(pdata->mc_vbase + MV64X60_SDRAM_ERR_ECC_RCVD);
|
|
|
|
comp_ecc = in_le32(pdata->mc_vbase + MV64X60_SDRAM_ERR_ECC_CALC);
|
|
|
|
syndrome = sdram_ecc ^ comp_ecc;
|
|
|
|
|
|
|
|
/* first bit clear in ECC Err Reg, 1 bit error, correctable by HW */
|
|
|
|
if (!(reg & 0x1))
|
2012-06-05 00:27:43 +08:00
|
|
|
edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1,
|
2012-04-17 02:11:20 +08:00
|
|
|
err_addr >> PAGE_SHIFT,
|
|
|
|
err_addr & PAGE_MASK, syndrome,
|
|
|
|
0, 0, -1,
|
2012-06-04 22:29:25 +08:00
|
|
|
mci->ctl_name, "");
|
2008-02-07 16:14:56 +08:00
|
|
|
else /* 2 bit error, UE */
|
2012-06-05 00:27:43 +08:00
|
|
|
edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1,
|
2012-04-17 02:11:20 +08:00
|
|
|
err_addr >> PAGE_SHIFT,
|
|
|
|
err_addr & PAGE_MASK, 0,
|
|
|
|
0, 0, -1,
|
2012-06-04 22:29:25 +08:00
|
|
|
mci->ctl_name, "");
|
2008-02-07 16:14:56 +08:00
|
|
|
|
|
|
|
/* clear the error */
|
|
|
|
out_le32(pdata->mc_vbase + MV64X60_SDRAM_ERR_ADDR, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static irqreturn_t mv64x60_mc_isr(int irq, void *dev_id)
|
|
|
|
{
|
|
|
|
struct mem_ctl_info *mci = dev_id;
|
|
|
|
struct mv64x60_mc_pdata *pdata = mci->pvt_info;
|
|
|
|
u32 reg;
|
|
|
|
|
|
|
|
reg = in_le32(pdata->mc_vbase + MV64X60_SDRAM_ERR_ADDR);
|
|
|
|
if (!reg)
|
|
|
|
return IRQ_NONE;
|
|
|
|
|
|
|
|
/* writing 0's to the ECC err addr in check function clears irq */
|
|
|
|
mv64x60_mc_check(mci);
|
|
|
|
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void get_total_mem(struct mv64x60_mc_pdata *pdata)
|
|
|
|
{
|
|
|
|
struct device_node *np = NULL;
|
|
|
|
const unsigned int *reg;
|
|
|
|
|
|
|
|
np = of_find_node_by_type(NULL, "memory");
|
|
|
|
if (!np)
|
|
|
|
return;
|
|
|
|
|
2008-07-25 16:49:13 +08:00
|
|
|
reg = of_get_property(np, "reg", NULL);
|
2008-02-07 16:14:56 +08:00
|
|
|
|
|
|
|
pdata->total_mem = reg[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mv64x60_init_csrows(struct mem_ctl_info *mci,
|
|
|
|
struct mv64x60_mc_pdata *pdata)
|
|
|
|
{
|
|
|
|
struct csrow_info *csrow;
|
2012-01-28 05:38:08 +08:00
|
|
|
struct dimm_info *dimm;
|
|
|
|
|
2008-02-07 16:14:56 +08:00
|
|
|
u32 devtype;
|
|
|
|
u32 ctl;
|
|
|
|
|
|
|
|
get_total_mem(pdata);
|
|
|
|
|
|
|
|
ctl = in_le32(pdata->mc_vbase + MV64X60_SDRAM_CONFIG);
|
|
|
|
|
2012-04-25 02:05:43 +08:00
|
|
|
csrow = mci->csrows[0];
|
|
|
|
dimm = csrow->channels[0]->dimm;
|
2012-01-28 20:09:38 +08:00
|
|
|
|
|
|
|
dimm->nr_pages = pdata->total_mem >> PAGE_SHIFT;
|
2012-01-28 05:38:08 +08:00
|
|
|
dimm->grain = 8;
|
2008-02-07 16:14:56 +08:00
|
|
|
|
2012-01-28 05:38:08 +08:00
|
|
|
dimm->mtype = (ctl & MV64X60_SDRAM_REGISTERED) ? MEM_RDDR : MEM_DDR;
|
2008-02-07 16:14:56 +08:00
|
|
|
|
|
|
|
devtype = (ctl >> 20) & 0x3;
|
|
|
|
switch (devtype) {
|
|
|
|
case 0x0:
|
2012-01-28 05:38:08 +08:00
|
|
|
dimm->dtype = DEV_X32;
|
2008-02-07 16:14:56 +08:00
|
|
|
break;
|
|
|
|
case 0x2: /* could be X8 too, but no way to tell */
|
2012-01-28 05:38:08 +08:00
|
|
|
dimm->dtype = DEV_X16;
|
2008-02-07 16:14:56 +08:00
|
|
|
break;
|
|
|
|
case 0x3:
|
2012-01-28 05:38:08 +08:00
|
|
|
dimm->dtype = DEV_X4;
|
2008-02-07 16:14:56 +08:00
|
|
|
break;
|
|
|
|
default:
|
2012-01-28 05:38:08 +08:00
|
|
|
dimm->dtype = DEV_UNKNOWN;
|
2008-02-07 16:14:56 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-01-28 05:38:08 +08:00
|
|
|
dimm->edac_mode = EDAC_SECDED;
|
2008-02-07 16:14:56 +08:00
|
|
|
}
|
|
|
|
|
2012-12-22 05:23:51 +08:00
|
|
|
static int mv64x60_mc_err_probe(struct platform_device *pdev)
|
2008-02-07 16:14:56 +08:00
|
|
|
{
|
|
|
|
struct mem_ctl_info *mci;
|
2012-04-17 02:11:20 +08:00
|
|
|
struct edac_mc_layer layers[2];
|
2008-02-07 16:14:56 +08:00
|
|
|
struct mv64x60_mc_pdata *pdata;
|
|
|
|
struct resource *r;
|
|
|
|
u32 ctl;
|
|
|
|
int res = 0;
|
|
|
|
|
|
|
|
if (!devres_open_group(&pdev->dev, mv64x60_mc_err_probe, GFP_KERNEL))
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2012-04-17 02:11:20 +08:00
|
|
|
layers[0].type = EDAC_MC_LAYER_CHIP_SELECT;
|
|
|
|
layers[0].size = 1;
|
|
|
|
layers[0].is_virt_csrow = true;
|
|
|
|
layers[1].type = EDAC_MC_LAYER_CHANNEL;
|
|
|
|
layers[1].size = 1;
|
|
|
|
layers[1].is_virt_csrow = false;
|
2012-05-03 01:37:00 +08:00
|
|
|
mci = edac_mc_alloc(edac_mc_idx, ARRAY_SIZE(layers), layers,
|
2012-04-17 02:11:20 +08:00
|
|
|
sizeof(struct mv64x60_mc_pdata));
|
2008-02-07 16:14:56 +08:00
|
|
|
if (!mci) {
|
|
|
|
printk(KERN_ERR "%s: No memory for CPU err\n", __func__);
|
|
|
|
devres_release_group(&pdev->dev, mv64x60_mc_err_probe);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
pdata = mci->pvt_info;
|
2012-03-16 18:44:18 +08:00
|
|
|
mci->pdev = &pdev->dev;
|
2008-02-07 16:14:56 +08:00
|
|
|
platform_set_drvdata(pdev, mci);
|
|
|
|
pdata->name = "mv64x60_mc_err";
|
|
|
|
pdata->irq = NO_IRQ;
|
2009-03-25 07:38:21 +08:00
|
|
|
mci->dev_name = dev_name(&pdev->dev);
|
2008-02-07 16:14:56 +08:00
|
|
|
pdata->edac_idx = edac_mc_idx++;
|
|
|
|
|
|
|
|
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
|
|
if (!r) {
|
|
|
|
printk(KERN_ERR "%s: Unable to get resource for "
|
|
|
|
"MC err regs\n", __func__);
|
|
|
|
res = -ENOENT;
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!devm_request_mem_region(&pdev->dev,
|
|
|
|
r->start,
|
2009-09-24 06:57:26 +08:00
|
|
|
resource_size(r),
|
2008-02-07 16:14:56 +08:00
|
|
|
pdata->name)) {
|
|
|
|
printk(KERN_ERR "%s: Error while requesting mem region\n",
|
|
|
|
__func__);
|
|
|
|
res = -EBUSY;
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
pdata->mc_vbase = devm_ioremap(&pdev->dev,
|
|
|
|
r->start,
|
2009-09-24 06:57:26 +08:00
|
|
|
resource_size(r));
|
2008-02-07 16:14:56 +08:00
|
|
|
if (!pdata->mc_vbase) {
|
|
|
|
printk(KERN_ERR "%s: Unable to setup MC err regs\n", __func__);
|
|
|
|
res = -ENOMEM;
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
ctl = in_le32(pdata->mc_vbase + MV64X60_SDRAM_CONFIG);
|
|
|
|
if (!(ctl & MV64X60_SDRAM_ECC)) {
|
|
|
|
/* Non-ECC RAM? */
|
|
|
|
printk(KERN_WARNING "%s: No ECC DIMMs discovered\n", __func__);
|
|
|
|
res = -ENODEV;
|
|
|
|
goto err2;
|
|
|
|
}
|
|
|
|
|
2012-04-30 04:08:39 +08:00
|
|
|
edac_dbg(3, "init mci\n");
|
2008-02-07 16:14:56 +08:00
|
|
|
mci->mtype_cap = MEM_FLAG_RDDR | MEM_FLAG_DDR;
|
|
|
|
mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED;
|
|
|
|
mci->edac_cap = EDAC_FLAG_SECDED;
|
|
|
|
mci->mod_name = EDAC_MOD_STR;
|
|
|
|
mci->mod_ver = MV64x60_REVISION;
|
|
|
|
mci->ctl_name = mv64x60_ctl_name;
|
|
|
|
|
|
|
|
if (edac_op_state == EDAC_OPSTATE_POLL)
|
|
|
|
mci->edac_check = mv64x60_mc_check;
|
|
|
|
|
|
|
|
mci->ctl_page_to_phys = NULL;
|
|
|
|
|
|
|
|
mci->scrub_mode = SCRUB_SW_SRC;
|
|
|
|
|
|
|
|
mv64x60_init_csrows(mci, pdata);
|
|
|
|
|
|
|
|
/* setup MC registers */
|
|
|
|
out_le32(pdata->mc_vbase + MV64X60_SDRAM_ERR_ADDR, 0);
|
|
|
|
ctl = in_le32(pdata->mc_vbase + MV64X60_SDRAM_ERR_ECC_CNTL);
|
|
|
|
ctl = (ctl & 0xff00ffff) | 0x10000;
|
|
|
|
out_le32(pdata->mc_vbase + MV64X60_SDRAM_ERR_ECC_CNTL, ctl);
|
|
|
|
|
2015-01-29 03:13:51 +08:00
|
|
|
res = edac_mc_add_mc(mci);
|
|
|
|
if (res) {
|
2012-04-30 04:08:39 +08:00
|
|
|
edac_dbg(3, "failed edac_mc_add_mc()\n");
|
2008-02-07 16:14:56 +08:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (edac_op_state == EDAC_OPSTATE_INT) {
|
|
|
|
/* acquire interrupt that reports errors */
|
|
|
|
pdata->irq = platform_get_irq(pdev, 0);
|
|
|
|
res = devm_request_irq(&pdev->dev,
|
|
|
|
pdata->irq,
|
|
|
|
mv64x60_mc_isr,
|
2014-10-01 18:24:03 +08:00
|
|
|
0,
|
2008-02-07 16:14:56 +08:00
|
|
|
"[EDAC] MC err",
|
|
|
|
mci);
|
|
|
|
if (res < 0) {
|
|
|
|
printk(KERN_ERR "%s: Unable to request irq %d for "
|
|
|
|
"MV64x60 DRAM ERR\n", __func__, pdata->irq);
|
|
|
|
res = -ENODEV;
|
|
|
|
goto err2;
|
|
|
|
}
|
|
|
|
|
|
|
|
printk(KERN_INFO EDAC_MOD_STR " acquired irq %d for MC Err\n",
|
|
|
|
pdata->irq);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get this far and it's successful */
|
2012-04-30 04:08:39 +08:00
|
|
|
edac_dbg(3, "success\n");
|
2008-02-07 16:14:56 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err2:
|
|
|
|
edac_mc_del_mc(&pdev->dev);
|
|
|
|
err:
|
|
|
|
devres_release_group(&pdev->dev, mv64x60_mc_err_probe);
|
|
|
|
edac_mc_free(mci);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mv64x60_mc_err_remove(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
struct mem_ctl_info *mci = platform_get_drvdata(pdev);
|
|
|
|
|
2012-04-30 04:08:39 +08:00
|
|
|
edac_dbg(0, "\n");
|
2008-02-07 16:14:56 +08:00
|
|
|
|
|
|
|
edac_mc_del_mc(&pdev->dev);
|
|
|
|
edac_mc_free(mci);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct platform_driver mv64x60_mc_err_driver = {
|
|
|
|
.probe = mv64x60_mc_err_probe,
|
|
|
|
.remove = mv64x60_mc_err_remove,
|
|
|
|
.driver = {
|
|
|
|
.name = "mv64x60_mc_err",
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init mv64x60_edac_init(void)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
printk(KERN_INFO "Marvell MV64x60 EDAC driver " MV64x60_REVISION "\n");
|
|
|
|
printk(KERN_INFO "\t(C) 2006-2007 MontaVista Software\n");
|
|
|
|
/* make sure error reporting method is sane */
|
|
|
|
switch (edac_op_state) {
|
|
|
|
case EDAC_OPSTATE_POLL:
|
|
|
|
case EDAC_OPSTATE_INT:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
edac_op_state = EDAC_OPSTATE_INT;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = platform_driver_register(&mv64x60_mc_err_driver);
|
|
|
|
if (ret)
|
|
|
|
printk(KERN_WARNING EDAC_MOD_STR "MC err failed to register\n");
|
|
|
|
|
|
|
|
ret = platform_driver_register(&mv64x60_cpu_err_driver);
|
|
|
|
if (ret)
|
|
|
|
printk(KERN_WARNING EDAC_MOD_STR
|
|
|
|
"CPU err failed to register\n");
|
|
|
|
|
|
|
|
ret = platform_driver_register(&mv64x60_sram_err_driver);
|
|
|
|
if (ret)
|
|
|
|
printk(KERN_WARNING EDAC_MOD_STR
|
|
|
|
"SRAM err failed to register\n");
|
|
|
|
|
|
|
|
#ifdef CONFIG_PCI
|
|
|
|
ret = platform_driver_register(&mv64x60_pci_err_driver);
|
|
|
|
if (ret)
|
|
|
|
printk(KERN_WARNING EDAC_MOD_STR
|
|
|
|
"PCI err failed to register\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
module_init(mv64x60_edac_init);
|
|
|
|
|
|
|
|
static void __exit mv64x60_edac_exit(void)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_PCI
|
|
|
|
platform_driver_unregister(&mv64x60_pci_err_driver);
|
|
|
|
#endif
|
|
|
|
platform_driver_unregister(&mv64x60_sram_err_driver);
|
|
|
|
platform_driver_unregister(&mv64x60_cpu_err_driver);
|
|
|
|
platform_driver_unregister(&mv64x60_mc_err_driver);
|
|
|
|
}
|
|
|
|
module_exit(mv64x60_edac_exit);
|
|
|
|
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_AUTHOR("Montavista Software, Inc.");
|
|
|
|
module_param(edac_op_state, int, 0444);
|
|
|
|
MODULE_PARM_DESC(edac_op_state,
|
|
|
|
"EDAC Error Reporting state: 0=Poll, 2=Interrupt");
|