From d7873bcd541b99a816c4ea6f1cce66858641f6fc Mon Sep 17 00:00:00 2001 From: Andre Przywara Date: Sat, 25 Jan 2020 00:58:35 +0000 Subject: [PATCH 1/9] imx: Use generic console_t data structure Since now the generic console_t structure holds the UART base address as well, let's use that generic location and drop the UART driver specific data structure at all. Change-Id: I058f793e4024fa7291e432f5be374a77faf16f36 Signed-off-by: Andre Przywara --- drivers/imx/uart/imx_uart.h | 7 +------ plat/imx/common/include/imx8_lpuart.h | 7 +------ plat/imx/common/include/imx_uart.h | 7 +------ plat/imx/imx7/common/imx7_bl2_el3_common.c | 4 ++-- plat/imx/imx8m/imx8mm/imx8mm_bl31_setup.c | 4 ++-- plat/imx/imx8m/imx8mq/imx8mq_bl31_setup.c | 2 +- plat/imx/imx8qm/imx8qm_bl31_setup.c | 2 +- plat/imx/imx8qx/imx8qx_bl31_setup.c | 2 +- 8 files changed, 10 insertions(+), 25 deletions(-) diff --git a/drivers/imx/uart/imx_uart.h b/drivers/imx/uart/imx_uart.h index 4f6d3de2e..a13302484 100644 --- a/drivers/imx/uart/imx_uart.h +++ b/drivers/imx/uart/imx_uart.h @@ -154,15 +154,10 @@ #ifndef __ASSEMBLER__ -typedef struct { - console_t console; - uintptr_t base; -} console_imx_uart_t; - int console_imx_uart_register(uintptr_t baseaddr, uint32_t clock, uint32_t baud, - console_imx_uart_t *console); + console_t *console); #endif /*__ASSEMBLER__*/ #endif /* IMX_UART_H */ diff --git a/plat/imx/common/include/imx8_lpuart.h b/plat/imx/common/include/imx8_lpuart.h index 0ea284fdf..26470e040 100644 --- a/plat/imx/common/include/imx8_lpuart.h +++ b/plat/imx/common/include/imx8_lpuart.h @@ -54,13 +54,8 @@ #include -typedef struct { - console_t console; - uintptr_t base; -} console_lpuart_t; - int console_lpuart_register(uintptr_t baseaddr, uint32_t clock, uint32_t baud, - console_lpuart_t *console); + console_t *console); #endif /*__ASSEMBLER__*/ #endif /* IMX8_LPUART_H */ diff --git a/plat/imx/common/include/imx_uart.h b/plat/imx/common/include/imx_uart.h index cc1b5318e..6c4d62f57 100644 --- a/plat/imx/common/include/imx_uart.h +++ b/plat/imx/common/include/imx_uart.h @@ -11,13 +11,8 @@ #ifndef __ASSEMBLER__ -typedef struct { - console_t console; - uintptr_t base; -} console_uart_t; - int console_imx_uart_register(uintptr_t baseaddr, uint32_t clock, uint32_t baud, - console_uart_t *console); + console_t *console); #endif /*__ASSEMBLER__*/ #endif /* IMX_UART_H */ diff --git a/plat/imx/imx7/common/imx7_bl2_el3_common.c b/plat/imx/imx7/common/imx7_bl2_el3_common.c index a1e2aafd4..7f156e306 100644 --- a/plat/imx/imx7/common/imx7_bl2_el3_common.c +++ b/plat/imx/imx7/common/imx7_bl2_el3_common.c @@ -150,7 +150,7 @@ static void imx7_setup_wdog_clocks(void) void bl2_el3_early_platform_setup(u_register_t arg1, u_register_t arg2, u_register_t arg3, u_register_t arg4) { - static console_imx_uart_t console; + static console_t console; int console_scope = CONSOLE_FLAG_BOOT | CONSOLE_FLAG_RUNTIME; /* Initialize common components */ @@ -170,7 +170,7 @@ void bl2_el3_early_platform_setup(u_register_t arg1, u_register_t arg2, PLAT_IMX7_BOOT_UART_CLK_IN_HZ, PLAT_IMX7_CONSOLE_BAUDRATE, &console); - console_set_scope(&console.console, console_scope); + console_set_scope(&console, console_scope); /* Open handles to persistent storage */ plat_imx7_io_setup(); diff --git a/plat/imx/imx8m/imx8mm/imx8mm_bl31_setup.c b/plat/imx/imx8m/imx8mm/imx8mm_bl31_setup.c index 4c5f4f0d1..40110d778 100644 --- a/plat/imx/imx8m/imx8mm/imx8mm_bl31_setup.c +++ b/plat/imx/imx8m/imx8mm/imx8mm_bl31_setup.c @@ -97,7 +97,7 @@ void bl31_tzc380_setup(void) void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, u_register_t arg2, u_register_t arg3) { - static console_uart_t console; + static console_t console; int i; /* Enable CSU NS access permission */ @@ -114,7 +114,7 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, console_imx_uart_register(IMX_BOOT_UART_BASE, IMX_BOOT_UART_CLK_IN_HZ, IMX_CONSOLE_BAUDRATE, &console); /* This console is only used for boot stage */ - console_set_scope(&console.console, CONSOLE_FLAG_BOOT); + console_set_scope(&console, CONSOLE_FLAG_BOOT); /* * tell BL3-1 where the non-secure software image is located diff --git a/plat/imx/imx8m/imx8mq/imx8mq_bl31_setup.c b/plat/imx/imx8m/imx8mq/imx8mq_bl31_setup.c index a347389a2..05b59705f 100644 --- a/plat/imx/imx8m/imx8mq/imx8mq_bl31_setup.c +++ b/plat/imx/imx8m/imx8mq/imx8mq_bl31_setup.c @@ -133,7 +133,7 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, imx8m_caam_init(); #if DEBUG_CONSOLE - static console_uart_t console; + static console_t console; console_imx_uart_register(IMX_BOOT_UART_BASE, IMX_BOOT_UART_CLK_IN_HZ, IMX_CONSOLE_BAUDRATE, &console); diff --git a/plat/imx/imx8qm/imx8qm_bl31_setup.c b/plat/imx/imx8qm/imx8qm_bl31_setup.c index 9232cbc2d..cffb140fb 100644 --- a/plat/imx/imx8qm/imx8qm_bl31_setup.c +++ b/plat/imx/imx8qm/imx8qm_bl31_setup.c @@ -295,7 +295,7 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, u_register_t arg2, u_register_t arg3) { #if DEBUG_CONSOLE - static console_lpuart_t console; + static console_t console; #endif if (sc_ipc_open(&ipc_handle, SC_IPC_BASE) != SC_ERR_NONE) panic(); diff --git a/plat/imx/imx8qx/imx8qx_bl31_setup.c b/plat/imx/imx8qx/imx8qx_bl31_setup.c index 58c82ce60..97d222787 100644 --- a/plat/imx/imx8qx/imx8qx_bl31_setup.c +++ b/plat/imx/imx8qx/imx8qx_bl31_setup.c @@ -255,7 +255,7 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, u_register_t arg2, u_register_t arg3) { #if DEBUG_CONSOLE - static console_lpuart_t console; + static console_t console; #endif if (sc_ipc_open(&ipc_handle, SC_IPC_BASE) != SC_ERR_NONE) panic(); From 98964f0523d6c5dc5ee8e6bb8212ffc7df5efe14 Mon Sep 17 00:00:00 2001 From: Andre Przywara Date: Sat, 25 Jan 2020 00:58:35 +0000 Subject: [PATCH 2/9] 16550: Use generic console_t data structure Since now the generic console_t structure holds the UART base address as well, let's use that generic location and drop the UART driver specific data structure at all. Change-Id: I5c2fe3b6a667acf80c808cfec4a64059a2c9c25f Signed-off-by: Andre Przywara --- drivers/ti/uart/aarch32/16550_console.S | 18 +++++++++--------- drivers/ti/uart/aarch64/16550_console.S | 18 +++++++++--------- include/drivers/ti/uart/uart_16550.h | 9 +-------- plat/allwinner/common/sunxi_bl31_setup.c | 2 +- plat/intel/soc/agilex/bl2_plat_setup.c | 2 +- plat/intel/soc/agilex/bl31_plat_setup.c | 2 +- plat/intel/soc/stratix10/bl2_plat_setup.c | 2 +- plat/intel/soc/stratix10/bl31_plat_setup.c | 2 +- plat/marvell/common/marvell_console.c | 14 ++++++-------- plat/mediatek/mt8173/bl31_plat_setup.c | 2 +- plat/mediatek/mt8183/bl31_plat_setup.c | 2 +- plat/nvidia/tegra/soc/t132/plat_setup.c | 4 ++-- plat/nvidia/tegra/soc/t186/plat_setup.c | 4 ++-- plat/nvidia/tegra/soc/t194/plat_setup.c | 2 +- plat/nvidia/tegra/soc/t210/plat_setup.c | 4 ++-- plat/rockchip/common/bl31_plat_setup.c | 2 +- plat/rockchip/common/sp_min_plat_setup.c | 2 +- plat/rpi/common/rpi3_common.c | 4 ++-- plat/ti/k3/common/k3_console.c | 2 +- 19 files changed, 44 insertions(+), 53 deletions(-) diff --git a/drivers/ti/uart/aarch32/16550_console.S b/drivers/ti/uart/aarch32/16550_console.S index 5cd9b30cd..bc0b3ab1c 100644 --- a/drivers/ti/uart/aarch32/16550_console.S +++ b/drivers/ti/uart/aarch32/16550_console.S @@ -91,7 +91,7 @@ endfunc console_16550_core_init /* ------------------------------------------------------- * int console_16550_register(uintptr_t baseaddr, * uint32_t clock, uint32_t baud, - * console_16550_t *console); + * console_t *console); * Function to initialize and register a new 16550 * console. Storage passed in for the console struct * *must* be persistent (i.e. not from the stack). @@ -101,7 +101,7 @@ endfunc console_16550_core_init * In: r0 - UART register base address * r1 - UART clock in Hz * r2 - Baud rate (ignored if r1 is 0) - * r3 - pointer to empty console_16550_t struct + * r3 - pointer to empty console_t struct * Out: return 1 on success, 0 on error * Clobber list : r0, r1, r2 * ------------------------------------------------------- @@ -111,7 +111,7 @@ func console_16550_register mov r4, r3 cmp r4, #0 beq register_fail - str r0, [r4, #CONSOLE_T_16550_BASE] + str r0, [r4, #CONSOLE_T_BASE] /* A clock rate of zero means to skip the initialisation. */ cmp r1, #0 @@ -167,7 +167,7 @@ func console_16550_core_putc endfunc console_16550_core_putc /* -------------------------------------------------------- - * int console_16550_putc(int c, console_16550_t *console) + * int console_16550_putc(int c, console_t *console) * Function to output a character over the console. It * returns the character printed on success or -1 on error. * In : r0 - character to be printed @@ -181,7 +181,7 @@ func console_16550_putc cmp r1, #0 ASM_ASSERT(ne) #endif /* ENABLE_ASSERTIONS */ - ldr r1, [r1, #CONSOLE_T_16550_BASE] + ldr r1, [r1, #CONSOLE_T_BASE] b console_16550_core_putc endfunc console_16550_putc @@ -213,7 +213,7 @@ no_char: endfunc console_16550_core_getc /* --------------------------------------------- - * int console_16550_getc(console_16550_t *console) + * int console_16550_getc(console_t *console) * Function to get a character from the console. * It returns the character grabbed on success * or -1 on if no character is available. @@ -227,7 +227,7 @@ func console_16550_getc cmp r0, #0 ASM_ASSERT(ne) #endif /* ENABLE_ASSERTIONS */ - ldr r0, [r0, #CONSOLE_T_16550_BASE] + ldr r0, [r0, #CONSOLE_T_BASE] b console_16550_core_getc endfunc console_16550_getc @@ -257,7 +257,7 @@ func console_16550_core_flush endfunc console_16550_core_flush /* --------------------------------------------- - * int console_16550_flush(console_pl011_t *console) + * int console_16550_flush(console_t *console) * Function to force a write of all buffered * data that hasn't been output. * In : r0 - pointer to console_t structure @@ -270,6 +270,6 @@ func console_16550_flush cmp r0, #0 ASM_ASSERT(ne) #endif /* ENABLE_ASSERTIONS */ - ldr r0, [r0, #CONSOLE_T_16550_BASE] + ldr r0, [r0, #CONSOLE_T_BASE] b console_16550_core_flush endfunc console_16550_flush diff --git a/drivers/ti/uart/aarch64/16550_console.S b/drivers/ti/uart/aarch64/16550_console.S index 80c1b8646..064022798 100644 --- a/drivers/ti/uart/aarch64/16550_console.S +++ b/drivers/ti/uart/aarch64/16550_console.S @@ -88,7 +88,7 @@ endfunc console_16550_core_init /* ----------------------------------------------- * int console_16550_register(uintptr_t baseaddr, * uint32_t clock, uint32_t baud, - * console_16550_t *console); + * console_t *console); * Function to initialize and register a new 16550 * console. Storage passed in for the console struct * *must* be persistent (i.e. not from the stack). @@ -98,7 +98,7 @@ endfunc console_16550_core_init * In: x0 - UART register base address * w1 - UART clock in Hz * w2 - Baud rate (ignored if w1 is 0) - * x3 - pointer to empty console_16550_t struct + * x3 - pointer to empty console_t struct * Out: return 1 on success, 0 on error * Clobber list : x0, x1, x2, x6, x7, x14 * ----------------------------------------------- @@ -107,7 +107,7 @@ func console_16550_register mov x7, x30 mov x6, x3 cbz x6, register_fail - str x0, [x6, #CONSOLE_T_16550_BASE] + str x0, [x6, #CONSOLE_T_BASE] /* A clock rate of zero means to skip the initialisation. */ cbz w1, register_16550 @@ -161,7 +161,7 @@ func console_16550_core_putc endfunc console_16550_core_putc /* -------------------------------------------------------- - * int console_16550_putc(int c, console_16550_t *console) + * int console_16550_putc(int c, console_t *console) * Function to output a character over the console. It * returns the character printed on success or -1 on error. * In : w0 - character to be printed @@ -175,7 +175,7 @@ func console_16550_putc cmp x1, #0 ASM_ASSERT(ne) #endif /* ENABLE_ASSERTIONS */ - ldr x1, [x1, #CONSOLE_T_16550_BASE] + ldr x1, [x1, #CONSOLE_T_BASE] b console_16550_core_putc endfunc console_16550_putc @@ -206,7 +206,7 @@ no_char: endfunc console_16550_core_getc /* --------------------------------------------- - * int console_16550_getc(console_16550_t *console) + * int console_16550_getc(console_t *console) * Function to get a character from the console. * It returns the character grabbed on success * or -1 on if no character is available. @@ -220,7 +220,7 @@ func console_16550_getc cmp x1, #0 ASM_ASSERT(ne) #endif /* ENABLE_ASSERTIONS */ - ldr x0, [x0, #CONSOLE_T_16550_BASE] + ldr x0, [x0, #CONSOLE_T_BASE] b console_16550_core_getc endfunc console_16550_getc @@ -250,7 +250,7 @@ func console_16550_core_flush endfunc console_16550_core_flush /* --------------------------------------------- - * int console_16550_flush(console_pl011_t *console) + * int console_16550_flush(console_t *console) * Function to force a write of all buffered * data that hasn't been output. * In : x0 - pointer to console_t structure @@ -263,6 +263,6 @@ func console_16550_flush cmp x0, #0 ASM_ASSERT(ne) #endif /* ENABLE_ASSERTIONS */ - ldr x0, [x0, #CONSOLE_T_16550_BASE] + ldr x0, [x0, #CONSOLE_T_BASE] b console_16550_core_flush endfunc console_16550_flush diff --git a/include/drivers/ti/uart/uart_16550.h b/include/drivers/ti/uart/uart_16550.h index 2b95fa33a..bddd9970c 100644 --- a/include/drivers/ti/uart/uart_16550.h +++ b/include/drivers/ti/uart/uart_16550.h @@ -71,17 +71,10 @@ #define UARTLSR_RDR_BIT (0) /* Rx Data Ready Bit */ #define UARTLSR_RDR (1 << UARTLSR_RDR_BIT) /* Rx Data Ready */ -#define CONSOLE_T_16550_BASE CONSOLE_T_DRVDATA - #ifndef __ASSEMBLER__ #include -typedef struct { - console_t console; - uintptr_t base; -} console_16550_t; - /* * Initialize a new 16550 console instance and register it with the console * framework. The |console| pointer must point to storage that will be valid @@ -94,7 +87,7 @@ typedef struct { * case as well. */ int console_16550_register(uintptr_t baseaddr, uint32_t clock, uint32_t baud, - console_16550_t *console); + console_t *console); #endif /*__ASSEMBLER__*/ diff --git a/plat/allwinner/common/sunxi_bl31_setup.c b/plat/allwinner/common/sunxi_bl31_setup.c index a24527c5d..e836a345b 100644 --- a/plat/allwinner/common/sunxi_bl31_setup.c +++ b/plat/allwinner/common/sunxi_bl31_setup.c @@ -28,7 +28,7 @@ static entry_point_info_t bl32_image_ep_info; static entry_point_info_t bl33_image_ep_info; -static console_16550_t console; +static console_t console; static const gicv2_driver_data_t sunxi_gic_data = { .gicd_base = SUNXI_GICD_BASE, diff --git a/plat/intel/soc/agilex/bl2_plat_setup.c b/plat/intel/soc/agilex/bl2_plat_setup.c index f32820777..468b356b5 100644 --- a/plat/intel/soc/agilex/bl2_plat_setup.c +++ b/plat/intel/soc/agilex/bl2_plat_setup.c @@ -51,7 +51,7 @@ boot_source_type boot_source = BOOT_SOURCE; void bl2_el3_early_platform_setup(u_register_t x0, u_register_t x1, u_register_t x2, u_register_t x4) { - static console_16550_t console; + static console_t console; handoff reverse_handoff_ptr; generic_delay_timer_init(); diff --git a/plat/intel/soc/agilex/bl31_plat_setup.c b/plat/intel/soc/agilex/bl31_plat_setup.c index 4b1144095..6f32aff4a 100644 --- a/plat/intel/soc/agilex/bl31_plat_setup.c +++ b/plat/intel/soc/agilex/bl31_plat_setup.c @@ -37,7 +37,7 @@ entry_point_info_t *bl31_plat_get_next_image_ep_info(uint32_t type) void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, u_register_t arg2, u_register_t arg3) { - static console_16550_t console; + static console_t console; console_16550_register(PLAT_UART0_BASE, PLAT_UART_CLOCK, PLAT_BAUDRATE, &console); diff --git a/plat/intel/soc/stratix10/bl2_plat_setup.c b/plat/intel/soc/stratix10/bl2_plat_setup.c index 78ca253e7..d0c8e4c7b 100644 --- a/plat/intel/soc/stratix10/bl2_plat_setup.c +++ b/plat/intel/soc/stratix10/bl2_plat_setup.c @@ -50,7 +50,7 @@ boot_source_type boot_source = BOOT_SOURCE; void bl2_el3_early_platform_setup(u_register_t x0, u_register_t x1, u_register_t x2, u_register_t x4) { - static console_16550_t console; + static console_t console; handoff reverse_handoff_ptr; generic_delay_timer_init(); diff --git a/plat/intel/soc/stratix10/bl31_plat_setup.c b/plat/intel/soc/stratix10/bl31_plat_setup.c index 4c3123815..5813c8f8c 100644 --- a/plat/intel/soc/stratix10/bl31_plat_setup.c +++ b/plat/intel/soc/stratix10/bl31_plat_setup.c @@ -45,7 +45,7 @@ entry_point_info_t *bl31_plat_get_next_image_ep_info(uint32_t type) void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, u_register_t arg2, u_register_t arg3) { - static console_16550_t console; + static console_t console; console_16550_register(PLAT_UART0_BASE, PLAT_UART_CLOCK, PLAT_BAUDRATE, &console); diff --git a/plat/marvell/common/marvell_console.c b/plat/marvell/common/marvell_console.c index 22c5eb3af..33931afda 100644 --- a/plat/marvell/common/marvell_console.c +++ b/plat/marvell/common/marvell_console.c @@ -20,8 +20,8 @@ static console_a3700_t marvell_runtime_console; #else #include -static console_16550_t marvell_boot_console; -static console_16550_t marvell_runtime_console; +static console_t marvell_boot_console; +static console_t marvell_runtime_console; #endif /******************************************************************************* @@ -50,15 +50,14 @@ void marvell_console_boot_init(void) panic(); } - console_set_scope(&marvell_boot_console.console, - CONSOLE_FLAG_BOOT); + console_set_scope(&marvell_boot_console, CONSOLE_FLAG_BOOT); } void marvell_console_boot_end(void) { (void)console_flush(); - (void)console_unregister(&marvell_boot_console.console); + (void)console_unregister(&marvell_boot_console); } /* Initialize the runtime console */ @@ -77,13 +76,12 @@ void marvell_console_runtime_init(void) if (rc == 0) panic(); - console_set_scope(&marvell_runtime_console.console, - CONSOLE_FLAG_RUNTIME); + console_set_scope(&marvell_runtime_console, CONSOLE_FLAG_RUNTIME); } void marvell_console_runtime_end(void) { (void)console_flush(); - (void)console_unregister(&marvell_runtime_console.console); + (void)console_unregister(&marvell_runtime_console); } diff --git a/plat/mediatek/mt8173/bl31_plat_setup.c b/plat/mediatek/mt8173/bl31_plat_setup.c index 73a479b50..bd7d0b0ee 100644 --- a/plat/mediatek/mt8173/bl31_plat_setup.c +++ b/plat/mediatek/mt8173/bl31_plat_setup.c @@ -100,7 +100,7 @@ entry_point_info_t *bl31_plat_get_next_image_ep_info(uint32_t type) void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, u_register_t arg2, u_register_t arg3) { - static console_16550_t console; + static console_t console; console_16550_register(MT8173_UART0_BASE, MT8173_UART_CLOCK, MT8173_BAUDRATE, &console); diff --git a/plat/mediatek/mt8183/bl31_plat_setup.c b/plat/mediatek/mt8183/bl31_plat_setup.c index 8204d7717..e96b4ad0c 100644 --- a/plat/mediatek/mt8183/bl31_plat_setup.c +++ b/plat/mediatek/mt8183/bl31_plat_setup.c @@ -112,7 +112,7 @@ entry_point_info_t *bl31_plat_get_next_image_ep_info(uint32_t type) void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, u_register_t arg2, u_register_t arg3) { - static console_16550_t console; + static console_t console; params_early_setup(arg1); diff --git a/plat/nvidia/tegra/soc/t132/plat_setup.c b/plat/nvidia/tegra/soc/t132/plat_setup.c index 4bfc2de0e..43acdd642 100644 --- a/plat/nvidia/tegra/soc/t132/plat_setup.c +++ b/plat/nvidia/tegra/soc/t132/plat_setup.c @@ -92,7 +92,7 @@ static uint32_t tegra132_uart_addresses[TEGRA132_MAX_UART_PORTS + 1] = { ******************************************************************************/ void plat_enable_console(int32_t id) { - static console_16550_t uart_console; + static console_t uart_console; uint32_t console_clock; if ((id > 0) && (id < TEGRA132_MAX_UART_PORTS)) { @@ -109,7 +109,7 @@ void plat_enable_console(int32_t id) console_clock, TEGRA_CONSOLE_BAUDRATE, &uart_console); - console_set_scope(&uart_console.console, CONSOLE_FLAG_BOOT | + console_set_scope(&uart_console, CONSOLE_FLAG_BOOT | CONSOLE_FLAG_RUNTIME | CONSOLE_FLAG_CRASH); } } diff --git a/plat/nvidia/tegra/soc/t186/plat_setup.c b/plat/nvidia/tegra/soc/t186/plat_setup.c index 06a328427..7028bfc5d 100644 --- a/plat/nvidia/tegra/soc/t186/plat_setup.c +++ b/plat/nvidia/tegra/soc/t186/plat_setup.c @@ -150,7 +150,7 @@ static uint32_t tegra186_uart_addresses[TEGRA186_MAX_UART_PORTS + 1] = { ******************************************************************************/ void plat_enable_console(int32_t id) { - static console_16550_t uart_console; + static console_t uart_console; uint32_t console_clock; if ((id > 0) && (id < TEGRA186_MAX_UART_PORTS)) { @@ -167,7 +167,7 @@ void plat_enable_console(int32_t id) console_clock, TEGRA_CONSOLE_BAUDRATE, &uart_console); - console_set_scope(&uart_console.console, CONSOLE_FLAG_BOOT | + console_set_scope(&uart_console, CONSOLE_FLAG_BOOT | CONSOLE_FLAG_RUNTIME | CONSOLE_FLAG_CRASH); } } diff --git a/plat/nvidia/tegra/soc/t194/plat_setup.c b/plat/nvidia/tegra/soc/t194/plat_setup.c index 3640ade0a..7f2b00d1b 100644 --- a/plat/nvidia/tegra/soc/t194/plat_setup.c +++ b/plat/nvidia/tegra/soc/t194/plat_setup.c @@ -174,7 +174,7 @@ void plat_enable_console(int32_t id) CONSOLE_FLAG_RUNTIME | CONSOLE_FLAG_CRASH); } #else - static console_16550_t uart_console; + static console_t uart_console; if ((id > 0) && (id < TEGRA194_MAX_UART_PORTS)) { /* diff --git a/plat/nvidia/tegra/soc/t210/plat_setup.c b/plat/nvidia/tegra/soc/t210/plat_setup.c index c32772de8..7afbe0d9a 100644 --- a/plat/nvidia/tegra/soc/t210/plat_setup.c +++ b/plat/nvidia/tegra/soc/t210/plat_setup.c @@ -119,7 +119,7 @@ static uint32_t tegra210_uart_addresses[TEGRA210_MAX_UART_PORTS + 1] = { ******************************************************************************/ void plat_enable_console(int32_t id) { - static console_16550_t uart_console; + static console_t uart_console; uint32_t console_clock; if ((id > 0) && (id < TEGRA210_MAX_UART_PORTS)) { @@ -136,7 +136,7 @@ void plat_enable_console(int32_t id) console_clock, TEGRA_CONSOLE_BAUDRATE, &uart_console); - console_set_scope(&uart_console.console, CONSOLE_FLAG_BOOT | + console_set_scope(&uart_console, CONSOLE_FLAG_BOOT | CONSOLE_FLAG_RUNTIME | CONSOLE_FLAG_CRASH); } } diff --git a/plat/rockchip/common/bl31_plat_setup.c b/plat/rockchip/common/bl31_plat_setup.c index c4a03592e..98ef415c9 100644 --- a/plat/rockchip/common/bl31_plat_setup.c +++ b/plat/rockchip/common/bl31_plat_setup.c @@ -57,7 +57,7 @@ void params_early_setup(u_register_t plat_param_from_bl2) void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, u_register_t arg2, u_register_t arg3) { - static console_16550_t console; + static console_t console; params_early_setup(arg1); diff --git a/plat/rockchip/common/sp_min_plat_setup.c b/plat/rockchip/common/sp_min_plat_setup.c index 6d15075f2..0237b167f 100644 --- a/plat/rockchip/common/sp_min_plat_setup.c +++ b/plat/rockchip/common/sp_min_plat_setup.c @@ -52,7 +52,7 @@ unsigned int plat_is_my_cpu_primary(void); void sp_min_early_platform_setup2(u_register_t arg0, u_register_t arg1, u_register_t arg2, u_register_t arg3) { - static console_16550_t console; + static console_t console; params_early_setup(arg1); diff --git a/plat/rpi/common/rpi3_common.c b/plat/rpi/common/rpi3_common.c index ff3369427..27281f2ba 100644 --- a/plat/rpi/common/rpi3_common.c +++ b/plat/rpi/common/rpi3_common.c @@ -102,7 +102,7 @@ static const mmap_region_t plat_rpi3_mmap[] = { /******************************************************************************* * Function that sets up the console ******************************************************************************/ -static console_16550_t rpi3_console; +static console_t rpi3_console; void rpi3_console_init(unsigned int base_clk_rate) { @@ -123,7 +123,7 @@ void rpi3_console_init(unsigned int base_clk_rate) panic(); } - console_set_scope(&rpi3_console.console, console_scope); + console_set_scope(&rpi3_console, console_scope); } /******************************************************************************* diff --git a/plat/ti/k3/common/k3_console.c b/plat/ti/k3/common/k3_console.c index ba0ddacec..8c44c17e2 100644 --- a/plat/ti/k3/common/k3_console.c +++ b/plat/ti/k3/common/k3_console.c @@ -13,7 +13,7 @@ void bl31_console_setup(void) { - static console_16550_t console; + static console_t console; /* Initialize the console to provide early debug support */ console_16550_register(K3_USART_BASE, K3_USART_CLK_SPEED, From 3968bc08abb3f43a03175ec7d30b797f253c0caa Mon Sep 17 00:00:00 2001 From: Andre Przywara Date: Sat, 25 Jan 2020 00:58:35 +0000 Subject: [PATCH 3/9] a3700: Use generic console_t data structure Since now the generic console_t structure holds the UART base address as well, let's use that generic location and drop the UART driver specific data structure at all. Change-Id: I89c3ab2ed85ab941d8b38ced48474feb4aaa8b7e Signed-off-by: Andre Przywara --- drivers/marvell/uart/a3700_console.S | 18 +++++++++--------- include/drivers/marvell/uart/a3700_console.h | 9 +-------- plat/marvell/common/marvell_console.c | 4 ++-- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/drivers/marvell/uart/a3700_console.S b/drivers/marvell/uart/a3700_console.S index da1ce351c..ecd494ca7 100644 --- a/drivers/marvell/uart/a3700_console.S +++ b/drivers/marvell/uart/a3700_console.S @@ -110,7 +110,7 @@ endfunc console_a3700_core_init .globl console_a3700_register /* ----------------------------------------------- - * int console_a3700_register(console_16550_t *console, + * int console_a3700_register(console_t *console, uintptr_t base, uint32_t clk, uint32_t baud) * Function to initialize and register a new a3700 * console. Storage passed in for the console struct @@ -118,7 +118,7 @@ endfunc console_a3700_core_init * In: x0 - UART register base address * w1 - UART clock in Hz * w2 - Baud rate - * x3 - pointer to empty console_a3700_t struct + * x3 - pointer to empty console_t struct * Out: return 1 on success, 0 on error * Clobber list : x0, x1, x2, x6, x7, x14 * ----------------------------------------------- @@ -127,7 +127,7 @@ func console_a3700_register mov x7, x30 mov x6, x3 cbz x6, register_fail - str x0, [x6, #CONSOLE_T_A3700_BASE] + str x0, [x6, #CONSOLE_T_BASE] bl console_a3700_core_init cbz x0, register_fail @@ -178,7 +178,7 @@ putc_error: endfunc console_a3700_core_putc /* -------------------------------------------------------- - * int console_a3700_putc(int c, console_a3700_t *console) + * int console_a3700_putc(int c, console_t *console) * Function to output a character over the console. It * returns the character printed on success or -1 on error. * In : w0 - character to be printed @@ -188,7 +188,7 @@ endfunc console_a3700_core_putc * -------------------------------------------------------- */ func console_a3700_putc - ldr x1, [x1, #CONSOLE_T_A3700_BASE] + ldr x1, [x1, #CONSOLE_T_BASE] b console_a3700_core_putc endfunc console_a3700_putc @@ -208,7 +208,7 @@ func console_a3700_core_getc endfunc console_a3700_core_getc /* --------------------------------------------- - * int console_a3700_getc(console_a3700_t *console) + * int console_a3700_getc(console_t *console) * Function to get a character from the console. * It returns the character grabbed on success * or -1 on if no character is available. @@ -218,7 +218,7 @@ endfunc console_a3700_core_getc * --------------------------------------------- */ func console_a3700_getc - ldr x0, [x0, #CONSOLE_T_A3700_BASE] + ldr x0, [x0, #CONSOLE_T_BASE] b console_a3700_core_getc endfunc console_a3700_getc @@ -237,7 +237,7 @@ func console_a3700_core_flush endfunc console_a3700_core_flush /* --------------------------------------------- - * int console_a3700_flush(console_a3700_t *console) + * int console_a3700_flush(console_t *console) * Function to force a write of all buffered * data that hasn't been output. * In : x0 - pointer to console_t structure @@ -246,7 +246,7 @@ endfunc console_a3700_core_flush * --------------------------------------------- */ func console_a3700_flush - ldr x0, [x0, #CONSOLE_T_A3700_BASE] + ldr x0, [x0, #CONSOLE_T_BASE] b console_a3700_core_flush endfunc console_a3700_flush diff --git a/include/drivers/marvell/uart/a3700_console.h b/include/drivers/marvell/uart/a3700_console.h index 517f01a8f..5e3ab0515 100644 --- a/include/drivers/marvell/uart/a3700_console.h +++ b/include/drivers/marvell/uart/a3700_console.h @@ -54,17 +54,10 @@ #define UART_CTRL_TXFIFO_RESET (1 << 15) #define UARTLSR_TXFIFOEMPTY (1 << 6) -#define CONSOLE_T_A3700_BASE CONSOLE_T_DRVDATA - #ifndef __ASSEMBLER__ #include -typedef struct { - console_t console; - uintptr_t base; -} console_a3700_t; - /* * Initialize a new a3700 console instance and register it with the console * framework. The |console| pointer must point to storage that will be valid @@ -72,7 +65,7 @@ typedef struct { * Its contents will be reinitialized from scratch. */ int console_a3700_register(uintptr_t baseaddr, uint32_t clock, uint32_t baud, - console_a3700_t *console); + console_t *console); #endif /*__ASSEMBLER__*/ diff --git a/plat/marvell/common/marvell_console.c b/plat/marvell/common/marvell_console.c index 33931afda..b57b84f3f 100644 --- a/plat/marvell/common/marvell_console.c +++ b/plat/marvell/common/marvell_console.c @@ -15,8 +15,8 @@ #ifdef PLAT_a3700 #include -static console_a3700_t marvell_boot_console; -static console_a3700_t marvell_runtime_console; +static console_t marvell_boot_console; +static console_t marvell_runtime_console; #else #include From c01ee06b53451d8792958b30b8ebce3e0e930359 Mon Sep 17 00:00:00 2001 From: Andre Przywara Date: Sat, 25 Jan 2020 00:58:35 +0000 Subject: [PATCH 4/9] rcar: Use generic console_t data structure Since now the generic console_t structure holds the UART base address as well, let's use that generic location and drop the UART driver specific data structure at all. Change-Id: I836e26ff1771abf21fd460d0ee40e90a452e9b43 Signed-off-by: Andre Przywara --- drivers/renesas/rcar/console/rcar_console.S | 10 +++++----- drivers/renesas/rcar/scif/scif.S | 6 +++--- include/drivers/renesas/rcar/console/console.h | 9 +-------- plat/renesas/rcar/rcar_common.c | 8 ++++---- 4 files changed, 13 insertions(+), 20 deletions(-) diff --git a/drivers/renesas/rcar/console/rcar_console.S b/drivers/renesas/rcar/console/rcar_console.S index 859efeceb..4d006b703 100644 --- a/drivers/renesas/rcar/console/rcar_console.S +++ b/drivers/renesas/rcar/console/rcar_console.S @@ -20,14 +20,14 @@ /* ----------------------------------------------- * int console_rcar_register( * uintptr_t base, uint32_t clk, uint32_t baud, - * console_rcar_t *console) + * console_t *console) * Function to initialize and register a new rcar * console. Storage passed in for the console struct * *must* be persistent (i.e. not from the stack). * In: x0 - UART register base address * w1 - UART clock in Hz * w2 - Baud rate - * x3 - pointer to empty console_rcar_t struct + * x3 - pointer to empty console_t struct * Out: return 1 on success, 0 on error * Clobber list : x0, x1, x2, x6, x7, x14 * ----------------------------------------------- @@ -36,7 +36,7 @@ func console_rcar_register mov x7, x30 mov x6, x3 cbz x6, register_fail - str x0, [x6, #CONSOLE_T_RCAR_BASE] + str x0, [x6, #CONSOLE_T_BASE] bl rcar_log_init cbz x0, register_fail @@ -68,11 +68,11 @@ func console_rcar_init endfunc console_rcar_init /* -------------------------------------------------------- - * int console_rcar_putc(int c, console_rcar_t *console) + * int console_rcar_putc(int c, console_t *console) * Function to output a character over the console. It * returns the character printed on success or -1 on error. * In : w0 - character to be printed - * x1 - pointer to console_rcar_t structure + * x1 - pointer to console_t structure * Out : return -1 on error else return character. * Clobber list : x2 * -------------------------------------------------------- diff --git a/drivers/renesas/rcar/scif/scif.S b/drivers/renesas/rcar/scif/scif.S index 8309bb26e..064aba471 100644 --- a/drivers/renesas/rcar/scif/scif.S +++ b/drivers/renesas/rcar/scif/scif.S @@ -126,14 +126,14 @@ /* ----------------------------------------------- * int console_rcar_register( * uintptr_t base, uint32_t clk, uint32_t baud, - * console_rcar_t *console) + * console_t *console) * Function to initialize and register a new rcar * console. Storage passed in for the console struct * *must* be persistent (i.e. not from the stack). * In: x0 - UART register base address * w1 - UART clock in Hz * w2 - Baud rate - * x3 - pointer to empty console_rcar_t struct + * x3 - pointer to empty console_t struct * Out: return 1 on success, 0 on error * Clobber list : x0, x1, x2, x6, x7, x14 * ----------------------------------------------- @@ -142,7 +142,7 @@ func console_rcar_register mov x7, x30 mov x6, x3 cbz x6, register_fail - str x0, [x6, #CONSOLE_T_RCAR_BASE] + str x0, [x6, #CONSOLE_T_BASE] bl console_rcar_init diff --git a/include/drivers/renesas/rcar/console/console.h b/include/drivers/renesas/rcar/console/console.h index 0e4ed8f35..7d5b5d3ce 100644 --- a/include/drivers/renesas/rcar/console/console.h +++ b/include/drivers/renesas/rcar/console/console.h @@ -7,17 +7,10 @@ #ifndef RCAR_PRINTF_H #define RCAR_PRINTF_H -#define CONSOLE_T_RCAR_BASE CONSOLE_T_DRVDATA - #ifndef __ASSEMBLER__ #include -typedef struct { - console_t console; - uintptr_t base; -} console_rcar_t; - /* * Initialize a new rcar console instance and register it with the console * framework. The |console| pointer must point to storage that will be valid @@ -25,7 +18,7 @@ typedef struct { * Its contents will be reinitialized from scratch. */ int console_rcar_register(uintptr_t baseaddr, uint32_t clock, uint32_t baud, - console_rcar_t *console); + console_t *console); #endif /*__ASSEMBLER__*/ diff --git a/plat/renesas/rcar/rcar_common.c b/plat/renesas/rcar/rcar_common.c index 4ea753f2d..dec7229b3 100644 --- a/plat/renesas/rcar/rcar_common.c +++ b/plat/renesas/rcar/rcar_common.c @@ -70,8 +70,8 @@ void plat_ea_handler(unsigned int ea_reason, uint64_t syndrome, void *cookie, #include -static console_rcar_t rcar_boot_console; -static console_rcar_t rcar_runtime_console; +static console_t rcar_boot_console; +static console_t rcar_runtime_console; void rcar_console_boot_init(void) { @@ -81,7 +81,7 @@ void rcar_console_boot_init(void) if (!ret) panic(); - console_set_scope(&rcar_boot_console.console, CONSOLE_FLAG_BOOT); + console_set_scope(&rcar_boot_console, CONSOLE_FLAG_BOOT); } void rcar_console_boot_end(void) @@ -96,7 +96,7 @@ void rcar_console_runtime_init(void) if (!ret) panic(); - console_set_scope(&rcar_boot_console.console, CONSOLE_FLAG_RUNTIME); + console_set_scope(&rcar_boot_console, CONSOLE_FLAG_RUNTIME); } void rcar_console_runtime_end(void) From c10db6deb1867d79c843391b29866a8119bc85b3 Mon Sep 17 00:00:00 2001 From: Andre Przywara Date: Sat, 25 Jan 2020 00:58:35 +0000 Subject: [PATCH 5/9] stm32: Use generic console_t data structure Since now the generic console_t structure holds the UART base address as well, let's use that generic location and drop the UART driver specific data structure at all. Change-Id: Iea6ca26ff4903c33f0fad27fec96fdbabd4e0a91 Signed-off-by: Andre Przywara --- drivers/st/uart/aarch32/stm32_console.S | 14 +++++++------- include/drivers/st/stm32_console.h | 9 +-------- plat/st/stm32mp1/bl2_plat_setup.c | 4 ++-- plat/st/stm32mp1/sp_min/sp_min_setup.c | 4 ++-- 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/drivers/st/uart/aarch32/stm32_console.S b/drivers/st/uart/aarch32/stm32_console.S index ca3c1f618..0ed37d1bd 100644 --- a/drivers/st/uart/aarch32/stm32_console.S +++ b/drivers/st/uart/aarch32/stm32_console.S @@ -91,14 +91,14 @@ endfunc console_stm32_core_init /* ------------------------------------------------------- * int console_stm32_register(uintptr_t baseaddr, * uint32_t clock, uint32_t baud, - * struct console_stm32 *console); + * console_t *console); * Function to initialize and register a new STM32 * console. Storage passed in for the console struct * *must* be persistent (i.e. not from the stack). * In: r0 - UART register base address * r1 - UART clock in Hz * r2 - Baud rate - * r3 - pointer to empty console_stm32 struct + * r3 - pointer to empty console_t struct * Out: return 1 on success, 0 on error * Clobber list : r0, r1, r2 * ------------------------------------------------------- @@ -108,7 +108,7 @@ func console_stm32_register mov r4, r3 cmp r4, #0 beq register_fail - str r0, [r4, #CONSOLE_T_STM32_BASE] + str r0, [r4, #CONSOLE_T_BASE] bl console_stm32_core_init cmp r0, #0 @@ -157,7 +157,7 @@ putc_error: endfunc console_stm32_core_putc /* ------------------------------------------------------------ - * int console_stm32_putc(int c, struct console_stm32 *console) + * int console_stm32_putc(int c, console_t *console) * Function to output a character over the console. It * returns the character printed on success or -1 on error. * In: r0 - character to be printed @@ -171,7 +171,7 @@ func console_stm32_putc cmp r1, #0 ASM_ASSERT(ne) #endif /* ENABLE_ASSERTIONS */ - ldr r1, [r1, #CONSOLE_T_STM32_BASE] + ldr r1, [r1, #CONSOLE_T_BASE] b console_stm32_core_putc endfunc console_stm32_putc @@ -219,7 +219,7 @@ flush_error: endfunc console_stm32_core_flush /* ------------------------------------------------------ - * int console_stm32_flush(struct console_stm32 *console) + * int console_stm32_flush(console_t *console) * Function to force a write of all buffered * data that hasn't been output. * In : r0 - pointer to console_t structure @@ -232,6 +232,6 @@ func console_stm32_flush cmp r0, #0 ASM_ASSERT(ne) #endif /* ENABLE_ASSERTIONS */ - ldr r0, [r0, #CONSOLE_T_STM32_BASE] + ldr r0, [r0, #CONSOLE_T_BASE] b console_stm32_core_flush endfunc console_stm32_flush diff --git a/include/drivers/st/stm32_console.h b/include/drivers/st/stm32_console.h index a2ad87cb5..8d9187d2a 100644 --- a/include/drivers/st/stm32_console.h +++ b/include/drivers/st/stm32_console.h @@ -9,17 +9,10 @@ #include -#define CONSOLE_T_STM32_BASE CONSOLE_T_DRVDATA - #ifndef __ASSEMBLER__ #include -struct console_stm32 { - console_t console; - uintptr_t base; -}; - /* * Initialize a new STM32 console instance and register it with the console * framework. The |console| pointer must point to storage that will be valid @@ -27,7 +20,7 @@ struct console_stm32 { * Its contents will be reinitialized from scratch. */ int console_stm32_register(uintptr_t baseaddr, uint32_t clock, uint32_t baud, - struct console_stm32 *console); + console_t *console); #endif /*__ASSEMBLER__*/ diff --git a/plat/st/stm32mp1/bl2_plat_setup.c b/plat/st/stm32mp1/bl2_plat_setup.c index d9e29b4e8..024dbe076 100644 --- a/plat/st/stm32mp1/bl2_plat_setup.c +++ b/plat/st/stm32mp1/bl2_plat_setup.c @@ -31,7 +31,7 @@ #include #include -static struct console_stm32 console; +static console_t console; static struct stm32mp_auth_ops stm32mp1_auth_ops; static void print_reset_reason(void) @@ -273,7 +273,7 @@ void bl2_el3_plat_arch_setup(void) panic(); } - console_set_scope(&console.console, CONSOLE_FLAG_BOOT | + console_set_scope(&console, CONSOLE_FLAG_BOOT | CONSOLE_FLAG_CRASH | CONSOLE_FLAG_TRANSLATE_CRLF); stm32mp_print_cpuinfo(); diff --git a/plat/st/stm32mp1/sp_min/sp_min_setup.c b/plat/st/stm32mp1/sp_min/sp_min_setup.c index e10dfbfc0..4e74c275d 100644 --- a/plat/st/stm32mp1/sp_min/sp_min_setup.c +++ b/plat/st/stm32mp1/sp_min/sp_min_setup.c @@ -35,7 +35,7 @@ ******************************************************************************/ static entry_point_info_t bl33_image_ep_info; -static struct console_stm32 console; +static console_t console; /******************************************************************************* * Interrupt handler for FIQ (secure IRQ) @@ -142,7 +142,7 @@ void sp_min_early_platform_setup2(u_register_t arg0, u_register_t arg1, #ifdef DEBUG console_flags |= CONSOLE_FLAG_RUNTIME; #endif - console_set_scope(&console.console, console_flags); + console_set_scope(&console, console_flags); } } From 9536a25e03e554afbb273583f24ca44c6ad889fd Mon Sep 17 00:00:00 2001 From: Andre Przywara Date: Sat, 25 Jan 2020 00:58:35 +0000 Subject: [PATCH 6/9] LS 16550: Use generic console_t data structure Since now the generic console_t structure holds the UART base address as well, let's use that generic location and drop the UART driver specific data structure at all. Change-Id: Ifd6aff1064ba1c3c029cdd8a83f715f7a9976db5 Signed-off-by: Andre Przywara --- plat/layerscape/common/aarch64/ls_console.S | 18 +++++++++--------- plat/layerscape/common/include/ls_16550.h | 9 +-------- plat/layerscape/common/ls_bl1_setup.c | 2 +- plat/layerscape/common/ls_bl2_setup.c | 2 +- plat/layerscape/common/ls_bl31_setup.c | 4 ++-- plat/layerscape/common/tsp/ls_tsp_setup.c | 2 +- plat/nvidia/tegra/soc/t194/plat_setup.c | 4 ++-- 7 files changed, 17 insertions(+), 24 deletions(-) diff --git a/plat/layerscape/common/aarch64/ls_console.S b/plat/layerscape/common/aarch64/ls_console.S index f8948b4ab..c1bd3f731 100644 --- a/plat/layerscape/common/aarch64/ls_console.S +++ b/plat/layerscape/common/aarch64/ls_console.S @@ -81,7 +81,7 @@ endfunc console_ls_16550_core_init .globl console_ls_16550_register /* ----------------------------------------------- - * int console_ls_16550_register(console_ls_16550_t *console, + * int console_ls_16550_register(console_t *console, * uintptr_t base, uint32_t clk, uint32_t baud) * Function to initialize and register a new 16550 * console. Storage passed in for the console struct @@ -89,7 +89,7 @@ endfunc console_ls_16550_core_init * In: x0 - UART register base address * w1 - UART clock in Hz * w2 - Baud rate - * x3 - pointer to empty console_ls_16550_t struct + * x3 - pointer to empty console_t struct * Out: return 1 on success, 0 on error * Clobber list : x0, x1, x2, x6, x7, x14 * ----------------------------------------------- @@ -98,7 +98,7 @@ func console_ls_16550_register mov x7, x30 mov x6, x3 cbz x6, register_fail - str x0, [x6, #CONSOLE_T_16550_BASE] + str x0, [x6, #CONSOLE_T_BASE] bl console_ls_16550_core_init cbz x0, register_fail @@ -150,7 +150,7 @@ func console_ls_16550_core_putc endfunc console_ls_16550_core_putc /* -------------------------------------------------------- - * int console_16550_putc(int c, console_ls_16550_t *console) + * int console_16550_putc(int c, console_t *console) * Function to output a character over the console. It * returns the character printed on success or -1 on error. * In : w0 - character to be printed @@ -164,7 +164,7 @@ func console_ls_16550_putc cmp x1, #0 ASM_ASSERT(ne) #endif /* ENABLE_ASSERTIONS */ - ldr x1, [x1, #CONSOLE_T_16550_BASE] + ldr x1, [x1, #CONSOLE_T_BASE] b console_ls_16550_core_putc endfunc console_ls_16550_putc @@ -195,7 +195,7 @@ no_char: endfunc console_ls_16550_core_getc /* --------------------------------------------- - * int console_ls_16550_getc(console_ls_16550_t *console) + * int console_ls_16550_getc(console_t *console) * Function to get a character from the console. * It returns the character grabbed on success * or -1 on if no character is available. @@ -209,7 +209,7 @@ func console_ls_16550_getc cmp x1, #0 ASM_ASSERT(ne) #endif /* ENABLE_ASSERTIONS */ - ldr x0, [x0, #CONSOLE_T_16550_BASE] + ldr x0, [x0, #CONSOLE_T_BASE] b console_ls_16550_core_getc endfunc console_ls_16550_getc @@ -239,7 +239,7 @@ func console_ls_16550_core_flush endfunc console_ls_16550_core_flush /* --------------------------------------------- - * int console_ls_16550_flush(console_ls_16550_t *console) + * int console_ls_16550_flush(console_t *console) * Function to force a write of all buffered * data that hasn't been output. * In : x0 - pointer to console_t structure @@ -252,6 +252,6 @@ func console_ls_16550_flush cmp x0, #0 ASM_ASSERT(ne) #endif /* ENABLE_ASSERTIONS */ - ldr x0, [x0, #CONSOLE_T_16550_BASE] + ldr x0, [x0, #CONSOLE_T_BASE] b console_ls_16550_core_flush endfunc console_ls_16550_flush diff --git a/plat/layerscape/common/include/ls_16550.h b/plat/layerscape/common/include/ls_16550.h index cb4514f3f..95a64ad34 100644 --- a/plat/layerscape/common/include/ls_16550.h +++ b/plat/layerscape/common/include/ls_16550.h @@ -61,17 +61,10 @@ #define UARTLSR_OVRF (1 << 2) /* Rx Overrun Error */ #define UARTLSR_RDR (1 << 2) /* Rx Data Ready */ -#define CONSOLE_T_16550_BASE CONSOLE_T_DRVDATA - #ifndef __ASSEMBLER__ #include -typedef struct { - console_t console; - uintptr_t base; -} console_ls_16550_t; - /* * Initialize a new 16550 console instance and register it with the console * framework. The |console| pointer must point to storage that will be valid @@ -79,7 +72,7 @@ typedef struct { * Its contents will be reinitialized from scratch. */ int console_ls_16550_register(uintptr_t baseaddr, uint32_t clock, uint32_t baud, - console_ls_16550_t *console); + console_t *console); #endif /*__ASSEMBLER__*/ diff --git a/plat/layerscape/common/ls_bl1_setup.c b/plat/layerscape/common/ls_bl1_setup.c index fff065efd..fa69be2e6 100644 --- a/plat/layerscape/common/ls_bl1_setup.c +++ b/plat/layerscape/common/ls_bl1_setup.c @@ -23,7 +23,7 @@ meminfo_t *bl1_plat_sec_mem_layout(void) ******************************************************************************/ void ls_bl1_early_platform_setup(void) { - static console_ls_16550_t console; + static console_t console; #if !LS1043_DISABLE_TRUSTED_WDOG /* TODO: Enable watchdog */ diff --git a/plat/layerscape/common/ls_bl2_setup.c b/plat/layerscape/common/ls_bl2_setup.c index 35f42e1fb..6ca66bd47 100644 --- a/plat/layerscape/common/ls_bl2_setup.c +++ b/plat/layerscape/common/ls_bl2_setup.c @@ -23,7 +23,7 @@ static meminfo_t bl2_tzram_layout __aligned(CACHE_WRITEBACK_GRANULE); ******************************************************************************/ void ls_bl2_early_platform_setup(meminfo_t *mem_layout) { - static console_ls_16550_t console; + static console_t console; /* Initialize the console to provide early debug support */ console_ls_16550_register(LS_TF_UART_BASE, LS_TF_UART_CLOCK, diff --git a/plat/layerscape/common/ls_bl31_setup.c b/plat/layerscape/common/ls_bl31_setup.c index 03e580768..7a91aef81 100644 --- a/plat/layerscape/common/ls_bl31_setup.c +++ b/plat/layerscape/common/ls_bl31_setup.c @@ -67,7 +67,7 @@ entry_point_info_t *bl31_plat_get_next_image_ep_info(uint32_t type) void ls_bl31_early_platform_setup(void *from_bl2, void *plat_params_from_bl2) { - static console_ls_16550_t console; + static console_t console; /* Initialize the console to provide early debug support */ console_ls_16550_register(LS_TF_UART_BASE, LS_TF_UART_CLOCK, @@ -182,7 +182,7 @@ void ls_bl31_platform_setup(void) ******************************************************************************/ void ls_bl31_plat_runtime_setup(void) { - static console_ls_16550_t console; + static console_t console; /* Initialize the runtime console */ console_ls_16550_register(PLAT_LS1043_UART_BASE, PLAT_LS1043_UART_CLOCK, diff --git a/plat/layerscape/common/tsp/ls_tsp_setup.c b/plat/layerscape/common/tsp/ls_tsp_setup.c index f3b60276c..969d0b83b 100644 --- a/plat/layerscape/common/tsp/ls_tsp_setup.c +++ b/plat/layerscape/common/tsp/ls_tsp_setup.c @@ -30,7 +30,7 @@ gicv2_driver_data_t ls_gic_data = { ******************************************************************************/ void ls_tsp_early_platform_setup(void) { - static console_ls_16550_t console; + static console_t console; /* * Initialize a different console than already in use to display * messages from TSP diff --git a/plat/nvidia/tegra/soc/t194/plat_setup.c b/plat/nvidia/tegra/soc/t194/plat_setup.c index 7f2b00d1b..b9d5dfe23 100644 --- a/plat/nvidia/tegra/soc/t194/plat_setup.c +++ b/plat/nvidia/tegra/soc/t194/plat_setup.c @@ -170,7 +170,7 @@ void plat_enable_console(int32_t id) console_clock, TEGRA_CONSOLE_BAUDRATE, &spe_console); - console_set_scope(&spe_console.console, CONSOLE_FLAG_BOOT | + console_set_scope(&spe_console, CONSOLE_FLAG_BOOT | CONSOLE_FLAG_RUNTIME | CONSOLE_FLAG_CRASH); } #else @@ -190,7 +190,7 @@ void plat_enable_console(int32_t id) console_clock, TEGRA_CONSOLE_BAUDRATE, &uart_console); - console_set_scope(&uart_console.console, CONSOLE_FLAG_BOOT | + console_set_scope(&uart_console, CONSOLE_FLAG_BOOT | CONSOLE_FLAG_RUNTIME | CONSOLE_FLAG_CRASH); } #endif From 7b8fe2de31222ef6cbbd1968b7d3fd5a9e38c499 Mon Sep 17 00:00:00 2001 From: Andre Przywara Date: Sat, 25 Jan 2020 00:58:35 +0000 Subject: [PATCH 7/9] spe: Use generic console_t data structure Since now the generic console_t structure holds the UART base address as well, let's use that generic location and drop the UART driver specific data structure at all. Change-Id: I75dbfafb67849833b3f7b5047e237651e3f553cd Signed-off-by: Andre Przywara --- plat/nvidia/tegra/common/drivers/spe/shared_console.S | 10 +++++----- plat/nvidia/tegra/include/drivers/spe.h | 7 +------ plat/nvidia/tegra/soc/t194/plat_setup.c | 2 +- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/plat/nvidia/tegra/common/drivers/spe/shared_console.S b/plat/nvidia/tegra/common/drivers/spe/shared_console.S index 0be34e417..c783373dd 100644 --- a/plat/nvidia/tegra/common/drivers/spe/shared_console.S +++ b/plat/nvidia/tegra/common/drivers/spe/shared_console.S @@ -49,14 +49,14 @@ /* ------------------------------------------------- * int console_spe_register(uintptr_t baseaddr, * uint32_t clock, uint32_t baud, - * console_spe_t *console); + * console_t *console); * Function to initialize and register a new spe * console. Storage passed in for the console struct * *must* be persistent (i.e. not from the stack). * In: x0 - UART register base address * w1 - UART clock in Hz * w2 - Baud rate - * x3 - pointer to empty console_spe_t struct + * x3 - pointer to empty console_t struct * Out: return 1 on success, 0 on error * Clobber list : x0, x1, x2, x6, x7, x14 * ------------------------------------------------- @@ -122,7 +122,7 @@ putc_error: endfunc console_spe_core_putc /* -------------------------------------------------------- - * int console_spe_putc(int c, console_spe_t *console) + * int console_spe_putc(int c, console_t *console) * Function to output a character over the console. It * returns the character printed on success or -1 on error. * In : w0 - character to be printed @@ -137,7 +137,7 @@ func console_spe_putc endfunc console_spe_putc /* --------------------------------------------- - * int console_spe_getc(console_spe_t *console) + * int console_spe_getc(console_t *console) * Function to get a character from the console. * It returns the character grabbed on success * or -1 if no character is available. @@ -174,7 +174,7 @@ flush_error: endfunc console_spe_core_flush /* --------------------------------------------- - * int console_spe_flush(console_spe_t *console) + * int console_spe_flush(console_t *console) * Function to force a write of all buffered * data that hasn't been output. * In : x0 - pointer to console_t structure diff --git a/plat/nvidia/tegra/include/drivers/spe.h b/plat/nvidia/tegra/include/drivers/spe.h index 0d6d69d10..e0f871408 100644 --- a/plat/nvidia/tegra/include/drivers/spe.h +++ b/plat/nvidia/tegra/include/drivers/spe.h @@ -11,11 +11,6 @@ #include -typedef struct { - console_t console; - uintptr_t base; -} console_spe_t; - /* * Initialize a new spe console instance and register it with the console * framework. The |console| pointer must point to storage that will be valid @@ -23,6 +18,6 @@ typedef struct { * Its contents will be reinitialized from scratch. */ int console_spe_register(uintptr_t baseaddr, uint32_t clock, uint32_t baud, - console_spe_t *console); + console_t *console); #endif /* SPE_H */ diff --git a/plat/nvidia/tegra/soc/t194/plat_setup.c b/plat/nvidia/tegra/soc/t194/plat_setup.c index b9d5dfe23..235fba43c 100644 --- a/plat/nvidia/tegra/soc/t194/plat_setup.c +++ b/plat/nvidia/tegra/soc/t194/plat_setup.c @@ -163,7 +163,7 @@ void plat_enable_console(int32_t id) uint32_t console_clock = 0U; #if ENABLE_CONSOLE_SPE - static console_spe_t spe_console; + static console_t spe_console; if (id == TEGRA_CONSOLE_SPE_ID) { (void)console_spe_register(TEGRA_CONSOLE_SPE_BASE, From af1e8fda23bd59a2c07be125f98517b2547ce412 Mon Sep 17 00:00:00 2001 From: Andre Przywara Date: Sat, 25 Jan 2020 00:58:35 +0000 Subject: [PATCH 8/9] uniphier: Use generic console_t data structure Since now the generic console_t structure holds the UART base address as well, let's use that generic location and drop the UART driver specific data structure at all. Change-Id: Ia9d996bb45ff3a7f1b240f12fd75805b48a048e9 Signed-off-by: Andre Przywara --- plat/socionext/uniphier/uniphier_console.S | 6 ++--- .../uniphier/uniphier_console_setup.c | 25 +++++++------------ 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/plat/socionext/uniphier/uniphier_console.S b/plat/socionext/uniphier/uniphier_console.S index 1113c6e81..f3dde0cc1 100644 --- a/plat/socionext/uniphier/uniphier_console.S +++ b/plat/socionext/uniphier/uniphier_console.S @@ -17,7 +17,7 @@ */ .globl uniphier_console_putc func uniphier_console_putc - ldr x1, [x1, #CONSOLE_T_DRVDATA] + ldr x1, [x1, #CONSOLE_T_BASE] /* Wait until the transmitter FIFO gets empty */ 0: ldr w2, [x1, #UNIPHIER_UART_LSR] @@ -36,7 +36,7 @@ endfunc uniphier_console_putc */ .globl uniphier_console_getc func uniphier_console_getc - ldr x0, [x0, #CONSOLE_T_DRVDATA] + ldr x0, [x0, #CONSOLE_T_BASE] ldr w1, [x0, #UNIPHIER_UART_LSR] tbz w1, #UNIPHIER_UART_LSR_DR_BIT, 0f @@ -55,7 +55,7 @@ endfunc uniphier_console_getc */ .global uniphier_console_flush func uniphier_console_flush - ldr x0, [x0, #CONSOLE_T_DRVDATA] + ldr x0, [x0, #CONSOLE_T_BASE] /* wait until the transmitter gets empty */ 0: ldr w1, [x0, #UNIPHIER_UART_LSR] diff --git a/plat/socionext/uniphier/uniphier_console_setup.c b/plat/socionext/uniphier/uniphier_console_setup.c index 1851e4da5..e2ae8bf28 100644 --- a/plat/socionext/uniphier/uniphier_console_setup.c +++ b/plat/socionext/uniphier/uniphier_console_setup.c @@ -17,28 +17,21 @@ #define UNIPHIER_UART_OFFSET 0x100 #define UNIPHIER_UART_NR_PORTS 4 -struct uniphier_console { - struct console console; - uintptr_t base; -}; - /* These callbacks are implemented in assembly to use crash_console_helpers.S */ int uniphier_console_putc(int character, struct console *console); int uniphier_console_getc(struct console *console); int uniphier_console_flush(struct console *console); -static struct uniphier_console uniphier_console = { - .console = { - .flags = CONSOLE_FLAG_BOOT | +static console_t uniphier_console = { + .flags = CONSOLE_FLAG_BOOT | #if DEBUG - CONSOLE_FLAG_RUNTIME | + CONSOLE_FLAG_RUNTIME | #endif - CONSOLE_FLAG_CRASH | - CONSOLE_FLAG_TRANSLATE_CRLF, - .putc = uniphier_console_putc, - .getc = uniphier_console_getc, - .flush = uniphier_console_flush, - }, + CONSOLE_FLAG_CRASH | + CONSOLE_FLAG_TRANSLATE_CRLF, + .putc = uniphier_console_putc, + .getc = uniphier_console_getc, + .flush = uniphier_console_flush, }; static const uintptr_t uniphier_uart_base[] = { @@ -86,7 +79,7 @@ void uniphier_console_setup(unsigned int soc) plat_error_handler(-EINVAL); uniphier_console.base = base; - console_register(&uniphier_console.console); + console_register(&uniphier_console); /* * The hardware might be still printing characters queued up in the From 7db9a0b9df68fbc2772dcf8c1b59506a7329c637 Mon Sep 17 00:00:00 2001 From: Andre Przywara Date: Sat, 25 Jan 2020 23:55:08 +0000 Subject: [PATCH 9/9] marvell: Consolidate console register calls Now that different UARTs share the same console_t struct, we can simplify the console selection for the Marvell platforms: We share the same console_t pointers, just change the name of the console register functions, depending on the selected platform. Change-Id: I6fe3e49fd7f208a9b3372c5deef43236a12867bc Signed-off-by: Andre Przywara --- plat/marvell/common/marvell_console.c | 33 +++++++++------------------ 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/plat/marvell/common/marvell_console.c b/plat/marvell/common/marvell_console.c index b57b84f3f..17166618a 100644 --- a/plat/marvell/common/marvell_console.c +++ b/plat/marvell/common/marvell_console.c @@ -14,15 +14,14 @@ #ifdef PLAT_a3700 #include - -static console_t marvell_boot_console; -static console_t marvell_runtime_console; +#define console_marvell_register console_a3700_register #else #include +#define console_marvell_register console_16550_register +#endif static console_t marvell_boot_console; static console_t marvell_runtime_console; -#endif /******************************************************************************* * Functions that set up the console @@ -32,15 +31,10 @@ static console_t marvell_runtime_console; void marvell_console_boot_init(void) { int rc = -#ifdef PLAT_a3700 - console_a3700_register( -#else - console_16550_register( -#endif - PLAT_MARVELL_BOOT_UART_BASE, - PLAT_MARVELL_BOOT_UART_CLK_IN_HZ, - MARVELL_CONSOLE_BAUDRATE, - &marvell_boot_console); + console_marvell_register(PLAT_MARVELL_BOOT_UART_BASE, + PLAT_MARVELL_BOOT_UART_CLK_IN_HZ, + MARVELL_CONSOLE_BAUDRATE, + &marvell_boot_console); if (rc == 0) { /* * The crash console doesn't use the multi console API, it uses @@ -64,15 +58,10 @@ void marvell_console_boot_end(void) void marvell_console_runtime_init(void) { int rc = -#ifdef PLAT_a3700 - console_a3700_register( -#else - console_16550_register( -#endif - PLAT_MARVELL_BOOT_UART_BASE, - PLAT_MARVELL_BOOT_UART_CLK_IN_HZ, - MARVELL_CONSOLE_BAUDRATE, - &marvell_runtime_console); + console_marvell_register(PLAT_MARVELL_BOOT_UART_BASE, + PLAT_MARVELL_BOOT_UART_CLK_IN_HZ, + MARVELL_CONSOLE_BAUDRATE, + &marvell_runtime_console); if (rc == 0) panic();