diff --git a/plat/st/common/include/stm32mp_common.h b/plat/st/common/include/stm32mp_common.h index d26064452..fbd0ddace 100644 --- a/plat/st/common/include/stm32mp_common.h +++ b/plat/st/common/include/stm32mp_common.h @@ -48,7 +48,7 @@ uint32_t stm32_iwdg_get_otp_config(uint32_t iwdg_inst); uint32_t stm32_iwdg_shadow_update(uint32_t iwdg_inst, uint32_t flags); #endif -#if STM32MP_UART_PROGRAMMER +#if STM32MP_UART_PROGRAMMER || !defined(IMAGE_BL2) /* Get the UART address from its instance number */ uintptr_t get_uart_address(uint32_t instance_nb); #endif diff --git a/plat/st/common/stm32mp_common.c b/plat/st/common/stm32mp_common.c index 9cbba04fd..072155fb7 100644 --- a/plat/st/common/stm32mp_common.c +++ b/plat/st/common/stm32mp_common.c @@ -161,6 +161,8 @@ int stm32mp_uart_console_setup(void) unsigned int console_flags; uint32_t clk_rate; int result; + uint32_t boot_itf __unused; + uint32_t boot_instance __unused; result = dt_get_stdout_uart_info(&dt_uart_info); @@ -171,6 +173,15 @@ int stm32mp_uart_console_setup(void) return -ENODEV; } +#if STM32MP_UART_PROGRAMMER || !defined(IMAGE_BL2) + stm32_get_boot_interface(&boot_itf, &boot_instance); + + if ((boot_itf == BOOT_API_CTX_BOOT_INTERFACE_SEL_SERIAL_UART) && + (get_uart_address(boot_instance) == dt_uart_info.base)) { + return -EACCES; + } +#endif + #if defined(IMAGE_BL2) if (dt_set_stdout_pinctrl() != 0) { return -ENODEV; diff --git a/plat/st/stm32mp1/bl2_plat_setup.c b/plat/st/stm32mp1/bl2_plat_setup.c index b55bc70ac..d52ac939f 100644 --- a/plat/st/stm32mp1/bl2_plat_setup.c +++ b/plat/st/stm32mp1/bl2_plat_setup.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -229,6 +230,16 @@ void bl2_el3_plat_arch_setup(void) generic_delay_timer_init(); +#if STM32MP_UART_PROGRAMMER + /* Disable programmer UART before changing clock tree */ + if (boot_context->boot_interface_selected == + BOOT_API_CTX_BOOT_INTERFACE_SEL_SERIAL_UART) { + uintptr_t uart_prog_addr = + get_uart_address(boot_context->boot_interface_instance); + + stm32_uart_stop(uart_prog_addr); + } +#endif if (stm32mp1_clk_probe() < 0) { panic(); } diff --git a/plat/st/stm32mp1/stm32mp1_private.c b/plat/st/stm32mp1/stm32mp1_private.c index eb8bc27c2..a8ffecb16 100644 --- a/plat/st/stm32mp1/stm32mp1_private.c +++ b/plat/st/stm32mp1/stm32mp1_private.c @@ -167,7 +167,7 @@ int stm32_get_gpio_bank_pinctrl_node(void *fdt, unsigned int bank) } } -#if STM32MP_UART_PROGRAMMER +#if STM32MP_UART_PROGRAMMER || !defined(IMAGE_BL2) /* * UART Management */