[Skiboot] [PATCH 2/2] flash: Add dt entries for flash that doesn't need erase

William A. Kennington III wak at google.com
Sat Apr 8 09:11:47 AEST 2017


Signed-off-by: William A. Kennington III <wak at google.com>
Change-Id: Iee4cfb809fe00bdaae24dd4a068a3fd395c9a7d1
---
 core/flash.c          | 16 ++++++++++------
 libflash/blocklevel.c |  2 ++
 libflash/blocklevel.h |  1 +
 libflash/mbox-flash.c |  4 ++++
 4 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/core/flash.c b/core/flash.c
index 10cf8b4d..39954ed3 100644
--- a/core/flash.c
+++ b/core/flash.c
@@ -29,12 +29,13 @@
 #include <elf.h>
 
 struct flash {
-	struct list_node	list;
-	bool			busy;
-	struct blocklevel_device *bl;
-	uint64_t		size;
-	uint32_t		block_size;
-	int			id;
+	struct list_node		list;
+	bool				busy;
+	bool				no_erase;
+	struct blocklevel_device 	*bl;
+	uint64_t			size;
+	uint32_t			block_size;
+	int				id;
 };
 
 static LIST_HEAD(flashes);
@@ -199,6 +200,8 @@ static struct dt_node *flash_add_dt_node(struct flash *flash, int id)
 	dt_add_property_u64(flash_node, "reg", flash->size);
 	dt_add_property_cells(flash_node, "ibm,flash-block-size",
 			flash->block_size);
+	if (flash->no_erase)
+		dt_add_property(flash_node, "no-erase", NULL, 0);
 
 	/* we fix to 32-bits */
 	dt_add_property_cells(flash_node, "#address-cells", 1);
@@ -279,6 +282,7 @@ int flash_register(struct blocklevel_device *bl)
 	}
 
 	flash->busy = false;
+	flash->no_erase = !(bl_info.flags & WRITE_NEED_ERASE);
 	flash->bl = bl;
 	flash->size = bl_info.size;
 	flash->block_size = bl_info.erase_granule;
diff --git a/libflash/blocklevel.c b/libflash/blocklevel.c
index 6272f8fd..5ca71c51 100644
--- a/libflash/blocklevel.c
+++ b/libflash/blocklevel.c
@@ -233,6 +233,8 @@ int blocklevel_get_info(struct blocklevel_device *bl, struct blocklevel_info *bl
 	if (rc)
 		return rc;
 
+	bl_info->flags = bl->flags;
+
 	rc = bl->get_info(bl, bl_info);
 
 	/* Check the validity of what we are being told */
diff --git a/libflash/blocklevel.h b/libflash/blocklevel.h
index 7e4a7e8d..92e5e4a5 100644
--- a/libflash/blocklevel.h
+++ b/libflash/blocklevel.h
@@ -38,6 +38,7 @@ struct blocklevel_info {
 	const char *name;
 	uint64_t size;
 	uint32_t erase_granule;
+	enum blocklevel_flags flags;
 };
 
 /*
diff --git a/libflash/mbox-flash.c b/libflash/mbox-flash.c
index 75e03005..5305f82b 100644
--- a/libflash/mbox-flash.c
+++ b/libflash/mbox-flash.c
@@ -438,6 +438,9 @@ static int mbox_flash_erase(struct blocklevel_device *bl __unused,
 	 * actually write all 0xFF here. I'll leave that as an extersise
 	 * for the future.
 	 */
+	/* NOTE: When implementing this function for mbox v2, remember to
+	 * change bl->flags = WRITE_NEED_ERASE in mbox_flash_init
+	 */
 	return 0;
 }
 
@@ -542,6 +545,7 @@ int mbox_flash_init(struct blocklevel_device **bl)
 	}
 
 	mbox_flash->bl.keep_alive = 0;
+	mbox_flash->bl.flags = 0; /* We don't need erases to write */
 	mbox_flash->bl.read = &mbox_flash_read;
 	mbox_flash->bl.write = &mbox_flash_write;
 	mbox_flash->bl.erase = &mbox_flash_erase;
-- 
2.12.2



More information about the Skiboot mailing list