Skip to contentSkip to conversation

stm32mp: soome changes and fixes for STM32MP13 and STM32MP15 boards

PATCH In review Patrick Delaunay 2 participants 14 messages Apr 27, 2023 – Jun 16, 2023

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

cover 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(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/6 stm32mp: add support of STM32MP15x Rev.Y

Add support of STM32MP15x Rev.Y for the Silicon revision REV_ID = 0x2003.

---

 arch/arm/mach-stm32mp/include/mach/sys_proto.h | 1 +
 arch/arm/mach-stm32mp/stm32mp15x.c             | 5 ++++-
 2 files changed, 5 insertions(+), 1 deletion(-)
arch/arm/mach-stm32mp/include/mach/sys_proto.h +1 -0
index 0d39b67178e4..83fb32a45fcc 100644
@@ -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);
arch/arm/mach-stm32mp/stm32mp15x.c +4 -1
index 660c907a6ba3..afc56b02eea4 100644
@@ -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;
Signature · 1 line
2.25.1
Reviewed-by on v1 1/6
#2 lore raw

Re: [PATCH 1/6] stm32mp: add support of STM32MP15x Rev.Y

Quoted 35 lines · Patrick Delaunay

Add support of STM32MP15x Rev.Y for the Silicon revision REV_ID = 0x2003.

---

 arch/arm/mach-stm32mp/include/mach/sys_proto.h | 1 +
 arch/arm/mach-stm32mp/stm32mp15x.c             | 5 ++++-
 2 files changed, 5 insertions(+), 1 deletion(-)
arch/arm/mach-stm32mp/include/mach/sys_proto.h +1 -0
index 0d39b67178e4..83fb32a45fcc 100644
@@ -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);
arch/arm/mach-stm32mp/stm32mp15x.c +1 -1
index 660c907a6ba3..afc56b02eea4 100644
@@ -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)

arch/arm/mach-stm32mp/stm32mp15x.c static void get_cpu_string_offsets(unsigned int *type, unsigned int *pkg, · line 315

Quoted 9 lines
arch/arm/mach-stm32mp/stm32mp15x.c +3 -0
@@ -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;

Thanks
Patrice

#3 lore raw

PATCH 2/6 stm32mp: bsec: add check on null size in misc ops

In reply to Patrick Delaunay

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.

---

 arch/arm/mach-stm32mp/bsec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-stm32mp/bsec.c +2 -2
index f5f4b20d4776..0dc1e5c3fdc4 100644
@@ -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) {
Signature · 1 line
2.25.1
Reviewed-by on v1 2/6
#4 lore raw

Re: [PATCH 2/6] stm32mp: bsec: add check on null size in misc ops

Quoted 25 lines · Patrick Delaunay

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.

---

 arch/arm/mach-stm32mp/bsec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-stm32mp/bsec.c +1 -1
index f5f4b20d4776..0dc1e5c3fdc4 100644
@@ -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) {

arch/arm/mach-stm32mp/bsec.c static int stm32mp_bsec_write(struct udevice *dev, int offset, · line 684

Quoted 8 lines
arch/arm/mach-stm32mp/bsec.c +1 -1
@@ -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) {

Thanks
Patrice

#5 lore raw

PATCH 3/6 configs: stm32mp1: reduce DDR_CACHEABLE_SIZE to supported 256MB DDR

In reply to Patrick Delaunay

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.

---

 configs/stm32mp13_defconfig | 2 +-
 configs/stm32mp15_defconfig | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
configs/stm32mp13_defconfig +1 -1
index b076573c450f..4c1e412af0e6 100644
@@ -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
configs/stm32mp15_defconfig +1 -1
index a8eda7b4ad88..b912d6735bc0 100644
@@ -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
Signature · 1 line
2.25.1
Reviewed-by on v1 3/6
#6 lore raw

Re: [PATCH 3/6] configs: stm32mp1: reduce DDR_CACHEABLE_SIZE to supported 256MB DDR

Quoted 36 lines · Patrick Delaunay

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.

---

 configs/stm32mp13_defconfig | 2 +-
 configs/stm32mp15_defconfig | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
configs/stm32mp13_defconfig +1 -1
index b076573c450f..4c1e412af0e6 100644
@@ -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
configs/stm32mp15_defconfig +0 -0
index a8eda7b4ad88..b912d6735bc0 100644

configs/stm32mp15_defconfig CONFIG_ENV_OFFSET=0x480000 · line 13

Quoted 8 lines
configs/stm32mp15_defconfig +1 -1
@@ -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

Thanks
Patrice

#7 lore raw

PATCH 4/6 stm32mp: stm32prog: fix OTP read/write error management

In reply to Patrick Delaunay

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.

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(-)
arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c +8 -1
index 6f3641ccf57b..c85217f6d61e 100644
@@ -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;
Signature · 1 line
2.25.1
Reviewed-by on v1 4/6
#8 lore raw

Re: [PATCH 4/6] stm32mp: stm32prog: fix OTP read/write error management

Quoted 41 lines · Patrick Delaunay

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.

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(-)
arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c +6 -1
index 6f3641ccf57b..c85217f6d61e 100644
@@ -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;

arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c int stm32prog_otp_start(struct stm32prog_data *data) · line 1568

Quoted 8 lines
arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c +2 -0
@@ -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;

Thanks
Patrice

#9 lore raw

PATCH 5/6 stm32mp: stm32prog: use the decimal format by default for offset parsing

In reply to Patrick Delaunay

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
....

---

 arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c +1 -1
index c85217f6d61e..90cf6c39b4a2 100644
@@ -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);
Signature · 1 line
2.25.1
Reviewed-by on v1 5/6
#10 lore raw

Re: [PATCH 5/6] stm32mp: stm32prog: use the decimal format by default for offset parsing

Quoted 24 lines · Patrick Delaunay

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
....

---

 arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c +0 -0
index c85217f6d61e..90cf6c39b4a2 100644

arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c static int parse_offset(struct stm32prog_data *data, · line 520

Quoted 8 lines
arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c +1 -1
@@ -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);

Thanks
Patrice

#11 lore raw

PATCH 6/6 pmic: stpmic1: support new prefix node name for regulator

In reply to Patrick Delaunay

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.

---

 drivers/power/pmic/stpmic1.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/power/pmic/stpmic1.c +2 -0
index 2c85410b1bf5..8701d4f971c9 100644
@@ -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" },
 	{ },
 };
Signature · 1 line
2.25.1
Reviewed-by on v1 6/6
#12 lore raw

Re: [PATCH 6/6] pmic: stpmic1: support new prefix node name for regulator

Quoted 18 lines · Patrick Delaunay

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.

---

 drivers/power/pmic/stpmic1.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/power/pmic/stpmic1.c +0 -0
index 2c85410b1bf5..8701d4f971c9 100644

drivers/power/pmic/stpmic1.c static const struct pmic_child_info stpmic1_children_info[] = { · line 42

Quoted 9 lines
drivers/power/pmic/stpmic1.c +2 -0
@@ -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" },
 	{ },
 };

Thanks
Patrice

#13 lore raw
In reply to Patrick Delaunay
Quoted 15 lines · Patrick Delaunay

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

Quoted 9 lines
 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