From 2e8ab4f538032dda4f0c3e69e3d94c6f37a9bd25 Mon Sep 17 00:00:00 2001 From: Anson Huang Date: Tue, 15 Jan 2019 14:27:10 +0800 Subject: [PATCH] imx: make imx uart work for debug mode With DEBUG_CONSOLE enabled, build will fail for imx8mq platform: ./build/imx8mq/release/bl31/imx8mq_bl31_setup.o: In function `bl31_early_platform_setup2': imx8mq_bl31_setup.c:(.text.bl31_early_platform_setup2+0x40): undefined reference to `console_uart_register' Makefile:741: recipe for target 'build/imx8mq/release/bl31/bl31.elf' failed make: *** [build/imx8mq/release/bl31/bl31.elf] Error 1 Besides, the .console_flush callback needs to be added to avoid panic when debug mode is enabled, since the console_flush() will call it without checking whether the function callback is valid. Signed-off-by: Anson Huang --- plat/imx/common/imx_uart_console.S | 18 ++++++++++++------ plat/imx/common/include/imx_uart.h | 4 ++-- plat/imx/imx8m/imx8mq/imx8mq_bl31_setup.c | 4 ++-- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/plat/imx/common/imx_uart_console.S b/plat/imx/common/imx_uart_console.S index 7dbde795b..03ec3133e 100644 --- a/plat/imx/common/imx_uart_console.S +++ b/plat/imx/common/imx_uart_console.S @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -16,10 +16,11 @@ #define UTS 0xb4 /* UART Test Register (mx31) */ #define URXD_RX_DATA (0xFF) - .globl console_uart_register - .globl console_uart_init - .globl console_uart_putc - .globl console_uart_getc + .globl console_imx_uart_register + .globl console_imx_uart_init + .globl console_imx_uart_putc + .globl console_imx_uart_getc + .globl console_imx_uart_flush func console_imx_uart_register mov x7, x30 @@ -32,7 +33,7 @@ func console_imx_uart_register mov x0, x6 mov x30, x7 - finish_console_register imx_uart putc=1, getc=1 + finish_console_register imx_uart putc=1, getc=1, flush=1 register_fail: ret x7 @@ -82,3 +83,8 @@ getc_error: mov w0, #-1 ret endfunc console_imx_uart_getc + +func console_imx_uart_flush + mov x0, #0 + ret +endfunc console_imx_uart_flush diff --git a/plat/imx/common/include/imx_uart.h b/plat/imx/common/include/imx_uart.h index a251024f1..1b52e2f0b 100644 --- a/plat/imx/common/include/imx_uart.h +++ b/plat/imx/common/include/imx_uart.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -16,7 +16,7 @@ typedef struct { uintptr_t base; } console_uart_t; -int console_uart_register(uintptr_t baseaddr, uint32_t clock, uint32_t baud, +int console_imx_uart_register(uintptr_t baseaddr, uint32_t clock, uint32_t baud, console_uart_t *console); #endif /*__ASSEMBLY__*/ diff --git a/plat/imx/imx8m/imx8mq/imx8mq_bl31_setup.c b/plat/imx/imx8m/imx8mq/imx8mq_bl31_setup.c index f4e6ee746..b18edd96d 100644 --- a/plat/imx/imx8m/imx8mq/imx8mq_bl31_setup.c +++ b/plat/imx/imx8m/imx8mq/imx8mq_bl31_setup.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -87,7 +87,7 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, #if DEBUG_CONSOLE static console_uart_t console; - console_uart_register(IMX_BOOT_UART_BASE, IMX_BOOT_UART_CLK_IN_HZ, + console_imx_uart_register(IMX_BOOT_UART_BASE, IMX_BOOT_UART_CLK_IN_HZ, IMX_CONSOLE_BAUDRATE, &console); #endif /*