Skip to content

Commit 4c286a1

Browse files
MaureenHelmjfischer-no
authored andcommitted
[nrf fromtree] drivers: serial: Refactor drivers to use shared init priority Kconfig
Refactors all of the serial drivers to use a shared driver class initialization priority configuration, CONFIG_SERIAL_INIT_PRIORITY, to allow configuring serial 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_DEVICE to preserve the existing default initialization priority for most drivers. The one exception is uart_lpc11u6x.c which previously used CONFIG_KERNEL_INIT_PRIORITY_OBJECTS. This change was motivated by an issue on the frdm_k64f board where the serial driver was incorrectly initialized before the clock control driver. Signed-off-by: Maureen Helm <[email protected]>
1 parent 83f7974 commit 4c286a1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+62
-56
lines changed

drivers/serial/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ config SERIAL_SUPPORT_INTERRUPT
3131
This is an option to be enabled by individual serial driver
3232
to signal that the driver and hardware supports interrupts.
3333

34+
config SERIAL_INIT_PRIORITY
35+
int "Serial init priority"
36+
default KERNEL_INIT_PRIORITY_DEVICE
37+
help
38+
Serial driver device initialization priority.
39+
3440
config UART_USE_RUNTIME_CONFIGURE
3541
bool "Enable runtime configuration for UART controllers"
3642
default y

drivers/serial/leuart_gecko.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ static struct leuart_gecko_data leuart_gecko_0_data;
354354
DEVICE_DT_INST_DEFINE(0, &leuart_gecko_init,
355355
NULL, &leuart_gecko_0_data,
356356
&leuart_gecko_0_config, PRE_KERNEL_1,
357-
CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
357+
CONFIG_SERIAL_INIT_PRIORITY,
358358
&leuart_gecko_driver_api);
359359

360360
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
@@ -407,7 +407,7 @@ static struct leuart_gecko_data leuart_gecko_1_data;
407407
DEVICE_DT_INST_DEFINE(1, &leuart_gecko_init,
408408
NULL, &leuart_gecko_1_data,
409409
&leuart_gecko_1_config, PRE_KERNEL_1,
410-
CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
410+
CONFIG_SERIAL_INIT_PRIORITY,
411411
&leuart_gecko_driver_api);
412412

413413
#ifdef CONFIG_UART_INTERRUPT_DRIVEN

drivers/serial/serial_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static int serial_vnd_init(const struct device *dev)
6161
#define VND_SERIAL_INIT(n) \
6262
DEVICE_DT_INST_DEFINE(n, &serial_vnd_init, NULL, \
6363
NULL, NULL, POST_KERNEL, \
64-
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \
64+
CONFIG_SERIAL_INIT_PRIORITY, \
6565
&serial_vnd_api);
6666

6767
DT_INST_FOREACH_STATUS_OKAY(VND_SERIAL_INIT)

