@@ -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;
@@ -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 */
@@ -38,6 +38,7 @@ struct blocklevel_info {
const char *name;
uint64_t size;
uint32_t erase_granule;
+ enum blocklevel_flags flags;
};
/*
@@ -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;
Signed-off-by: William A. Kennington III <wak@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(-)