Re: [PATCH v2] stm32mp: Reserve OPTEE area in EFI memory map
Hi, On 4/22/24 17:06, Patrice Chotard wrote: Since commit 7b78d6438a2b3 ("efi_loader: Reserve unaccessible memory") memory region above ram_top is tagged in EFI memory map as EFI_BOOT_SERVICES_DATA. In case of STM32MP1/STM32MP13 platforms, above ram_top, there is one reserved-memory region tagged "no-map" dedicated to OP-TEE : _ addr=de00 size=200 for stm32mp157x-dkx and stm32mp135f-dk _ addr=fe00 size=200 for stm32mp157c-ev1 Before booting kernel, EFI memory map is first built, the OPTEE region is tagged as EFI_BOOT_SERVICES_DATA and when reserving LMB, the tag LMB_NONE is used. Then after, the LMB are completed by boot_fdt_add_mem_rsv_regions() which try to add again the same OPTEE region (addr=de00 size=200 in case of stm32mp157x-dkx / stm32mp135f-dk or addr=fe00 size=200 in case for stm2mp157c-ev1) but now with LMB_NOMAP tag which produces the following error message : _ for stm32mp157x-dkx / stm32mp135f-dk : "ERROR: reserving fdt memory region failed (addr=de00 size=200 flags=4)" _ for stm32mp157c-ev1 : "ERROR: reserving fdt memory region failed (addr=fe00 size=200 flags=4)" To avoid this, OPTEE area shouldn't be used by EFI, so we need to mark it as reserved. Signed-off-by: Patrice Chotard --- Changes in v2: _ update commit message by adding information about memory area dedicated for OPTEE for various STM32MP1/STM32MP13 boards. arch/arm/mach-stm32mp/dram_init.c | 12 1 file changed, 12 insertions(+) diff --git a/arch/arm/mach-stm32mp/dram_init.c b/arch/arm/mach-stm32mp/dram_init.c index fb1208fc5d5..f67f54f2ae0 100644 --- a/arch/arm/mach-stm32mp/dram_init.c +++ b/arch/arm/mach-stm32mp/dram_init.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -75,3 +76,14 @@ phys_addr_t board_get_usable_ram_top(phys_size_t total_size) return reg + size; } + +void efi_add_known_memory(void) +{ + if (IS_ENABLED(CONFIG_EFI_LOADER)) + /* +* Memory over ram_top is reserved to OPTEE. +* Declare to EFI only memory area below ram_top +*/ + efi_add_memory_map(gd->ram_base, gd->ram_top - gd->ram_base, + EFI_CONVENTIONAL_MEMORY); +} It seen like a temporary workaround after commit 7b78d6438a2b3 ("efi_loader: Reserve unaccessible memory") to avoid warnings. And it is working because in the default memory mapping OP-TEE base address == RAM_TOP and the rest of memory is used by OP-TEE tagged "no map" (protected by firewall) Reviewed-by: Patrick Delaunay FYI: workaround because the memory above ram_top is "already occupied by firmware" = and it is OP-TEE for STM32MP2 platform. For me the LMB type used by EFI in not correct for OP-TEE usage region with "no-map" tag in device tree= see boot_fdt_add_mem_rsv_regions() for linux DT parsing and we have no way to indicated this LMB tag= LMB_NOMAP with EFI stack (with enum efi_memory_type ?) EFI_BOOT_SERVICES_DATA => doesn't means NOMAP flag for LMB so something is missing in EFI side like EFI_BOOT_NOMAP to be used in board implementation of efi_add_known_memory() ? Thanks Patrick
Re: [PATCH 2/2] stm32mp1: spl: Update optee_get_reserved_memory() return value
Hi Patrice On 6/11/24 11:52, Patrice Chotard wrote: In case node "/reserved-memory/optee" is not found, return -ENOENT instead of 0. Signed-off-by: Patrice Chotard --- arch/arm/mach-stm32mp/stm32mp1/spl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-stm32mp/stm32mp1/spl.c b/arch/arm/mach-stm32mp/stm32mp1/spl.c index 10abbed87f0..beda69f3359 100644 --- a/arch/arm/mach-stm32mp/stm32mp1/spl.c +++ b/arch/arm/mach-stm32mp/stm32mp1/spl.c @@ -118,7 +118,7 @@ static int optee_get_reserved_memory(uint32_t *start, uint32_t *size) node = ofnode_path("/reserved-memory/optee"); if (!ofnode_valid(node)) - return 0; + return -ENOENT; fdt_start = ofnode_get_addr_size(node, "reg", _mem_size); *start = fdt_start; Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH 1/2] stm32mp1: spl: Fix compilation warnings
Hi Patrice, On 6/11/24 11:52, Patrice Chotard wrote: Fix the following compilation warnings : ../arch/arm/mach-stm32mp/stm32mp1/spl.c: In function 'stm32_init_tzc_for_optee': ../arch/arm/mach-stm32mp/stm32mp1/spl.c:148:37: warning: 'optee_size' may be used uninitialized [-Wmaybe-uninitialized] 148 | tee_shmem_base = optee_base + optee_size - CFG_SHMEM_SIZE; | ~~~^~~~ ../arch/arm/mach-stm32mp/stm32mp1/spl.c:137:30: note: 'optee_size' was declared here 137 | uint32_t optee_base, optee_size, tee_shmem_base; | ^~ ../arch/arm/mach-stm32mp/stm32mp1/spl.c:148:37: warning: 'optee_base' may be used uninitialized [-Wmaybe-uninitialized] 148 | tee_shmem_base = optee_base + optee_size - CFG_SHMEM_SIZE; | ~~~^~~~ ../arch/arm/mach-stm32mp/stm32mp1/spl.c:137:18: note: 'optee_base' was declared here 137 | uint32_t optee_base, optee_size, tee_shmem_base; | ^~ Fix also the following checkpatch "check" : CHECK: Prefer kernel type 'u32' over 'uint32_t' 37: FILE: arch/arm/mach-stm32mp/stm32mp1/spl.c:137: + uint32_t optee_base = 0, optee_size = 0, tee_shmem_base; Signed-off-by: Patrice Chotard --- arch/arm/mach-stm32mp/stm32mp1/spl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-stm32mp/stm32mp1/spl.c b/arch/arm/mach-stm32mp/stm32mp1/spl.c index 6c79259b2c8..10abbed87f0 100644 --- a/arch/arm/mach-stm32mp/stm32mp1/spl.c +++ b/arch/arm/mach-stm32mp/stm32mp1/spl.c @@ -134,7 +134,7 @@ void stm32_init_tzc_for_optee(void) { const uint32_t dram_size = stm32mp_get_dram_size(); const uintptr_t dram_top = STM32_DDR_BASE + (dram_size - 1); - uint32_t optee_base, optee_size, tee_shmem_base; + u32 optee_base = 0, optee_size = 0, tee_shmem_base; const uintptr_t tzc = STM32_TZC_BASE; int ret; Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v2] ARM: stm32: Initialize TAMP_SMCR BKP..PROT fields on STM32MP15xx
Hi, On 4/15/24 14:55, Marek Vasut wrote: In case of an OTP-CLOSED STM32MP15xx system, the CPU core 1 cannot be released from endless loop in BootROM only by populating TAMP BKPxR 4 and 5 with magic and branch address and sending SGI0 interrupt from core 0 to core 1 twice. TAMP_SMCR BKP..PROT fields must be initialized as well to release the core 1 from endless loop during the second SGI0 handling on core 1. Initialize TAMP_SMCR to protect the first 16 backup registers, the ones which contain the core 1 magic, branch address and boot information. This requirement seems to be undocumented, therefore it was necessary to trace and analyze the STM32MP15xx BootROM using OpenOCD and objdump. Ultimately, it turns out that a certain BootROM function reads out the TAMP_SMCR register and tests whether the BKP..PROT fields are non-zero. If they are zero, the BootROM code again waits for SGI0 using WFI, else the execution moves forward until it reaches handoff to the TAMP BKPxR 5 branch address. These backup registers are documented in https://wiki.st.com/stm32mpu/wiki/STM32MP15_backup_registers This "security" configuration is done in STMicoelectronics delivery (OpenSTLinux) in OP-TEE. This fixes CPU core 1 release using U-Boot PSCI implementation on an OTP-CLOSED system, i.e. system with fuse 0 bit 6 set. A ROM code security check is done only for closed device to avoid malicious code execution: "unsecure" code on CPU2 during wake-up by changing BRANCH_ADDRESS => the STM32MP15 ROM check that only the secure world can update the TAMP_BKP5R = BRANCH_ADDRESS before to start the CPU2 and jump to this address. Sorry to inconvenient, we will improve this part on next release = OpenSTLinux V5.1 Reviewed-by: Patrick Delaunay Thanks Patrick Signed-off-by: Marek Vasut --- Cc: Igor Opaniuk Cc: Patrice Chotard Cc: Patrick Delaunay Cc: Simon Glass Cc: Tom Rini Cc: u-b...@dh-electronics.com Cc: uboot-st...@st-md-mailman.stormreply.com --- V2: Fix up the BKPRWD/BKPWD mask typo --- arch/arm/mach-stm32mp/stm32mp1/stm32mp15x.c | 16 1 file changed, 16 insertions(+) diff --git a/arch/arm/mach-stm32mp/stm32mp1/stm32mp15x.c b/arch/arm/mach-stm32mp/stm32mp1/stm32mp15x.c index dd99150fbc2..a2496361e01 100644 --- a/arch/arm/mach-stm32mp/stm32mp1/stm32mp15x.c +++ b/arch/arm/mach-stm32mp/stm32mp1/stm32mp15x.c @@ -14,6 +14,7 @@ #include #include #include +#include /* RCC register */ #define RCC_TZCR (STM32_RCC_BASE + 0x00) @@ -41,6 +42,9 @@ #define TZC_REGION_ID_ACCESS0 (STM32_TZC_BASE + 0x114) #define TAMP_CR1 (STM32_TAMP_BASE + 0x00) +#define TAMP_SMCR (STM32_TAMP_BASE + 0x20) +#define TAMP_SMCR_BKPRWDPROT GENMASK(7, 0) +#define TAMP_SMCR_BKPWDPROTGENMASK(23, 16) #define PWR_CR1 (STM32_PWR_BASE + 0x00) #define PWR_MCUCR (STM32_PWR_BASE + 0x14) @@ -136,6 +140,18 @@ static void security_init(void) */ writel(0x0, TAMP_CR1); + /* +* TAMP: Configure non-zero secure protection settings. This is +* checked by BootROM function 35ac on OTP-CLOSED device during +* CPU core 1 release from endless loop. If secure protection +* fields are zero, the core 1 is not released from endless +* loop on second SGI0. +*/ + clrsetbits_le32(TAMP_SMCR, + TAMP_SMCR_BKPRWDPROT | TAMP_SMCR_BKPWDPROT, + FIELD_PREP(TAMP_SMCR_BKPRWDPROT, 0x10) | + FIELD_PREP(TAMP_SMCR_BKPWDPROT, 0x10)); + /* GPIOZ: deactivate the security */ writel(BIT(0), RCC_MP_AHB5ENSETR); writel(0x0, GPIOZ_SECCFGR); The recommended mapping (the mapping done in OP-TEE for OpenSTLinux) is described in Wiki page - 10 backup register secure - 4 backup register secure write / non secure read - 17 backup register Non-secure It is done in https://github.com/STMicroelectronics/optee_os/blob/3.19.0-stm32mp/core/arch/arm/plat-stm32mp1/main.c with static TEE_Result stm32_configure_tamp(void) { TEE_Result res __maybe_unused = TEE_SUCCESS; struct stm32_bkpregs_conf bkpregs_conf = { .nb_zone1_regs = 10, /* 10 registers in zone 1 */ .nb_zone2_regs = 5 /* 5 registers in zone 2 */ /* Zone3 all remaining */ }; /* Enable BKP Register protection */ if (stm32_tamp_set_secure_bkpregs(_conf)) panic(); But when you are booting with SPL U-boot, all the boot chain and the Linux kernel is running in secure world So you have no reason to manage any limit for the access to backup register, you can allocate all the backup registers (the 32 one) to secure world See "Figure 552. Backup registers secure protections" in reference mnauel Protection zone 1 => x = 31 with BKPRWDPROT = 31 Protection zone 2 & 3 => empty + clrsetbits_le32(TAMP_SMCR, +
Re: [PATCH v1 25/25] ARM: dts: stm32: Add led-blue for stm32mp157c-ed1-scmi-u-boot
Hi, On 4/9/24 17:02, Patrice Chotard wrote: The blue led is used to indicate U-Boot entering / exit indication then Linux heartbeat. Signed-off-by: Patrice Chotard --- arch/arm/dts/stm32mp157c-ed1-scmi-u-boot.dtsi | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 24/25] ARM: dts: stm32: Update red led node for stm32mp157c-ed1-scmi-u-boot
Hi, On 4/9/24 17:02, Patrice Chotard wrote: As indicated in kernel led dt-bindings, label is a deprecated property, so remove it and use led node's name instead for u-boot,error-led property. Rename red led node's name to led-red. Remove status property which is useless. Add compatible = "gpio-leds"; which is not present in kernel DT. Signed-off-by: Patrice Chotard --- arch/arm/dts/stm32mp157c-ed1-scmi-u-boot.dtsi | 8 1 file changed, 4 insertions(+), 4 deletions(-) Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 23/25] ARM: dts: stm32: Don't probe red led at boot for stm32mp157c-ed1-scmi-u-boot
Hi, On 4/9/24 17:02, Patrice Chotard wrote: red led and button dedicated to fastboot share the same gpio GPIOA13. Led driver is probed early so the corresponding gpio is taken and configured in output which forbid fastboot and stm32prog button usage. To avoid this, remove the "default-state" property from red led node. This will avoid to trigger the led driver probe() to configure the led default state during startup. Signed-off-by: Patrice Chotard --- arch/arm/dts/stm32mp157c-ed1-scmi-u-boot.dtsi | 1 - 1 file changed, 1 deletion(-) Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 22/25] ARM: dts: stm32: Add gpio-keys for stm32mp157c-ed1-scmi-u-boot
Hi, On 4/9/24 17:02, Patrice Chotard wrote: Add 2 gpio-keys : _ button-user-1 for stm32prog mode activation. _ button-user-2 for fastboot mode activation. Remove proprietary st,fastboot-gpios and st,stm32prog-gpios. Signed-off-by: Patrice Chotard --- arch/arm/dts/stm32mp157c-ed1-scmi-u-boot.dtsi | 19 +-- 1 file changed, 17 insertions(+), 2 deletions(-) Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 21/25] ARM: dts: stm32: Add led-blue for stm32mp157c-ed1-u-boot
Hi, On 4/9/24 17:02, Patrice Chotard wrote: The blue led is used to indicate U-Boot entering / exit indication then Linux heartbeat. Signed-off-by: Patrice Chotard --- arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 20/25] ARM: dts: stm32: Update red led node for stm32mp157c-ed1-u-boot
Hi, On 4/9/24 17:02, Patrice Chotard wrote: As indicated in kernel led dt-bindings, label is a deprecated property, so remove it and use led node's name instead for u-boot,error-led property. Rename red led node's name to led-red. Remove status property which is useless. Add compatible = "gpio-leds" which is not present in kernel DT. Signed-off-by: Patrice Chotard --- arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi | 8 1 file changed, 4 insertions(+), 4 deletions(-) Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 19/25] ARM: dts: stm32: Don't probe red led at boot for stm32mp157c-ed1-u-boot
Hi, On 4/9/24 17:02, Patrice Chotard wrote: red led and button dedicated to fastboot share the same gpio GPIOA13. Led driver is probed early so the corresponding gpio is taken and configured in output which forbid fastboot and stm32prog button usage. To avoid this, remove the "default-state" property from red led node. This will avoid to trigger the led driver probe() to configure the led default state during startup. Signed-off-by: Patrice Chotard --- arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi | 1 - 1 file changed, 1 deletion(-) Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 18/25] ARM: dts: stm32: Add gpio-keys for stm32mp157c-ed1-u-boot
Hi, On 4/9/24 17:02, Patrice Chotard wrote: Add 2 gpio-keys : _ button-user-1 for stm32prog mode activation. _ button-user-2 for fastboot mode activation. Remove proprietary st,fastboot-gpios and st,stm32prog-gpios. Signed-off-by: Patrice Chotard --- arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi | 19 +-- 1 file changed, 17 insertions(+), 2 deletions(-) Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 17/25] ARM: dts: stm32: Update u-boot,boot-led for stm32mp157a-dk1-u-boot
Hi, On 4/9/24 17:02, Patrice Chotard wrote: As indicated in kernel led dt-bindings, label is a deprecated property, so remove it and use blue led node's name instead for u-boot,boot-led property. Signed-off-by: Patrice Chotard --- arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 16/25] ARM: dts: stm32: Update red led node for stm32mp157a-dk1-u-boot
Hi, On 4/9/24 17:02, Patrice Chotard wrote: As indicated in kernel led dt-bindings, label is a deprecated property, so remove it and use red led node's name instead for u-boot,error-led property. Rename red led node's name to led-red. Remove status property which is useless. Signed-off-by: Patrice Chotard --- arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 15/25] ARM: dts: stm32: Don't probe red led at boot for stm32mp157a-dk1-u-boot
Hi, On 4/9/24 17:02, Patrice Chotard wrote: red led and button dedicated to fastboot share the same gpio GPIOA13. Led driver is probed early so the corresponding gpio is taken and configured in output which forbid fastboot and stm32prog button usage. To avoid this, remove the "default-state" property from red led node. This will avoid to trigger the led driver probe() to configure the led default state during startup. Signed-off-by: Patrice Chotard --- arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi b/arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi index 6bf6136c5fd..ee9b51d42b7 100644 --- a/arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi +++ b/arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi @@ -67,7 +67,6 @@ red { label = "error"; gpios = < 13 GPIO_ACTIVE_LOW>; - default-state = "off"; status = "okay"; }; }; Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 14/25] ARM: dts: stm32: Add gpio-keys for stm32mp157a-dk1-u-boot
Hi, On 4/9/24 17:02, Patrice Chotard wrote: Instead of using "st,fastboot-gpios" and "st,stm32prog-gpios", declare 2 gpio-keys. Signed-off-by: Patrice Chotard --- arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi | 19 +-- 1 file changed, 17 insertions(+), 2 deletions(-) Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 13/25] ARM: dts: stm32: Add led-blue for stm32mp157a-dk1-scmi-u-boot
Hi, On 4/9/24 17:02, Patrice Chotard wrote: As indicated in kernel led dt-bindings, label is a deprecated property, so remove it and use blue led node's name instead for u-boot,boot-led property. Signed-off-by: Patrice Chotard --- arch/arm/dts/stm32mp157a-dk1-scmi-u-boot.dtsi | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/arm/dts/stm32mp157a-dk1-scmi-u-boot.dtsi b/arch/arm/dts/stm32mp157a-dk1-scmi-u-boot.dtsi index e61814fd66e..a5158fec7ef 100644 --- a/arch/arm/dts/stm32mp157a-dk1-scmi-u-boot.dtsi +++ b/arch/arm/dts/stm32mp157a-dk1-scmi-u-boot.dtsi @@ -13,7 +13,7 @@ }; config { - u-boot,boot-led = "heartbeat"; + u-boot,boot-led = "led-blue"; u-boot,error-led = "led-red"; u-boot,mmc-env-partition = "u-boot-env"; st,adc_usb_pd = < 18>, < 19>; @@ -36,6 +36,10 @@ }; led { + led-blue { + /delete-property/label; + }; + led-red { gpios = < 13 GPIO_ACTIVE_LOW>; }; Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 12/25] ARM: dts: stm32: Update red led node for stm32mp157a-dk1-scmi-u-boot
Hi, On 4/9/24 17:02, Patrice Chotard wrote: As indicated in kernel led dt-bindings, label is a deprecated property, so remove it and use red led node's name instead for u-boot,error-led property. Rename "red" led node's name to "led-red". Remove status property which is useless. Signed-off-by: Patrice Chotard --- arch/arm/dts/stm32mp157a-dk1-scmi-u-boot.dtsi | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/arm/dts/stm32mp157a-dk1-scmi-u-boot.dtsi b/arch/arm/dts/stm32mp157a-dk1-scmi-u-boot.dtsi index 8760d6c7d93..e61814fd66e 100644 --- a/arch/arm/dts/stm32mp157a-dk1-scmi-u-boot.dtsi +++ b/arch/arm/dts/stm32mp157a-dk1-scmi-u-boot.dtsi @@ -14,7 +14,7 @@ config { u-boot,boot-led = "heartbeat"; - u-boot,error-led = "error"; + u-boot,error-led = "led-red"; u-boot,mmc-env-partition = "u-boot-env"; st,adc_usb_pd = < 18>, < 19>; }; @@ -36,10 +36,8 @@ }; led { - red { - label = "error"; + led-red { gpios = < 13 GPIO_ACTIVE_LOW>; - status = "okay"; }; }; }; Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 10/25] ARM: dts: stm32: Add gpio-keys for stm32mp157a-dk1-scmi-u-boot
Hi, On 4/9/24 17:02, Patrice Chotard wrote: Instead of using "st,fastboot-gpios" and "st,stm32prog-gpios", declare 2 gpio-keys. Signed-off-by: Patrice Chotard --- arch/arm/dts/stm32mp157a-dk1-scmi-u-boot.dtsi | 19 +-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/arch/arm/dts/stm32mp157a-dk1-scmi-u-boot.dtsi b/arch/arm/dts/stm32mp157a-dk1-scmi-u-boot.dtsi index 20728f27ee1..5d49b09c35d 100644 --- a/arch/arm/dts/stm32mp157a-dk1-scmi-u-boot.dtsi +++ b/arch/arm/dts/stm32mp157a-dk1-scmi-u-boot.dtsi @@ -3,6 +3,7 @@ * Copyright : STMicroelectronics 2022 */ +#include #include "stm32mp15-scmi-u-boot.dtsi" / { @@ -16,8 +17,22 @@ u-boot,error-led = "error"; u-boot,mmc-env-partition = "u-boot-env"; st,adc_usb_pd = < 18>, < 19>; - st,fastboot-gpios = < 13 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; - st,stm32prog-gpios = < 14 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; + }; + + gpio-keys { + compatible = "gpio-keys"; + + button-user-1 { + label = "User-1"; + linux,code = ; + gpios = < 14 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; + }; + + button-user-2 { + label = "User-2"; + linux,code = ; + gpios = < 13 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; + }; }; led { Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 11/25] ARM: dts: stm32: Don't probe red led at boot for stm32mp157a-dk1-scmi-u-boot
Hi, On 4/9/24 17:02, Patrice Chotard wrote: red led and button dedicated to fastboot share the same gpio GPIOA13. Led driver is probed early so the corresponding gpio is taken and configured in output which forbid fastboot and stm32prog button usage. To avoid this, remove the "default-state" property from red led node. This will avoid to trigger the led driver probe() to configure the led default state during startup. Signed-off-by: Patrice Chotard --- arch/arm/dts/stm32mp157a-dk1-scmi-u-boot.dtsi | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/arm/dts/stm32mp157a-dk1-scmi-u-boot.dtsi b/arch/arm/dts/stm32mp157a-dk1-scmi-u-boot.dtsi index 5d49b09c35d..8760d6c7d93 100644 --- a/arch/arm/dts/stm32mp157a-dk1-scmi-u-boot.dtsi +++ b/arch/arm/dts/stm32mp157a-dk1-scmi-u-boot.dtsi @@ -39,7 +39,6 @@ red { label = "error"; gpios = < 13 GPIO_ACTIVE_LOW>; - default-state = "off"; status = "okay"; }; }; Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 09/25] ARM: dts: stm32: Clean led-red node for stm32mp135f-dk-u-boot
Hi, On 4/9/24 17:01, Patrice Chotard wrote: Remove "color" property from led-red node which is not supported by U-Boot. Signed-off-by: Patrice Chotard --- arch/arm/dts/stm32mp135f-dk-u-boot.dtsi | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/arm/dts/stm32mp135f-dk-u-boot.dtsi b/arch/arm/dts/stm32mp135f-dk-u-boot.dtsi index 8f42735609a..f004e9840a2 100644 --- a/arch/arm/dts/stm32mp135f-dk-u-boot.dtsi +++ b/arch/arm/dts/stm32mp135f-dk-u-boot.dtsi @@ -35,7 +35,6 @@ }; led-red { - color = ; gpios = < 13 GPIO_ACTIVE_LOW>; }; }; Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 08/25] ARM: dts: stm32: Don't probe led-red/led-blue at boot for stm32mp135f-dk-u-boot
Hi, On 4/9/24 17:01, Patrice Chotard wrote: led-red and button dedicated to fastboot share the same gpio GPIOA13. led-blue and button dedicated to stm32prog share the same gpio GPIOA14. Led driver is probed early so the corresponding gpio is taken and configured in output which forbid fastboot and stm32prog button usage. To avoid this, remove the "default-state" property from led-red and led-blue led's node. This will avoid to trigger the led driver probe() to configure the led default state during startup. Signed-off-by: Patrice Chotard --- arch/arm/dts/stm32mp135f-dk-u-boot.dtsi | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 07/25] ARM: dts: stm32: Add gpio-keys for stm32mp135f-dk-u-boot
Hi On 4/9/24 17:01, Patrice Chotard wrote: Add 2 gpio-keys : _ button-user-1 for stm32prog mode activation. _ update button-user's label (defined in kernel DT) to match label requested in board_key_check() for fastboot mode activation. Signed-off-by: Patrice Chotard --- arch/arm/dts/stm32mp135f-dk-u-boot.dtsi | 13 + 1 file changed, 13 insertions(+) Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 06/25] board: st: stmp32mp1: Use BUTTON UCLASS in board_key_check()
Hi, On 4/9/24 17:01, Patrice Chotard wrote: Instead of using gpio directly to detect key pressed on button dedicated for fastboot and stm32mprog, make usage of BUTTON UCLASS. Signed-off-by: Patrice Chotard --- board/st/stm32mp1/stm32mp1.c | 68 +--- 1 file changed, 40 insertions(+), 28 deletions(-) Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 05/25] configs: stm32mp1: Enable BUTTON_GPIO flag for stm32mp13_defconfig
Hi, On 4/9/24 17:01, Patrice Chotard wrote: Enable BUTTON_GPIO flag for STM32MP15. Signed-off-by: Patrice Chotard --- configs/stm32mp13_defconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configs/stm32mp13_defconfig b/configs/stm32mp13_defconfig index db09e63100e..caaabf39ef3 100644 --- a/configs/stm32mp13_defconfig +++ b/configs/stm32mp13_defconfig @@ -52,6 +52,8 @@ CONFIG_SYS_REDUNDAND_ENVIRONMENT=y CONFIG_SYS_RELOC_GD_ENV_ADDR=y CONFIG_SYS_MMC_ENV_DEV=-1 CONFIG_ENV_MMC_USE_DT=y +CONFIG_BUTTON=y +CONFIG_BUTTON_GPIO=y CONFIG_CLK_SCMI=y CONFIG_SET_DFU_ALT_INFO=y CONFIG_USB_FUNCTION_FASTBOOT=y Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 04/25] configs: stm32mp1: Enable BUTTON_GPIO flag for stm32mp15_trusted_defconfig
Hi, On 4/9/24 17:01, Patrice Chotard wrote: Enable BUTTON_GPIO flag for STM32MP15. Signed-off-by: Patrice Chotard --- configs/stm32mp15_trusted_defconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configs/stm32mp15_trusted_defconfig b/configs/stm32mp15_trusted_defconfig index 84b0854b557..74deaaba2e4 100644 --- a/configs/stm32mp15_trusted_defconfig +++ b/configs/stm32mp15_trusted_defconfig @@ -70,6 +70,8 @@ CONFIG_TFTP_TSIZE=y CONFIG_USE_SERVERIP=y CONFIG_SERVERIP="192.168.1.1" CONFIG_STM32_ADC=y +CONFIG_BUTTON=y +CONFIG_BUTTON_GPIO=y CONFIG_CLK_SCMI=y CONFIG_SET_DFU_ALT_INFO=y CONFIG_USB_FUNCTION_FASTBOOT=y Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 03/25] configs: stm32mp1: Enable BUTTON_GPIO flag for stm32mp15_basic_defconfig
Hi, On 4/9/24 17:01, Patrice Chotard wrote: Enable BUTTON_GPIO flag for STM32MP15. Signed-off-by: Patrice Chotard --- configs/stm32mp15_basic_defconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configs/stm32mp15_basic_defconfig b/configs/stm32mp15_basic_defconfig index 005f1d55f80..2e22bf86000 100644 --- a/configs/stm32mp15_basic_defconfig +++ b/configs/stm32mp15_basic_defconfig @@ -97,6 +97,8 @@ CONFIG_TFTP_TSIZE=y CONFIG_USE_SERVERIP=y CONFIG_SERVERIP="192.168.1.1" CONFIG_STM32_ADC=y +CONFIG_BUTTON=y +CONFIG_BUTTON_GPIO=y CONFIG_SET_DFU_ALT_INFO=y CONFIG_USB_FUNCTION_FASTBOOT=y CONFIG_FASTBOOT_BUF_ADDR=0xC000 Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 02/25] configs: stm32mp1: Enable BUTTON_GPIO flag for stm32mp15_defconfig
Hi, On 4/9/24 17:01, Patrice Chotard wrote: Enable BUTTON_GPIO flag for STM32MP15. Signed-off-by: Patrice Chotard --- configs/stm32mp15_defconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configs/stm32mp15_defconfig b/configs/stm32mp15_defconfig index 3302b306996..ffe7512650e 100644 --- a/configs/stm32mp15_defconfig +++ b/configs/stm32mp15_defconfig @@ -69,6 +69,8 @@ CONFIG_TFTP_TSIZE=y CONFIG_USE_SERVERIP=y CONFIG_SERVERIP="192.168.1.1" CONFIG_STM32_ADC=y +CONFIG_BUTTON=y +CONFIG_BUTTON_GPIO=y CONFIG_CLK_SCMI=y CONFIG_SET_DFU_ALT_INFO=y CONFIG_USB_FUNCTION_FASTBOOT=y Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 01/25] configs: stm32mp13: Enable FASTBOOT
Hi, On 4/9/24 17:01, Patrice Chotard wrote: Enable FASTBOOT relative flags for stm32mp13_defconfig. Signed-off-by: Patrice Chotard --- configs/stm32mp13_defconfig | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH 2/2] mmc: stm32_sdmmc2: Fix AARCH64 compilation warnings
Hi, On 3/8/24 15:26, Patrice Chotard wrote: When building with AARCH64 defconfig, we got warnings, fix them. Signed-off-by: Patrice Chotard --- drivers/mmc/stm32_sdmmc2.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/stm32_sdmmc2.c b/drivers/mmc/stm32_sdmmc2.c index d4982a14281..39ae79ba129 100644 --- a/drivers/mmc/stm32_sdmmc2.c +++ b/drivers/mmc/stm32_sdmmc2.c @@ -220,9 +220,9 @@ static void stm32_sdmmc2_start_data(struct udevice *dev, if (data->flags & MMC_DATA_READ) { data_ctrl |= SDMMC_DCTRL_DTDIR; - idmabase0 = (u32)data->dest; + idmabase0 = (u32)(long)data->dest; } else { - idmabase0 = (u32)data->src; + idmabase0 = (u32)(long)data->src; } /* Set the SDMMC DataLength value */ @@ -463,8 +463,8 @@ retry_cmd: stm32_sdmmc2_start_cmd(dev, cmd, cmdat, ); - dev_dbg(dev, "send cmd %d data: 0x%x @ 0x%x\n", - cmd->cmdidx, data ? ctx.data_length : 0, (unsigned int)data); + dev_dbg(dev, "send cmd %d data: 0x%x @ 0x%p\n", + cmd->cmdidx, data ? ctx.data_length : 0, data); ret = stm32_sdmmc2_end_cmd(dev, cmd, ); Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH 1/2] mmc: stm32_sdmmc2: Add "st,stm32mp25-sdmmc2" compatible
Hi, On 3/8/24 15:26, Patrice Chotard wrote: From: Patrick Delaunay Add compatible used for STM32MP25 family. Signed-off-by: Patrick Delaunay Signed-off-by: Patrice Chotard --- drivers/mmc/stm32_sdmmc2.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/mmc/stm32_sdmmc2.c b/drivers/mmc/stm32_sdmmc2.c index a2b111a8435..d4982a14281 100644 --- a/drivers/mmc/stm32_sdmmc2.c +++ b/drivers/mmc/stm32_sdmmc2.c @@ -789,6 +789,7 @@ static int stm32_sdmmc2_bind(struct udevice *dev) static const struct udevice_id stm32_sdmmc2_ids[] = { { .compatible = "st,stm32-sdmmc2" }, + { .compatible = "st,stm32mp25-sdmmc2" }, { } }; Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH 3/3] ARM: dts: stm32: Fix partition node name for stm32mp15xx-dhcom-u-boot
Hi, On 3/8/24 14:50, Patrice Chotard wrote: Fix flash@0 partition node name with correct offset. Fixes: 90f992e6a58c ("arm: dts: stm32: Add partitions in flash0 and nand node for stm32mp15xx-dhcom/dhcor") Signed-off-by: Patrice Chotard --- arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi b/arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi index 2f70b0690d2..1b445619325 100644 --- a/arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi +++ b/arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi @@ -106,15 +106,15 @@ label = "fsbl2"; reg = <0x0004 0x0004>; }; - partition@50 { + partition@8 { label = "uboot"; reg = <0x0008 0x0016>; }; - partition@90 { + partition@1e { label = "env1"; reg = <0x001E 0x0001>; }; - partition@98 { + partition@1f { label = "env2"; reg = <0x001F 0x0001>; }; Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH 2/3] ARM: dts: stm32: Fix partition node name for stm32mp15xx-dhcor-u-boot
Hi On 3/8/24 14:50, Patrice Chotard wrote: Fix flash@0 partition node name with correct offset. Fixes: 90f992e6a58c ("arm: dts: stm32: Add partitions in flash0 and nand node for stm32mp15xx-dhcom/dhcor") Signed-off-by: Patrice Chotard --- arch/arm/dts/stm32mp15xx-dhcor-u-boot.dtsi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm/dts/stm32mp15xx-dhcor-u-boot.dtsi b/arch/arm/dts/stm32mp15xx-dhcor-u-boot.dtsi index 552b35db3c7..ba84db679e1 100644 --- a/arch/arm/dts/stm32mp15xx-dhcor-u-boot.dtsi +++ b/arch/arm/dts/stm32mp15xx-dhcor-u-boot.dtsi @@ -42,15 +42,15 @@ label = "fsbl2"; reg = <0x0004 0x0004>; }; - partition@50 { + partition@8 { label = "uboot"; reg = <0x0008 0x0016>; }; - partition@90 { + partition@1e { label = "env1"; reg = <0x001E 0x0001>; }; - partition@98 { + partition@1f { label = "env2"; reg = <0x001F 0x0001>; }; Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH 1/3] ARM: dts: stm32: Fix partition node name for stm32mp157c-ev1-u-boot
Hi, On 3/8/24 14:50, Patrice Chotard wrote: Fix flash@0 and nand@0 partition node name with correct offset. Fixes: e91d3c61767b ("arm: dts: stm32: Add partitions in flash0 and nand node for stm32mp15xx-ev1") Signed-off-by: Patrice Chotard --- arch/arm/dts/stm32mp157c-ev1-u-boot.dtsi | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/arm/dts/stm32mp157c-ev1-u-boot.dtsi b/arch/arm/dts/stm32mp157c-ev1-u-boot.dtsi index 139940bd5d4..3515347e91d 100644 --- a/arch/arm/dts/stm32mp157c-ev1-u-boot.dtsi +++ b/arch/arm/dts/stm32mp157c-ev1-u-boot.dtsi @@ -33,11 +33,11 @@ label = "fsbl1"; reg = <0x 0x0004>; }; - partition@8 { + partition@4 { label = "fsbl2"; reg = <0x0004 0x0004>; }; - partition@10 { + partition@8 { label = "ssbl"; reg = <0x0008 0x0020>; }; @@ -58,7 +58,7 @@ label = "fsbl2"; reg = <0x0004 0x0004>; }; - partition@10 { + partition@8 { label = "fip"; reg = <0x0008 0x0040>; }; @@ -112,7 +112,7 @@ label = "fip2"; reg = <0x0060 0x0040>; }; - partition@120 { + partition@a0 { label = "UBI"; reg = <0x00a0 0x3f60>; }; Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH] stm32mp: Reserve OPTEE area in EFI memory map
Hi, On 3/8/24 11:12, Patrice Chotard wrote: Since commit 7b78d6438a2b3 ("efi_loader: Reserve unaccessible memory") memory region above ram_top is tagged in EFI memory map as EFI_BOOT_SERVICES_DATA. In case of STM32MP1 platform, above ram_top, there is one reserved-memory region tagged "no-map" dedicated to OP-TEE (addr=de00 size=200). Before booting kernel, EFI memory map is first built, the OPTEE region is tagged as EFI_BOOT_SERVICES_DATA and when reserving LMB, the tag LMB_NONE is used. Then after, the LMB are completed by boot_fdt_add_mem_rsv_regions() which try to add again the same OPTEE region (addr=de00 size=200) but now with LMB_NOMAP tag which produces the following error message : "ERROR: reserving fdt memory region failed (addr=de00 size=200 flags=4)" To avoid this, OPTEE area shouldn't be used by EFI, so we need to mark it as reserved. Signed-off-by: Patrice Chotard --- arch/arm/mach-stm32mp/dram_init.c | 12 1 file changed, 12 insertions(+) diff --git a/arch/arm/mach-stm32mp/dram_init.c b/arch/arm/mach-stm32mp/dram_init.c index fb1208fc5d5..f67f54f2ae0 100644 --- a/arch/arm/mach-stm32mp/dram_init.c +++ b/arch/arm/mach-stm32mp/dram_init.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -75,3 +76,14 @@ phys_addr_t board_get_usable_ram_top(phys_size_t total_size) return reg + size; } + +void efi_add_known_memory(void) +{ + if (IS_ENABLED(CONFIG_EFI_LOADER)) + /* +* Memory over ram_top is reserved to OPTEE. +* Declare to EFI only memory area below ram_top +*/ + efi_add_memory_map(gd->ram_base, gd->ram_top - gd->ram_base, + EFI_CONVENTIONAL_MEMORY); +} Reviewed-by: Patrick Delaunay Thanks Patrick
[PATCH] stm32mp: cmd_stm32prog: add dependencies with USB_GADGET_DOWNLOAD
This patch avoids compilation issue when CONFIG_USB_GADGET is deactivated in defconfig, with undefined reference to run_usb_dnl_gadget and to g_dnl_set_product. Signed-off-by: Patrick Delaunay --- arch/arm/mach-stm32mp/cmd_stm32prog/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/Kconfig b/arch/arm/mach-stm32mp/cmd_stm32prog/Kconfig index 8f91db4b46b9..589276282e44 100644 --- a/arch/arm/mach-stm32mp/cmd_stm32prog/Kconfig +++ b/arch/arm/mach-stm32mp/cmd_stm32prog/Kconfig @@ -17,6 +17,7 @@ config CMD_STM32PROG config CMD_STM32PROG_USB bool "support stm32prog over USB" depends on CMD_STM32PROG + depends on USB_GADGET_DOWNLOAD default y help activate the command "stm32prog usb" for STM32MP soc family -- 2.25.1
Re: [PATCH] stm32mp2: Fix CONFIG_STM32MP25X flag usage
Hi On 1/9/24 15:00, Patrice Chotard wrote: "#if" was used instead of "#ifdef" Fixes: 01a701994b05 ("stm32mp2: initial support") Signed-off-by: Patrice Chotard --- arch/arm/mach-stm32mp/include/mach/stm32.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-stm32mp/include/mach/stm32.h b/arch/arm/mach-stm32mp/include/mach/stm32.h index 46d469881b3..175f2a88490 100644 --- a/arch/arm/mach-stm32mp/include/mach/stm32.h +++ b/arch/arm/mach-stm32mp/include/mach/stm32.h @@ -157,7 +157,7 @@ enum forced_boot_mode { #endif /* __ASSEMBLY__ */ #endif /* CONFIG_STM32MP15X || CONFIG_STM32MP13X */ -#if CONFIG_STM32MP25X +#ifdef CONFIG_STM32MP25X #define STM32_RCC_BASE0x4420 #define STM32_TAMP_BASE 0x46010000 Reviewed-by: Patrick Delaunay Thanks Patrick
[PATCH v2 14/14] arm: Rename STM32MP15x
CONFIG options must not use lower-case letter. Convert this and related ones to upper case. Signed-off-by: Simon Glass --- See Simon's patch in serie "Clean up of bad Kconfig options" never merged https://patchwork.ozlabs.org/project/uboot/list/?series=339004=* https://patchwork.ozlabs.org/project/uboot/patch/20230129005903.74918-69-...@chromium.org/ Changes in v2: - add "arm: Rename STM32MP15x" arch/arm/dts/Makefile | 2 +- arch/arm/dts/stm32mp15-u-boot.dtsi | 2 +- arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi| 4 ++-- arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi| 4 ++-- arch/arm/dts/stm32mp157c-ev1-u-boot.dtsi| 4 ++-- arch/arm/mach-stm32mp/Kconfig | 6 +++--- arch/arm/mach-stm32mp/Kconfig.15x | 6 +++--- arch/arm/mach-stm32mp/Makefile | 2 +- arch/arm/mach-stm32mp/cmd_stm32key.c| 10 +- arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h | 4 ++-- arch/arm/mach-stm32mp/include/mach/stm32.h | 12 ++-- arch/arm/mach-stm32mp/stm32mp1/Makefile | 2 +- arch/arm/mach-stm32mp/stm32mp1/fdt.c| 6 +++--- board/st/common/Kconfig | 2 +- board/st/stm32mp1/Kconfig | 2 +- board/st/stm32mp1/stm32mp1.c| 6 +++--- configs/stm32mp15_basic_defconfig | 2 +- configs/stm32mp15_defconfig | 2 +- configs/stm32mp15_trusted_defconfig | 4 ++-- drivers/clk/stm32/Kconfig | 2 +- 20 files changed, 42 insertions(+), 42 deletions(-) diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index 8dcf1f5717ce..02074440b55d 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile @@ -1363,7 +1363,7 @@ dtb-$(CONFIG_ARCH_STI) += stih410-b2260.dtb dtb-$(CONFIG_STM32MP13X) += \ stm32mp135f-dk.dtb -dtb-$(CONFIG_STM32MP15x) += \ +dtb-$(CONFIG_STM32MP15X) += \ stm32mp157a-dk1.dtb \ stm32mp157a-dk1-scmi.dtb \ stm32mp157a-icore-stm32mp1-ctouch2.dtb \ diff --git a/arch/arm/dts/stm32mp15-u-boot.dtsi b/arch/arm/dts/stm32mp15-u-boot.dtsi index 573dd4d3ed56..fe56f05616a0 100644 --- a/arch/arm/dts/stm32mp15-u-boot.dtsi +++ b/arch/arm/dts/stm32mp15-u-boot.dtsi @@ -206,7 +206,7 @@ resets = < UART8_R>; }; -#if defined(CONFIG_STM32MP15x_STM32IMAGE) +#if defined(CONFIG_STM32MP15X_STM32IMAGE) { u-boot-stm32 { filename = "u-boot.stm32"; diff --git a/arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi b/arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi index 2623cebf21a4..a16358266a2d 100644 --- a/arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi +++ b/arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi @@ -22,13 +22,13 @@ st,stm32prog-gpios = < 14 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; }; -#if defined(CONFIG_STM32MP15x_STM32IMAGE) || defined(CONFIG_SPL) +#if defined(CONFIG_STM32MP15X_STM32IMAGE) || defined(CONFIG_SPL) config { u-boot,mmc-env-partition = "ssbl"; }; #endif -#ifdef CONFIG_STM32MP15x_STM32IMAGE +#ifdef CONFIG_STM32MP15X_STM32IMAGE /* only needed for boot with TF-A, witout FIP support */ firmware { optee { diff --git a/arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi b/arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi index b8288273ddb5..ef91088aa375 100644 --- a/arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi +++ b/arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi @@ -20,13 +20,13 @@ st,stm32prog-gpios = < 14 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; }; -#if defined(CONFIG_STM32MP15x_STM32IMAGE) || defined(CONFIG_SPL) +#if defined(CONFIG_STM32MP15X_STM32IMAGE) || defined(CONFIG_SPL) config { u-boot,mmc-env-partition = "ssbl"; }; #endif -#ifdef CONFIG_STM32MP15x_STM32IMAGE +#ifdef CONFIG_STM32MP15X_STM32IMAGE /* only needed for boot with TF-A, witout FIP support */ firmware { optee { diff --git a/arch/arm/dts/stm32mp157c-ev1-u-boot.dtsi b/arch/arm/dts/stm32mp157c-ev1-u-boot.dtsi index eb283cacd27d..139940bd5d47 100644 --- a/arch/arm/dts/stm32mp157c-ev1-u-boot.dtsi +++ b/arch/arm/dts/stm32mp157c-ev1-u-boot.dtsi @@ -28,7 +28,7 @@ #address-cells = <1>; #size-cells = <1>; -#if defined(CONFIG_STM32MP15x_STM32IMAGE) || defined(CONFIG_SPL) +#if defined(CONFIG_STM32MP15X_STM32IMAGE) || defined(CONFIG_SPL) partition@0 { label = "fsbl1"; reg = <0x 0x0004>; @@ -82,7 +82,7 @@ #address-cells = <1>; #size-cells = <1>; -#if defined(CONFIG_STM32MP15x_STM32IMAGE) || defined(CONFIG_SPL) +#if defined(CONFIG_STM32MP15X_STM32IMAGE) || defined(CONFIG_SPL) partition@0 { label = "fsbl"; reg =
[PATCH v2 13/14] arm: Rename STM32MP13x
CONFIG options must not use lower-case letter. Convert this and related ones to upper case. Signed-off-by: Simon Glass Signed-off-by: Patrick Delaunay --- See Simon's patch in serie "Clean up of bad Kconfig options" never merged https://patchwork.ozlabs.org/project/uboot/list/?series=339004=* https://patchwork.ozlabs.org/project/uboot/patch/20230129005903.74918-68-...@chromium.org/ Changes in v2: - add "arm: Rename STM32MP13x" arch/arm/dts/Makefile | 2 +- arch/arm/mach-stm32mp/Kconfig | 4 ++-- arch/arm/mach-stm32mp/Kconfig.13x | 4 ++-- arch/arm/mach-stm32mp/Makefile | 2 +- arch/arm/mach-stm32mp/cmd_stm32key.c| 10 +- arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h | 2 +- arch/arm/mach-stm32mp/include/mach/stm32.h | 8 arch/arm/mach-stm32mp/stm32mp1/Makefile | 2 +- arch/arm/mach-stm32mp/stm32mp1/fdt.c| 4 ++-- board/st/common/Kconfig | 2 +- board/st/stm32mp1/Kconfig | 2 +- configs/stm32mp13_defconfig | 4 ++-- drivers/clk/stm32/Kconfig | 2 +- 13 files changed, 24 insertions(+), 24 deletions(-) diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index 773c2546131c..8dcf1f5717ce 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile @@ -1360,7 +1360,7 @@ dtb-$(CONFIG_ASPEED_AST2600) += ast2600-evb.dtb dtb-$(CONFIG_ARCH_STI) += stih410-b2260.dtb -dtb-$(CONFIG_STM32MP13x) += \ +dtb-$(CONFIG_STM32MP13X) += \ stm32mp135f-dk.dtb dtb-$(CONFIG_STM32MP15x) += \ diff --git a/arch/arm/mach-stm32mp/Kconfig b/arch/arm/mach-stm32mp/Kconfig index 5fc92d07fe6d..241fcf3e0d22 100644 --- a/arch/arm/mach-stm32mp/Kconfig +++ b/arch/arm/mach-stm32mp/Kconfig @@ -37,7 +37,7 @@ choice prompt "Select STMicroelectronics STM32MPxxx Soc" default STM32MP15x -config STM32MP13x +config STM32MP13X bool "Support STMicroelectronics STM32MP13x Soc" select ARM_SMCCC select CPU_V7A @@ -127,7 +127,7 @@ config SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION_MMC2 config STM32_ETZPC bool "STM32 Extended TrustZone Protection" - depends on STM32MP15x || STM32MP13x + depends on STM32MP15x || STM32MP13X default y imply BOOTP_SERVERIP help diff --git a/arch/arm/mach-stm32mp/Kconfig.13x b/arch/arm/mach-stm32mp/Kconfig.13x index acc02a5a1872..4d74b35055b8 100644 --- a/arch/arm/mach-stm32mp/Kconfig.13x +++ b/arch/arm/mach-stm32mp/Kconfig.13x @@ -1,10 +1,10 @@ -if STM32MP13x +if STM32MP13X choice prompt "STM32MP13x board select" optional -config TARGET_ST_STM32MP13x +config TARGET_ST_STM32MP13X bool "STMicroelectronics STM32MP13x boards" imply BOOTSTAGE imply CMD_BOOTSTAGE diff --git a/arch/arm/mach-stm32mp/Makefile b/arch/arm/mach-stm32mp/Makefile index fdcbbf91dfd5..3d194de0631c 100644 --- a/arch/arm/mach-stm32mp/Makefile +++ b/arch/arm/mach-stm32mp/Makefile @@ -9,7 +9,7 @@ obj-y += bsec.o obj-y += soc.o obj-$(CONFIG_STM32MP15x) += stm32mp1/ -obj-$(CONFIG_STM32MP13x) += stm32mp1/ +obj-$(CONFIG_STM32MP13X) += stm32mp1/ obj-$(CONFIG_STM32MP25X) += stm32mp2/ obj-$(CONFIG_STM32_ECDSA_VERIFY) += ecdsa_romapi.o diff --git a/arch/arm/mach-stm32mp/cmd_stm32key.c b/arch/arm/mach-stm32mp/cmd_stm32key.c index e16fcf4424dc..dcef6ac4fb82 100644 --- a/arch/arm/mach-stm32mp/cmd_stm32key.c +++ b/arch/arm/mach-stm32mp/cmd_stm32key.c @@ -19,7 +19,7 @@ * STM32MP13x: 0b11 = 0x3F for OTP_SECURED closed device */ #define STM32_OTP_CLOSE_ID 0 -#define STM32_OTP_STM32MP13x_CLOSE_MASK0x3F +#define STM32_OTP_STM32MP13X_CLOSE_MASK0x3F #define STM32_OTP_STM32MP15x_CLOSE_MASKBIT(6) /* PKH is the first element of the key list */ @@ -61,7 +61,7 @@ static u8 stm32key_index; static u8 get_key_nb(void) { - if (IS_ENABLED(CONFIG_STM32MP13x)) + if (IS_ENABLED(CONFIG_STM32MP13X)) return ARRAY_SIZE(stm32mp13_list); if (IS_ENABLED(CONFIG_STM32MP15x)) @@ -70,7 +70,7 @@ static u8 get_key_nb(void) static const struct stm32key *get_key(u8 index) { - if (IS_ENABLED(CONFIG_STM32MP13x)) + if (IS_ENABLED(CONFIG_STM32MP13X)) return _list[index]; if (IS_ENABLED(CONFIG_STM32MP15x)) @@ -79,8 +79,8 @@ static const struct stm32key *get_key(u8 index) static u32 get_otp_close_mask(void) { - if (IS_ENABLED(CONFIG_STM32MP13x)) - return STM32_OTP_STM32MP13x_CLOSE_MASK; + if (IS_ENABLED(CONFIG_STM32MP13X)) + return STM32_OTP_STM32MP13X_CLOSE_MASK; if (IS_ENABLED(CONFIG_STM32MP15x)) return STM32_OTP_STM32MP15x_CLOSE_MASK; diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h index eda98
[PATCH v2 12/14] board: st: stm32mp2: display the board identification
Add the display of the STMicroelectronics board identification saved in OTP in stm32mp2 checkboard function. Reviewed-by: Patrice Chotard Signed-off-by: Patrick Delaunay --- (no changes since v1) board/st/stm32mp2/stm32mp2.c | 23 +++ 1 file changed, 23 insertions(+) diff --git a/board/st/stm32mp2/stm32mp2.c b/board/st/stm32mp2/stm32mp2.c index 9a881583d904..aa7dd31996ea 100644 --- a/board/st/stm32mp2/stm32mp2.c +++ b/board/st/stm32mp2/stm32mp2.c @@ -9,9 +9,12 @@ #include #include #include +#include #include #include +#include #include +#include /* * Get a global data pointer @@ -20,6 +23,9 @@ DECLARE_GLOBAL_DATA_PTR; int checkboard(void) { + int ret; + u32 otp; + struct udevice *dev; const char *fdt_compat; int fdt_compat_len; @@ -27,6 +33,23 @@ int checkboard(void) log_info("Board: stm32mp2 (%s)\n", fdt_compat && fdt_compat_len ? fdt_compat : ""); + /* display the STMicroelectronics board identification */ + if (CONFIG_IS_ENABLED(CMD_STBOARD)) { + ret = uclass_get_device_by_driver(UCLASS_MISC, + DM_DRIVER_GET(stm32mp_bsec), + ); + if (!ret) + ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_BOARD), + , sizeof(otp)); + if (ret > 0 && otp) + log_info("Board: MB%04x Var%d.%d Rev.%c-%02d\n", +otp >> 16, +(otp >> 12) & 0xF, +(otp >> 4) & 0xF, +((otp >> 8) & 0xF) - 1 + 'A', +otp & 0xF); + } + return 0; } -- 2.25.1
[PATCH v2 10/14] stm32mp: activate the command stboard for stm32mp25 boards
Activate the command stboard for stm32mp25 STMicroelectronics boards, add the default used OTP identifier and the associated board identifier: - stm32mp25xx-ev1 = MB1936 - stm32mp25xx-dk = MB1605 Signed-off-by: Patrick Delaunay --- Changes in v2: - fix CONFIG name with 'x': TARGET_ST_STM32MP15x TARGET_ST_STM32MP13x arch/arm/mach-stm32mp/include/mach/stm32.h | 1 + board/st/common/Kconfig| 2 +- board/st/common/cmd_stboard.c | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-stm32mp/include/mach/stm32.h b/arch/arm/mach-stm32mp/include/mach/stm32.h index 45c929aa605d..726c390977e3 100644 --- a/arch/arm/mach-stm32mp/include/mach/stm32.h +++ b/arch/arm/mach-stm32mp/include/mach/stm32.h @@ -198,6 +198,7 @@ enum forced_boot_mode { #define BSEC_OTP_SERIAL5 #define BSEC_OTP_RPN 9 #define BSEC_OTP_PKG 122 +#define BSEC_OTP_BOARD 246 #define BSEC_OTP_MAC 247 #endif diff --git a/board/st/common/Kconfig b/board/st/common/Kconfig index c1c254d07354..f40d1a78ca36 100644 --- a/board/st/common/Kconfig +++ b/board/st/common/Kconfig @@ -1,7 +1,7 @@ config CMD_STBOARD bool "stboard - command for OTP board information" depends on ARCH_STM32MP - default y if TARGET_ST_STM32MP15x || TARGET_ST_STM32MP13x + default y if TARGET_ST_STM32MP25X || TARGET_ST_STM32MP15x || TARGET_ST_STM32MP13x help This compile the stboard command to read and write the board in the OTP. diff --git a/board/st/common/cmd_stboard.c b/board/st/common/cmd_stboard.c index 853ab78bbf16..cb103e69b369 100644 --- a/board/st/common/cmd_stboard.c +++ b/board/st/common/cmd_stboard.c @@ -49,7 +49,9 @@ static bool check_stboard(u16 board) 0x1298, 0x1341, 0x1497, + 0x1605, /* stm32mp25xx-dk */ 0x1635, + 0x1936, /* stm32mp25xx-ev1 */ }; for (i = 0; i < ARRAY_SIZE(st_board_id); i++) -- 2.25.1
[PATCH v2 11/14] board: st: stm32mp2: add checkboard
Implement the weak function checkboard to identify the used board with compatible in device tree for the support of stm32mp2 STMicroelectronics boards. Reviewed-by: Patrice Chotard Signed-off-by: Patrick Delaunay --- (no changes since v1) board/st/stm32mp2/stm32mp2.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/board/st/stm32mp2/stm32mp2.c b/board/st/stm32mp2/stm32mp2.c index c97a7efff46e..9a881583d904 100644 --- a/board/st/stm32mp2/stm32mp2.c +++ b/board/st/stm32mp2/stm32mp2.c @@ -8,14 +8,28 @@ #include #include #include +#include #include #include +#include /* * Get a global data pointer */ DECLARE_GLOBAL_DATA_PTR; +int checkboard(void) +{ + const char *fdt_compat; + int fdt_compat_len; + + fdt_compat = ofnode_get_property(ofnode_root(), "compatible", _compat_len); + + log_info("Board: stm32mp2 (%s)\n", fdt_compat && fdt_compat_len ? fdt_compat : ""); + + return 0; +} + /* board dependent setup after realloc */ int board_init(void) { -- 2.25.1
[PATCH v2 07/14] stm32mp: add setup_serial_number for stm32mp25
From: Patrice Chotard Add support of serial number for stm32mp25, gets from OTP with BSEC driver. Reviewed-by: Patrice Chotard Signed-off-by: Patrice Chotard Signed-off-by: Patrick Delaunay --- (no changes since v1) .../arm/mach-stm32mp/include/mach/sys_proto.h | 1 + arch/arm/mach-stm32mp/soc.c | 31 +++ arch/arm/mach-stm32mp/stm32mp1/cpu.c | 27 arch/arm/mach-stm32mp/stm32mp2/cpu.c | 2 ++ 4 files changed, 34 insertions(+), 27 deletions(-) diff --git a/arch/arm/mach-stm32mp/include/mach/sys_proto.h b/arch/arm/mach-stm32mp/include/mach/sys_proto.h index 83388fdb7371..2a65efc0a50a 100644 --- a/arch/arm/mach-stm32mp/include/mach/sys_proto.h +++ b/arch/arm/mach-stm32mp/include/mach/sys_proto.h @@ -97,6 +97,7 @@ u32 get_bootauth(void); int get_eth_nb(void); int setup_mac_address(void); +int setup_serial_number(void); /* board power management : configure vddcore according OPP */ void board_vddcore_init(u32 voltage_mv); diff --git a/arch/arm/mach-stm32mp/soc.c b/arch/arm/mach-stm32mp/soc.c index 8d5fa474ccaf..ff70ebe97464 100644 --- a/arch/arm/mach-stm32mp/soc.c +++ b/arch/arm/mach-stm32mp/soc.c @@ -3,7 +3,11 @@ * Copyright (C) 2024, STMicroelectronics - All Rights Reserved */ +#include +#include #include +#include +#include /* used when CONFIG_DISPLAY_CPUINFO is activated */ int print_cpuinfo(void) @@ -15,3 +19,30 @@ int print_cpuinfo(void) return 0; } + +int setup_serial_number(void) +{ + char serial_string[25]; + u32 otp[3] = {0, 0, 0 }; + struct udevice *dev; + int ret; + + if (env_get("serial#")) + return 0; + + ret = uclass_get_device_by_driver(UCLASS_MISC, + DM_DRIVER_GET(stm32mp_bsec), + ); + if (ret) + return ret; + + ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_SERIAL), + otp, sizeof(otp)); + if (ret < 0) + return ret; + + sprintf(serial_string, "%08X%08X%08X", otp[0], otp[1], otp[2]); + env_set("serial#", serial_string); + + return 0; +} diff --git a/arch/arm/mach-stm32mp/stm32mp1/cpu.c b/arch/arm/mach-stm32mp/stm32mp1/cpu.c index 00fea7929b2f..f84cb26fa565 100644 --- a/arch/arm/mach-stm32mp/stm32mp1/cpu.c +++ b/arch/arm/mach-stm32mp/stm32mp1/cpu.c @@ -336,33 +336,6 @@ __weak int setup_mac_address(void) return 0; } -static int setup_serial_number(void) -{ - char serial_string[25]; - u32 otp[3] = {0, 0, 0 }; - struct udevice *dev; - int ret; - - if (env_get("serial#")) - return 0; - - ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_DRIVER_GET(stm32mp_bsec), - ); - if (ret) - return ret; - - ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_SERIAL), - otp, sizeof(otp)); - if (ret < 0) - return ret; - - sprintf(serial_string, "%08X%08X%08X", otp[0], otp[1], otp[2]); - env_set("serial#", serial_string); - - return 0; -} - __weak void stm32mp_misc_init(void) { } diff --git a/arch/arm/mach-stm32mp/stm32mp2/cpu.c b/arch/arm/mach-stm32mp/stm32mp2/cpu.c index c0f6519e8d7c..301e365cf4f4 100644 --- a/arch/arm/mach-stm32mp/stm32mp2/cpu.c +++ b/arch/arm/mach-stm32mp/stm32mp2/cpu.c @@ -69,6 +69,8 @@ void enable_caches(void) int arch_misc_init(void) { + setup_serial_number(); + return 0; } -- 2.25.1
[PATCH v2 08/14] smt32mp: add setup_mac_address for stm32mp25
Add a function setup_mac_address() to update the MAC address from the default location in OTP for stm32mp2 platform. The max number of OTP for MAC address is increased to 8 for STM32MP25, defined with get_eth_nb() and checked in setup_mac_address. The MAC address FF:FF:FF:FF:FF:FF, the broadcast ethaddr, is a invalid value used for unused MAC address slot in OTP, for example for board with STM32MP25x part number allows up to 5 ethernet ports but it is not supported by the hardware, without switch; the associated variable "enetaddr%d" is not created. Reviewed-by: Patrice Chotard Signed-off-by: Patrick Delaunay --- (no changes since v1) arch/arm/mach-stm32mp/soc.c | 70 arch/arm/mach-stm32mp/stm32mp1/cpu.c | 58 +-- arch/arm/mach-stm32mp/stm32mp2/cpu.c | 1 + 3 files changed, 72 insertions(+), 57 deletions(-) diff --git a/arch/arm/mach-stm32mp/soc.c b/arch/arm/mach-stm32mp/soc.c index ff70ebe97464..fa56b0d2e0f1 100644 --- a/arch/arm/mach-stm32mp/soc.c +++ b/arch/arm/mach-stm32mp/soc.c @@ -5,10 +5,14 @@ #include #include +#include #include #include #include +/* max: 8 OTP for 5 mac address on stm32mp2*/ +#define MAX_NB_OTP 8 + /* used when CONFIG_DISPLAY_CPUINFO is activated */ int print_cpuinfo(void) { @@ -46,3 +50,69 @@ int setup_serial_number(void) return 0; } + +/* + * If there is no MAC address in the environment, then it will be initialized + * (silently) from the value in the OTP. + */ +__weak int setup_mac_address(void) +{ + int ret; + int i; + u32 otp[MAX_NB_OTP]; + uchar enetaddr[ARP_HLEN]; + struct udevice *dev; + int nb_eth, nb_otp, index; + + if (!IS_ENABLED(CONFIG_NET)) + return 0; + + nb_eth = get_eth_nb(); + if (!nb_eth) + return 0; + + /* 6 bytes for each MAC addr and 4 bytes for each OTP */ + nb_otp = DIV_ROUND_UP(ARP_HLEN * nb_eth, 4); + if (nb_otp > MAX_NB_OTP) { + log_err("invalid number of OTP = %d, max = %d\n", nb_otp, MAX_NB_OTP); + return -EINVAL; + } + + ret = uclass_get_device_by_driver(UCLASS_MISC, + DM_DRIVER_GET(stm32mp_bsec), + ); + if (ret) + return ret; + + ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_MAC), otp, 4 * nb_otp); + if (ret < 0) + return ret; + + for (index = 0; index < nb_eth; index++) { + /* MAC already in environment */ + if (eth_env_get_enetaddr_by_index("eth", index, enetaddr)) + continue; + + for (i = 0; i < ARP_HLEN; i++) + enetaddr[i] = ((uint8_t *))[i + ARP_HLEN * index]; + + /* skip FF:FF:FF:FF:FF:FF */ + if (is_broadcast_ethaddr(enetaddr)) + continue; + + if (!is_valid_ethaddr(enetaddr)) { + log_err("invalid MAC address %d in OTP %pM\n", + index, enetaddr); + return -EINVAL; + } + log_debug("OTP MAC address %d = %pM\n", index, enetaddr); + ret = eth_env_set_enetaddr_by_index("eth", index, enetaddr); + if (ret) { + log_err("Failed to set mac address %pM from OTP: %d\n", + enetaddr, ret); + return ret; + } + } + + return 0; +} diff --git a/arch/arm/mach-stm32mp/stm32mp1/cpu.c b/arch/arm/mach-stm32mp/stm32mp1/cpu.c index f84cb26fa565..524778f00c67 100644 --- a/arch/arm/mach-stm32mp/stm32mp1/cpu.c +++ b/arch/arm/mach-stm32mp/stm32mp1/cpu.c @@ -14,8 +14,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -280,62 +280,6 @@ static void setup_boot_mode(void) clrsetbits_le32(TAMP_BOOT_CONTEXT, TAMP_BOOT_FORCED_MASK, BOOT_NORMAL); } -/* - * If there is no MAC address in the environment, then it will be initialized - * (silently) from the value in the OTP. - */ -__weak int setup_mac_address(void) -{ - int ret; - int i; - u32 otp[3]; - uchar enetaddr[6]; - struct udevice *dev; - int nb_eth, nb_otp, index; - - if (!IS_ENABLED(CONFIG_NET)) - return 0; - - nb_eth = get_eth_nb(); - - /* 6 bytes for each MAC addr and 4 bytes for each OTP */ - nb_otp = DIV_ROUND_UP(6 * nb_eth, 4); - - ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_DRIVER_GET(stm32mp_bsec), - ); - if (ret) - return ret; - - ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_MAC), otp, 4 * nb_otp); - if (re
[PATCH v2 09/14] stm32mp: stm32prog: add support of stm32mp25
Change OTP number to 364 for STM32MP25 as it is done in bsec driver. Signed-off-by: Patrick Delaunay --- (no changes since v1) arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h index ae4bd8842f53..eda98eb61d76 100644 --- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h +++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h @@ -28,7 +28,15 @@ #else #define OTP_SIZE_SMC 0 #endif -#define OTP_SIZE_TA776 +/* size of the OTP struct in NVMEM PTA */ +#define _OTP_SIZE_TA(otp) (((otp) * 2 + 2) * 4) +#if defined(CONFIG_STM32MP13x) || defined(CONFIG_STM32MP15x) +/* STM32MP1 with BSEC2 */ +#define OTP_SIZE_TA_OTP_SIZE_TA(96) +#else +/* STM32MP2 with BSEC3 */ +#define OTP_SIZE_TA_OTP_SIZE_TA(368) +#endif #define PMIC_SIZE 8 enum stm32prog_target { -- 2.25.1
[PATCH v2 06/14] stm32mp: add soc.c file
Add a new file soc.c for common functions between stm32mp1 and stm32mp2 family and move print_cpuinfo() in this new file. Reviewed-by: Patrice Chotard Signed-off-by: Patrick Delaunay --- (no changes since v1) arch/arm/mach-stm32mp/Makefile | 1 + arch/arm/mach-stm32mp/soc.c | 17 + arch/arm/mach-stm32mp/stm32mp1/cpu.c | 11 --- arch/arm/mach-stm32mp/stm32mp2/cpu.c | 11 --- 4 files changed, 18 insertions(+), 22 deletions(-) create mode 100644 arch/arm/mach-stm32mp/soc.c diff --git a/arch/arm/mach-stm32mp/Makefile b/arch/arm/mach-stm32mp/Makefile index 00dc25bb275c..fdcbbf91dfd5 100644 --- a/arch/arm/mach-stm32mp/Makefile +++ b/arch/arm/mach-stm32mp/Makefile @@ -6,6 +6,7 @@ obj-y += dram_init.o obj-y += syscon.o obj-y += bsec.o +obj-y += soc.o obj-$(CONFIG_STM32MP15x) += stm32mp1/ obj-$(CONFIG_STM32MP13x) += stm32mp1/ diff --git a/arch/arm/mach-stm32mp/soc.c b/arch/arm/mach-stm32mp/soc.c new file mode 100644 index ..8d5fa474ccaf --- /dev/null +++ b/arch/arm/mach-stm32mp/soc.c @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR BSD-3-Clause +/* + * Copyright (C) 2024, STMicroelectronics - All Rights Reserved + */ + +#include + +/* used when CONFIG_DISPLAY_CPUINFO is activated */ +int print_cpuinfo(void) +{ + char name[SOC_NAME_SIZE]; + + get_soc_name(name); + printf("CPU: %s\n", name); + + return 0; +} diff --git a/arch/arm/mach-stm32mp/stm32mp1/cpu.c b/arch/arm/mach-stm32mp/stm32mp1/cpu.c index 55574fd4bebf..00fea7929b2f 100644 --- a/arch/arm/mach-stm32mp/stm32mp1/cpu.c +++ b/arch/arm/mach-stm32mp/stm32mp1/cpu.c @@ -158,17 +158,6 @@ void enable_caches(void) dcache_enable(); } -/* used when CONFIG_DISPLAY_CPUINFO is activated */ -int print_cpuinfo(void) -{ - char name[SOC_NAME_SIZE]; - - get_soc_name(name); - printf("CPU: %s\n", name); - - return 0; -} - static void setup_boot_mode(void) { const u32 serial_addr[] = { diff --git a/arch/arm/mach-stm32mp/stm32mp2/cpu.c b/arch/arm/mach-stm32mp/stm32mp2/cpu.c index f43d1aaf72cc..c0f6519e8d7c 100644 --- a/arch/arm/mach-stm32mp/stm32mp2/cpu.c +++ b/arch/arm/mach-stm32mp/stm32mp2/cpu.c @@ -67,17 +67,6 @@ void enable_caches(void) dcache_enable(); } -/* used when CONFIG_DISPLAY_CPUINFO is activated */ -int print_cpuinfo(void) -{ - char name[SOC_NAME_SIZE]; - - get_soc_name(name); - printf("CPU: %s\n", name); - - return 0; -} - int arch_misc_init(void) { return 0; -- 2.25.1
[PATCH v2 05/14] configs: stm32mp25: add support of fuse command
Add support of the command fuse with CONFIG_CMD_FUSE to allow access on OTP with command line. Reviewed-by: Patrice Chotard Signed-off-by: Patrick Delaunay --- (no changes since v1) configs/stm32mp25_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/stm32mp25_defconfig b/configs/stm32mp25_defconfig index 75f27c98b441..9fbd7eb15755 100644 --- a/configs/stm32mp25_defconfig +++ b/configs/stm32mp25_defconfig @@ -21,6 +21,7 @@ CONFIG_CMD_ADTIMG=y CONFIG_CMD_MEMINFO=y CONFIG_CMD_MEMTEST=y CONFIG_CMD_CLK=y +CONFIG_CMD_FUSE=y CONFIG_CMD_GPIO=y # CONFIG_CMD_LOADB is not set CONFIG_CMD_CACHE=y -- 2.25.1
[PATCH v2 00/14] stm32: add bsec and OTP support to stm32mp25
Add BSEC support to STM32MP25 SoC family with SoC information: - SERIAL number with UUID (BSEC_OTP_DATA5) - RPN = Device part number (BSEC_OTP_DATA9) - PKG = package data register (Bits 2:0 of BSEC_OTP_DATA122) and with board information for STMicroelectronics boards - BOARD identifier: OTP246 - MAC address: OTP247 and after Changes in v2: - fix CONFIG name with 'x': TARGET_ST_STM32MP15x TARGET_ST_STM32MP13x - add "arm: Rename STM32MP13x" - add "arm: Rename STM32MP15x" Patrice Chotard (1): stm32mp: add setup_serial_number for stm32mp25 Patrick Delaunay (12): arm64: dts: st: add bsec support to stm32mp25 stm32mp: bsec: add driver data stm32mp: bsec: add support of stm32mp25 configs: stm32mp25: add support of fuse command stm32mp: add soc.c file smt32mp: add setup_mac_address for stm32mp25 stm32mp: stm32prog: add support of stm32mp25 stm32mp: activate the command stboard for stm32mp25 boards board: st: stm32mp2: add checkboard board: st: stm32mp2: display the board identification arm: Rename STM32MP13x arm: Rename STM32MP15x Yann Gautier (1): arm: stm32mp: add Rev.B support for STM32MP25 arch/arm/dts/Makefile | 4 +- arch/arm/dts/stm32mp15-u-boot.dtsi| 2 +- arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi | 4 +- arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi | 4 +- arch/arm/dts/stm32mp157c-ev1-u-boot.dtsi | 4 +- arch/arm/dts/stm32mp25-u-boot.dtsi| 4 + arch/arm/dts/stm32mp251.dtsi | 16 +++ arch/arm/mach-stm32mp/Kconfig | 8 +- arch/arm/mach-stm32mp/Kconfig.13x | 4 +- arch/arm/mach-stm32mp/Kconfig.15x | 6 +- arch/arm/mach-stm32mp/Makefile| 5 +- arch/arm/mach-stm32mp/bsec.c | 45 +-- arch/arm/mach-stm32mp/cmd_stm32key.c | 20 +-- .../mach-stm32mp/cmd_stm32prog/stm32prog.h| 12 +- arch/arm/mach-stm32mp/include/mach/stm32.h| 22 ++-- .../arm/mach-stm32mp/include/mach/sys_proto.h | 1 + arch/arm/mach-stm32mp/soc.c | 118 ++ arch/arm/mach-stm32mp/stm32mp1/Makefile | 4 +- arch/arm/mach-stm32mp/stm32mp1/cpu.c | 96 +- arch/arm/mach-stm32mp/stm32mp1/fdt.c | 10 +- arch/arm/mach-stm32mp/stm32mp2/cpu.c | 14 +-- arch/arm/mach-stm32mp/stm32mp2/stm32mp25x.c | 3 + board/st/common/Kconfig | 2 +- board/st/common/cmd_stboard.c | 2 + board/st/stm32mp1/Kconfig | 4 +- board/st/stm32mp1/stm32mp1.c | 6 +- board/st/stm32mp2/stm32mp2.c | 37 ++ configs/stm32mp13_defconfig | 4 +- configs/stm32mp15_basic_defconfig | 2 +- configs/stm32mp15_defconfig | 2 +- configs/stm32mp15_trusted_defconfig | 4 +- configs/stm32mp25_defconfig | 1 + drivers/clk/stm32/Kconfig | 4 +- 33 files changed, 297 insertions(+), 177 deletions(-) create mode 100644 arch/arm/mach-stm32mp/soc.c -- 2.25.1
[PATCH v2 04/14] stm32mp: bsec: add support of stm32mp25
Add support of BSEC for STM32MP25x family to access OTP. Reviewed-by: Patrice Chotard Signed-off-by: Patrick Delaunay --- (no changes since v1) arch/arm/mach-stm32mp/bsec.c | 7 +++ arch/arm/mach-stm32mp/include/mach/stm32.h | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-stm32mp/bsec.c b/arch/arm/mach-stm32mp/bsec.c index 705c994d9307..5b869017ec1a 100644 --- a/arch/arm/mach-stm32mp/bsec.c +++ b/arch/arm/mach-stm32mp/bsec.c @@ -784,9 +784,16 @@ static const struct stm32mp_bsec_drvdata stm32mp15_data = { .size = 96, .ta = false, }; + +static const struct stm32mp_bsec_drvdata stm32mp25_data = { + .size = 368, /* 384 but no access to HWKEY and STM32PRVKEY */ + .ta = true, +}; + static const struct udevice_id stm32mp_bsec_ids[] = { { .compatible = "st,stm32mp13-bsec", .data = (ulong)_data}, { .compatible = "st,stm32mp15-bsec", .data = (ulong)_data}, + { .compatible = "st,stm32mp25-bsec", .data = (ulong)_data}, {} }; diff --git a/arch/arm/mach-stm32mp/include/mach/stm32.h b/arch/arm/mach-stm32mp/include/mach/stm32.h index 46d469881b32..45c929aa605d 100644 --- a/arch/arm/mach-stm32mp/include/mach/stm32.h +++ b/arch/arm/mach-stm32mp/include/mach/stm32.h @@ -197,7 +197,8 @@ enum forced_boot_mode { #ifdef CONFIG_STM32MP25X #define BSEC_OTP_SERIAL5 #define BSEC_OTP_RPN 9 -#define BSEC_OTP_PKG 246 +#define BSEC_OTP_PKG 122 +#define BSEC_OTP_MAC 247 #endif #ifndef __ASSEMBLY__ -- 2.25.1
[PATCH v2 03/14] stm32mp: bsec: add driver data
Add driver data in BSEC driver to test presence of OP-TEE TA, mandatory for STM32MP13 family and prepare the support of new device with more OTP than 95. Reviewed-by: Patrice Chotard Signed-off-by: Patrick Delaunay --- (no changes since v1) arch/arm/mach-stm32mp/bsec.c | 38 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/arch/arm/mach-stm32mp/bsec.c b/arch/arm/mach-stm32mp/bsec.c index 28a8280b2804..705c994d9307 100644 --- a/arch/arm/mach-stm32mp/bsec.c +++ b/arch/arm/mach-stm32mp/bsec.c @@ -20,7 +20,6 @@ #include #include -#define BSEC_OTP_MAX_VALUE 95 #define BSEC_OTP_UPPER_START 32 #define BSEC_TIMEOUT_US1 @@ -400,6 +399,11 @@ struct stm32mp_bsec_priv { struct udevice *tee; }; +struct stm32mp_bsec_drvdata { + int size; + bool ta; +}; + static int stm32mp_bsec_read_otp(struct udevice *dev, u32 *val, u32 otp) { struct stm32mp_bsec_plat *plat; @@ -609,6 +613,7 @@ static int stm32mp_bsec_read(struct udevice *dev, int offset, void *buf, int size) { struct stm32mp_bsec_priv *priv = dev_get_priv(dev); + struct stm32mp_bsec_drvdata *data = (struct stm32mp_bsec_drvdata *)dev_get_driver_data(dev); int ret; int i; bool shadow = true, lock = false; @@ -642,7 +647,7 @@ static int stm32mp_bsec_read(struct udevice *dev, int offset, otp = offs / sizeof(u32); - for (i = otp; i < (otp + nb_otp) && i <= BSEC_OTP_MAX_VALUE; i++) { + for (i = otp; i < (otp + nb_otp) && i < data->size; i++) { u32 *addr = &((u32 *)buf)[i - otp]; if (lock) @@ -665,6 +670,7 @@ static int stm32mp_bsec_write(struct udevice *dev, int offset, const void *buf, int size) { struct stm32mp_bsec_priv *priv = dev_get_priv(dev); + struct stm32mp_bsec_drvdata *data = (struct stm32mp_bsec_drvdata *)dev_get_driver_data(dev); int ret = 0; int i; bool shadow = true, lock = false; @@ -698,7 +704,7 @@ static int stm32mp_bsec_write(struct udevice *dev, int offset, otp = offs / sizeof(u32); - for (i = otp; i < otp + nb_otp && i <= BSEC_OTP_MAX_VALUE; i++) { + for (i = otp; i < otp + nb_otp && i < data->size; i++) { u32 *val = &((u32 *)buf)[i - otp]; if (lock) @@ -732,6 +738,7 @@ static int stm32mp_bsec_of_to_plat(struct udevice *dev) static int stm32mp_bsec_probe(struct udevice *dev) { + struct stm32mp_bsec_drvdata *data = (struct stm32mp_bsec_drvdata *)dev_get_driver_data(dev); int otp; struct stm32mp_bsec_plat *plat; struct clk_bulk clk_bulk; @@ -745,16 +752,22 @@ static int stm32mp_bsec_probe(struct udevice *dev) } if (IS_ENABLED(CONFIG_OPTEE)) - bsec_optee_open(dev); + ret = bsec_optee_open(dev); + else + ret = -ENOTSUPP; + /* failed if OP-TEE TA is required */ + if (data->ta && !ret) + return ret; /* * update unlocked shadow for OTP cleared by the rom code * only executed in SPL, it is done in TF-A for TFABOOT */ - if (IS_ENABLED(CONFIG_SPL_BUILD)) { + if (IS_ENABLED(CONFIG_SPL_BUILD) && !data->ta) { plat = dev_get_plat(dev); - for (otp = 57; otp <= BSEC_OTP_MAX_VALUE; otp++) + /* here 57 is the value for STM32MP15x ROM code, only MPU with SPL support*/ + for (otp = 57; otp < data->size; otp++) if (!bsec_read_SR_lock(plat->base, otp)) bsec_shadow_register(dev, plat->base, otp); } @@ -762,9 +775,18 @@ static int stm32mp_bsec_probe(struct udevice *dev) return 0; } +static const struct stm32mp_bsec_drvdata stm32mp13_data = { + .size = 96, + .ta = true, +}; + +static const struct stm32mp_bsec_drvdata stm32mp15_data = { + .size = 96, + .ta = false, +}; static const struct udevice_id stm32mp_bsec_ids[] = { - { .compatible = "st,stm32mp13-bsec" }, - { .compatible = "st,stm32mp15-bsec" }, + { .compatible = "st,stm32mp13-bsec", .data = (ulong)_data}, + { .compatible = "st,stm32mp15-bsec", .data = (ulong)_data}, {} }; -- 2.25.1
[PATCH v2 02/14] arm: stm32mp: add Rev.B support for STM32MP25
From: Yann Gautier Add chip revision B support for STM32MP25, for displaying it in trace. Reviewed-by: Patrice Chotard Signed-off-by: Yann Gautier Signed-off-by: Patrick Delaunay --- (no changes since v1) arch/arm/mach-stm32mp/stm32mp2/stm32mp25x.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm/mach-stm32mp/stm32mp2/stm32mp25x.c b/arch/arm/mach-stm32mp/stm32mp2/stm32mp25x.c index 4b2f70af9cc6..7f896a0d65d2 100644 --- a/arch/arm/mach-stm32mp/stm32mp2/stm32mp25x.c +++ b/arch/arm/mach-stm32mp/stm32mp2/stm32mp25x.c @@ -167,6 +167,9 @@ void get_soc_name(char name[SOC_NAME_SIZE]) case CPU_REV1: cpu_r = "A"; break; + case CPU_REV2: + cpu_r = "B"; + break; default: break; } -- 2.25.1
[PATCH v2 01/14] arm64: dts: st: add bsec support to stm32mp25
Add BSEC support to STM32MP25 SoC family with SoC information: - RPN = Device part number (BSEC_OTP_DATA9) - PKG = package data register (Bits 2:0 of BSEC_OTP_DATA122) Reviewed-by: Patrice Chotard Signed-off-by: Patrick Delaunay Signed-off-by: Alexandre Torgue --- (no changes since v1) arch/arm/dts/stm32mp25-u-boot.dtsi | 4 arch/arm/dts/stm32mp251.dtsi | 16 2 files changed, 20 insertions(+) diff --git a/arch/arm/dts/stm32mp25-u-boot.dtsi b/arch/arm/dts/stm32mp25-u-boot.dtsi index f4f26add2a41..0c8e95b34163 100644 --- a/arch/arm/dts/stm32mp25-u-boot.dtsi +++ b/arch/arm/dts/stm32mp25-u-boot.dtsi @@ -37,6 +37,10 @@ }; }; + { + bootph-all; +}; + { bootph-all; }; diff --git a/arch/arm/dts/stm32mp251.dtsi b/arch/arm/dts/stm32mp251.dtsi index cf2f28dc1582..44eb664fb510 100644 --- a/arch/arm/dts/stm32mp251.dtsi +++ b/arch/arm/dts/stm32mp251.dtsi @@ -127,6 +127,22 @@ }; }; + bsec: efuse@4400 { + compatible = "st,stm32mp25-bsec"; + reg = <0x4400 0x1000>; + #address-cells = <1>; + #size-cells = <1>; + + part_number_otp@24 { + reg = <0x24 0x4>; + }; + + package_otp@1e8 { + reg = <0x1e8 0x1>; + bits = <0 3>; + }; + }; + syscfg: syscon@4423 { compatible = "st,stm32mp25-syscfg", "syscon"; reg = <0x4423 0x1>; -- 2.25.1
Re: [PATCH 10/12] stm32mp: activate the command stboard for stm32mp25 boards
Hi, On 1/15/24 14:03, Patrice CHOTARD wrote: On 1/15/24 13:46, Patrick Delaunay wrote: Activate the command stboard for stm32mp25 STMicroelectronics boards, add the default used OTP identifier and the associated board identifier: - stm32mp25xx-ev1 = MB1936 - stm32mp25xx-dk = MB1605 Signed-off-by: Patrick Delaunay --- arch/arm/mach-stm32mp/include/mach/stm32.h | 1 + board/st/common/Kconfig| 2 +- board/st/common/cmd_stboard.c | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-stm32mp/include/mach/stm32.h b/arch/arm/mach-stm32mp/include/mach/stm32.h index 45c929aa605d..726c390977e3 100644 --- a/arch/arm/mach-stm32mp/include/mach/stm32.h +++ b/arch/arm/mach-stm32mp/include/mach/stm32.h @@ -198,6 +198,7 @@ enum forced_boot_mode { #define BSEC_OTP_SERIAL 5 #define BSEC_OTP_RPN 9 #define BSEC_OTP_PKG 122 +#define BSEC_OTP_BOARD 246 #define BSEC_OTP_MAC 247 #endif diff --git a/board/st/common/Kconfig b/board/st/common/Kconfig index c1c254d07354..5efac658cf4d 100644 --- a/board/st/common/Kconfig +++ b/board/st/common/Kconfig @@ -1,7 +1,7 @@ config CMD_STBOARD bool "stboard - command for OTP board information" depends on ARCH_STM32MP - default y if TARGET_ST_STM32MP15x || TARGET_ST_STM32MP13x + default y if TARGET_ST_STM32MP25X || TARGET_ST_STM32MP15X || TARGET_ST_STM32MP13X TARGET_ST_STM32MP15x or TARGET_ST_STM32MP15X ? ;-) Internally, we use all our flags in uppercase, whereas at upstream there are some camelcase as TARGET_ST_STM32MP15x or TARGET_ST_STM32MP13x Thks, I don't see that the Simon patches was not merged. I will correct this part in V2 and also include the 2 Simon patches which rename the stm32mp config to avoid the same issue in futur. See series "Clean up of bad Kconfig options" https://patchwork.ozlabs.org/project/uboot/list/?series=339004=* => [v2,67/87] arm: Rename STM32MP13x https://patchwork.ozlabs.org/project/uboot/patch/20230129005903.74918-68-...@chromium.org/ => [v2,68/87] arm: Rename STM32MP15x https://patchwork.ozlabs.org/project/uboot/patch/20230129005903.74918-69-...@chromium.org/ help This compile the stboard command to read and write the board in the OTP. diff --git a/board/st/common/cmd_stboard.c b/board/st/common/cmd_stboard.c index 853ab78bbf16..cb103e69b369 100644 --- a/board/st/common/cmd_stboard.c +++ b/board/st/common/cmd_stboard.c @@ -49,7 +49,9 @@ static bool check_stboard(u16 board) 0x1298, 0x1341, 0x1497, + 0x1605, /* stm32mp25xx-dk */ 0x1635, + 0x1936, /* stm32mp25xx-ev1 */ }; for (i = 0; i < ARRAY_SIZE(st_board_id); i++)
[PATCH] smt32mp: Add dependencies on CMDLINE for command stm32key
We cannot use stm32key commands without CONFIG_CMDLINE so add the required condition. Signed-off-by: Patrick Delaunay --- arch/arm/mach-stm32mp/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/mach-stm32mp/Kconfig b/arch/arm/mach-stm32mp/Kconfig index 5fc92d07fe6d..c6c89883f2b0 100644 --- a/arch/arm/mach-stm32mp/Kconfig +++ b/arch/arm/mach-stm32mp/Kconfig @@ -144,6 +144,7 @@ config STM32_ECDSA_VERIFY config CMD_STM32KEY bool "command stm32key to fuse public key hash" + depends on CMDLINE help fuse public key hash in corresponding fuse used to authenticate binary. -- 2.25.1
[PATCH 12/12] board: st: stm32mp2: display the board identification
Add the display of the STMicroelectronics board identification saved in OTP in stm32mp2 checkboard function. Signed-off-by: Patrick Delaunay --- board/st/stm32mp2/stm32mp2.c | 23 +++ 1 file changed, 23 insertions(+) diff --git a/board/st/stm32mp2/stm32mp2.c b/board/st/stm32mp2/stm32mp2.c index 9a881583d904..aa7dd31996ea 100644 --- a/board/st/stm32mp2/stm32mp2.c +++ b/board/st/stm32mp2/stm32mp2.c @@ -9,9 +9,12 @@ #include #include #include +#include #include #include +#include #include +#include /* * Get a global data pointer @@ -20,6 +23,9 @@ DECLARE_GLOBAL_DATA_PTR; int checkboard(void) { + int ret; + u32 otp; + struct udevice *dev; const char *fdt_compat; int fdt_compat_len; @@ -27,6 +33,23 @@ int checkboard(void) log_info("Board: stm32mp2 (%s)\n", fdt_compat && fdt_compat_len ? fdt_compat : ""); + /* display the STMicroelectronics board identification */ + if (CONFIG_IS_ENABLED(CMD_STBOARD)) { + ret = uclass_get_device_by_driver(UCLASS_MISC, + DM_DRIVER_GET(stm32mp_bsec), + ); + if (!ret) + ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_BOARD), + , sizeof(otp)); + if (ret > 0 && otp) + log_info("Board: MB%04x Var%d.%d Rev.%c-%02d\n", +otp >> 16, +(otp >> 12) & 0xF, +(otp >> 4) & 0xF, +((otp >> 8) & 0xF) - 1 + 'A', +otp & 0xF); + } + return 0; } -- 2.25.1
[PATCH 10/12] stm32mp: activate the command stboard for stm32mp25 boards
Activate the command stboard for stm32mp25 STMicroelectronics boards, add the default used OTP identifier and the associated board identifier: - stm32mp25xx-ev1 = MB1936 - stm32mp25xx-dk = MB1605 Signed-off-by: Patrick Delaunay --- arch/arm/mach-stm32mp/include/mach/stm32.h | 1 + board/st/common/Kconfig| 2 +- board/st/common/cmd_stboard.c | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-stm32mp/include/mach/stm32.h b/arch/arm/mach-stm32mp/include/mach/stm32.h index 45c929aa605d..726c390977e3 100644 --- a/arch/arm/mach-stm32mp/include/mach/stm32.h +++ b/arch/arm/mach-stm32mp/include/mach/stm32.h @@ -198,6 +198,7 @@ enum forced_boot_mode { #define BSEC_OTP_SERIAL5 #define BSEC_OTP_RPN 9 #define BSEC_OTP_PKG 122 +#define BSEC_OTP_BOARD 246 #define BSEC_OTP_MAC 247 #endif diff --git a/board/st/common/Kconfig b/board/st/common/Kconfig index c1c254d07354..5efac658cf4d 100644 --- a/board/st/common/Kconfig +++ b/board/st/common/Kconfig @@ -1,7 +1,7 @@ config CMD_STBOARD bool "stboard - command for OTP board information" depends on ARCH_STM32MP - default y if TARGET_ST_STM32MP15x || TARGET_ST_STM32MP13x + default y if TARGET_ST_STM32MP25X || TARGET_ST_STM32MP15X || TARGET_ST_STM32MP13X help This compile the stboard command to read and write the board in the OTP. diff --git a/board/st/common/cmd_stboard.c b/board/st/common/cmd_stboard.c index 853ab78bbf16..cb103e69b369 100644 --- a/board/st/common/cmd_stboard.c +++ b/board/st/common/cmd_stboard.c @@ -49,7 +49,9 @@ static bool check_stboard(u16 board) 0x1298, 0x1341, 0x1497, + 0x1605, /* stm32mp25xx-dk */ 0x1635, + 0x1936, /* stm32mp25xx-ev1 */ }; for (i = 0; i < ARRAY_SIZE(st_board_id); i++) -- 2.25.1
[PATCH 11/12] board: st: stm32mp2: add checkboard
Implement the weak function checkboard to identify the used board with compatible in device tree for the support of stm32mp2 STMicroelectronics boards. Signed-off-by: Patrick Delaunay --- board/st/stm32mp2/stm32mp2.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/board/st/stm32mp2/stm32mp2.c b/board/st/stm32mp2/stm32mp2.c index c97a7efff46e..9a881583d904 100644 --- a/board/st/stm32mp2/stm32mp2.c +++ b/board/st/stm32mp2/stm32mp2.c @@ -8,14 +8,28 @@ #include #include #include +#include #include #include +#include /* * Get a global data pointer */ DECLARE_GLOBAL_DATA_PTR; +int checkboard(void) +{ + const char *fdt_compat; + int fdt_compat_len; + + fdt_compat = ofnode_get_property(ofnode_root(), "compatible", _compat_len); + + log_info("Board: stm32mp2 (%s)\n", fdt_compat && fdt_compat_len ? fdt_compat : ""); + + return 0; +} + /* board dependent setup after realloc */ int board_init(void) { -- 2.25.1
[PATCH 08/12] smt32mp: add setup_mac_address for stm32mp25
Add a function setup_mac_address() to update the MAC address from the default location in OTP for stm32mp2 platform. The max number of OTP for MAC address is increased to 8 for STM32MP25, defined with get_eth_nb() and checked in setup_mac_address. The MAC address FF:FF:FF:FF:FF:FF, the broadcast ethaddr, is a invalid value used for unused MAC address slot in OTP, for example for board with STM32MP25x part number allows up to 5 ethernet ports but it is not supported by the hardware, without switch; the associated variable "enetaddr%d" is not created. Signed-off-by: Patrick Delaunay --- arch/arm/mach-stm32mp/soc.c | 70 arch/arm/mach-stm32mp/stm32mp1/cpu.c | 58 +-- arch/arm/mach-stm32mp/stm32mp2/cpu.c | 1 + 3 files changed, 72 insertions(+), 57 deletions(-) diff --git a/arch/arm/mach-stm32mp/soc.c b/arch/arm/mach-stm32mp/soc.c index ff70ebe97464..fa56b0d2e0f1 100644 --- a/arch/arm/mach-stm32mp/soc.c +++ b/arch/arm/mach-stm32mp/soc.c @@ -5,10 +5,14 @@ #include #include +#include #include #include #include +/* max: 8 OTP for 5 mac address on stm32mp2*/ +#define MAX_NB_OTP 8 + /* used when CONFIG_DISPLAY_CPUINFO is activated */ int print_cpuinfo(void) { @@ -46,3 +50,69 @@ int setup_serial_number(void) return 0; } + +/* + * If there is no MAC address in the environment, then it will be initialized + * (silently) from the value in the OTP. + */ +__weak int setup_mac_address(void) +{ + int ret; + int i; + u32 otp[MAX_NB_OTP]; + uchar enetaddr[ARP_HLEN]; + struct udevice *dev; + int nb_eth, nb_otp, index; + + if (!IS_ENABLED(CONFIG_NET)) + return 0; + + nb_eth = get_eth_nb(); + if (!nb_eth) + return 0; + + /* 6 bytes for each MAC addr and 4 bytes for each OTP */ + nb_otp = DIV_ROUND_UP(ARP_HLEN * nb_eth, 4); + if (nb_otp > MAX_NB_OTP) { + log_err("invalid number of OTP = %d, max = %d\n", nb_otp, MAX_NB_OTP); + return -EINVAL; + } + + ret = uclass_get_device_by_driver(UCLASS_MISC, + DM_DRIVER_GET(stm32mp_bsec), + ); + if (ret) + return ret; + + ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_MAC), otp, 4 * nb_otp); + if (ret < 0) + return ret; + + for (index = 0; index < nb_eth; index++) { + /* MAC already in environment */ + if (eth_env_get_enetaddr_by_index("eth", index, enetaddr)) + continue; + + for (i = 0; i < ARP_HLEN; i++) + enetaddr[i] = ((uint8_t *))[i + ARP_HLEN * index]; + + /* skip FF:FF:FF:FF:FF:FF */ + if (is_broadcast_ethaddr(enetaddr)) + continue; + + if (!is_valid_ethaddr(enetaddr)) { + log_err("invalid MAC address %d in OTP %pM\n", + index, enetaddr); + return -EINVAL; + } + log_debug("OTP MAC address %d = %pM\n", index, enetaddr); + ret = eth_env_set_enetaddr_by_index("eth", index, enetaddr); + if (ret) { + log_err("Failed to set mac address %pM from OTP: %d\n", + enetaddr, ret); + return ret; + } + } + + return 0; +} diff --git a/arch/arm/mach-stm32mp/stm32mp1/cpu.c b/arch/arm/mach-stm32mp/stm32mp1/cpu.c index f84cb26fa565..524778f00c67 100644 --- a/arch/arm/mach-stm32mp/stm32mp1/cpu.c +++ b/arch/arm/mach-stm32mp/stm32mp1/cpu.c @@ -14,8 +14,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -280,62 +280,6 @@ static void setup_boot_mode(void) clrsetbits_le32(TAMP_BOOT_CONTEXT, TAMP_BOOT_FORCED_MASK, BOOT_NORMAL); } -/* - * If there is no MAC address in the environment, then it will be initialized - * (silently) from the value in the OTP. - */ -__weak int setup_mac_address(void) -{ - int ret; - int i; - u32 otp[3]; - uchar enetaddr[6]; - struct udevice *dev; - int nb_eth, nb_otp, index; - - if (!IS_ENABLED(CONFIG_NET)) - return 0; - - nb_eth = get_eth_nb(); - - /* 6 bytes for each MAC addr and 4 bytes for each OTP */ - nb_otp = DIV_ROUND_UP(6 * nb_eth, 4); - - ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_DRIVER_GET(stm32mp_bsec), - ); - if (ret) - return ret; - - ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_MAC), otp, 4 * nb_otp); - if (ret < 0) - return ret; - - for
[PATCH 07/12] stm32mp: add setup_serial_number for stm32mp25
From: Patrice Chotard Add support of serial number for stm32mp25, gets from OTP with BSEC driver. Signed-off-by: Patrice Chotard Signed-off-by: Patrick Delaunay --- .../arm/mach-stm32mp/include/mach/sys_proto.h | 1 + arch/arm/mach-stm32mp/soc.c | 31 +++ arch/arm/mach-stm32mp/stm32mp1/cpu.c | 27 arch/arm/mach-stm32mp/stm32mp2/cpu.c | 2 ++ 4 files changed, 34 insertions(+), 27 deletions(-) diff --git a/arch/arm/mach-stm32mp/include/mach/sys_proto.h b/arch/arm/mach-stm32mp/include/mach/sys_proto.h index 83388fdb7371..2a65efc0a50a 100644 --- a/arch/arm/mach-stm32mp/include/mach/sys_proto.h +++ b/arch/arm/mach-stm32mp/include/mach/sys_proto.h @@ -97,6 +97,7 @@ u32 get_bootauth(void); int get_eth_nb(void); int setup_mac_address(void); +int setup_serial_number(void); /* board power management : configure vddcore according OPP */ void board_vddcore_init(u32 voltage_mv); diff --git a/arch/arm/mach-stm32mp/soc.c b/arch/arm/mach-stm32mp/soc.c index 8d5fa474ccaf..ff70ebe97464 100644 --- a/arch/arm/mach-stm32mp/soc.c +++ b/arch/arm/mach-stm32mp/soc.c @@ -3,7 +3,11 @@ * Copyright (C) 2024, STMicroelectronics - All Rights Reserved */ +#include +#include #include +#include +#include /* used when CONFIG_DISPLAY_CPUINFO is activated */ int print_cpuinfo(void) @@ -15,3 +19,30 @@ int print_cpuinfo(void) return 0; } + +int setup_serial_number(void) +{ + char serial_string[25]; + u32 otp[3] = {0, 0, 0 }; + struct udevice *dev; + int ret; + + if (env_get("serial#")) + return 0; + + ret = uclass_get_device_by_driver(UCLASS_MISC, + DM_DRIVER_GET(stm32mp_bsec), + ); + if (ret) + return ret; + + ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_SERIAL), + otp, sizeof(otp)); + if (ret < 0) + return ret; + + sprintf(serial_string, "%08X%08X%08X", otp[0], otp[1], otp[2]); + env_set("serial#", serial_string); + + return 0; +} diff --git a/arch/arm/mach-stm32mp/stm32mp1/cpu.c b/arch/arm/mach-stm32mp/stm32mp1/cpu.c index 00fea7929b2f..f84cb26fa565 100644 --- a/arch/arm/mach-stm32mp/stm32mp1/cpu.c +++ b/arch/arm/mach-stm32mp/stm32mp1/cpu.c @@ -336,33 +336,6 @@ __weak int setup_mac_address(void) return 0; } -static int setup_serial_number(void) -{ - char serial_string[25]; - u32 otp[3] = {0, 0, 0 }; - struct udevice *dev; - int ret; - - if (env_get("serial#")) - return 0; - - ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_DRIVER_GET(stm32mp_bsec), - ); - if (ret) - return ret; - - ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_SERIAL), - otp, sizeof(otp)); - if (ret < 0) - return ret; - - sprintf(serial_string, "%08X%08X%08X", otp[0], otp[1], otp[2]); - env_set("serial#", serial_string); - - return 0; -} - __weak void stm32mp_misc_init(void) { } diff --git a/arch/arm/mach-stm32mp/stm32mp2/cpu.c b/arch/arm/mach-stm32mp/stm32mp2/cpu.c index c0f6519e8d7c..301e365cf4f4 100644 --- a/arch/arm/mach-stm32mp/stm32mp2/cpu.c +++ b/arch/arm/mach-stm32mp/stm32mp2/cpu.c @@ -69,6 +69,8 @@ void enable_caches(void) int arch_misc_init(void) { + setup_serial_number(); + return 0; } -- 2.25.1
[PATCH 09/12] stm32mp: stm32prog: add support of stm32mp25
Change OTP number to 364 for STM32MP25 as it is done in bsec driver. Signed-off-by: Patrick Delaunay --- arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h index ae4bd8842f53..eda98eb61d76 100644 --- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h +++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h @@ -28,7 +28,15 @@ #else #define OTP_SIZE_SMC 0 #endif -#define OTP_SIZE_TA776 +/* size of the OTP struct in NVMEM PTA */ +#define _OTP_SIZE_TA(otp) (((otp) * 2 + 2) * 4) +#if defined(CONFIG_STM32MP13x) || defined(CONFIG_STM32MP15x) +/* STM32MP1 with BSEC2 */ +#define OTP_SIZE_TA_OTP_SIZE_TA(96) +#else +/* STM32MP2 with BSEC3 */ +#define OTP_SIZE_TA_OTP_SIZE_TA(368) +#endif #define PMIC_SIZE 8 enum stm32prog_target { -- 2.25.1
[PATCH 06/12] stm32mp: add soc.c file
Add a new file soc.c for common functions between stm32mp1 and stm32mp2 family and move print_cpuinfo() in this new file. Signed-off-by: Patrick Delaunay --- arch/arm/mach-stm32mp/Makefile | 1 + arch/arm/mach-stm32mp/soc.c | 17 + arch/arm/mach-stm32mp/stm32mp1/cpu.c | 11 --- arch/arm/mach-stm32mp/stm32mp2/cpu.c | 11 --- 4 files changed, 18 insertions(+), 22 deletions(-) create mode 100644 arch/arm/mach-stm32mp/soc.c diff --git a/arch/arm/mach-stm32mp/Makefile b/arch/arm/mach-stm32mp/Makefile index 00dc25bb275c..fdcbbf91dfd5 100644 --- a/arch/arm/mach-stm32mp/Makefile +++ b/arch/arm/mach-stm32mp/Makefile @@ -6,6 +6,7 @@ obj-y += dram_init.o obj-y += syscon.o obj-y += bsec.o +obj-y += soc.o obj-$(CONFIG_STM32MP15x) += stm32mp1/ obj-$(CONFIG_STM32MP13x) += stm32mp1/ diff --git a/arch/arm/mach-stm32mp/soc.c b/arch/arm/mach-stm32mp/soc.c new file mode 100644 index ..8d5fa474ccaf --- /dev/null +++ b/arch/arm/mach-stm32mp/soc.c @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR BSD-3-Clause +/* + * Copyright (C) 2024, STMicroelectronics - All Rights Reserved + */ + +#include + +/* used when CONFIG_DISPLAY_CPUINFO is activated */ +int print_cpuinfo(void) +{ + char name[SOC_NAME_SIZE]; + + get_soc_name(name); + printf("CPU: %s\n", name); + + return 0; +} diff --git a/arch/arm/mach-stm32mp/stm32mp1/cpu.c b/arch/arm/mach-stm32mp/stm32mp1/cpu.c index 55574fd4bebf..00fea7929b2f 100644 --- a/arch/arm/mach-stm32mp/stm32mp1/cpu.c +++ b/arch/arm/mach-stm32mp/stm32mp1/cpu.c @@ -158,17 +158,6 @@ void enable_caches(void) dcache_enable(); } -/* used when CONFIG_DISPLAY_CPUINFO is activated */ -int print_cpuinfo(void) -{ - char name[SOC_NAME_SIZE]; - - get_soc_name(name); - printf("CPU: %s\n", name); - - return 0; -} - static void setup_boot_mode(void) { const u32 serial_addr[] = { diff --git a/arch/arm/mach-stm32mp/stm32mp2/cpu.c b/arch/arm/mach-stm32mp/stm32mp2/cpu.c index f43d1aaf72cc..c0f6519e8d7c 100644 --- a/arch/arm/mach-stm32mp/stm32mp2/cpu.c +++ b/arch/arm/mach-stm32mp/stm32mp2/cpu.c @@ -67,17 +67,6 @@ void enable_caches(void) dcache_enable(); } -/* used when CONFIG_DISPLAY_CPUINFO is activated */ -int print_cpuinfo(void) -{ - char name[SOC_NAME_SIZE]; - - get_soc_name(name); - printf("CPU: %s\n", name); - - return 0; -} - int arch_misc_init(void) { return 0; -- 2.25.1
[PATCH 05/12] configs: stm32mp25: add support of fuse command
Add support of the command fuse with CONFIG_CMD_FUSE to allow access on OTP with command line. Signed-off-by: Patrick Delaunay --- configs/stm32mp25_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/stm32mp25_defconfig b/configs/stm32mp25_defconfig index 75f27c98b441..9fbd7eb15755 100644 --- a/configs/stm32mp25_defconfig +++ b/configs/stm32mp25_defconfig @@ -21,6 +21,7 @@ CONFIG_CMD_ADTIMG=y CONFIG_CMD_MEMINFO=y CONFIG_CMD_MEMTEST=y CONFIG_CMD_CLK=y +CONFIG_CMD_FUSE=y CONFIG_CMD_GPIO=y # CONFIG_CMD_LOADB is not set CONFIG_CMD_CACHE=y -- 2.25.1
[PATCH 04/12] stm32mp: bsec: add support of stm32mp25
Add support of BSEC for STM32MP25x family to access OTP. Signed-off-by: Patrick Delaunay --- arch/arm/mach-stm32mp/bsec.c | 7 +++ arch/arm/mach-stm32mp/include/mach/stm32.h | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-stm32mp/bsec.c b/arch/arm/mach-stm32mp/bsec.c index 705c994d9307..5b869017ec1a 100644 --- a/arch/arm/mach-stm32mp/bsec.c +++ b/arch/arm/mach-stm32mp/bsec.c @@ -784,9 +784,16 @@ static const struct stm32mp_bsec_drvdata stm32mp15_data = { .size = 96, .ta = false, }; + +static const struct stm32mp_bsec_drvdata stm32mp25_data = { + .size = 368, /* 384 but no access to HWKEY and STM32PRVKEY */ + .ta = true, +}; + static const struct udevice_id stm32mp_bsec_ids[] = { { .compatible = "st,stm32mp13-bsec", .data = (ulong)_data}, { .compatible = "st,stm32mp15-bsec", .data = (ulong)_data}, + { .compatible = "st,stm32mp25-bsec", .data = (ulong)_data}, {} }; diff --git a/arch/arm/mach-stm32mp/include/mach/stm32.h b/arch/arm/mach-stm32mp/include/mach/stm32.h index 46d469881b32..45c929aa605d 100644 --- a/arch/arm/mach-stm32mp/include/mach/stm32.h +++ b/arch/arm/mach-stm32mp/include/mach/stm32.h @@ -197,7 +197,8 @@ enum forced_boot_mode { #ifdef CONFIG_STM32MP25X #define BSEC_OTP_SERIAL5 #define BSEC_OTP_RPN 9 -#define BSEC_OTP_PKG 246 +#define BSEC_OTP_PKG 122 +#define BSEC_OTP_MAC 247 #endif #ifndef __ASSEMBLY__ -- 2.25.1
[PATCH 00/12] stm32: add bsec and OTP support to stm32mp25
Add BSEC support to STM32MP25 SoC family with SoC information: - SERIAL number with UUID (BSEC_OTP_DATA5) - RPN = Device part number (BSEC_OTP_DATA9) - PKG = package data register (Bits 2:0 of BSEC_OTP_DATA122) and with board information for STMicroelectronics boards - BOARD identifier: OTP246 - MAC address: OTP247 and after Patrice Chotard (1): stm32mp: add setup_serial_number for stm32mp25 Patrick Delaunay (10): arm64: dts: st: add bsec support to stm32mp25 stm32mp: bsec: add driver data stm32mp: bsec: add support of stm32mp25 configs: stm32mp25: add support of fuse command stm32mp: add soc.c file smt32mp: add setup_mac_address for stm32mp25 stm32mp: stm32prog: add support of stm32mp25 stm32mp: activate the command stboard for stm32mp25 boards board: st: stm32mp2: add checkboard board: st: stm32mp2: display the board identification Yann Gautier (1): arm: stm32mp: add Rev.B support for STM32MP25 arch/arm/dts/stm32mp25-u-boot.dtsi| 4 + arch/arm/dts/stm32mp251.dtsi | 16 +++ arch/arm/mach-stm32mp/Makefile| 1 + arch/arm/mach-stm32mp/bsec.c | 45 +-- .../mach-stm32mp/cmd_stm32prog/stm32prog.h| 10 +- arch/arm/mach-stm32mp/include/mach/stm32.h| 4 +- .../arm/mach-stm32mp/include/mach/sys_proto.h | 1 + arch/arm/mach-stm32mp/soc.c | 118 ++ arch/arm/mach-stm32mp/stm32mp1/cpu.c | 96 +- arch/arm/mach-stm32mp/stm32mp2/cpu.c | 14 +-- arch/arm/mach-stm32mp/stm32mp2/stm32mp25x.c | 3 + board/st/common/Kconfig | 2 +- board/st/common/cmd_stboard.c | 2 + board/st/stm32mp2/stm32mp2.c | 37 ++ configs/stm32mp25_defconfig | 1 + 15 files changed, 237 insertions(+), 117 deletions(-) create mode 100644 arch/arm/mach-stm32mp/soc.c -- 2.25.1
[PATCH 03/12] stm32mp: bsec: add driver data
Add driver data in BSEC driver to test presence of OP-TEE TA, mandatory for STM32MP13 family and prepare the support of new device with more OTP than 95. Signed-off-by: Patrick Delaunay --- arch/arm/mach-stm32mp/bsec.c | 38 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/arch/arm/mach-stm32mp/bsec.c b/arch/arm/mach-stm32mp/bsec.c index 28a8280b2804..705c994d9307 100644 --- a/arch/arm/mach-stm32mp/bsec.c +++ b/arch/arm/mach-stm32mp/bsec.c @@ -20,7 +20,6 @@ #include #include -#define BSEC_OTP_MAX_VALUE 95 #define BSEC_OTP_UPPER_START 32 #define BSEC_TIMEOUT_US1 @@ -400,6 +399,11 @@ struct stm32mp_bsec_priv { struct udevice *tee; }; +struct stm32mp_bsec_drvdata { + int size; + bool ta; +}; + static int stm32mp_bsec_read_otp(struct udevice *dev, u32 *val, u32 otp) { struct stm32mp_bsec_plat *plat; @@ -609,6 +613,7 @@ static int stm32mp_bsec_read(struct udevice *dev, int offset, void *buf, int size) { struct stm32mp_bsec_priv *priv = dev_get_priv(dev); + struct stm32mp_bsec_drvdata *data = (struct stm32mp_bsec_drvdata *)dev_get_driver_data(dev); int ret; int i; bool shadow = true, lock = false; @@ -642,7 +647,7 @@ static int stm32mp_bsec_read(struct udevice *dev, int offset, otp = offs / sizeof(u32); - for (i = otp; i < (otp + nb_otp) && i <= BSEC_OTP_MAX_VALUE; i++) { + for (i = otp; i < (otp + nb_otp) && i < data->size; i++) { u32 *addr = &((u32 *)buf)[i - otp]; if (lock) @@ -665,6 +670,7 @@ static int stm32mp_bsec_write(struct udevice *dev, int offset, const void *buf, int size) { struct stm32mp_bsec_priv *priv = dev_get_priv(dev); + struct stm32mp_bsec_drvdata *data = (struct stm32mp_bsec_drvdata *)dev_get_driver_data(dev); int ret = 0; int i; bool shadow = true, lock = false; @@ -698,7 +704,7 @@ static int stm32mp_bsec_write(struct udevice *dev, int offset, otp = offs / sizeof(u32); - for (i = otp; i < otp + nb_otp && i <= BSEC_OTP_MAX_VALUE; i++) { + for (i = otp; i < otp + nb_otp && i < data->size; i++) { u32 *val = &((u32 *)buf)[i - otp]; if (lock) @@ -732,6 +738,7 @@ static int stm32mp_bsec_of_to_plat(struct udevice *dev) static int stm32mp_bsec_probe(struct udevice *dev) { + struct stm32mp_bsec_drvdata *data = (struct stm32mp_bsec_drvdata *)dev_get_driver_data(dev); int otp; struct stm32mp_bsec_plat *plat; struct clk_bulk clk_bulk; @@ -745,16 +752,22 @@ static int stm32mp_bsec_probe(struct udevice *dev) } if (IS_ENABLED(CONFIG_OPTEE)) - bsec_optee_open(dev); + ret = bsec_optee_open(dev); + else + ret = -ENOTSUPP; + /* failed if OP-TEE TA is required */ + if (data->ta && !ret) + return ret; /* * update unlocked shadow for OTP cleared by the rom code * only executed in SPL, it is done in TF-A for TFABOOT */ - if (IS_ENABLED(CONFIG_SPL_BUILD)) { + if (IS_ENABLED(CONFIG_SPL_BUILD) && !data->ta) { plat = dev_get_plat(dev); - for (otp = 57; otp <= BSEC_OTP_MAX_VALUE; otp++) + /* here 57 is the value for STM32MP15x ROM code, only MPU with SPL support*/ + for (otp = 57; otp < data->size; otp++) if (!bsec_read_SR_lock(plat->base, otp)) bsec_shadow_register(dev, plat->base, otp); } @@ -762,9 +775,18 @@ static int stm32mp_bsec_probe(struct udevice *dev) return 0; } +static const struct stm32mp_bsec_drvdata stm32mp13_data = { + .size = 96, + .ta = true, +}; + +static const struct stm32mp_bsec_drvdata stm32mp15_data = { + .size = 96, + .ta = false, +}; static const struct udevice_id stm32mp_bsec_ids[] = { - { .compatible = "st,stm32mp13-bsec" }, - { .compatible = "st,stm32mp15-bsec" }, + { .compatible = "st,stm32mp13-bsec", .data = (ulong)_data}, + { .compatible = "st,stm32mp15-bsec", .data = (ulong)_data}, {} }; -- 2.25.1
[PATCH 02/12] arm: stm32mp: add Rev.B support for STM32MP25
From: Yann Gautier Add chip revision B support for STM32MP25, for displaying it in trace. Signed-off-by: Yann Gautier Signed-off-by: Patrick Delaunay --- arch/arm/mach-stm32mp/stm32mp2/stm32mp25x.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm/mach-stm32mp/stm32mp2/stm32mp25x.c b/arch/arm/mach-stm32mp/stm32mp2/stm32mp25x.c index 4b2f70af9cc6..7f896a0d65d2 100644 --- a/arch/arm/mach-stm32mp/stm32mp2/stm32mp25x.c +++ b/arch/arm/mach-stm32mp/stm32mp2/stm32mp25x.c @@ -167,6 +167,9 @@ void get_soc_name(char name[SOC_NAME_SIZE]) case CPU_REV1: cpu_r = "A"; break; + case CPU_REV2: + cpu_r = "B"; + break; default: break; } -- 2.25.1
[PATCH 01/12] arm64: dts: st: add bsec support to stm32mp25
Add BSEC support to STM32MP25 SoC family with SoC information: - RPN = Device part number (BSEC_OTP_DATA9) - PKG = package data register (Bits 2:0 of BSEC_OTP_DATA122) Signed-off-by: Patrick Delaunay Signed-off-by: Alexandre Torgue --- arch/arm/dts/stm32mp25-u-boot.dtsi | 4 arch/arm/dts/stm32mp251.dtsi | 16 2 files changed, 20 insertions(+) diff --git a/arch/arm/dts/stm32mp25-u-boot.dtsi b/arch/arm/dts/stm32mp25-u-boot.dtsi index f4f26add2a41..0c8e95b34163 100644 --- a/arch/arm/dts/stm32mp25-u-boot.dtsi +++ b/arch/arm/dts/stm32mp25-u-boot.dtsi @@ -37,6 +37,10 @@ }; }; + { + bootph-all; +}; + { bootph-all; }; diff --git a/arch/arm/dts/stm32mp251.dtsi b/arch/arm/dts/stm32mp251.dtsi index cf2f28dc1582..44eb664fb510 100644 --- a/arch/arm/dts/stm32mp251.dtsi +++ b/arch/arm/dts/stm32mp251.dtsi @@ -127,6 +127,22 @@ }; }; + bsec: efuse@4400 { + compatible = "st,stm32mp25-bsec"; + reg = <0x4400 0x1000>; + #address-cells = <1>; + #size-cells = <1>; + + part_number_otp@24 { + reg = <0x24 0x4>; + }; + + package_otp@1e8 { + reg = <0x1e8 0x1>; + bits = <0 3>; + }; + }; + syscfg: syscon@4423 { compatible = "st,stm32mp25-syscfg", "syscon"; reg = <0x4423 0x1>; -- 2.25.1
Re: [PATCH] ARM: dts: stm32: Fix reset for usart1 in scmi configuration
Hi, On 1/4/24 13:37, Patrice Chotard wrote: In SCMI configuration, usart1 is secure, so all its resources are secured (clock and reset) and can't be set/unset by non-secure world but by OP-TEE. Fixes: 68d396bf ("ARM: dts: stm32: add SCMI version of STM32 boards (DK1/DK2/ED1/EV1)") Signed-off-by: Patrice Chotard --- arch/arm/dts/stm32mp15-scmi-u-boot.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/dts/stm32mp15-scmi-u-boot.dtsi b/arch/arm/dts/stm32mp15-scmi-u-boot.dtsi index 7c8fec6cbfb..79494ecad90 100644 --- a/arch/arm/dts/stm32mp15-scmi-u-boot.dtsi +++ b/arch/arm/dts/stm32mp15-scmi-u-boot.dtsi @@ -135,7 +135,7 @@ }; { - resets = < USART1_R>; + resets = <_reset RST_SCMI_USART1>; }; { Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v2 20/21] stm32: Use bootm_run() and bootz_run()
Hi, On 12/14/23 17:50, Simon Glass wrote: Use the new bootm/z_run() functions to avoid having to create an argument list for the stm32prog code. Signed-off-by: Simon Glass --- (no changes since v1) .../cmd_stm32prog/cmd_stm32prog.c | 20 ++- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c index 8670535844d3..3ed393b7199f 100644 --- a/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c +++ b/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include @@ -125,12 +126,10 @@ static int do_stm32prog(struct cmd_tbl *cmdtp, int flag, int argc, char dtb_addr[20]; char initrd_addr[40]; char *fdt_arg, *initrd_arg; - char *bootm_argv[5] = { - "bootm", boot_addr_start, - }; const void *uimage = (void *)data->uimage; const void *dtb = (void *)data->dtb; const void *initrd = (void *)data->initrd; + struct bootm_info bmi; fdt_arg = dtb_addr; if (!dtb) @@ -141,7 +140,7 @@ static int do_stm32prog(struct cmd_tbl *cmdtp, int flag, int argc, snprintf(boot_addr_start, sizeof(boot_addr_start) - 1, "0x%p", uimage); - initrd_arg = "-"; + initrd_arg = NULL; if (initrd) { snprintf(initrd_addr, sizeof(initrd_addr) - 1, "0x%p:0x%zx", initrd, data->initrd_size); @@ -149,15 +148,18 @@ static int do_stm32prog(struct cmd_tbl *cmdtp, int flag, int argc, } printf("Booting kernel at %s %s %s...\n\n\n", boot_addr_start, - initrd_arg, fdt_arg); - bootm_argv[2] = initrd_arg; - bootm_argv[3] = fdt_arg; + initrd_arg ?: "-", fdt_arg); + + bootm_init(); + bmi.addr_fit = boot_addr_start; + bmi.conf_ramdisk = initrd_arg; + bmi.conf_fdt = fdt_arg; /* Try bootm for legacy and FIT format image */ if (genimg_get_format(uimage) != IMAGE_FORMAT_INVALID) - do_bootm(cmdtp, 0, 4, bootm_argv); + bootm_run(); else if (IS_ENABLED(CONFIG_CMD_BOOTZ)) - do_bootz(cmdtp, 0, 4, bootm_argv); + bootz_run(); } if (data->script) cmd_source_script(data->script, NULL, NULL); Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v2 18/21] stm32: Use local vars in stm32prog for initrd and fdt
Hi, On 12/14/23 17:50, Simon Glass wrote: Rather than assigning to the bootm_argv[] array multiple times, use local variables for the two things that can change and assign them at the end. This makes it easier to drop the array eventually. Tidu up an overly short line while we are here. Signed-off-by: Simon Glass --- (no changes since v1) .../cmd_stm32prog/cmd_stm32prog.c | 23 +++ 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c index 2411bcf06d8f..8670535844d3 100644 --- a/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c +++ b/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c @@ -124,30 +124,35 @@ static int do_stm32prog(struct cmd_tbl *cmdtp, int flag, int argc, char boot_addr_start[20]; char dtb_addr[20]; char initrd_addr[40]; + char *fdt_arg, *initrd_arg; char *bootm_argv[5] = { - "bootm", boot_addr_start, "-", dtb_addr, NULL + "bootm", boot_addr_start, }; const void *uimage = (void *)data->uimage; const void *dtb = (void *)data->dtb; const void *initrd = (void *)data->initrd; + fdt_arg = dtb_addr; if (!dtb) - bootm_argv[3] = env_get("fdtcontroladdr"); + fdt_arg = env_get("fdtcontroladdr"); else - snprintf(dtb_addr, sizeof(dtb_addr) - 1, -"0x%p", dtb); + snprintf(dtb_addr, sizeof(dtb_addr) - 1, "0x%p", dtb); snprintf(boot_addr_start, sizeof(boot_addr_start) - 1, "0x%p", uimage); + initrd_arg = "-"; if (initrd) { - snprintf(initrd_addr, sizeof(initrd_addr) - 1, "0x%p:0x%zx", -initrd, data->initrd_size); - bootm_argv[2] = initrd_addr; + snprintf(initrd_addr, sizeof(initrd_addr) - 1, +"0x%p:0x%zx", initrd, data->initrd_size); + initrd_arg = initrd_addr; } - printf("Booting kernel at %s %s %s...\n\n\n", - boot_addr_start, bootm_argv[2], bootm_argv[3]); + printf("Booting kernel at %s %s %s...\n\n\n", boot_addr_start, + initrd_arg, fdt_arg); + bootm_argv[2] = initrd_arg; + bootm_argv[3] = fdt_arg; + /* Try bootm for legacy and FIT format image */ if (genimg_get_format(uimage) != IMAGE_FORMAT_INVALID) do_bootm(cmdtp, 0, 4, bootm_argv); Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH 2/2] board: st: common: simplify MTD device parsing
Hi, On 11/17/23 18:01, Patrice Chotard wrote: Simplify the way all MTD devices are parsed. Signed-off-by: Patrice Chotard --- board/st/common/stm32mp_dfu.c | 19 ++- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/board/st/common/stm32mp_dfu.c b/board/st/common/stm32mp_dfu.c index ded3bf81961..77edb86e78c 100644 --- a/board/st/common/stm32mp_dfu.c +++ b/board/st/common/stm32mp_dfu.c @@ -123,24 +123,9 @@ void set_dfu_alt_info(char *interface, char *devstr) /* probe all MTD devices */ mtd_probe_devices(); - /* probe SPI flash device on a bus */ - if (!uclass_get_device(UCLASS_SPI_FLASH, 0, )) { - mtd = get_mtd_device_nm("nor0"); - if (!IS_ERR_OR_NULL(mtd)) + mtd_for_each_device(mtd) + if (!mtd_is_partition(mtd)) board_get_alt_info_mtd(mtd, buf); - - mtd = get_mtd_device_nm("nor1"); - if (!IS_ERR_OR_NULL(mtd)) - board_get_alt_info_mtd(mtd, buf); - } - - mtd = get_mtd_device_nm("nand0"); - if (!IS_ERR_OR_NULL(mtd)) - board_get_alt_info_mtd(mtd, buf); - - mtd = get_mtd_device_nm("spi-nand0"); - if (!IS_ERR_OR_NULL(mtd)) - board_get_alt_info_mtd(mtd, buf); } if (IS_ENABLED(CONFIG_DFU_VIRT)) { Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH 1/2] board: st: common: Fix board_get_alt_info_mtd()
Hi, On 11/17/23 18:01, Patrice Chotard wrote: Since MTD devices are partioned, we got the following error when command "dfu 0" is executed: DFU alt info setting: done ERROR: Too many arguments for nor0 ERROR: DFU entities configuration failed! ERROR: (partition table does not match dfu_alt_info?) Fixes: 31325e1b8b9c ("stm32mp1: dynamically build DFU_ALT_INFO") Signed-off-by: Patrice Chotard --- board/st/common/stm32mp_dfu.c | 9 ++--- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/board/st/common/stm32mp_dfu.c b/board/st/common/stm32mp_dfu.c index a8eb8d5cae2..ded3bf81961 100644 --- a/board/st/common/stm32mp_dfu.c +++ b/board/st/common/stm32mp_dfu.c @@ -73,7 +73,6 @@ static void board_get_alt_info_mmc(struct udevice *dev, char *buf) static void board_get_alt_info_mtd(struct mtd_info *mtd, char *buf) { struct mtd_info *part; - bool first = true; const char *name; int len, partnum = 0; @@ -86,17 +85,13 @@ static void board_get_alt_info_mtd(struct mtd_info *mtd, char *buf) "mtd %s=", name); len += snprintf(buf + len, DFU_ALT_BUF_LEN - len, - "%s raw 0x0 0x%llx ", + "%s raw 0x0 0x%llx", name, mtd->size); list_for_each_entry(part, >partitions, node) { partnum++; - if (!first) - len += snprintf(buf + len, DFU_ALT_BUF_LEN - len, ";"); - first = false; - len += snprintf(buf + len, DFU_ALT_BUF_LEN - len, - "%s_%s part %d", + ";%s_%s part %d", name, part->name, partnum); } } Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 9/9] stm32mp2: initial support
Hi, On 10/27/23 16:43, Patrice Chotard wrote: Add initial support for STM32MP2 SoCs family. SoCs information are available here : https://www.st.com/content/st_com/en/campaigns/microprocessor-stm32mp2.html Migrate all MP1 related code into stm32mp1/ directory Minor: MP1 => STM32MP1 series Create stm32mp2 directory dedicated for STM32MP2 SoCs. Common code to MP1, MP13 and MP25 is kept into Minor MP1 => STM32MP15 MP13 => STM32MP13 MP25 => STM32MP25 arch/arm/mach-stm32/mach-stm32mp directory : - boot_params.c - bsec - cmd_stm32key - cmd_stm32prog - dram_init.c - syscon.c - ecdsa_romapi.c For STM32MP2, it also : - adds memory region description needed for ARMv8 MMU. - enables early data cache before relocation. During the transition before/after relocation, the MMU, initially setup at the beginning of DDR, must be setup again at a correct address after relocation. This is done in enables_caches() by disabling cache, force arch.tlb_fillptr to NULL which will force the MMU to be setup again but with a new value for gd->arch.tlb_addr. gd->arch.tlb_addr has been updated after relocation in arm_reserve_mmu(). Signed-off-by: Patrice Chotard --- arch/arm/Kconfig | 2 +- arch/arm/mach-stm32mp/Kconfig | 26 ++- arch/arm/mach-stm32mp/Kconfig.25x | 43 arch/arm/mach-stm32mp/Makefile| 15 +- arch/arm/mach-stm32mp/include/mach/stm32.h| 141 - .../arm/mach-stm32mp/include/mach/sys_proto.h | 26 +++ arch/arm/mach-stm32mp/stm32mp1/Makefile | 20 ++ arch/arm/mach-stm32mp/{ => stm32mp1}/cpu.c| 0 arch/arm/mach-stm32mp/{ => stm32mp1}/fdt.c| 0 arch/arm/mach-stm32mp/{ => stm32mp1}/psci.c | 0 .../{ => stm32mp1}/pwr_regulator.c| 0 arch/arm/mach-stm32mp/{ => stm32mp1}/spl.c| 0 .../mach-stm32mp/{ => stm32mp1}/stm32mp13x.c | 0 .../mach-stm32mp/{ => stm32mp1}/stm32mp15x.c | 0 arch/arm/mach-stm32mp/{ => stm32mp1}/tzc400.c | 0 arch/arm/mach-stm32mp/stm32mp2/Makefile | 9 + arch/arm/mach-stm32mp/stm32mp2/arm64-mmu.c| 68 ++ arch/arm/mach-stm32mp/stm32mp2/cpu.c | 108 ++ arch/arm/mach-stm32mp/stm32mp2/fdt.c | 16 ++ arch/arm/mach-stm32mp/stm32mp2/stm32mp25x.c | 194 ++ arch/arm/mach-stm32mp/syscon.c| 4 +- board/st/stm32mp2/Kconfig | 13 ++ board/st/stm32mp2/MAINTAINERS | 9 + board/st/stm32mp2/Makefile| 6 + board/st/stm32mp2/stm32mp2.c | 52 + configs/stm32mp25_defconfig | 52 + include/configs/stm32mp25_common.h| 24 +++ 27 files changed, 757 insertions(+), 71 deletions(-) create mode 100644 arch/arm/mach-stm32mp/Kconfig.25x create mode 100644 arch/arm/mach-stm32mp/stm32mp1/Makefile rename arch/arm/mach-stm32mp/{ => stm32mp1}/cpu.c (100%) rename arch/arm/mach-stm32mp/{ => stm32mp1}/fdt.c (100%) rename arch/arm/mach-stm32mp/{ => stm32mp1}/psci.c (100%) rename arch/arm/mach-stm32mp/{ => stm32mp1}/pwr_regulator.c (100%) rename arch/arm/mach-stm32mp/{ => stm32mp1}/spl.c (100%) rename arch/arm/mach-stm32mp/{ => stm32mp1}/stm32mp13x.c (100%) rename arch/arm/mach-stm32mp/{ => stm32mp1}/stm32mp15x.c (100%) rename arch/arm/mach-stm32mp/{ => stm32mp1}/tzc400.c (100%) create mode 100644 arch/arm/mach-stm32mp/stm32mp2/Makefile create mode 100644 arch/arm/mach-stm32mp/stm32mp2/arm64-mmu.c create mode 100644 arch/arm/mach-stm32mp/stm32mp2/cpu.c create mode 100644 arch/arm/mach-stm32mp/stm32mp2/fdt.c create mode 100644 arch/arm/mach-stm32mp/stm32mp2/stm32mp25x.c create mode 100644 board/st/stm32mp2/Kconfig create mode 100644 board/st/stm32mp2/MAINTAINERS create mode 100644 board/st/stm32mp2/Makefile create mode 100644 board/st/stm32mp2/stm32mp2.c create mode 100644 configs/stm32mp25_defconfig create mode 100644 include/configs/stm32mp25_common.h with the minor remark on commit message Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 8/9] ARM: dts: stm32: Add STM32MP257F Evaluation board support
Hi, On 10/27/23 16:43, Patrice Chotard wrote: Add STM32MP257F Evaluation board support. It embeds a STM32MP257FAI SoC, with 4GB of DDR4, TSN switch (2+1 ports), 2*USB typeA, 1*USB2 typeC, SNOR OctoSPI, mini PCIe, STPMIC2 for power distribution ... Sync device tree with kernel v6.6-rc1. Signed-off-by: Patrice Chotard --- arch/arm/dts/Makefile | 3 + arch/arm/dts/stm32mp25-pinctrl.dtsi | 38 +++ arch/arm/dts/stm32mp25-u-boot.dtsi | 102 +++ arch/arm/dts/stm32mp251.dtsi| 285 arch/arm/dts/stm32mp253.dtsi| 23 ++ arch/arm/dts/stm32mp255.dtsi| 9 + arch/arm/dts/stm32mp257.dtsi| 9 + arch/arm/dts/stm32mp257f-ev1-u-boot.dtsi| 20 ++ arch/arm/dts/stm32mp257f-ev1.dts| 55 arch/arm/dts/stm32mp25xc.dtsi | 8 + arch/arm/dts/stm32mp25xf.dtsi | 8 + arch/arm/dts/stm32mp25xxai-pinctrl.dtsi | 83 ++ arch/arm/dts/stm32mp25xxak-pinctrl.dtsi | 71 + arch/arm/dts/stm32mp25xxal-pinctrl.dtsi | 71 + include/dt-bindings/pinctrl/stm32-pinfunc.h | 3 + 15 files changed, 788 insertions(+) create mode 100644 arch/arm/dts/stm32mp25-pinctrl.dtsi create mode 100644 arch/arm/dts/stm32mp25-u-boot.dtsi create mode 100644 arch/arm/dts/stm32mp251.dtsi create mode 100644 arch/arm/dts/stm32mp253.dtsi create mode 100644 arch/arm/dts/stm32mp255.dtsi create mode 100644 arch/arm/dts/stm32mp257.dtsi create mode 100644 arch/arm/dts/stm32mp257f-ev1-u-boot.dtsi create mode 100644 arch/arm/dts/stm32mp257f-ev1.dts create mode 100644 arch/arm/dts/stm32mp25xc.dtsi create mode 100644 arch/arm/dts/stm32mp25xf.dtsi create mode 100644 arch/arm/dts/stm32mp25xxai-pinctrl.dtsi create mode 100644 arch/arm/dts/stm32mp25xxak-pinctrl.dtsi create mode 100644 arch/arm/dts/stm32mp25xxal-pinctrl.dtsi Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 7/9] pinctrl: pinctrl_stm32: Add stm32mp2 support
Hi, On 10/27/23 16:43, Patrice Chotard wrote: Add stm32mp2 compatible. Signed-off-by: Patrice Chotard --- drivers/pinctrl/pinctrl_stm32.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/pinctrl/pinctrl_stm32.c b/drivers/pinctrl/pinctrl_stm32.c index 8bb7588714a..7120b8edba0 100644 --- a/drivers/pinctrl/pinctrl_stm32.c +++ b/drivers/pinctrl/pinctrl_stm32.c @@ -505,6 +505,8 @@ static const struct udevice_id stm32_pinctrl_ids[] = { { .compatible = "st,stm32mp157-pinctrl" }, { .compatible = "st,stm32mp157-z-pinctrl" }, { .compatible = "st,stm32mp135-pinctrl" }, + { .compatible = "st,stm32mp257-pinctrl" }, + { .compatible = "st,stm32mp257-z-pinctrl" }, { } }; Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 6/9] serial: stm32: Fix AARCH64 compilation warnings
Hi, On 10/27/23 16:43, Patrice Chotard wrote: From: Patrice Chotard When building with AARCH64 defconfig, we got warnings, fix them by using registers base address defined as void __iomem * instead of fdt_addr_t. Signed-off-by: Patrice Chotard Signed-off-by: Patrice Chotard --- drivers/serial/serial_stm32.c | 23 +-- drivers/serial/serial_stm32.h | 2 +- 2 files changed, 14 insertions(+), 11 deletions(-) Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 5/9] stm32mp: bsec: Fix AARCH64 compilation warnings
Hi, On 10/27/23 16:43, Patrice Chotard wrote: When building with AARCH64 defconfig, we got warnings, fix them. Signed-off-by: Patrice Chotard --- arch/arm/mach-stm32mp/bsec.c | 29 +++-- 1 file changed, 15 insertions(+), 14 deletions(-) Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 4/9] stm32mp: dram_init: Limit DDR usage under 4GB boundary for STM32MP
Hi, On 10/27/23 16:42, Patrice Chotard wrote: Limit DDR usage under 4GB boundary on STM32MP regardless of memory size declared in device tree. Signed-off-by: Patrice Chotard --- arch/arm/mach-stm32mp/dram_init.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-stm32mp/dram_init.c b/arch/arm/mach-stm32mp/dram_init.c index cb35ed60ca1..fb1208fc5d5 100644 --- a/arch/arm/mach-stm32mp/dram_init.c +++ b/arch/arm/mach-stm32mp/dram_init.c @@ -52,9 +52,15 @@ phys_addr_t board_get_usable_ram_top(phys_size_t total_size) if (!total_size) return gd->ram_top; + /* +* make sure U-Boot uses address space below 4GB boundaries even +* if the effective available memory is bigger +*/ + gd->ram_top = clamp_val(gd->ram_top, 0, SZ_4G - 1); + /* found enough not-reserved memory to relocated U-Boot */ lmb_init(); - lmb_add(, gd->ram_base, get_effective_memsize()); + lmb_add(, gd->ram_base, gd->ram_top - gd->ram_base); boot_fdt_add_mem_rsv_regions(, (void *)gd->fdt_blob); /* add 8M for reserved memory for display, fdt, gd,... */ size = ALIGN(SZ_8M + CONFIG_SYS_MALLOC_LEN + total_size, MMU_SECTION_SIZE), Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 3/9] stm32mp: dram_init: Fix AARCH64 compilation warnings
Hi, On 10/27/23 16:42, Patrice Chotard wrote: From: Patrick Delaunay When building with AARCH64 defconfig, we got warnings for debug message - format '%x' expects argument of type 'unsigned int', but argument 3 has type 'size_t' {aka 'long unsigned int'}). - format '%lx' expects argument of type 'long unsigned int', but argument 2 has type 'phys_addr_t' {aka 'long long unsigned int'} Signed-off-by: Patrick Delaunay Signed-off-by: Patrice Chotard --- arch/arm/mach-stm32mp/dram_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-stm32mp/dram_init.c b/arch/arm/mach-stm32mp/dram_init.c index a1e77a42e4f..cb35ed60ca1 100644 --- a/arch/arm/mach-stm32mp/dram_init.c +++ b/arch/arm/mach-stm32mp/dram_init.c @@ -36,7 +36,7 @@ int dram_init(void) log_debug("Cannot get RAM size: %d\n", ret); return ret; } - log_debug("RAM init base=%lx, size=%x\n", ram.base, ram.size); + log_debug("RAM init base=%p, size=%zx\n", (void *)ram.base, ram.size); gd->ram_size = ram.size; Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 2/9] stm32mp: dram_init: Get RAM size from DT if no RAM driver found
Hi, On 10/27/23 16:42, Patrice Chotard wrote: From: Patrice Chotard In case there is no RAM driver retrieve RAM size from DT as fallback. Signed-off-by: Patrice Chotard Signed-off-by: Patrice Chotard --- arch/arm/mach-stm32mp/dram_init.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-stm32mp/dram_init.c b/arch/arm/mach-stm32mp/dram_init.c index 7f37b0d2aa2..a1e77a42e4f 100644 --- a/arch/arm/mach-stm32mp/dram_init.c +++ b/arch/arm/mach-stm32mp/dram_init.c @@ -24,8 +24,11 @@ int dram_init(void) int ret; ret = uclass_get_device(UCLASS_RAM, 0, ); - if (ret) { - log_debug("RAM init failed: %d\n", ret); + /* in case there is no RAM driver, retrieve DDR size from DT */ + if (ret == -ENODEV) { + return fdtdec_setup_mem_size_base(); + } else if (ret) { + log_err("RAM init failed: %d\n", ret); return ret; } ret = ram_get_info(dev, ); Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 1/9] arm: caches: Make DCACHE_DEFAULT_OPTION accessible for ARM64 arch
Hi, On 10/27/23 16:42, Patrice Chotard wrote: This fixes the following compilation error in ARM64: arch/arm/mach-stm32mp/dram_init.c: In function ‘board_get_usable_ram_top’: arch/arm/mach-stm32mp/dram_init.c:59:45: error: ‘DCACHE_DEFAULT_OPTION’ undeclared (first use in this function) 59 | mmu_set_region_dcache_behaviour(reg, size, DCACHE_DEFAULT_OPTION); | ^ Signed-off-by: Patrice Chotard --- arch/arm/include/asm/system.h | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h index 0eae857e73a..43f7503571d 100644 --- a/arch/arm/include/asm/system.h +++ b/arch/arm/include/asm/system.h @@ -513,14 +513,6 @@ enum dcache_option { }; #endif -#if defined(CONFIG_SYS_ARM_CACHE_WRITETHROUGH) -#define DCACHE_DEFAULT_OPTION DCACHE_WRITETHROUGH -#elif defined(CONFIG_SYS_ARM_CACHE_WRITEALLOC) -#define DCACHE_DEFAULT_OPTION DCACHE_WRITEALLOC -#elif defined(CONFIG_SYS_ARM_CACHE_WRITEBACK) -#define DCACHE_DEFAULT_OPTION DCACHE_WRITEBACK -#endif - /* Size of an MMU section */ enum { #ifdef CONFIG_ARMV7_LPAE @@ -578,6 +570,14 @@ void psci_system_reset(void); #endif /* CONFIG_ARM64 */ +#if defined(CONFIG_SYS_ARM_CACHE_WRITETHROUGH) +#define DCACHE_DEFAULT_OPTION DCACHE_WRITETHROUGH +#elif defined(CONFIG_SYS_ARM_CACHE_WRITEALLOC) +#define DCACHE_DEFAULT_OPTION DCACHE_WRITEALLOC +#elif defined(CONFIG_SYS_ARM_CACHE_WRITEBACK) +#define DCACHE_DEFAULT_OPTION DCACHE_WRITEBACK +#endif + #ifndef __ASSEMBLY__ /** * save_boot_params() - Save boot parameters before starting reset sequence Reviewed-by: Patrick Delaunay Thanks Patrick
[PATCH] bootstage: Correct exhasuted typo
From: Simon Glass Correct this typo in the warning message shown when no more bootstage records can be added. Signed-off-by: Simon Glass Signed-off-by: Patrick Delaunay --- I just cherry-pick the Simon's patch in the branch fix-bs-working of the dm custodian git but it is not yet present in patchwork. https://source.denx.de/u-boot/custodians/u-boot-dm/-/commit/8810b8dd3d233978c15203b23420fa819ab1e791 Regards Patrick common/bootstage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/bootstage.c b/common/bootstage.c index a68d883c684c..0e6d80718fd5 100644 --- a/common/bootstage.c +++ b/common/bootstage.c @@ -137,7 +137,7 @@ ulong bootstage_add_record(enum bootstage_id id, const char *name, rec->flags = flags; rec->id = id; } else { - log_warning("Bootstage space exhasuted\n"); + log_warning("Bootstage space exhausted\n"); } } -- 2.25.1
Re: [PATCH] Revert "fs: ext4: check the minimal partition size to mount"
Hi, On 9/30/23 22:42, Sean Anderson wrote: This check breaks small partitions (under 1024 blocks) because part_length is in units of part.blksz and not bytes. Given the purpose of this function, we really want to make sure the partition is SUPERBLOCK_START + SUPERBLOCK_SIZE (2048) bytes so we can call ext4_read_superblock without error. The obvious solution is to convert callers from things like ext4fs_mount(part_info.size) to ext4fs_mount(part_info.size * part_info.blksz); However, I'm not really a fan of the bloat that would cause, especially since the error is now suppressed. I think the best course of action here is to just revert the patch. This reverts commit 9905cae65e03335aefcb1ebfab5b7ee62d89f64e. Signed-off-by: Sean Anderson --- fs/ext4/ext4_common.c | 4 1 file changed, 4 deletions(-) diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c index 9a9c520e22c..f50de7c089e 100644 --- a/fs/ext4/ext4_common.c +++ b/fs/ext4/ext4_common.c @@ -2373,10 +2373,6 @@ int ext4fs_mount(unsigned part_length) struct ext2_data *data; int status; struct ext_filesystem *fs = get_fs(); - - if (part_length < SUPERBLOCK_SIZE) - return 0; - data = zalloc(SUPERBLOCK_SIZE); if (!data) return 0; Agreed, I introduced error for part size in parameter (in blk multiple even if after dev read if done after with bytes size) And with caller change (part_info.size * part_info.blksz) we have risk of overflow for large ex4 partition. minor remark: "part_length" is no more used it can be removed to avoid warining ? include/ext4fs.h:149:int ext4fs_mount(void); or use the tag "__always_unused": int ext4fs_mount(unsigned __always_unused part_length) { With the remarks: Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 6/6] board: st: common: cleanup dfu support
Hi, On 9/26/23 17:09, Patrice Chotard wrote: From: Patrick Delaunay split the file stm32mp_dfu.c in two files to simplify the Makefile - stm32mp_dfu.c: required by CONFIG_SET_DFU_ALT_INFO - stm32mp_dfu_virt.c: required by CONFIG_DFU_VIRT for stm32prog command or VIRT device for PMIC for CONFIG_SET_DFU_ALT_INFO. This patch also remove some remaining #ifdef CONFIG and avoid compilation error when CONFIG_SET_DFU_ALT_INFO is not activated. Signed-off-by: Patrick Delaunay Signed-off-by: Patrice Chotard --- board/st/common/Makefile | 1 + board/st/common/stm32mp_dfu.c | 103 ++--- board/st/common/stm32mp_dfu_virt.c | 99 +++ 3 files changed, 104 insertions(+), 99 deletions(-) create mode 100644 board/st/common/stm32mp_dfu_virt.c Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 5/6] configs: stm32mp13: add support of usb boot
Hi, On 9/26/23 17:09, Patrice Chotard wrote: From: Patrick Delaunay Add support of USB key boot in distro boot command. Signed-off-by: Patrick Delaunay Signed-off-by: Patrice Chotard --- include/configs/stm32mp13_common.h | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/configs/stm32mp13_common.h b/include/configs/stm32mp13_common.h index d36fbf00548..5b0658ced92 100644 --- a/include/configs/stm32mp13_common.h +++ b/include/configs/stm32mp13_common.h @@ -35,9 +35,16 @@ #define BOOT_TARGET_MMC1(func) #endif +#ifdef CONFIG_CMD_USB +#define BOOT_TARGET_USB(func) func(USB, usb, 0) +#else +#define BOOT_TARGET_USB(func) +#endif + #define BOOT_TARGET_DEVICES(func) \ BOOT_TARGET_MMC1(func) \ - BOOT_TARGET_MMC0(func) + BOOT_TARGET_MMC0(func) \ + BOOT_TARGET_USB(func) /* * default bootcmd for stm32mp13: Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 4/6] configs: stm32mp13: activate command stm32prog
Hi, On 9/26/23 17:09, Patrice Chotard wrote: From: Patrick Delaunay Activate the command stm32prog with CONFIG_CMD_STM32MPROG. The CONFIG_SET_DFU_ALT_INFO is also activated to support the required weak functions for the DFU virtual backen defined in board/st/common/stm32mp_dfu.c. Signed-off-by: Patrick Delaunay Signed-off-by: Patrice Chotard --- configs/stm32mp13_defconfig| 2 ++ include/configs/stm32mp13_common.h | 4 2 files changed, 6 insertions(+) Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 3/6] configs: stm32mp13: Enable USB related flags
Hi, On 9/26/23 17:09, Patrice Chotard wrote: Enable USB related flags. Signed-off-by: Patrice Chotard --- configs/stm32mp13_defconfig | 18 ++ 1 file changed, 18 insertions(+) Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 2/6] ARM: dts: stm32: force b-session-valid for otg on stm32mp135f-dk board
Hi, On 9/26/23 17:09, Patrice Chotard wrote: From: Fabrice Gasnier stm32mp135f-dk board has a type-c connector to retrieve the connection state. For now, simply force an active peripheral mode in u-boot for flashing. Signed-off-by: Fabrice Gasnier Signed-off-by: Patrice Chotard --- arch/arm/dts/stm32mp135f-dk-u-boot.dtsi | 4 1 file changed, 4 insertions(+) diff --git a/arch/arm/dts/stm32mp135f-dk-u-boot.dtsi b/arch/arm/dts/stm32mp135f-dk-u-boot.dtsi index 48605ff8bbe..ba0c02489d1 100644 --- a/arch/arm/dts/stm32mp135f-dk-u-boot.dtsi +++ b/arch/arm/dts/stm32mp135f-dk-u-boot.dtsi @@ -38,3 +38,7 @@ bootph-all; }; }; + +_hs { + u-boot,force-b-session-valid; +}; Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v1 1/6] ARM: dts: stm32mp: alignment with v6.6-rc1
Hi, On 9/26/23 17:09, Patrice Chotard wrote: Device tree alignment with Linux kernel v6.6.rc1. Signed-off-by: Patrice Chotard --- arch/arm/dts/stm32mp131.dtsi | 52 +-- arch/arm/dts/stm32mp135f-dk.dts | 68 ++-- arch/arm/dts/stm32mp15-pinctrl.dtsi | 364 +- arch/arm/dts/stm32mp15-scmi.dtsi | 7 +- arch/arm/dts/stm32mp151.dtsi | 34 +- arch/arm/dts/stm32mp157.dtsi | 15 +- arch/arm/dts/stm32mp157a-dk1-scmi.dts | 7 +- ...157a-microgea-stm32mp1-microdev2.0-of7.dts | 3 + arch/arm/dts/stm32mp157c-dk2-scmi.dts | 7 +- arch/arm/dts/stm32mp157c-dk2.dts | 30 +- arch/arm/dts/stm32mp157c-ed1-scmi.dts | 7 +- arch/arm/dts/stm32mp157c-ed1.dts | 24 +- arch/arm/dts/stm32mp157c-ev1-scmi.dts | 7 +- arch/arm/dts/stm32mp157c-ev1.dts | 34 +- arch/arm/dts/stm32mp15xx-dkx.dtsi | 42 +- include/dt-bindings/clock/stm32mp1-clks.h | 2 +- include/dt-bindings/clock/stm32mp13-clks.h| 2 +- .../regulator/st,stm32mp13-regulator.h| 42 ++ include/dt-bindings/reset/stm32mp1-resets.h | 2 +- include/dt-bindings/reset/stm32mp13-resets.h | 2 +- 20 files changed, 585 insertions(+), 166 deletions(-) create mode 100644 include/dt-bindings/regulator/st,stm32mp13-regulator.h Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH v2 1/7] rng: stm32: rename STM32 RNG driver
Hi, On 9/11/23 17:37, Gatien Chevallier wrote: Rename the RNG driver as it is usable by other STM32 platforms than the STM32MP1x ones. Rename CONFIG_RNG_STM32MP1 to CONFIG_RNG_STM32 Signed-off-by: Gatien Chevallier Reviewed-by: Grzegorz Szymaszek --- Changes in V2: - Added ARCH_STM32 in the "depends on" section of the RNG_STM32 configuration field. - Added Grzegorz's tag and discarded Patrick's and Heinrich's as there's a modification MAINTAINERS | 2 +- configs/stm32mp15_basic_defconfig | 2 +- configs/stm32mp15_defconfig | 2 +- configs/stm32mp15_trusted_defconfig | 2 +- drivers/rng/Kconfig | 8 drivers/rng/Makefile| 2 +- drivers/rng/{stm32mp1_rng.c => stm32_rng.c} | 0 7 files changed, 9 insertions(+), 9 deletions(-) rename drivers/rng/{stm32mp1_rng.c => stm32_rng.c} (100%) Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH 7/7] ARM: dts: stm32: add RNG node for STM32MP13x platforms
Hi, On 9/7/23 18:22, Gatien Chevallier wrote: Add RNG node for STM32MP13x platforms. Signed-off-by: Gatien Chevallier --- arch/arm/dts/stm32mp131.dtsi | 8 1 file changed, 8 insertions(+) diff --git a/arch/arm/dts/stm32mp131.dtsi b/arch/arm/dts/stm32mp131.dtsi index d23bbc3639..bd7285053d 100644 --- a/arch/arm/dts/stm32mp131.dtsi +++ b/arch/arm/dts/stm32mp131.dtsi @@ -1208,6 +1208,14 @@ }; }; + rng: rng@54004000 { + compatible = "st,stm32mp13-rng"; + reg = <0x54004000 0x400>; + clocks = < RNG1_K>; + resets = < RNG1_R>; + status = "disabled"; + }; + mdma: dma-controller@5800 { compatible = "st,stm32h7-mdma"; reg = <0x5800 0x1000>; Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH 6/7] rng: stm32: Implement custom RNG configuration support
Hi, On 9/7/23 18:21, Gatien Chevallier wrote: STM32 RNG configuration should best fit the requirements of the platform. Therefore, put a platform-specific RNG configuration field in the platform data. Default RNG configuration for STM32MP13 is the NIST certified configuration [1]. While there, fix and the RNG init sequence to support all RNG versions. [1] https://csrc.nist.gov/projects/cryptographic-module-validation-program/entropy-validations/certificate/53 Signed-off-by: Gatien Chevallier --- drivers/rng/stm32_rng.c | 54 ++--- 1 file changed, 51 insertions(+), 3 deletions(-) Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH 5/7] rng: stm32: add error concealment sequence
Hi, On 9/7/23 18:21, Gatien Chevallier wrote: Seed errors can occur when using the hardware RNG. Implement the sequences to handle them. This avoids irrecoverable RNG state. Try to conceal seed errors when possible. If, despite the error concealing tries, a seed error is still present, then return an error. A clock error does not compromise the hardware block and data can still be read from RNG_DR. Just warn that the RNG clock is too slow and clear RNG_SR. Signed-off-by: Gatien Chevallier --- drivers/rng/stm32_rng.c | 163 ++-- 1 file changed, 140 insertions(+), 23 deletions(-) Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH 4/7] rng: stm32: add RNG clock frequency restraint
Hi, On 9/7/23 18:21, Gatien Chevallier wrote: In order to ensure a good RNG quality and compatibility with certified RNG configuration, add RNG clock frequency restraint. Signed-off-by: Gatien Chevallier --- drivers/rng/stm32_rng.c | 43 - 1 file changed, 38 insertions(+), 5 deletions(-) Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH 3/7] rng: stm32: Implement configurable RNG clock error detection
Hi, On 9/7/23 18:21, Gatien Chevallier wrote: RNG clock error detection is now enabled if the "clock-error-detect" property is set in the device tree. Signed-off-by: Gatien Chevallier --- drivers/rng/stm32_rng.c | 22 +- 1 file changed, 17 insertions(+), 5 deletions(-) Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH 2/7] configs: default activate CONFIG_RNG_STM32 for STM32MP13x platforms
Hi, On 9/7/23 18:21, Gatien Chevallier wrote: Default embed this configuration. If OP-TEE PTA RNG is present as well, the priority will be given to it instead of the U-Boot driver. The STM32 RNG driver will be probed when the is activated in U-Boot device tree, it is avaiable for non secure world. OP-TEE RNG PTA will be registered when the RNG access is liited to secure world by firewall. For me not priority here but secure/non secure configuration, managed by device tree. Signed-off-by: Gatien Chevallier --- configs/stm32mp13_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/stm32mp13_defconfig b/configs/stm32mp13_defconfig index 82b62744f6..4a899c85de 100644 --- a/configs/stm32mp13_defconfig +++ b/configs/stm32mp13_defconfig @@ -65,6 +65,7 @@ CONFIG_DM_REGULATOR_GPIO=y CONFIG_DM_REGULATOR_SCMI=y CONFIG_RESET_SCMI=y CONFIG_DM_RNG=y +CONFIG_RNG_STM32=y CONFIG_DM_RTC=y CONFIG_RTC_STM32=y CONFIG_SERIAL_RX_BUFFER=y with commit message update Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH 1/7] rng: stm32: rename STM32 RNG driver
Hi, On 9/7/23 18:21, Gatien Chevallier wrote: Rename the RNG driver as it is usable by other STM32 platforms than the STM32MP1x ones. Rename CONFIG_RNG_STM32MP1 to CONFIG_RNG_STM32 Signed-off-by: Gatien Chevallier --- MAINTAINERS | 2 +- configs/stm32mp15_basic_defconfig | 2 +- configs/stm32mp15_defconfig | 2 +- configs/stm32mp15_trusted_defconfig | 2 +- drivers/rng/Kconfig | 6 +++--- drivers/rng/Makefile| 2 +- drivers/rng/{stm32mp1_rng.c => stm32_rng.c} | 0 7 files changed, 8 insertions(+), 8 deletions(-) rename drivers/rng/{stm32mp1_rng.c => stm32_rng.c} (100%) Reviewed-by: Patrick Delaunay Thanks Patrick
Re: [PATCH 3/7] rng: stm32: Implement configurable RNG clock error detection
Hi, On 9/8/23 21:07, Heinrich Schuchardt wrote: On 9/7/23 18:21, Gatien Chevallier wrote: RNG clock error detection is now enabled if the "clock-error-detect" property is set in the device tree. Signed-off-by: Gatien Chevallier --- drivers/rng/stm32_rng.c | 22 +- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/rng/stm32_rng.c b/drivers/rng/stm32_rng.c index 89da78c6c8..ada5d92214 100644 --- a/drivers/rng/stm32_rng.c +++ b/drivers/rng/stm32_rng.c @@ -40,6 +40,7 @@ struct stm32_rng_plat { struct clk clk; struct reset_ctl rst; const struct stm32_rng_data *data; + bool ced; }; static int stm32_rng_read(struct udevice *dev, void *data, size_t len) @@ -97,25 +98,34 @@ static int stm32_rng_init(struct stm32_rng_plat *pdata) cr = readl(pdata->base + RNG_CR); - /* Disable CED */ - cr |= RNG_CR_CED; if (pdata->data->has_cond_reset) { cr |= RNG_CR_CONDRST; + if (pdata->ced) + cr &= ~RNG_CR_CED; + else + cr |= RNG_CR_CED; writel(cr, pdata->base + RNG_CR); cr &= ~RNG_CR_CONDRST; + cr |= RNG_CR_RNGEN; writel(cr, pdata->base + RNG_CR); err = readl_poll_timeout(pdata->base + RNG_CR, cr, (!(cr & RNG_CR_CONDRST)), 1); if (err) return err; + } else { + if (pdata->ced) + cr &= ~RNG_CR_CED; + else + cr |= RNG_CR_CED; + + cr |= RNG_CR_RNGEN; + + writel(cr, pdata->base + RNG_CR); } /* clear error indicators */ writel(0, pdata->base + RNG_SR); - cr |= RNG_CR_RNGEN; - writel(cr, pdata->base + RNG_CR); - err = readl_poll_timeout(pdata->base + RNG_SR, sr, sr & RNG_SR_DRDY, 1); return err; @@ -165,6 +175,8 @@ static int stm32_rng_of_to_plat(struct udevice *dev) if (err) return err; + pdata->ced = dev_read_bool(dev, "clock-error-detect"); The kernel describes this property in Documentation/devicetree/bindings/rng/st,stm32-rng.yaml Which patch is adding it to the U-Boot device-trees? I can't find it in this patch series. For STM32 platform we rely on the bindin files of kernel to avoid to duplicate the binding after yaml migration and we add the U-Boot specificity only when it is needed (for clock and ram) See Documentation: https://u-boot.readthedocs.io/en/stable/board/st/st-dt.html doc/board/st/st-dt.rst * rng - rng/st,stm32-rng.yaml So for me no need of binding patch in U-Boot since [1] as this property is already supported by kernel binding. [1] 551a959a8c11 ("doc: stm32mp1: add page for device tree bindings") http://patchwork.ozlabs.org/project/uboot/patch/20210802180823.1.I3aa79d907e5213c8692d2d428f5a1fbccdce555b@changeid/ Patrick It would have been helpful to send a cover-letter with the patch series to get an overview of the changed files in the patch set. Best regards Heinrich + return 0; }
Re: [PATCH 6/6] stm32mp15: Use u-boot-spl-stm32.bin instead of u-boot-spl.stm32
Hi Simon, On 8/24/23 17:14, Tom Rini wrote: On Thu, Aug 24, 2023 at 05:09:07PM +0200, Marek Vasut wrote: On 8/24/23 16:25, Tom Rini wrote: On Thu, Aug 24, 2023 at 05:12:45AM +0200, Marek Vasut wrote: On 8/24/23 05:02, Simon Glass wrote: A '.stm32' extension is not allowed anymore, so change it. Why? This will likely break a huge amount of scripts, I'm tempted to NAK it unless there is a very good reason. This is in the cover letter. Today, buildman --keep-outputs doesn't actually keep the needed for booting outputs from a build for a number of platforms. Simon's response is to stop having a free-form list of outputs. With I guess the caveat being ROM-defined names (for example, we still keep "MLO" because that is the literal filename TI ROM looks for on FAT partitions, on mos of their 32bit platforms). Why not just place the free-form files into some output/ directory and be done with it ? Then they can have whatever extension they want, as long as the output/ directory name is stable. Yes, an alternative here is to just extend the list that's removed in patch 2/6. The ".stm32" was choosen on output on mkimage to be aligned with: - all STMicroelectonics documentation (for example https://wiki.st.com/stm32mpu/wiki/STM32_header_for_binary_files) - the proposed scripts or files, in particular in the YOCTO generated flashlayout files. - this extension list expected by our tools: STM CubeProgrammer (https://wiki.st.com/stm32mpu/wiki/STM32CubeProgrammer) and Signing tools (https://wiki.st.com/stm32mpu/wiki/Signing_tool) So I prefer to kept the ".stm32" extension here: filename = "u-boot-spl.stm32" NB: the justification for buildman '-k' option seens not fully relevant here because in patch 2/6 you kept not only the ALLOWED extension but also some particular files +to_copy = ['u-boot*', '*.map', 'MLO', 'SPL', + 'include/autoconf.mk', 'spl/u-boot-spl*'] +to_copy += [f'*{ext}' for ext in ALLOWED_EXTS] so all the files "u-boot*" are kept with buildman -k even if it is not a allowed extension. I propose to change the patch 1/6 if you are agree and allow binman to generate the file with same rules than buildman -k option in patch 2/6 The filename is valid if - the file is named with the allowed prefix 'u-boot' => 'u-boot*' so "u-boot-spl.stm32" is allowed - the file is with allowed extension =>.bin, .rom, .itb, .img Regards Patrick
Re: [PATCH] configs: stm32f769-disco: Enable VIDEO_LOGO flag
Hi, On 8/25/23 18:24, Patrice Chotard wrote: The patch removes the legacy mode of displaying the ST logo and adopts the approach introduced by the commit 284b08fb51b6 ("board: stm32mp1: add splash screen with stmicroelectronics logo"). Signed-off-by: Patrice Chotard --- configs/stm32f769-disco_defconfig | 2 +- configs/stm32f769-disco_spl_defconfig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configs/stm32f769-disco_defconfig b/configs/stm32f769-disco_defconfig index 72ef133fe4a..20dbb1af630 100644 --- a/configs/stm32f769-disco_defconfig +++ b/configs/stm32f769-disco_defconfig @@ -56,6 +56,7 @@ CONFIG_SPI=y CONFIG_DM_SPI=y CONFIG_STM32_QSPI=y CONFIG_VIDEO=y +CONFIG_VIDEO_LOGO=y CONFIG_BACKLIGHT_GPIO=y CONFIG_VIDEO_LCD_ORISETECH_OTM8009A=y CONFIG_VIDEO_STM32=y @@ -64,7 +65,6 @@ CONFIG_VIDEO_STM32_MAX_XRES=480 CONFIG_VIDEO_STM32_MAX_YRES=800 CONFIG_SPLASH_SCREEN=y CONFIG_SPLASH_SCREEN_ALIGN=y -CONFIG_VIDEO_BMP_RLE8=y CONFIG_BMP_16BPP=y CONFIG_BMP_24BPP=y CONFIG_BMP_32BPP=y diff --git a/configs/stm32f769-disco_spl_defconfig b/configs/stm32f769-disco_spl_defconfig index dd17cad7362..a5298e7cdc1 100644 --- a/configs/stm32f769-disco_spl_defconfig +++ b/configs/stm32f769-disco_spl_defconfig @@ -82,6 +82,7 @@ CONFIG_DM_SPI=y CONFIG_STM32_QSPI=y CONFIG_SPL_TIMER=y CONFIG_VIDEO=y +CONFIG_VIDEO_LOGO=y CONFIG_BACKLIGHT_GPIO=y CONFIG_VIDEO_LCD_ORISETECH_OTM8009A=y CONFIG_VIDEO_STM32=y @@ -90,7 +91,6 @@ CONFIG_VIDEO_STM32_MAX_XRES=480 CONFIG_VIDEO_STM32_MAX_YRES=800 CONFIG_SPLASH_SCREEN=y CONFIG_SPLASH_SCREEN_ALIGN=y -CONFIG_VIDEO_BMP_RLE8=y CONFIG_BMP_16BPP=y CONFIG_BMP_24BPP=y CONFIG_BMP_32BPP=y Reviewed-by: Patrick Delaunay Thanks Patrick