[Skiboot] [PATCH] flash: Move flash node under ibm,opal/flash/

Jack Miller jack at codezen.org
Tue Aug 2 06:47:18 AEST 2016


This changes the boot ABI, so it's only active for P9 and later systems,
even though it's unrelated to hardware changes. There is an associated
Linux change to properly search for this node as well.

This change properly specifies #address-cells for the flash node, so we
can avoid DTC errors like

---
device tree: Warning (reg_format): "reg" property in /ibm,opal/flash at 0
has invalid length (8 bytes) (#address-cells == 0, #size-cells == 0)
---

Base on a patch from Cyril Bur

Signed-off-by: Jack Miller <jack at codezen.org>
---
 core/flash.c | 31 ++++++++++++++++++++++++-------
 1 file changed, 24 insertions(+), 7 deletions(-)

diff --git a/core/flash.c b/core/flash.c
index e9c1f7d..0d3a160 100644
--- a/core/flash.c
+++ b/core/flash.c
@@ -187,19 +187,36 @@ static int flash_nvram_probe(struct flash *flash, struct ffs_handle *ffs)
 
 static struct dt_node *flash_add_dt_node(struct flash *flash, int id)
 {
-	struct dt_node *flash_node;
+	struct dt_node *flash_node, *flash_dir;
 
-	flash_node = dt_new_addr(opal_node, "flash", id);
-	dt_add_property_strings(flash_node, "compatible", "ibm,opal-flash");
+	/* Boot ABI on P9+, flash node is in ibm,opal/flash/flash at 0 */
+
+	if (proc_gen >= proc_gen_p9) {
+		flash_dir = dt_new(opal_node, "flash");
+		assert(flash_dir);
+
+		dt_add_property_cells(flash_dir, "#address-cells", 1);
+		dt_add_property_cells(flash_dir, "#size-cells", 0);
+
+		flash_node = dt_new_addr(flash_dir, "flash", id);
+		assert(flash_node);
+
+	/* <= P8, flash is ibm,opal/flash at 0, with legacy cell settings */
+
+	} else {
+		flash_node = dt_new_addr(opal_node, "flash", id);
+		assert(flash_node);
+
+		dt_add_property_cells(flash_node, "#address-cells", 1);
+		dt_add_property_cells(flash_node, "#size-cells", 1);
+	}
+
+	dt_add_property_string(flash_node, "compatible", "ibm,opal-flash");
 	dt_add_property_cells(flash_node, "ibm,opal-id", id);
 	dt_add_property_cells(flash_node, "reg", 0, flash->size);
 	dt_add_property_cells(flash_node, "ibm,flash-block-size",
 			flash->block_size);
 
-	/* we fix to 32-bits */
-	dt_add_property_cells(flash_node, "#address-cells", 1);
-	dt_add_property_cells(flash_node, "#size-cells", 1);
-
 	return flash_node;
 }
 
-- 
2.9.2



More information about the Skiboot mailing list