From 43fa7ce53ff008889b9a537d8ba00fcb5d8b5bde Mon Sep 17 00:00:00 2001 From: Maureen Helm Date: Thu, 21 Oct 2021 13:29:33 -0500 Subject: [PATCH] drivers: console: Refactor drivers to use shared init priority Refactors all of the console drivers to use a shared driver class initialization priority configuration, CONFIG_CONSOLE_INIT_PRIORITY, to allow configuring console drivers separately from other devices. This is similar to other driver classes like I2C and SPI. The default is set to CONFIG_KERNEL_INIT_PRIORITY_DEFAULT to preserve the existing default initialization priority for most drivers. The driver-specific option, CONFIG_NATIVE_POSIX_CONSOLE_INIT_PRIORITY, is left intact because the native posix console driver needs to initialize after the UART console driver when both drivers are enabled. Signed-off-by: Maureen Helm --- drivers/console/Kconfig | 32 +++++++--------------------- drivers/console/ipm_console.c | 2 +- drivers/console/ram_console.c | 2 +- drivers/console/rtt_console.c | 2 +- drivers/console/semihost_console.c | 2 +- drivers/console/uart_console.c | 2 +- drivers/console/uart_mux.c | 4 ++-- drivers/console/xtensa_sim_console.c | 2 +- 8 files changed, 16 insertions(+), 32 deletions(-) diff --git a/drivers/console/Kconfig b/drivers/console/Kconfig index b21e14f3de4..6fd9ea0be26 100644 --- a/drivers/console/Kconfig +++ b/drivers/console/Kconfig @@ -32,6 +32,14 @@ config CONSOLE_HANDLER This option enables console input handler allowing to write simple interaction between serial console and the OS. +config CONSOLE_INIT_PRIORITY + int "Console init priority" + default 95 if USB_UART_CONSOLE || UART_MUX + default 60 if UART_CONSOLE || XTENSA_SIM_CONSOLE + default KERNEL_INIT_PRIORITY_DEFAULT + help + Console driver device initialization priority. + config UART_CONSOLE bool "Use UART for console" depends on SERIAL && SERIAL_HAS_DRIVER @@ -39,16 +47,6 @@ config UART_CONSOLE help Enable this option to use one UART for console. -config UART_CONSOLE_INIT_PRIORITY - int "Init priority" - default 95 if USB_UART_CONSOLE - default 60 - depends on UART_CONSOLE - help - Device driver initialization priority. - Console has to be initialized after the UART driver - it uses. - config UART_CONSOLE_DEBUG_SERVER_HOOKS bool "Debug server hooks in debug console" depends on UART_CONSOLE @@ -290,13 +288,6 @@ config NATIVE_POSIX_STDOUT_CONSOLE help Zephyr's printk messages will be directed to the host terminal stdout. -config XTENSA_CONSOLE_INIT_PRIORITY - int "Init priority" - default 60 - depends on XTENSA_SIM_CONSOLE - help - Device driver initialization priority. - config NATIVE_POSIX_CONSOLE_INIT_PRIORITY int "Init priority" default 99 @@ -335,13 +326,6 @@ config UART_MUX if UART_MUX -config UART_MUX_INIT_PRIORITY - int "Init priority" - default 95 - help - Device driver initialization priority. UART mux has to be - initialized after the UART driver it uses. - config UART_MUX_DEVICE_NAME string "UART mux device name template" default "GSM" diff --git a/drivers/console/ipm_console.c b/drivers/console/ipm_console.c index d36b99b4a7e..0c8f9d6519b 100644 --- a/drivers/console/ipm_console.c +++ b/drivers/console/ipm_console.c @@ -88,4 +88,4 @@ static int ipm_console_init(const struct device *dev) } /* Need to be initialized after IPM */ -SYS_INIT(ipm_console_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT); +SYS_INIT(ipm_console_init, POST_KERNEL, CONFIG_CONSOLE_INIT_PRIORITY); diff --git a/drivers/console/ram_console.c b/drivers/console/ram_console.c index 7dc304eb269..3da9e49482c 100644 --- a/drivers/console/ram_console.c +++ b/drivers/console/ram_console.c @@ -35,4 +35,4 @@ static int ram_console_init(const struct device *d) return 0; } -SYS_INIT(ram_console_init, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT); +SYS_INIT(ram_console_init, PRE_KERNEL_1, CONFIG_CONSOLE_INIT_PRIORITY); diff --git a/drivers/console/rtt_console.c b/drivers/console/rtt_console.c index 867209749b0..59c86ad68a3 100644 --- a/drivers/console/rtt_console.c +++ b/drivers/console/rtt_console.c @@ -88,4 +88,4 @@ static int rtt_console_init(const struct device *d) return 0; } -SYS_INIT(rtt_console_init, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT); +SYS_INIT(rtt_console_init, PRE_KERNEL_1, CONFIG_CONSOLE_INIT_PRIORITY); diff --git a/drivers/console/semihost_console.c b/drivers/console/semihost_console.c index d1cd95249b6..17acbb4d18e 100644 --- a/drivers/console/semihost_console.c +++ b/drivers/console/semihost_console.c @@ -51,4 +51,4 @@ static int semihost_console_init(const struct device *dev) return 0; } -SYS_INIT(semihost_console_init, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT); +SYS_INIT(semihost_console_init, PRE_KERNEL_1, CONFIG_CONSOLE_INIT_PRIORITY); diff --git a/drivers/console/uart_console.c b/drivers/console/uart_console.c index 0c9d096435e..2ad259a8422 100644 --- a/drivers/console/uart_console.c +++ b/drivers/console/uart_console.c @@ -613,4 +613,4 @@ SYS_INIT(uart_console_init, #else POST_KERNEL, #endif - CONFIG_UART_CONSOLE_INIT_PRIORITY); + CONFIG_CONSOLE_INIT_PRIORITY); diff --git a/drivers/console/uart_mux.c b/drivers/console/uart_mux.c index 3f829ad2900..84fb8f6fdf6 100644 --- a/drivers/console/uart_mux.c +++ b/drivers/console/uart_mux.c @@ -890,7 +890,7 @@ void uart_mux_foreach(uart_mux_cb_t cb, void *user_data) &uart_mux_dev_data_##x, \ &uart_mux_config_##x, \ POST_KERNEL, \ - CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \ + CONFIG_CONSOLE_INIT_PRIORITY, \ &uart_mux_driver_api); UTIL_LISTIFY(CONFIG_UART_MUX_DEVICE_COUNT, DEFINE_UART_MUX_CFG_DATA, _) @@ -909,4 +909,4 @@ static int init_uart_mux(const struct device *dev) return 0; } -SYS_INIT(init_uart_mux, POST_KERNEL, CONFIG_UART_MUX_INIT_PRIORITY); +SYS_INIT(init_uart_mux, POST_KERNEL, CONFIG_CONSOLE_INIT_PRIORITY); diff --git a/drivers/console/xtensa_sim_console.c b/drivers/console/xtensa_sim_console.c index 0d4b8e357f7..8f68c0d7ec5 100644 --- a/drivers/console/xtensa_sim_console.c +++ b/drivers/console/xtensa_sim_console.c @@ -77,4 +77,4 @@ SYS_INIT(xt_sim_console_init, #else POST_KERNEL, #endif - CONFIG_XTENSA_CONSOLE_INIT_PRIORITY); + CONFIG_CONSOLE_INIT_PRIORITY);