From 4170079ae05a962a43962f426815e12d516fb3f9 Mon Sep 17 00:00:00 2001 From: Yann Gautier Date: Tue, 25 Feb 2020 17:51:52 +0100 Subject: [PATCH] stm32mp1: correct crash console GPIO alternate configuration If GPIO port for UART TX is less than 8, the register GPIO_AFRL should be used to set the alternate. GPIO_AFRH is used if GPIO port is greater or equal to 8. The macro GPIO_TX_ALT_SHIFT is removed and the GPIO port number is tested against GPIO_ALT_LOWER_LIMIT (=8) in plat_crash_console_init() function. Change-Id: Ibb62223ed6bce589bbcab59a5e986b2677e6d118 Signed-off-by: Yann Gautier --- plat/st/stm32mp1/stm32mp1_helper.S | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/plat/st/stm32mp1/stm32mp1_helper.S b/plat/st/stm32mp1/stm32mp1_helper.S index 560e06e20..407eb3979 100644 --- a/plat/st/stm32mp1/stm32mp1_helper.S +++ b/plat/st/stm32mp1/stm32mp1_helper.S @@ -12,7 +12,6 @@ #include #define GPIO_TX_SHIFT (DEBUG_UART_TX_GPIO_PORT << 1) -#define GPIO_TX_ALT_SHIFT ((DEBUG_UART_TX_GPIO_PORT - GPIO_ALT_LOWER_LIMIT) << 2) .globl platform_mem_init .globl plat_report_exception @@ -170,10 +169,19 @@ func plat_crash_console_init bic r2, r2, #(GPIO_PULL_MASK << GPIO_TX_SHIFT) str r2, [r1, #GPIO_PUPD_OFFSET] /* Set alternate */ +#if DEBUG_UART_TX_GPIO_PORT >= GPIO_ALT_LOWER_LIMIT ldr r2, [r1, #GPIO_AFRH_OFFSET] - bic r2, r2, #(GPIO_ALTERNATE_MASK << GPIO_TX_ALT_SHIFT) - orr r2, r2, #(DEBUG_UART_TX_GPIO_ALTERNATE << GPIO_TX_ALT_SHIFT) + bic r2, r2, #(GPIO_ALTERNATE_MASK << \ + ((DEBUG_UART_TX_GPIO_PORT - GPIO_ALT_LOWER_LIMIT) << 2)) + orr r2, r2, #(DEBUG_UART_TX_GPIO_ALTERNATE << \ + ((DEBUG_UART_TX_GPIO_PORT - GPIO_ALT_LOWER_LIMIT) << 2)) str r2, [r1, #GPIO_AFRH_OFFSET] +#else + ldr r2, [r1, #GPIO_AFRL_OFFSET] + bic r2, r2, #(GPIO_ALTERNATE_MASK << (DEBUG_UART_TX_GPIO_PORT << 2)) + orr r2, r2, #(DEBUG_UART_TX_GPIO_ALTERNATE << (DEBUG_UART_TX_GPIO_PORT << 2)) + str r2, [r1, #GPIO_AFRL_OFFSET] +#endif /* Enable UART clock, with its source */ ldr r1, =(RCC_BASE + DEBUG_UART_TX_CLKSRC_REG) mov r2, #DEBUG_UART_TX_CLKSRC -- 2.39.5