summaryrefslogtreecommitdiff
path: root/drivers/serial/serial_stm32.c
diff options
context:
space:
mode:
authorPatrice Chotard <patrice.chotard@foss.st.com>2025-01-30 12:57:54 +0100
committerPatrice Chotard <patrice.chotard@foss.st.com>2025-03-12 16:44:31 +0100
commit1a87755ecd0d36ec29acdbcbc9b381e76cfd6cfd (patch)
tree7ae18d6ac68c4b3ba6f08a27d94eaad8ec68b975 /drivers/serial/serial_stm32.c
parent2cc38eb83c4c7752c56bd27baa6c7aaf87d2867b (diff)
serial: stm32: restrict _debug_uart_init() usage
Since commit 948da7773e34 ("arm: Add new config option ARCH_VERY_EARLY_INIT") debug_uart_init() is called respectively in crt0.S and crt0_64.S. That means that _debug_uart_init() is called for all STM32MP platforms even for those which doesn't support SPL_BUILD. So restrict _debug_uart_init() execution for platforms which can have SPL_BUILD enabled (STM32MP1 platform only). It's more needed to call debug_uart_init() in stm32mp1/cpu.c. Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com> Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Diffstat (limited to 'drivers/serial/serial_stm32.c')
-rw-r--r--drivers/serial/serial_stm32.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/drivers/serial/serial_stm32.c b/drivers/serial/serial_stm32.c
index 1ee58142b3f..1675a9cb9d1 100644
--- a/drivers/serial/serial_stm32.c
+++ b/drivers/serial/serial_stm32.c
@@ -299,13 +299,19 @@ static inline struct stm32_uart_info *_debug_uart_info(void)
static inline void _debug_uart_init(void)
{
- void __iomem *base = (void __iomem *)CONFIG_VAL(DEBUG_UART_BASE);
- struct stm32_uart_info *uart_info = _debug_uart_info();
+ void __maybe_unused __iomem *base = (void __iomem *)CONFIG_VAL(DEBUG_UART_BASE);
+ struct stm32_uart_info *uart_info __maybe_unused = _debug_uart_info();
- _stm32_serial_init(base, uart_info);
- _stm32_serial_setbrg(base, uart_info,
- CONFIG_DEBUG_UART_CLOCK,
- CONFIG_BAUDRATE);
+ /*
+ * debug_uart_init() is only usable when SPL_BUILD is enabled
+ * (STM32MP1 case only)
+ */
+ if (IS_ENABLED(CONFIG_DEBUG_UART) && IS_ENABLED(CONFIG_SPL_BUILD)) {
+ _stm32_serial_init(base, uart_info);
+ _stm32_serial_setbrg(base, uart_info,
+ CONFIG_DEBUG_UART_CLOCK,
+ CONFIG_BAUDRATE);
+ }
}
static inline void _debug_uart_putc(int c)