aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam A. Kennington III <wak@google.com>2017-08-28 23:48:40 -0700
committerStewart Smith <stewart@linux.vnet.ibm.com>2017-09-05 14:41:22 +1000
commitba99af9b149d02438347b055e6e7d6bd15e33551 (patch)
tree5bee2d621361d5e0c3de9bb71252cc03f940cb3e
parent058e5839a150c2ce6512b553581d875eacf7e6a5 (diff)
downloadskiboot-ba99af9b149d02438347b055e6e7d6bd15e33551.zip
skiboot-ba99af9b149d02438347b055e6e7d6bd15e33551.tar.gz
skiboot-ba99af9b149d02438347b055e6e7d6bd15e33551.tar.bz2
flash: Support adding the no-erase property to flash
The mbox protocol explicitly states that an erase is not required before a write. This means that issuing an erase from userspace, through the mtd device, and back returns a successful operation that does nothing. Unfortunately, this makes userspace tools unhappy. Linux MTD devices support the MTD_NO_ERASE flag which conveys that writes do not require erases on the underlying flash devices. We should set this property on all of our devices which do not require erases to be performed. NOTE: This still requires a linux kernel component to set the MTD_NO_ERASE flag from the device tree property. Signed-off-by: William A. Kennington III <wak@google.com> Reviewed-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com> [stewart@linux.vnet.ibm.com: slightly reword commit msg based on Suraj's comments] Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
-rw-r--r--core/flash.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/core/flash.c b/core/flash.c
index 7e46f0a..93db8cb 100644
--- a/core/flash.c
+++ b/core/flash.c
@@ -32,6 +32,7 @@
struct flash {
struct list_node list;
bool busy;
+ bool no_erase;
struct blocklevel_device *bl;
uint64_t size;
uint32_t block_size;
@@ -307,6 +308,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);
@@ -389,6 +392,7 @@ int flash_register(struct blocklevel_device *bl)
flash->busy = false;
flash->bl = bl;
+ flash->no_erase = !(bl->flags & WRITE_NEED_ERASE);
flash->size = size;
flash->block_size = block_size;
flash->id = num_flashes();