* [U-Boot] [PATCH v2] ppc4xx: Update flash size in reg property of the NOR flash node
@ 2009-10-20 14:28 Stefan Roese
2009-10-20 21:12 ` Wolfgang Denk
0 siblings, 1 reply; 4+ messages in thread
From: Stefan Roese @ 2009-10-20 14:28 UTC (permalink / raw)
To: u-boot
Till now only the ranges in the ebc node are updated with the values
currently configured in the PPC4xx EBC controller. With this patch now
the NOR flash size is updated in the device tree blob as well. This is
done by scanning the compatible nodes "cfi-flash" and "jedec-flash"
for the correct chip select number.
Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Wolfgang Denk <wd@denx.de>
---
Changes in v2:
- NOR flash nodes are now scanned/detected via the compatible node.
cpu/ppc4xx/fdt.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 42 insertions(+), 1 deletions(-)
diff --git a/cpu/ppc4xx/fdt.c b/cpu/ppc4xx/fdt.c
index 496e028..2688af1 100644
--- a/cpu/ppc4xx/fdt.c
+++ b/cpu/ppc4xx/fdt.c
@@ -35,6 +35,43 @@
DECLARE_GLOBAL_DATA_PTR;
+static int fdt_update_nor_flash_node(void *blob, int cs, u32 size)
+{
+ char *compat[] = { "cfi-flash", "jedec-flash" };
+ int off;
+ int len;
+ struct fdt_property *prop;
+ u32 *reg;
+ int i;
+
+ for (i = 0; i < 2; i++) {
+ off = fdt_node_offset_by_compatible(blob, -1, compat[i]);
+ while (off != -FDT_ERR_NOTFOUND) {
+ /*
+ * Found one compatible node, now check if this one
+ * has the correct CS
+ */
+ prop = fdt_get_property_w(blob, off, "reg", &len);
+ if (prop) {
+ reg = (u32 *)&prop->data[0];
+ if (reg[0] == cs) {
+ reg[2] = size;
+ fdt_setprop(blob, off, "reg", reg,
+ 3 * sizeof(u32));
+
+ return 0;
+ }
+ }
+
+ /* Move to next compatible node */
+ off = fdt_node_offset_by_compatible(blob, off,
+ compat[i]);
+ }
+ }
+
+ return -1;
+}
+
void __ft_board_setup(void *blob, bd_t *bd)
{
int rc;
@@ -59,11 +96,15 @@ void __ft_board_setup(void *blob, bd_t *bd)
*p++ = 0;
*p++ = bxcr & EBC_BXCR_BAS_MASK;
*p++ = EBC_BXCR_BANK_SIZE(bxcr);
+
+ /* Try to update reg property in nor flash node too */
+ fdt_update_nor_flash_node(blob, i,
+ EBC_BXCR_BANK_SIZE(bxcr));
}
}
/* Some 405 PPC's have EBC as direct PLB child in the dts */
- if (fdt_path_offset(blob, "/plb/opb/ebc") < 0)
+ if (fdt_path_offset(blob, ebc_path) < 0)
strcpy(ebc_path, "/plb/ebc");
rc = fdt_find_and_setprop(blob, ebc_path, "ranges", ranges,
(p - ranges) * sizeof(u32), 1);
--
1.6.5.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH v2] ppc4xx: Update flash size in reg property of the NOR flash node
2009-10-20 14:28 [U-Boot] [PATCH v2] ppc4xx: Update flash size in reg property of the NOR flash node Stefan Roese
@ 2009-10-20 21:12 ` Wolfgang Denk
2009-10-21 9:05 ` Stefan Roese
0 siblings, 1 reply; 4+ messages in thread
From: Wolfgang Denk @ 2009-10-20 21:12 UTC (permalink / raw)
To: u-boot
Dear Stefan Roese,
In message <1256048896-10508-1-git-send-email-sr@denx.de> you wrote:
> Till now only the ranges in the ebc node are updated with the values
> currently configured in the PPC4xx EBC controller. With this patch now
> the NOR flash size is updated in the device tree blob as well. This is
> done by scanning the compatible nodes "cfi-flash" and "jedec-flash"
> for the correct chip select number.
>
> Signed-off-by: Stefan Roese <sr@denx.de>
> Cc: Wolfgang Denk <wd@denx.de>
> ---
> Changes in v2:
> - NOR flash nodes are now scanned/detected via the compatible node.
Thanks.
Hm... thinking about it, this problem most probably affects other
(non-4xx boards as well). I guess there is no easy way to generalize
this code enough tomake it usable by other (or even all?) boards as
well?
Thanks.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Philosophy is a game with objectives and no rules.
Mathematics is a game with rules and no objectives.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH v2] ppc4xx: Update flash size in reg property of the NOR flash node
2009-10-20 21:12 ` Wolfgang Denk
@ 2009-10-21 9:05 ` Stefan Roese
2009-10-21 9:44 ` Wolfgang Denk
0 siblings, 1 reply; 4+ messages in thread
From: Stefan Roese @ 2009-10-21 9:05 UTC (permalink / raw)
To: u-boot
Hi Wolfgang,
On Tuesday 20 October 2009 23:12:47 Wolfgang Denk wrote:
> > Till now only the ranges in the ebc node are updated with the values
> > currently configured in the PPC4xx EBC controller. With this patch now
> > the NOR flash size is updated in the device tree blob as well. This is
> > done by scanning the compatible nodes "cfi-flash" and "jedec-flash"
> > for the correct chip select number.
> >
> > Signed-off-by: Stefan Roese <sr@denx.de>
> > Cc: Wolfgang Denk <wd@denx.de>
> > ---
> > Changes in v2:
> > - NOR flash nodes are now scanned/detected via the compatible node.
>
> Thanks.
>
> Hm... thinking about it, this problem most probably affects other
> (non-4xx boards as well). I guess there is no easy way to generalize
> this code enough tomake it usable by other (or even all?) boards as
> well?
I see no way to easily fix the NOR flash "reg" property for all non-4xx boards
as well. But what I can do is, move the fdt_update_nor_flash_node() function
into some common code (commond/fdt_support.c). This way it could be used by
other boards/platforms as well.
Should I send an updated patch for this?
Cheers,
Stefan
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office at denx.de
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH v2] ppc4xx: Update flash size in reg property of the NOR flash node
2009-10-21 9:05 ` Stefan Roese
@ 2009-10-21 9:44 ` Wolfgang Denk
0 siblings, 0 replies; 4+ messages in thread
From: Wolfgang Denk @ 2009-10-21 9:44 UTC (permalink / raw)
To: u-boot
Dear Stefan Roese,
In message <200910211105.10055.sr@denx.de> you wrote:
>
> > Hm... thinking about it, this problem most probably affects other
> > (non-4xx boards as well). I guess there is no easy way to generalize
> > this code enough tomake it usable by other (or even all?) boards as
> > well?
>
> I see no way to easily fix the NOR flash "reg" property for all non-4xx boards
> as well. But what I can do is, move the fdt_update_nor_flash_node() function
> into some common code (commond/fdt_support.c). This way it could be used by
> other boards/platforms as well.
That's a good idea.
> Should I send an updated patch for this?
Yes, please do. And please add a comment that describes what it's good
for.
Thanks
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
ATTENTION: Despite Any Other Listing of Product Contents Found Here-
on, the Consumer is Advised That, in Actuality, This Product Consists
Of 99.9999999999% Empty Space.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-10-21 9:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-20 14:28 [U-Boot] [PATCH v2] ppc4xx: Update flash size in reg property of the NOR flash node Stefan Roese
2009-10-20 21:12 ` Wolfgang Denk
2009-10-21 9:05 ` Stefan Roese
2009-10-21 9:44 ` Wolfgang Denk
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.