From 8f0ab3038cb48a1175ba0c6b630fe30ada1c7d9c Mon Sep 17 00:00:00 2001 From: Daniel Leung Date: Thu, 28 Apr 2016 15:14:38 -0700 Subject: [PATCH] arm/nxp_kinetis/k6x: simplify uart init The UART console init should be done after UART init. So it can be folded into general UART init, thus one fewer SYS_INIT(). Change-Id: Ifb18c5308dfef790325e6bff5bc7b5976fcd421e Signed-off-by: Daniel Leung --- arch/arm/soc/nxp_kinetis/k6x/soc_config.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/arch/arm/soc/nxp_kinetis/k6x/soc_config.c b/arch/arm/soc/nxp_kinetis/k6x/soc_config.c index 03334740ba1..c8e4e4c926c 100644 --- a/arch/arm/soc/nxp_kinetis/k6x/soc_config.c +++ b/arch/arm/soc/nxp_kinetis/k6x/soc_config.c @@ -39,8 +39,8 @@ #ifdef CONFIG_UART_K20 -#if defined(CONFIG_UART_CONSOLE) -#if defined(CONFIG_PRINTK) || defined(CONFIG_STDOUT_CONSOLE) +#if defined(CONFIG_UART_CONSOLE) && \ + (defined(CONFIG_PRINTK) || defined(CONFIG_STDOUT_CONSOLE)) /** * @brief Initialize K20 serial port as console @@ -51,7 +51,7 @@ * * @return 0 if successful, otherwise failed. */ -static int uart_k20_console_init(struct device *dev) +static ALWAYS_INLINE int uart_k20_console_init(void) { uint32_t port; uint32_t rxPin; @@ -76,10 +76,9 @@ static int uart_k20_console_init(struct device *dev) return 0; } -SYS_INIT(uart_k20_console_init, PRIMARY, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT); - -#endif -#endif /* CONFIG_UART_CONSOLE */ +#else +#define uart_k20_console_init(...) +#endif /* CONFIG_UART_CONSOLE && (CONFIG_PRINTK || CONFIG_STDOUT_CONSOLE) */ static int uart_k20_init(struct device *dev) { @@ -117,6 +116,9 @@ static int uart_k20_init(struct device *dev) sim->scgc1.field.uart4_clk_en = 1; #endif + /* Initialize UART port for console if needed */ + uart_k20_console_init(); + return 0; }