meta-st-stm32mp/recipes-bsp/u-boot/u-boot-stm32mp/0006-ARM-v2021.10-stm32mp-r...

148 lines
4.9 KiB
Diff

From 0afeb764866b755d64728e58f279db3e10d8a328 Mon Sep 17 00:00:00 2001
From: Romuald JEANNE <romuald.jeanne@st.com>
Date: Wed, 19 Oct 2022 16:58:04 +0200
Subject: [PATCH 6/9] ARM v2021.10-stm32mp-r2 MACHINE
Signed-off-by: Romuald JEANNE <romuald.jeanne@st.com>
---
.../mach-stm32mp/cmd_stm32prog/stm32prog.c | 33 +++++++++++++------
.../mach-stm32mp/cmd_stm32prog/stm32prog.h | 5 +++
arch/arm/mach-stm32mp/include/mach/stm32.h | 1 -
.../arm/mach-stm32mp/include/mach/sys_proto.h | 2 +-
4 files changed, 29 insertions(+), 12 deletions(-)
diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
index ce568b44dc2..f9b502c9375 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
@@ -1091,7 +1091,6 @@ static int create_gpt_partitions(struct stm32prog_data *data)
if (!buf)
return -ENOMEM;
- puts("partitions : ");
/* initialize the selected device */
for (i = 0; i < data->dev_nb; i++) {
/* create gpt partition support only for full update on MMC */
@@ -1099,6 +1098,7 @@ static int create_gpt_partitions(struct stm32prog_data *data)
!data->dev[i].full_update)
continue;
+ printf("partitions on mmc%d: ", data->dev[i].dev_id);
offset = 0;
rootfs_found = false;
memset(buf, 0, buflen);
@@ -1198,8 +1198,8 @@ static int create_gpt_partitions(struct stm32prog_data *data)
sprintf(buf, "part list mmc %d", data->dev[i].dev_id);
run_command(buf, 0);
#endif
+ puts("done\n");
}
- puts("done\n");
#ifdef DEBUG
run_command("mtd list", 0);
@@ -1343,10 +1343,22 @@ static int dfu_init_entities(struct stm32prog_data *data)
struct stm32prog_part_t *part;
struct dfu_entity *dfu;
int alt_nb;
+ u32 otp_size = 0;
alt_nb = 1; /* number of virtual = CMD*/
- if (IS_ENABLED(CONFIG_CMD_STM32PROG_OTP))
- alt_nb++; /* OTP*/
+
+ if (IS_ENABLED(CONFIG_CMD_STM32PROG_OTP)) {
+ /* OTP_SIZE_SMC = 0 if SMC is not supported */
+ otp_size = OTP_SIZE_SMC;
+ /* check if PTA BSEC is supported */
+ ret = optee_ta_open(data);
+ log_debug("optee_ta_open(PTA_NVMEM) result %d\n", ret);
+ if (!ret && data->tee)
+ otp_size = OTP_SIZE_TA;
+ if (otp_size)
+ alt_nb++; /* OTP*/
+ }
+
if (CONFIG_IS_ENABLED(DM_PMIC))
alt_nb++; /* PMIC NVMEM*/
@@ -1364,6 +1376,7 @@ static int dfu_init_entities(struct stm32prog_data *data)
puts("DFU alt info setting: ");
if (data->part_nb) {
alt_id = 0;
+ ret = 0;
for (phase = 1;
(phase <= PHASE_LAST_USER) &&
(alt_id < alt_nb) && !ret;
@@ -1397,12 +1410,8 @@ static int dfu_init_entities(struct stm32prog_data *data)
if (!ret)
ret = stm32prog_alt_add_virt(dfu, "virtual", PHASE_CMD, CMD_SIZE);
- if (!ret && IS_ENABLED(CONFIG_CMD_STM32PROG_OTP)) {
- ret = optee_ta_open(data);
- log_debug("optee_ta result %d\n", ret);
- ret = stm32prog_alt_add_virt(dfu, "OTP", PHASE_OTP,
- data->tee ? OTP_SIZE_TA : OTP_SIZE_SMC);
- }
+ if (!ret && IS_ENABLED(CONFIG_CMD_STM32PROG_OTP) && otp_size)
+ ret = stm32prog_alt_add_virt(dfu, "OTP", PHASE_OTP, otp_size);
if (!ret && CONFIG_IS_ENABLED(DM_PMIC))
ret = stm32prog_alt_add_virt(dfu, "PMIC", PHASE_PMIC, PMIC_SIZE);
@@ -1885,6 +1894,10 @@ static void stm32prog_devices_init(struct stm32prog_data *data)
if (ret)
goto error;
+ /* empty flashlayout */
+ if (!data->dev_nb)
+ return;
+
/* initialize the selected device */
for (i = 0; i < data->dev_nb; i++) {
ret = init_device(data, &data->dev[i]);
diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h
index ac300768ca0..0cda487ddd5 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h
@@ -20,7 +20,12 @@
#define DEFAULT_ADDRESS 0xFFFFFFFF
#define CMD_SIZE 512
+/* SMC is only supported in SPMIN for STM32MP15x */
+#ifdef CONFIG_STM32MP15x
#define OTP_SIZE_SMC 1024
+#else
+#define OTP_SIZE_SMC 0
+#endif
#define OTP_SIZE_TA 776
#define PMIC_SIZE 8
diff --git a/arch/arm/mach-stm32mp/include/mach/stm32.h b/arch/arm/mach-stm32mp/include/mach/stm32.h
index 62acd76c013..fc456ff8e80 100644
--- a/arch/arm/mach-stm32mp/include/mach/stm32.h
+++ b/arch/arm/mach-stm32mp/include/mach/stm32.h
@@ -134,7 +134,6 @@ enum boot_device {
#define TAMP_BOOT_DEVICE_MASK GENMASK(7, 4)
#define TAMP_BOOT_INSTANCE_MASK GENMASK(3, 0)
#define TAMP_BOOT_FORCED_MASK GENMASK(7, 0)
-#define TAMP_BOOT_DEBUG_ON BIT(16)
enum forced_boot_mode {
BOOT_NORMAL = 0x00,
diff --git a/arch/arm/mach-stm32mp/include/mach/sys_proto.h b/arch/arm/mach-stm32mp/include/mach/sys_proto.h
index 02debea5469..f19a70e53e0 100644
--- a/arch/arm/mach-stm32mp/include/mach/sys_proto.h
+++ b/arch/arm/mach-stm32mp/include/mach/sys_proto.h
@@ -41,7 +41,7 @@ u32 get_cpu_dev(void);
#define CPU_REV1 0x1000
#define CPU_REV1_1 0x1001
-#define CPU_REV1_2 0x1002
+#define CPU_REV1_2 0x1003
#define CPU_REV2 0x2000
#define CPU_REV2_1 0x2001
--
2.17.1