linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [v2 PATCH 1/1] Fix 64bit Maple Host Bridge 'reg' property
@ 2009-04-14 10:13 tiejun.china
  2009-05-01  5:02 ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 2+ messages in thread
From: tiejun.china @ 2009-04-14 10:13 UTC (permalink / raw)
  To: segher; +Cc: linuxppc-dev, akpm

In the DTB tree created by firmware on some Maple 64bit targets, such as ATCA6101, 
the "reg" property of host bridge node is incorrectly encoded as if #address-cells 
and #size-cells were 1. So we have to provide one fixup function to fix that.

Signed-off-by: Tiejun Chen <tiejun.china@gmail.com>
---
 arch/powerpc/kernel/prom_init.c |   50 ++++++++++++++++++++++++++++++++++++++-
 1 files changed, 49 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 2445945..36ef9f2 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -1907,14 +1907,62 @@ static void __init flatten_device_tree(void)
 }
 
 #ifdef CONFIG_PPC_MAPLE
+/* On ATCA6101 64bit target host bridge parent node has specified address and
+ * size properties to be 2. But the actual "cell" value for host bridge node 
+ * is 1 since early MOTLoad internal bug. */
+static void __init fixup_device_tree_atca6101(void)
+{
+	phandle hb;
+	u32 hb_ranges[4];
+	u32 size_cell, addr_cell;
+	struct prom_t *_prom = &RELOC(prom);
+	char *name;
+
+	name = "/hostbridge@f8000000";
+	hb = call_prom("finddevice", 1, 1, ADDR(name));
+	if (!PHANDLE_VALID(hb))
+		return;
+
+	if (prom_getproplen(hb, "reg") != 8)
+		return;
+
+	if (prom_getprop(hb, "reg", hb_ranges, (sizeof(hb_ranges))/2) 
+		== PROM_ERROR)
+		return;
+
+	prom_getprop(_prom->root, "#address-cells", &addr_cell, sizeof(addr_cell));
+	prom_getprop(_prom->root, "#size-cells", &size_cell, sizeof(size_cell));
+	
+	if ((addr_cell != 2) || (size_cell != 2) || 
+		(hb_ranges[0] != 0xf8000000))
+		return;
+
+	prom_printf("Fixing up bogus HOSTBRIDGE reg on ATCA6101...\n");
+
+	hb_ranges[3] = hb_ranges[1];
+	hb_ranges[1] = hb_ranges[0];
+	hb_ranges[0] = hb_ranges[2] = 0;
+	prom_setprop(hb, name, "reg", hb_ranges, sizeof(hb_ranges));
+}
 /* PIBS Version 1.05.0000 04/26/2005 has an incorrect /ht/isa/ranges property.
- * The values are bad, and it doesn't even have the right number of cells. */
+ * The values are bad, and it doesn't even have the right number of cells. 
+ * Additionally, the early MOTLoad generate incorrect address&size cells on 
+ * some Maple platform such as ATCA6101. */ 
 static void __init fixup_device_tree_maple(void)
 {
 	phandle isa;
 	u32 rloc = 0x01002000; /* IO space; PCI device = 4 */
 	u32 isa_ranges[6];
 	char *name;
+	u32 node;
+	char prop[64];
+	int model;
+	
+	/*  FIXME: This may be used for more Maple targets not only ATCA6101. */
+	node = call_prom("finddevice", 1, 1, ADDR("/"));
+	model = prom_getprop(node, "model", prop, sizeof(prop));
+	if (model != PROM_ERROR && (strcmp(prop, "Motorola,ATCA-6101") == 0))
+                fixup_device_tree_atca6101();
 
 	name = "/ht@0/isa@4";
 	isa = call_prom("finddevice", 1, 1, ADDR(name));
-- 
1.5.6

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [v2 PATCH 1/1] Fix 64bit Maple Host Bridge 'reg' property
  2009-04-14 10:13 [v2 PATCH 1/1] Fix 64bit Maple Host Bridge 'reg' property tiejun.china
@ 2009-05-01  5:02 ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 2+ messages in thread
From: Benjamin Herrenschmidt @ 2009-05-01  5:02 UTC (permalink / raw)
  To: tiejun.china; +Cc: linuxppc-dev, akpm

On Tue, 2009-04-14 at 18:13 +0800, tiejun.china@gamil.com wrote:
> In the DTB tree created by firmware on some Maple 64bit targets, such as ATCA6101, 
> the "reg" property of host bridge node is incorrectly encoded as if #address-cells 
> and #size-cells were 1. So we have to provide one fixup function to fix that.
> 
> Signed-off-by: Tiejun Chen <tiejun.china@gmail.com>

Almost there :-)

> +	/*  FIXME: This may be used for more Maple targets not only ATCA6101. */
> +	node = call_prom("finddevice", 1, 1, ADDR("/"));
> +	model = prom_getprop(node, "model", prop, sizeof(prop));

Couldn't you use _prom->root above ?

> +	if (model != PROM_ERROR && (strcmp(prop, "Motorola,ATCA-6101") == 0))
> +                fixup_device_tree_atca6101();
>  
>  	name = "/ht@0/isa@4";
>  	isa = call_prom("finddevice", 1, 1, ADDR(name));

Cheers,
Ben.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-05-01  5:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-14 10:13 [v2 PATCH 1/1] Fix 64bit Maple Host Bridge 'reg' property tiejun.china
2009-05-01  5:02 ` Benjamin Herrenschmidt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).