All of lore.kernel.org
 help / color / mirror / Atom feed
* [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

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.