From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rv-out-0506.google.com (rv-out-0506.google.com [209.85.198.239]) by ozlabs.org (Postfix) with ESMTP id E999ADDDA1 for ; Thu, 26 Feb 2009 21:08:06 +1100 (EST) Received: by rv-out-0506.google.com with SMTP id l9so469282rvb.9 for ; Thu, 26 Feb 2009 02:08:04 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <1235642785-9684-1-git-send-email-tiejun.chen@windriver.com> References: <1235642785-9684-1-git-send-email-tiejun.chen@windriver.com> Date: Thu, 26 Feb 2009 18:08:04 +0800 Message-ID: <7a800c8d0902260208g4a65b07fi1bb287910c51b342@mail.gmail.com> Subject: [PATCH 1/1] Fix 64bit Mapple Host Bridge Address and Size Nodes From: Tiejun Chen To: benh@kernel.crashing.org Content-Type: multipart/alternative; boundary=000e0cd20d1435b8ec0463cf87c5 Cc: linuxppc-dev@ozlabs.org, akpm@linux-foundation.org List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , --000e0cd20d1435b8ec0463cf87c5 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit In the DTB tree created by firmware on Maple 64bit target, host bridge parent node has specified both of these two properties to be 2. However, the actual "cell" value for host bridge node is 1. we have to provide one fixup function. Signed-off-by: Tiejun Chen --- arch/powerpc/kernel/prom_init.c | 42 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 42 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c index 2445945..9cd23b6 100644 --- a/arch/powerpc/kernel/prom_init.c +++ b/arch/powerpc/kernel/prom_init.c @@ -1948,8 +1948,49 @@ static void __init fixup_device_tree_maple(void) prom_setprop(isa, name, "ranges", isa_ranges, sizeof(isa_ranges)); } + +/* On Maple 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_maple_hb(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 Maple/Apache...\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)); +} + #else #define fixup_device_tree_maple() +#define fixup_device_tree_maple_hb() #endif #ifdef CONFIG_PPC_CHRP @@ -2190,6 +2231,7 @@ static void __init fixup_device_tree_efika(void) static void __init fixup_device_tree(void) { fixup_device_tree_maple(); + fixup_device_tree_maple_hb(); fixup_device_tree_chrp(); fixup_device_tree_pmac(); fixup_device_tree_efika(); -- 1.5.6 --000e0cd20d1435b8ec0463cf87c5 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable In the DTB tree created by firmware on Maple 64bit target, host bridge pare= nt
node has specified both of these two properties to be 2. However, the actua= l
"cell" value for host bridge node is 1. we have to provide one fi= xup function.

Signed-off-by: Tiejun Chen <ti= ejun.china@gmail.com>
---
=A0arch/powerpc/kernel/prom_init.c | =A0 42 +++++++++++++++++++++++++++++++= ++++++++
=A01 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_ini= t.c
index 2445945..9cd23b6 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -1948,8 +1948,49 @@ static void __init fixup_device_tree_maple(void)
=A0 =A0 =A0 =A0prom_setprop(isa, name, "ranges",
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0isa_ranges, sizeof(isa_rang= es));
=A0}
+
+/* On Maple 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_maple_hb(void)
+{
+ =A0 =A0 =A0 phandle hb;
+ =A0 =A0 =A0 u32 hb_ranges[4];
+ =A0 =A0 =A0 u32 size_cell, addr_cell;
+ =A0 =A0 =A0 struct prom_t *_prom =3D &RELOC(prom);
+ =A0 =A0 =A0 char *name;
+
+ =A0 =A0 =A0 name =3D "/hostbridge@f8000000";
+ =A0 =A0 =A0 hb =3D call_prom("finddevice", 1, 1, ADDR(name)); + =A0 =A0 =A0 if (!PHANDLE_VALID(hb))
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 return;
+
+ =A0 =A0 =A0 if (prom_getproplen(hb, "reg") !=3D 8)
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 return;
+
+ =A0 =A0 =A0 if (prom_getprop(hb, "reg", hb_ranges, (sizeof(hb_r= anges))/2)
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =3D=3D PROM_ERROR)
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 return;
+
+ =A0 =A0 =A0 prom_getprop(_prom->root, "#address-cells", &= ;addr_cell, sizeof(addr_cell));
+ =A0 =A0 =A0 prom_getprop(_prom->root, "#size-cells", &si= ze_cell, sizeof(size_cell));
+
+ =A0 =A0 =A0 if ((addr_cell !=3D 2) || (size_cell !=3D 2) ||
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 (hb_ranges[0] !=3D 0xf8000000))
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 return;
+
+ =A0 =A0 =A0 prom_printf("Fixing up bogus HOSTBRIDGE reg on Maple/Apa= che...\n");
+
+ =A0 =A0 =A0 hb_ranges[3] =3D hb_ranges[1];
+ =A0 =A0 =A0 hb_ranges[1] =3D hb_ranges[0];
+ =A0 =A0 =A0 hb_ranges[0] =3D hb_ranges[2] =3D 0;
+ =A0 =A0 =A0 prom_setprop(hb, name, "reg",
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 hb_ranges, sizeof(hb_ranges));
+}
+
=A0#else
=A0#define fixup_device_tree_maple()
+#define fixup_device_tree_maple_hb()
=A0#endif

=A0#ifdef CONFIG_PPC_CHRP
@@ -2190,6 +2231,7 @@ static void __init fixup_device_tree_efika(void)
=A0static void __init fixup_device_tree(void)
=A0{
=A0 =A0 =A0 =A0fixup_device_tree_maple();
+ =A0 =A0 =A0 fixup_device_tree_maple_hb();
=A0 =A0 =A0 =A0fixup_device_tree_chrp();
=A0 =A0 =A0 =A0fixup_device_tree_pmac();
=A0 =A0 =A0 =A0fixup_device_tree_efika();
--
1.5.6


--000e0cd20d1435b8ec0463cf87c5--