Skip to contentSkip to conversation

board: stm32mp2: read boot index from backup register

PATCH RESEND In review Dario Binacchi 2 participants 3 messages Jan 18 – Jan 29

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 board: stm32mp2: read boot index from backup register

Following the commit 95b5a7de30f6 (“FWU: STM32MP1: Add support to read boot index from backup register”), this patch enables reading the boot index from backup registers on STM32MP2 platforms.

---

 arch/arm/mach-stm32mp/include/mach/stm32.h |  4 ++++
 board/st/stm32mp2/stm32mp2.c               | 21 +++++++++++++++++++++
 2 files changed, 25 insertions(+)
arch/arm/mach-stm32mp/include/mach/stm32.h +4 -0
index 2bf50c755cbd..90f06a052d3f 100644
@@ -188,8 +188,12 @@ enum forced_boot_mode {
 /* TAMP registers x = 0 to 127 : hardcoded description, waiting NVMEM node in DT */
 #define TAMP_BACKUP_REGISTER(x)		(STM32_TAMP_BASE + 0x100 + 4 * (x))
 
+#define TAMP_FWU_BOOT_INFO_REG		TAMP_BACKUP_REGISTER(48)
 /* TAMP registers zone 3 RIF 1 (RW) at 96*/
 #define TAMP_BOOT_CONTEXT		TAMP_BACKUP_REGISTER(96)
+
+#define TAMP_FWU_BOOT_IDX_MASK		GENMASK(3, 0)
+#define TAMP_FWU_BOOT_IDX_OFFSET	0
 #endif /* defined(CONFIG_STM32MP23X) || defined(CONFIG_STM32MP25X) */
 
 /* offset used for BSEC driver: misc_read and misc_write */
board/st/stm32mp2/stm32mp2.c +21 -0
index 7bc7d2a608fd..43bc583378e6 100644
@@ -188,3 +188,24 @@ void board_quiesce_devices(void)
 {
 	led_boot_off();
 }
+
+#if defined(CONFIG_FWU_MULTI_BANK_UPDATE)
+
+#include <fwu.h>
+
+/**
+ * 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)
+{
+	*boot_idx = (readl(TAMP_FWU_BOOT_INFO_REG) >>
+		    TAMP_FWU_BOOT_IDX_OFFSET) & TAMP_FWU_BOOT_IDX_MASK;
+}
+#endif /* CONFIG_FWU_MULTI_BANK_UPDATE */
Signature · 4 lines
2.43.0

base-commit: ff498a3c5efb424accc1d825cc45cede2540ca13
branch: stm32mp2-active-index
Reviewed-by on v1 1/1
#1 lore raw
Quoted 48 lines · Dario Binacchi

Following the commit 95b5a7de30f6 (“FWU: STM32MP1: Add support to read boot index from backup register”), this patch enables reading the boot index from backup registers on STM32MP2 platforms.

---

 arch/arm/mach-stm32mp/include/mach/stm32.h |  4 ++++
 board/st/stm32mp2/stm32mp2.c               | 21 +++++++++++++++++++++
 2 files changed, 25 insertions(+)
arch/arm/mach-stm32mp/include/mach/stm32.h +4 -0
index 2bf50c755cbd..90f06a052d3f 100644
@@ -188,8 +188,12 @@ enum forced_boot_mode {
 /* TAMP registers x = 0 to 127 : hardcoded description, waiting NVMEM node in DT */
 #define TAMP_BACKUP_REGISTER(x)		(STM32_TAMP_BASE + 0x100 + 4 * (x))
 
+#define TAMP_FWU_BOOT_INFO_REG		TAMP_BACKUP_REGISTER(48)
 /* TAMP registers zone 3 RIF 1 (RW) at 96*/
 #define TAMP_BOOT_CONTEXT		TAMP_BACKUP_REGISTER(96)
+
+#define TAMP_FWU_BOOT_IDX_MASK		GENMASK(3, 0)
+#define TAMP_FWU_BOOT_IDX_OFFSET	0
 #endif /* defined(CONFIG_STM32MP23X) || defined(CONFIG_STM32MP25X) */
 
 /* offset used for BSEC driver: misc_read and misc_write */
board/st/stm32mp2/stm32mp2.c +11 -0
index 7bc7d2a608fd..43bc583378e6 100644
@@ -188,3 +188,24 @@ void board_quiesce_devices(void)
 {
 	led_boot_off();
 }
+
+#if defined(CONFIG_FWU_MULTI_BANK_UPDATE)
+
+#include <fwu.h>
+
+/**
+ * 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

board/st/stm32mp2/stm32mp2.c void board_quiesce_devices(void) · line 211

Quoted 10 lines
board/st/stm32mp2/stm32mp2.c +10 -0
+ * stage bootloader which loads and boots all the relevant
+ * firmware images
+ *
+ */
+void fwu_plat_get_bootidx(uint *boot_idx)
+{
+	*boot_idx = (readl(TAMP_FWU_BOOT_INFO_REG) >>
+		    TAMP_FWU_BOOT_IDX_OFFSET) & TAMP_FWU_BOOT_IDX_MASK;
+}
+#endif /* CONFIG_FWU_MULTI_BANK_UPDATE */

Hi Dario

Thanks
Patrice

#2 lore raw
Quoted 64 lines · Patrice CHOTARD
Quoted 48 lines · Dario Binacchi

Following the commit 95b5a7de30f6 (“FWU: STM32MP1: Add support to read boot index from backup register”), this patch enables reading the boot index from backup registers on STM32MP2 platforms.

---

 arch/arm/mach-stm32mp/include/mach/stm32.h |  4 ++++
 board/st/stm32mp2/stm32mp2.c               | 21 +++++++++++++++++++++
 2 files changed, 25 insertions(+)
arch/arm/mach-stm32mp/include/mach/stm32.h +4 -0
index 2bf50c755cbd..90f06a052d3f 100644
@@ -188,8 +188,12 @@ enum forced_boot_mode {
 /* TAMP registers x = 0 to 127 : hardcoded description, waiting NVMEM node in DT */
 #define TAMP_BACKUP_REGISTER(x)		(STM32_TAMP_BASE + 0x100 + 4 * (x))
 
+#define TAMP_FWU_BOOT_INFO_REG		TAMP_BACKUP_REGISTER(48)
 /* TAMP registers zone 3 RIF 1 (RW) at 96*/
 #define TAMP_BOOT_CONTEXT		TAMP_BACKUP_REGISTER(96)
+
+#define TAMP_FWU_BOOT_IDX_MASK		GENMASK(3, 0)
+#define TAMP_FWU_BOOT_IDX_OFFSET	0
 #endif /* defined(CONFIG_STM32MP23X) || defined(CONFIG_STM32MP25X) */
 
 /* offset used for BSEC driver: misc_read and misc_write */
board/st/stm32mp2/stm32mp2.c +11 -0
index 7bc7d2a608fd..43bc583378e6 100644
@@ -188,3 +188,24 @@ void board_quiesce_devices(void)
 {
 	led_boot_off();
 }
+
+#if defined(CONFIG_FWU_MULTI_BANK_UPDATE)
+
+#include <fwu.h>
+
+/**
+ * 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

board/st/stm32mp2/stm32mp2.c void board_quiesce_devices(void) · line 211

Quoted 10 lines
board/st/stm32mp2/stm32mp2.c +10 -0
+ * stage bootloader which loads and boots all the relevant
+ * firmware images
+ *
+ */
+void fwu_plat_get_bootidx(uint *boot_idx)
+{
+	*boot_idx = (readl(TAMP_FWU_BOOT_INFO_REG) >>
+		    TAMP_FWU_BOOT_IDX_OFFSET) & TAMP_FWU_BOOT_IDX_MASK;
+}
+#endif /* CONFIG_FWU_MULTI_BANK_UPDATE */

Hi Dario

Quoted 5 lines

Thanks
Patrice

Applied to u-boot-stm32/master

Thanks
Patrice