diff mbox

[v2,1/3] external/common: Teach ARM code to erase 'mtd chips'

Message ID 20161108060841.18119-1-cyril.bur@au1.ibm.com
State Accepted
Headers show

Commit Message

Cyril Bur Nov. 8, 2016, 6:08 a.m. UTC
Currently the arch flash code for all architectures can only perform
chip erases if there is a real flash driver attached.

With increasing use of MTD on both host and BMC this code needs to know
how to behave of the backend of blocklevel is MTD.

This patch teaches the ARM specific code to pass an erase for the full
size of the chip down the stack. This can be optimised into a chip erase
within the kernel.

Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
---
V2: No change

 external/common/arch_flash_arm.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

Comments

Joel Stanley Nov. 8, 2016, 6:18 a.m. UTC | #1
On Tue, Nov 8, 2016 at 4:38 PM, Cyril Bur <cyril.bur@au1.ibm.com> wrote:
> Currently the arch flash code for all architectures can only perform
> chip erases if there is a real flash driver attached.
>
> With increasing use of MTD on both host and BMC this code needs to know
> how to behave of the backend of blocklevel is MTD.
>
> This patch teaches the ARM specific code to pass an erase for the full
> size of the chip down the stack. This can be optimised into a chip erase
> within the kernel.
>
> Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>

Reviewed-by: Joel Stanley <joel@jms.id.au>
Stewart Smith Nov. 8, 2016, 6:50 a.m. UTC | #2
Cyril Bur <cyril.bur@au1.ibm.com> writes:
> Currently the arch flash code for all architectures can only perform
> chip erases if there is a real flash driver attached.
>
> With increasing use of MTD on both host and BMC this code needs to know
> how to behave of the backend of blocklevel is MTD.
>
> This patch teaches the ARM specific code to pass an erase for the full
> size of the chip down the stack. This can be optimised into a chip erase
> within the kernel.
>
> Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>

Thanks, series merged to master as of e5720d3fe94f5b85c374520b89fb8fbb2143df94
diff mbox

Patch

diff --git a/external/common/arch_flash_arm.c b/external/common/arch_flash_arm.c
index 697609d..bb8800f 100644
--- a/external/common/arch_flash_arm.c
+++ b/external/common/arch_flash_arm.c
@@ -300,8 +300,17 @@  int arch_flash_erase_chip(struct blocklevel_device *bl)
 	if (!arch_data.init_bl || arch_data.init_bl != bl)
 		return -1;
 
-	if (!arch_data.flash_chip)
-		return -1;
+	if (!arch_data.flash_chip) {
+		/* Just assume its a regular erase */
+		int rc;
+		uint64_t total_size;
+
+		rc = blocklevel_get_info(bl, NULL, &total_size, NULL);
+		if (rc)
+			return rc;
+
+		return blocklevel_erase(bl, 0, total_size);
+	}
 
 	return flash_erase_chip(arch_data.flash_chip);
 }