Patchwork [1/2] Maple: register CPC925 EDAC device on all boards with CPC925

login
register
mail settings
Submitter Dmitry Eremin-Solenikov
Date May 21, 2011, 10:31 a.m.
Message ID <1305973871-28244-1-git-send-email-dbaryshkov@gmail.com>
Download mbox | patch
Permalink /patch/96689/
State Superseded
Headers show

Comments

Dmitry Eremin-Solenikov - May 21, 2011, 10:31 a.m.
Currently Maple setup code creates cpc925_edac device only on
Motorola ATCA-6101 blade. Make setup code check bridge revision
and enable EDAC on all U3 bridges.

Verified on Momentum MapleD (ppc970fx kit) board.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 arch/powerpc/platforms/maple/setup.c |   41 +++++++++++++++------------------
 1 files changed, 19 insertions(+), 22 deletions(-)
Segher Boessenkool - May 21, 2011, 1:09 p.m.
> Currently Maple setup code creates cpc925_edac device only on
> Motorola ATCA-6101 blade. Make setup code check bridge revision
> and enable EDAC on all U3 bridges.

But the EDAC code only works on U3H (CPC925), not old U3.

> +	if ((rev & 0xf0) != 0x30) { /* U3 */
> +		printk(KERN_ERR "%s: Non-CPC925(U3) bridge revision: %02x\n",

Should be:  if (rev >= 0x34 && rev <= 0x3f)


Segher
Dmitry Eremin-Solenikov - May 21, 2011, 6:15 p.m.
On 5/21/11, Segher Boessenkool <segher@kernel.crashing.org> wrote:
>> Currently Maple setup code creates cpc925_edac device only on
>> Motorola ATCA-6101 blade. Make setup code check bridge revision
>> and enable EDAC on all U3 bridges.
>
> But the EDAC code only works on U3H (CPC925), not old U3.

Ack, corrected. Thank you for the info.

>
>> +	if ((rev & 0xf0) != 0x30) { /* U3 */
>> +		printk(KERN_ERR "%s: Non-CPC925(U3) bridge revision: %02x\n",
>
> Should be:  if (rev >= 0x34 && rev <= 0x3f)
>
>
> Segher
>
>

Patch

diff --git a/arch/powerpc/platforms/maple/setup.c b/arch/powerpc/platforms/maple/setup.c
index fe34c3d..2c48a91 100644
--- a/arch/powerpc/platforms/maple/setup.c
+++ b/arch/powerpc/platforms/maple/setup.c
@@ -338,35 +338,16 @@  define_machine(maple) {
 #ifdef CONFIG_EDAC
 /*
  * Register a platform device for CPC925 memory controller on
- * Motorola ATCA-6101 blade.
+ * all boards with U3 (CPC925) bridge.
  */
-#define MAPLE_CPC925_MODEL	"Motorola,ATCA-6101"
 static int __init maple_cpc925_edac_setup(void)
 {
 	struct platform_device *pdev;
 	struct device_node *np = NULL;
 	struct resource r;
-	const unsigned char *model;
 	int ret;
-
-	np = of_find_node_by_path("/");
-	if (!np) {
-		printk(KERN_ERR "%s: Unable to get root node\n", __func__);
-		return -ENODEV;
-	}
-
-	model = (const unsigned char *)of_get_property(np, "model", NULL);
-	if (!model) {
-		printk(KERN_ERR "%s: Unabel to get model info\n", __func__);
-		of_node_put(np);
-		return -ENODEV;
-	}
-
-	ret = strcmp(model, MAPLE_CPC925_MODEL);
-	of_node_put(np);
-
-	if (ret != 0)
-		return 0;
+	volatile void __iomem *mem;
+	u32 rev;
 
 	np = of_find_node_by_type(NULL, "memory-controller");
 	if (!np) {
@@ -384,6 +365,22 @@  static int __init maple_cpc925_edac_setup(void)
 		return -ENODEV;
 	}
 
+	mem = ioremap(r.start, resource_size(&r));
+	if (!mem) {
+		printk(KERN_ERR "%s: Unable to map memory-controller memory\n",
+				__func__);
+		return -ENOMEM;
+	}
+
+	rev = __raw_readl(mem);
+	iounmap(mem);
+
+	if ((rev & 0xf0) != 0x30) { /* U3 */
+		printk(KERN_ERR "%s: Non-CPC925(U3) bridge revision: %02x\n",
+			__func__, rev);
+		return -ENODEV;
+	}
+
 	pdev = platform_device_register_simple("cpc925_edac", 0, &r, 1);
 	if (IS_ERR(pdev))
 		return PTR_ERR(pdev);