diff mbox series

[v2] FWU: developerbox: read boot index from NOR flash

Message ID 20240228055344.2335332-1-kojima.masahisa@socionext.com
State Accepted
Commit fd50ae3f2628d1197829e0c2ef52aed653e80d68
Delegated to: Tom Rini
Headers show
Series [v2] FWU: developerbox: read boot index from NOR flash | expand

Commit Message

Masahisa Kojima Feb. 28, 2024, 5:53 a.m. UTC
The FWU Multi Bank Update feature allows the platform to boot the
firmware images from one of the partitions(banks).
On the Developerbox, SCP-firmware running on the SCB(Cortex-M3)
passes the value of the boot index on the NOR flash.
Add a function to read the boot index value from the NOR flash.

Signed-off-by: Masahisa Kojima <kojima.masahisa@socionext.com>
---
v1 -> v2
- update my email address

 board/socionext/developerbox/fwu_plat.c | 31 +++++++++++++++++++++++++
 include/configs/synquacer.h             |  1 +
 2 files changed, 32 insertions(+)

Comments

Jassi Brar Feb. 28, 2024, 3:48 p.m. UTC | #1
On Tue, 27 Feb 2024 at 23:53, Masahisa Kojima
<kojima.masahisa@socionext.com> wrote:
>
> The FWU Multi Bank Update feature allows the platform to boot the
> firmware images from one of the partitions(banks).
> On the Developerbox, SCP-firmware running on the SCB(Cortex-M3)
> passes the value of the boot index on the NOR flash.
> Add a function to read the boot index value from the NOR flash.
>
> Signed-off-by: Masahisa Kojima <kojima.masahisa@socionext.com>

Acked-by: Jassi Brar <jaswinder.singh@linaro.org>
diff mbox series

Patch

diff --git a/board/socionext/developerbox/fwu_plat.c b/board/socionext/developerbox/fwu_plat.c
index e724e702bd..26031795b0 100644
--- a/board/socionext/developerbox/fwu_plat.c
+++ b/board/socionext/developerbox/fwu_plat.c
@@ -35,3 +35,34 @@  void set_dfu_alt_info(char *interface, char *devstr)
 
 	env_set("dfu_alt_info", buf);
 }
+
+/**
+ * fwu_plat_get_bootidx() - Get the value of the boot index
+ * @boot_idx: Boot index value
+ *
+ * Get the value of the bank(partition) from which the platform
+ * has booted. This value is passed to U-Boot from the earlier
+ * stage bootloader which loads and boots all the relevant
+ * firmware images
+ */
+void fwu_plat_get_bootidx(uint *boot_idx)
+{
+	int ret;
+	u32 buf;
+	size_t readlen;
+	struct mtd_info *mtd;
+
+	*boot_idx = 0;
+
+	mtd_probe_devices();
+	mtd = get_mtd_device_nm("nor1");
+	if (IS_ERR_OR_NULL(mtd))
+		return;
+
+	ret = mtd_read(mtd, SCB_PLAT_METADATA_OFFSET, sizeof(buf),
+		       &readlen, (u_char *)&buf);
+	if (ret < 0)
+		return;
+
+	*boot_idx = buf;
+}
diff --git a/include/configs/synquacer.h b/include/configs/synquacer.h
index e36e63e81e..f0867227ac 100644
--- a/include/configs/synquacer.h
+++ b/include/configs/synquacer.h
@@ -21,6 +21,7 @@ 
 /*
  * Boot info
  */
+#define SCB_PLAT_METADATA_OFFSET	(0x510000)
 
 /*
  * Hardware drivers support