Skip to contentSkip to conversation

ppc4xx: Update flash size in reg property of the NOR flash node

PATCH Superseded Stefan Roese 2 participants 4 messages Oct 20, 2009 – Oct 21, 2009

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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.

---
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(-)
cpu/ppc4xx/fdt.c +42 -1
index 496e028..2688af1 100644
@@ -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);
Signature · 1 line
1.6.5.1
#1 lore raw

PATCH v2 1/1 ppc4xx: Update flash size in reg property of the NOR flash node

Dear Stefan Roese,

Quoted 11 lines · In message <[email protected]> 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.

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

Signature · 5 lines
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.
#2 lore raw

PATCH v2 1/1 ppc4xx: Update flash size in reg property of the NOR flash node

Hi Wolfgang,

Quoted 12 lines · On Tuesday 20 October 2009 23:12:47 Wolfgang Denk wrote:
Quoted 11 lines

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.

---
Changes in v2:
- NOR flash nodes are now scanned/detected via the compatible node.

Quoted 6 lines

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

#3 lore raw

PATCH v2 1/1 ppc4xx: Update flash size in reg property of the NOR flash node

Dear Stefan Roese,

Quoted 10 lines · In message <[email protected]> you wrote:
Quoted 5 lines

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.

Quoted 1 line

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

Signature · 6 lines
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.