[PATCH 0/6] stm32mp: soome changes and fixes for STM32MP13 and STM32MP15 boards

Hi,
here come some cleanups and fixed for the STM32MP13 and STM32MP15 boards.
Patrick Delaunay (6): stm32mp: add support of STM32MP15x Rev.Y stm32mp: bsec: add check on null size in misc ops configs: stm32mp1: reduce DDR_CACHEABLE_SIZE to supported 256MB DDR stm32mp: stm32prog: fix OTP read/write error management stm32mp: stm32prog: use the decimal format by default for offset parsing pmic: stpmic1: support new prefix node name for regulator
arch/arm/mach-stm32mp/bsec.c | 4 ++-- arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c | 11 +++++++++-- arch/arm/mach-stm32mp/include/mach/sys_proto.h | 1 + arch/arm/mach-stm32mp/stm32mp15x.c | 5 ++++- configs/stm32mp13_defconfig | 2 +- configs/stm32mp15_defconfig | 2 +- drivers/power/pmic/stpmic1.c | 2 ++ 7 files changed, 20 insertions(+), 7 deletions(-)

Add support of STM32MP15x Rev.Y for the Silicon revision REV_ID = 0x2003.
Signed-off-by: Patrick Delaunay patrick.delaunay@foss.st.com ---
arch/arm/mach-stm32mp/include/mach/sys_proto.h | 1 + arch/arm/mach-stm32mp/stm32mp15x.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-stm32mp/include/mach/sys_proto.h b/arch/arm/mach-stm32mp/include/mach/sys_proto.h index 0d39b67178e4..83fb32a45fcc 100644 --- a/arch/arm/mach-stm32mp/include/mach/sys_proto.h +++ b/arch/arm/mach-stm32mp/include/mach/sys_proto.h @@ -44,6 +44,7 @@ u32 get_cpu_dev(void); #define CPU_REV1_2 0x1003 #define CPU_REV2 0x2000 #define CPU_REV2_1 0x2001 +#define CPU_REV2_2 0x2003
/* return Silicon revision = REV_ID[15:0] of Device Version */ u32 get_cpu_rev(void); diff --git a/arch/arm/mach-stm32mp/stm32mp15x.c b/arch/arm/mach-stm32mp/stm32mp15x.c index 660c907a6ba3..afc56b02eea4 100644 --- a/arch/arm/mach-stm32mp/stm32mp15x.c +++ b/arch/arm/mach-stm32mp/stm32mp15x.c @@ -266,7 +266,7 @@ static const char * const soc_type[] = { };
static const char * const soc_pkg[] = { "??", "AD", "AC", "AB", "AA" }; -static const char * const soc_rev[] = { "?", "A", "B", "Z" }; +static const char * const soc_rev[] = { "?", "A", "B", "Z", "Y"};
static void get_cpu_string_offsets(unsigned int *type, unsigned int *pkg, unsigned int *rev) @@ -307,6 +307,9 @@ static void get_cpu_string_offsets(unsigned int *type, unsigned int *pkg, case CPU_REV2_1: *rev = 3; break; + case CPU_REV2_2: + *rev = 4; + break; default: *rev = 0; break;

On 4/27/23 15:36, Patrick Delaunay wrote:
Add support of STM32MP15x Rev.Y for the Silicon revision REV_ID = 0x2003.
Signed-off-by: Patrick Delaunay patrick.delaunay@foss.st.com
arch/arm/mach-stm32mp/include/mach/sys_proto.h | 1 + arch/arm/mach-stm32mp/stm32mp15x.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-stm32mp/include/mach/sys_proto.h b/arch/arm/mach-stm32mp/include/mach/sys_proto.h index 0d39b67178e4..83fb32a45fcc 100644 --- a/arch/arm/mach-stm32mp/include/mach/sys_proto.h +++ b/arch/arm/mach-stm32mp/include/mach/sys_proto.h @@ -44,6 +44,7 @@ u32 get_cpu_dev(void); #define CPU_REV1_2 0x1003 #define CPU_REV2 0x2000 #define CPU_REV2_1 0x2001 +#define CPU_REV2_2 0x2003
/* return Silicon revision = REV_ID[15:0] of Device Version */ u32 get_cpu_rev(void); diff --git a/arch/arm/mach-stm32mp/stm32mp15x.c b/arch/arm/mach-stm32mp/stm32mp15x.c index 660c907a6ba3..afc56b02eea4 100644 --- a/arch/arm/mach-stm32mp/stm32mp15x.c +++ b/arch/arm/mach-stm32mp/stm32mp15x.c @@ -266,7 +266,7 @@ static const char * const soc_type[] = { };
static const char * const soc_pkg[] = { "??", "AD", "AC", "AB", "AA" }; -static const char * const soc_rev[] = { "?", "A", "B", "Z" }; +static const char * const soc_rev[] = { "?", "A", "B", "Z", "Y"};
static void get_cpu_string_offsets(unsigned int *type, unsigned int *pkg, unsigned int *rev) @@ -307,6 +307,9 @@ static void get_cpu_string_offsets(unsigned int *type, unsigned int *pkg, case CPU_REV2_1: *rev = 3; break;
- case CPU_REV2_2:
*rev = 4;
default: *rev = 0; break;break;
Reviewed-by: Patrice Chotard patrice.chotard@foss.st.com
Thanks Patrice

Add a protection in misc bsec ops for request with null size.
For example OP-TEE error occurs when get_eth_nb() return 0 in setup_mac_address() for unknown part number because U-Boot read 0 OTPs.
Signed-off-by: Patrick Delaunay patrick.delaunay@foss.st.com ---
arch/arm/mach-stm32mp/bsec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-stm32mp/bsec.c b/arch/arm/mach-stm32mp/bsec.c index f5f4b20d4776..0dc1e5c3fdc4 100644 --- a/arch/arm/mach-stm32mp/bsec.c +++ b/arch/arm/mach-stm32mp/bsec.c @@ -622,7 +622,7 @@ static int stm32mp_bsec_read(struct udevice *dev, int offset, shadow = false; }
- if ((offs % 4) || (size % 4)) + if ((offs % 4) || (size % 4) || !size) return -EINVAL;
if (IS_ENABLED(CONFIG_OPTEE) && priv->tee) { @@ -678,7 +678,7 @@ static int stm32mp_bsec_write(struct udevice *dev, int offset, shadow = false; }
- if ((offs % 4) || (size % 4)) + if ((offs % 4) || (size % 4) || !size) return -EINVAL;
if (IS_ENABLED(CONFIG_OPTEE) && priv->tee) {

On 4/27/23 15:36, Patrick Delaunay wrote:
Add a protection in misc bsec ops for request with null size.
For example OP-TEE error occurs when get_eth_nb() return 0 in setup_mac_address() for unknown part number because U-Boot read 0 OTPs.
Signed-off-by: Patrick Delaunay patrick.delaunay@foss.st.com
arch/arm/mach-stm32mp/bsec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-stm32mp/bsec.c b/arch/arm/mach-stm32mp/bsec.c index f5f4b20d4776..0dc1e5c3fdc4 100644 --- a/arch/arm/mach-stm32mp/bsec.c +++ b/arch/arm/mach-stm32mp/bsec.c @@ -622,7 +622,7 @@ static int stm32mp_bsec_read(struct udevice *dev, int offset, shadow = false; }
- if ((offs % 4) || (size % 4))
if ((offs % 4) || (size % 4) || !size) return -EINVAL;
if (IS_ENABLED(CONFIG_OPTEE) && priv->tee) {
@@ -678,7 +678,7 @@ static int stm32mp_bsec_write(struct udevice *dev, int offset, shadow = false; }
- if ((offs % 4) || (size % 4))
if ((offs % 4) || (size % 4) || !size) return -EINVAL;
if (IS_ENABLED(CONFIG_OPTEE) && priv->tee) {
Reviewed-by: Patrice Chotard patrice.chotard@foss.st.com
Thanks Patrice

Reduces the CONFIG_DDR_CACHEABLE_SIZE, the size of DDR mapped cacheable before relocation, to support DDR with only 256MB because the OP-TEE reserved memory is located at end of the DDR.
By default the new size of 128MB cacheable memory is enough in dram_bank_mmu_setup() for early_enable_caches() in arch_cpu_init() and is correct for DDR size = 256MB.
After relocation the real size of DDR, excluding the no-map reserved memory, is used after the U-Boot device tree parsing.
Signed-off-by: Patrick Delaunay patrick.delaunay@foss.st.com ---
configs/stm32mp13_defconfig | 2 +- configs/stm32mp15_defconfig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/configs/stm32mp13_defconfig b/configs/stm32mp13_defconfig index b076573c450f..4c1e412af0e6 100644 --- a/configs/stm32mp13_defconfig +++ b/configs/stm32mp13_defconfig @@ -7,7 +7,7 @@ CONFIG_ENV_OFFSET=0x900000 CONFIG_DEFAULT_DEVICE_TREE="stm32mp135f-dk" CONFIG_SYS_PROMPT="STM32MP> " CONFIG_STM32MP13x=y -CONFIG_DDR_CACHEABLE_SIZE=0x10000000 +CONFIG_DDR_CACHEABLE_SIZE=0x8000000 CONFIG_CMD_STM32KEY=y CONFIG_TARGET_ST_STM32MP13x=y CONFIG_ENV_OFFSET_REDUND=0x940000 diff --git a/configs/stm32mp15_defconfig b/configs/stm32mp15_defconfig index a8eda7b4ad88..b912d6735bc0 100644 --- a/configs/stm32mp15_defconfig +++ b/configs/stm32mp15_defconfig @@ -7,7 +7,7 @@ CONFIG_ENV_OFFSET=0x480000 CONFIG_ENV_SECT_SIZE=0x40000 CONFIG_DEFAULT_DEVICE_TREE="stm32mp157c-ev1" CONFIG_SYS_PROMPT="STM32MP> " -CONFIG_DDR_CACHEABLE_SIZE=0x10000000 +CONFIG_DDR_CACHEABLE_SIZE=0x8000000 CONFIG_CMD_STM32KEY=y CONFIG_TYPEC_STUSB160X=y CONFIG_TARGET_ST_STM32MP15x=y

On 4/27/23 15:36, Patrick Delaunay wrote:
Reduces the CONFIG_DDR_CACHEABLE_SIZE, the size of DDR mapped cacheable before relocation, to support DDR with only 256MB because the OP-TEE reserved memory is located at end of the DDR.
By default the new size of 128MB cacheable memory is enough in dram_bank_mmu_setup() for early_enable_caches() in arch_cpu_init() and is correct for DDR size = 256MB.
After relocation the real size of DDR, excluding the no-map reserved memory, is used after the U-Boot device tree parsing.
Signed-off-by: Patrick Delaunay patrick.delaunay@foss.st.com
configs/stm32mp13_defconfig | 2 +- configs/stm32mp15_defconfig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/configs/stm32mp13_defconfig b/configs/stm32mp13_defconfig index b076573c450f..4c1e412af0e6 100644 --- a/configs/stm32mp13_defconfig +++ b/configs/stm32mp13_defconfig @@ -7,7 +7,7 @@ CONFIG_ENV_OFFSET=0x900000 CONFIG_DEFAULT_DEVICE_TREE="stm32mp135f-dk" CONFIG_SYS_PROMPT="STM32MP> " CONFIG_STM32MP13x=y -CONFIG_DDR_CACHEABLE_SIZE=0x10000000 +CONFIG_DDR_CACHEABLE_SIZE=0x8000000 CONFIG_CMD_STM32KEY=y CONFIG_TARGET_ST_STM32MP13x=y CONFIG_ENV_OFFSET_REDUND=0x940000 diff --git a/configs/stm32mp15_defconfig b/configs/stm32mp15_defconfig index a8eda7b4ad88..b912d6735bc0 100644 --- a/configs/stm32mp15_defconfig +++ b/configs/stm32mp15_defconfig @@ -7,7 +7,7 @@ CONFIG_ENV_OFFSET=0x480000 CONFIG_ENV_SECT_SIZE=0x40000 CONFIG_DEFAULT_DEVICE_TREE="stm32mp157c-ev1" CONFIG_SYS_PROMPT="STM32MP> " -CONFIG_DDR_CACHEABLE_SIZE=0x10000000 +CONFIG_DDR_CACHEABLE_SIZE=0x8000000 CONFIG_CMD_STM32KEY=y CONFIG_TYPEC_STUSB160X=y CONFIG_TARGET_ST_STM32MP15x=y
Reviewed-by: Patrice Chotard patrice.chotard@foss.st.com
Thanks Patrice

Avoid to ignore the OTP read/write error and transmits the error to STM32CubeProgrammer.
Today the error is only displayed in log error: so the user on HOST thinks the OTP operation is performed.
Reported-by: Mickael GARDET m.gardet@overkiz.com Signed-off-by: Patrick Delaunay patrick.delaunay@foss.st.com Fixes: 75ea9e75931c ("stm32mp: stm32prog: add TEE support in stm32prog command") ---
arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c index 6f3641ccf57b..c85217f6d61e 100644 --- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c +++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c @@ -1439,8 +1439,11 @@ int stm32prog_otp_write(struct stm32prog_data *data, u32 offset, u8 *buffer,
if (!data->otp_part) { data->otp_part = memalign(CONFIG_SYS_CACHELINE_SIZE, otp_size); - if (!data->otp_part) + if (!data->otp_part) { + stm32prog_err("OTP write issue %d", -ENOMEM); + return -ENOMEM; + } }
if (!offset) @@ -1503,6 +1506,8 @@ int stm32prog_otp_read(struct stm32prog_data *data, u32 offset, u8 *buffer, memcpy(buffer, (void *)((uintptr_t)data->otp_part + offset), *size);
end_otp_read: + if (result) + stm32prog_err("OTP read issue %d", result); log_debug("%s: result %i\n", __func__, result);
return result; @@ -1556,6 +1561,8 @@ int stm32prog_otp_start(struct stm32prog_data *data)
free(data->otp_part); data->otp_part = NULL; + if (result) + stm32prog_err("OTP write issue %d", result); log_debug("%s: result %i\n", __func__, result);
return result;

On 4/27/23 15:36, Patrick Delaunay wrote:
Avoid to ignore the OTP read/write error and transmits the error to STM32CubeProgrammer.
Today the error is only displayed in log error: so the user on HOST thinks the OTP operation is performed.
Reported-by: Mickael GARDET m.gardet@overkiz.com Signed-off-by: Patrick Delaunay patrick.delaunay@foss.st.com Fixes: 75ea9e75931c ("stm32mp: stm32prog: add TEE support in stm32prog command")
arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c index 6f3641ccf57b..c85217f6d61e 100644 --- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c +++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c @@ -1439,8 +1439,11 @@ int stm32prog_otp_write(struct stm32prog_data *data, u32 offset, u8 *buffer,
if (!data->otp_part) { data->otp_part = memalign(CONFIG_SYS_CACHELINE_SIZE, otp_size);
if (!data->otp_part)
if (!data->otp_part) {
stm32prog_err("OTP write issue %d", -ENOMEM);
return -ENOMEM;
}
}
if (!offset)
@@ -1503,6 +1506,8 @@ int stm32prog_otp_read(struct stm32prog_data *data, u32 offset, u8 *buffer, memcpy(buffer, (void *)((uintptr_t)data->otp_part + offset), *size);
end_otp_read:
if (result)
stm32prog_err("OTP read issue %d", result);
log_debug("%s: result %i\n", __func__, result);
return result;
@@ -1556,6 +1561,8 @@ int stm32prog_otp_start(struct stm32prog_data *data)
free(data->otp_part); data->otp_part = NULL;
if (result)
stm32prog_err("OTP write issue %d", result);
log_debug("%s: result %i\n", __func__, result);
return result;
Reviewed-by: Patrice Chotard patrice.chotard@foss.st.com
Thanks Patrice

Change the default base for offset parsing with simple_strtoull(), so offset in flashlayout is coded in base 10 by default, even if string start with '0'. The Octal encoding is not supported. The base 16 is still supported when the '0x' header is detected.
This patch solves an unexpected parsing result when the address, provided by decimal value is starting by 0, for example 0x4400 = 00017408 is a invalid with current code.
... P 0x04 fsbl1 Binary mmc0 00017408 tf-a.stm32 ....
Signed-off-by: Patrick Delaunay patrick.delaunay@foss.st.com ---
arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c index c85217f6d61e..90cf6c39b4a2 100644 --- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c +++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c @@ -514,7 +514,7 @@ static int parse_offset(struct stm32prog_data *data, stm32prog_err("Layout line %d: invalid part '%s'", i, p); } else { - part->addr = simple_strtoull(p, &tail, 0); + part->addr = simple_strtoull(p, &tail, 10); if (tail == p || *tail != '\0') { stm32prog_err("Layout line %d: invalid offset '%s'", i, p);

On 4/27/23 15:36, Patrick Delaunay wrote:
Change the default base for offset parsing with simple_strtoull(), so offset in flashlayout is coded in base 10 by default, even if string start with '0'. The Octal encoding is not supported. The base 16 is still supported when the '0x' header is detected.
This patch solves an unexpected parsing result when the address, provided by decimal value is starting by 0, for example 0x4400 = 00017408 is a invalid with current code.
... P 0x04 fsbl1 Binary mmc0 00017408 tf-a.stm32 ....
Signed-off-by: Patrick Delaunay patrick.delaunay@foss.st.com
arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c index c85217f6d61e..90cf6c39b4a2 100644 --- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c +++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c @@ -514,7 +514,7 @@ static int parse_offset(struct stm32prog_data *data, stm32prog_err("Layout line %d: invalid part '%s'", i, p); } else {
part->addr = simple_strtoull(p, &tail, 0);
if (tail == p || *tail != '\0') { stm32prog_err("Layout line %d: invalid offset '%s'", i, p);part->addr = simple_strtoull(p, &tail, 10);
Reviewed-by: Patrice Chotard patrice.chotard@foss.st.com
Thanks Patrice

The '_' character is discouraged in the node name, this patch adds the new prefix of regulator subnode, with the '-' character, in STM32MP1 driver to support the new naming rule in Linux kernel device trees.
It is a preliminary patch before Linux device tree synchronization for STMicroelectronics boards.
Signed-off-by: Patrick Delaunay patrick.delaunay@foss.st.com ---
drivers/power/pmic/stpmic1.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/drivers/power/pmic/stpmic1.c b/drivers/power/pmic/stpmic1.c index 2c85410b1bf5..8701d4f971c9 100644 --- a/drivers/power/pmic/stpmic1.c +++ b/drivers/power/pmic/stpmic1.c @@ -34,7 +34,9 @@ static const struct pmic_child_info stpmic1_children_info[] = { { .prefix = "ldo", .driver = "stpmic1_ldo" }, { .prefix = "buck", .driver = "stpmic1_buck" }, { .prefix = "vref_ddr", .driver = "stpmic1_vref_ddr" }, + { .prefix = "vref-ddr", .driver = "stpmic1_vref_ddr" }, { .prefix = "pwr_sw", .driver = "stpmic1_pwr_sw" }, + { .prefix = "pwr-sw", .driver = "stpmic1_pwr_sw" }, { .prefix = "boost", .driver = "stpmic1_boost" }, { }, };

On 4/27/23 15:36, Patrick Delaunay wrote:
The '_' character is discouraged in the node name, this patch adds the new prefix of regulator subnode, with the '-' character, in STM32MP1 driver to support the new naming rule in Linux kernel device trees.
It is a preliminary patch before Linux device tree synchronization for STMicroelectronics boards.
Signed-off-by: Patrick Delaunay patrick.delaunay@foss.st.com
drivers/power/pmic/stpmic1.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/drivers/power/pmic/stpmic1.c b/drivers/power/pmic/stpmic1.c index 2c85410b1bf5..8701d4f971c9 100644 --- a/drivers/power/pmic/stpmic1.c +++ b/drivers/power/pmic/stpmic1.c @@ -34,7 +34,9 @@ static const struct pmic_child_info stpmic1_children_info[] = { { .prefix = "ldo", .driver = "stpmic1_ldo" }, { .prefix = "buck", .driver = "stpmic1_buck" }, { .prefix = "vref_ddr", .driver = "stpmic1_vref_ddr" },
- { .prefix = "vref-ddr", .driver = "stpmic1_vref_ddr" }, { .prefix = "pwr_sw", .driver = "stpmic1_pwr_sw" },
- { .prefix = "pwr-sw", .driver = "stpmic1_pwr_sw" }, { .prefix = "boost", .driver = "stpmic1_boost" }, { },
};
Reviewed-by: Patrice Chotard patrice.chotard@foss.st.com
Thanks Patrice

On 4/27/23 15:36, Patrick Delaunay wrote:
Hi,
here come some cleanups and fixed for the STM32MP13 and STM32MP15 boards.
Patrick Delaunay (6): stm32mp: add support of STM32MP15x Rev.Y stm32mp: bsec: add check on null size in misc ops configs: stm32mp1: reduce DDR_CACHEABLE_SIZE to supported 256MB DDR stm32mp: stm32prog: fix OTP read/write error management stm32mp: stm32prog: use the decimal format by default for offset parsing pmic: stpmic1: support new prefix node name for regulator
arch/arm/mach-stm32mp/bsec.c | 4 ++-- arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c | 11 +++++++++-- arch/arm/mach-stm32mp/include/mach/sys_proto.h | 1 + arch/arm/mach-stm32mp/stm32mp15x.c | 5 ++++- configs/stm32mp13_defconfig | 2 +- configs/stm32mp15_defconfig | 2 +- drivers/power/pmic/stpmic1.c | 2 ++ 7 files changed, 20 insertions(+), 7 deletions(-)
for the whole series:
Applied to u-boot-stm/next
Thanks Patrice
participants (2)
-
Patrice CHOTARD
-
Patrick Delaunay