drivers/serial/uart_altera_jtag_hal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,5 @@ static const struct uart_device_config uart_altera_jtag_dev_cfg_0 = {
6161

6262
DEVICE_DT_INST_DEFINE(0, uart_altera_jtag_init, NULL,
6363
NULL, &uart_altera_jtag_dev_cfg_0,
64-
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
64+
PRE_KERNEL_1, CONFIG_SERIAL_INIT_PRIORITY,
6565
&uart_altera_jtag_driver_api);

drivers/serial/uart_apbuart.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ static const struct uart_driver_api apbuart_driver_api = {
538538
&apbuart##index##_data, \
539539
&apbuart##index##_config, \
540540
PRE_KERNEL_1, \
541-
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \
541+
CONFIG_SERIAL_INIT_PRIORITY, \
542542
&apbuart_driver_api);
543543

544544
DT_INST_FOREACH_STATUS_OKAY(APBUART_INIT)

drivers/serial/uart_b91.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ static const struct uart_driver_api uart_b91_driver_api = {
558558
&uart_b91_data_##n, \
559559
&uart_b91_cfg_##n, \
560560
PRE_KERNEL_1, \
561-
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \
561+
CONFIG_SERIAL_INIT_PRIORITY, \
562562
(void *)&uart_b91_driver_api); \
563563
\
564564
static void uart_b91_irq_connect_##n(void) \

drivers/serial/uart_cc13xx_cc26xx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ static const struct uart_driver_api uart_cc13xx_cc26xx_driver_api = {
539539
uart_cc13xx_cc26xx_init_##n, \
540540
uart_cc13xx_cc26xx_pm_control, \
541541
&uart_cc13xx_cc26xx_data_##n, &uart_cc13xx_cc26xx_config_##n,\
542-
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \
542+
PRE_KERNEL_1, CONFIG_SERIAL_INIT_PRIORITY, \
543543
&uart_cc13xx_cc26xx_driver_api)
544544

545545
#ifdef CONFIG_PM_DEVICE

drivers/serial/uart_cc32xx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ static struct uart_cc32xx_dev_data_t uart_cc32xx_dev_data_##idx = { \
331331
DEVICE_DT_INST_DEFINE(idx, uart_cc32xx_init, \
332332
NULL, &uart_cc32xx_dev_data_##idx, \
333333
&uart_cc32xx_dev_cfg_##idx, \
334-
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \
334+
PRE_KERNEL_1, CONFIG_SERIAL_INIT_PRIORITY, \
335335
(void *)&uart_cc32xx_driver_api); \
336336

337337
DT_INST_FOREACH_STATUS_OKAY(UART_32XX_DEVICE);

drivers/serial/uart_cmsdk_apb.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ DEVICE_DT_INST_DEFINE(0,
508508
NULL,
509509
&uart_cmsdk_apb_dev_data_0,
510510
&uart_cmsdk_apb_dev_cfg_0, PRE_KERNEL_1,
511-
CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
511+
CONFIG_SERIAL_INIT_PRIORITY,
512512
&uart_cmsdk_apb_driver_api);
513513

514514
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
@@ -573,7 +573,7 @@ DEVICE_DT_INST_DEFINE(1,
573573
NULL,
574574
&uart_cmsdk_apb_dev_data_1,
575575
&uart_cmsdk_apb_dev_cfg_1, PRE_KERNEL_1,
576-
CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
576+
CONFIG_SERIAL_INIT_PRIORITY,
577577
&uart_cmsdk_apb_driver_api);
578578

579579
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
@@ -638,7 +638,7 @@ DEVICE_DT_INST_DEFINE(2,
638638
NULL,
639639
&uart_cmsdk_apb_dev_data_2,
640640
&uart_cmsdk_apb_dev_cfg_2, PRE_KERNEL_1,
641-
CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
641+
CONFIG_SERIAL_INIT_PRIORITY,
642642
&uart_cmsdk_apb_driver_api);
643643

644644
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
@@ -703,7 +703,7 @@ DEVICE_DT_INST_DEFINE(3,
703703
NULL,
704704
&uart_cmsdk_apb_dev_data_3,
705705
&uart_cmsdk_apb_dev_cfg_3, PRE_KERNEL_1,
706-
CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
706+
CONFIG_SERIAL_INIT_PRIORITY,
707707
&uart_cmsdk_apb_driver_api);
708708

709709
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
@@ -768,7 +768,7 @@ DEVICE_DT_INST_DEFINE(4,
768768
NULL,
769769
&uart_cmsdk_apb_dev_data_4,
770770
&uart_cmsdk_apb_dev_cfg_4, PRE_KERNEL_1,
771-
CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
771+
CONFIG_SERIAL_INIT_PRIORITY,
772772
&uart_cmsdk_apb_driver_api);
773773

774774
#ifdef CONFIG_UART_INTERRUPT_DRIVEN

drivers/serial/uart_esp32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ DEVICE_DT_DEFINE(DT_NODELABEL(uart##idx), \
519519
&uart_esp32_data_##idx, \
520520
&uart_esp32_cfg_port_##idx, \
521521
PRE_KERNEL_1, \
522-
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \
522+
CONFIG_SERIAL_INIT_PRIORITY, \
523523
&uart_esp32_api);
524524

525525
#if DT_NODE_HAS_STATUS(DT_NODELABEL(uart0), okay)

0 commit comments

Comments
 (0)