[U-Boot] [PATCH v2] ppc4xx: Update flash size in reg property of the NOR flash node

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);

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

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@denx.de

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
participants (2)
-
Stefan Roese
-
Wolfgang Denk