From 9eef764c655b50641f8dcea69a57e04073e7baa6 Mon Sep 17 00:00:00 2001 From: Maureen Helm Date: Mon, 25 Oct 2021 19:13:48 -0500 Subject: [PATCH] drivers: dac: Refactor drivers to use shared init priority Refactors all of the DAC drivers to use a shared driver class initialization priority configuration, CONFIG_DAC_INIT_PRIORITY, to allow configuring DAC 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 exceptions are dacx0508, dacx3608, and mcp4725 drivers which have dependencies on SPI or I2C drivers and must therefore initialize later than the default device priority. Signed-off-by: Maureen Helm --- boards/arm/bl5340_dvk/Kconfig.defconfig | 3 +++ boards/arm/bl652_dvk/Kconfig.defconfig | 3 +++ boards/arm/bl653_dvk/Kconfig.defconfig | 3 +++ boards/arm/bl654_dvk/Kconfig.defconfig | 3 +++ boards/shields/dac80508_evm/Kconfig.defconfig | 3 +++ drivers/dac/Kconfig | 6 ++++++ drivers/dac/Kconfig.dacx0508 | 10 ---------- drivers/dac/Kconfig.dacx3608 | 7 ------- drivers/dac/Kconfig.mcp4725 | 10 ---------- drivers/dac/dac_dacx0508.c | 2 +- drivers/dac/dac_dacx3608.c | 2 +- drivers/dac/dac_mcp4725.c | 2 +- drivers/dac/dac_mcux_dac.c | 2 +- drivers/dac/dac_mcux_dac32.c | 2 +- drivers/dac/dac_sam.c | 2 +- drivers/dac/dac_sam0.c | 2 +- drivers/dac/dac_stm32.c | 2 +- 17 files changed, 29 insertions(+), 35 deletions(-) diff --git a/boards/arm/bl5340_dvk/Kconfig.defconfig b/boards/arm/bl5340_dvk/Kconfig.defconfig index d08a3c0f657..6838d427cd4 100644 --- a/boards/arm/bl5340_dvk/Kconfig.defconfig +++ b/boards/arm/bl5340_dvk/Kconfig.defconfig @@ -25,6 +25,9 @@ if DAC config DAC_MCP4725 default y +config DAC_INIT_PRIORITY + default 80 + config I2C default y diff --git a/boards/arm/bl652_dvk/Kconfig.defconfig b/boards/arm/bl652_dvk/Kconfig.defconfig index 1cb161db5f7..d39560e0290 100644 --- a/boards/arm/bl652_dvk/Kconfig.defconfig +++ b/boards/arm/bl652_dvk/Kconfig.defconfig @@ -16,6 +16,9 @@ if DAC config DAC_MCP4725 default y +config DAC_INIT_PRIORITY + default 80 + config I2C default y diff --git a/boards/arm/bl653_dvk/Kconfig.defconfig b/boards/arm/bl653_dvk/Kconfig.defconfig index ffc9f17b2e3..2acf1a15104 100644 --- a/boards/arm/bl653_dvk/Kconfig.defconfig +++ b/boards/arm/bl653_dvk/Kconfig.defconfig @@ -20,6 +20,9 @@ if DAC config DAC_MCP4725 default y +config DAC_INIT_PRIORITY + default 80 + config I2C default y diff --git a/boards/arm/bl654_dvk/Kconfig.defconfig b/boards/arm/bl654_dvk/Kconfig.defconfig index 6b768af9b61..6a409414c18 100644 --- a/boards/arm/bl654_dvk/Kconfig.defconfig +++ b/boards/arm/bl654_dvk/Kconfig.defconfig @@ -16,6 +16,9 @@ if DAC config DAC_MCP4725 default y +config DAC_INIT_PRIORITY + default 80 + config I2C default y diff --git a/boards/shields/dac80508_evm/Kconfig.defconfig b/boards/shields/dac80508_evm/Kconfig.defconfig index 97355b56299..d1948f0a761 100644 --- a/boards/shields/dac80508_evm/Kconfig.defconfig +++ b/boards/shields/dac80508_evm/Kconfig.defconfig @@ -11,6 +11,9 @@ config SPI config DAC_DACX0508 default y +config DAC_INIT_PRIORITY + default 80 + endif # DAC endif # SHIELD_DAC80508_EVM diff --git a/drivers/dac/Kconfig b/drivers/dac/Kconfig index ce9ce9879ef..d1b19ddbc62 100644 --- a/drivers/dac/Kconfig +++ b/drivers/dac/Kconfig @@ -24,6 +24,12 @@ config DAC_SHELL help Enable DAC related shell commands. +config DAC_INIT_PRIORITY + int "DAC init priority" + default KERNEL_INIT_PRIORITY_DEVICE + help + DAC driver device initialization priority. + source "drivers/dac/Kconfig.mcux" source "drivers/dac/Kconfig.stm32" diff --git a/drivers/dac/Kconfig.dacx0508 b/drivers/dac/Kconfig.dacx0508 index db09d4d55d0..33f13b2ba13 100644 --- a/drivers/dac/Kconfig.dacx0508 +++ b/drivers/dac/Kconfig.dacx0508 @@ -9,13 +9,3 @@ config DAC_DACX0508 depends on SPI help Enable the driver for the TI DACx0508. - -if DAC_DACX0508 - -config DAC_DACX0508_INIT_PRIORITY - int "Init priority" - default 80 - help - DACx0508 DAC device driver initialization priority. - -endif # DAC_DACX0508 diff --git a/drivers/dac/Kconfig.dacx3608 b/drivers/dac/Kconfig.dacx3608 index de8f218bee3..a4f3ca5664c 100644 --- a/drivers/dac/Kconfig.dacx3608 +++ b/drivers/dac/Kconfig.dacx3608 @@ -9,10 +9,3 @@ config DAC_DACX3608 depends on I2C help Enable the driver for the TI DACX3608. - -config DAC_DACX3608_INIT_PRIORITY - int "Init priority" - depends on DAC_DACX3608 - default 80 - help - DACX3608 DAC device driver initialization priority. diff --git a/drivers/dac/Kconfig.mcp4725 b/drivers/dac/Kconfig.mcp4725 index d4f9a5d55b9..532040740a1 100644 --- a/drivers/dac/Kconfig.mcp4725 +++ b/drivers/dac/Kconfig.mcp4725 @@ -9,13 +9,3 @@ config DAC_MCP4725 depends on I2C help Enable the driver for the Microchip MCP4725. - -if DAC_MCP4725 - -config DAC_MCP4725_INIT_PRIORITY - int "Init priority" - default 80 - help - MCP4725 DAC device driver initialization priority. - -endif # DAC_MCP4725 diff --git a/drivers/dac/dac_dacx0508.c b/drivers/dac/dac_dacx0508.c index 6d452c22733..79f88743f1c 100644 --- a/drivers/dac/dac_dacx0508.c +++ b/drivers/dac/dac_dacx0508.c @@ -385,7 +385,7 @@ static const struct dac_driver_api dacx0508_driver_api = { &dacx0508_init, NULL, \ &dac##t##_data_##n, \ &dac##t##_config_##n, POST_KERNEL, \ - CONFIG_DAC_DACX0508_INIT_PRIORITY, \ + CONFIG_DAC_INIT_PRIORITY, \ &dacx0508_driver_api) /* diff --git a/drivers/dac/dac_dacx3608.c b/drivers/dac/dac_dacx3608.c index eb0b7c10458..e6f95405e90 100644 --- a/drivers/dac/dac_dacx3608.c +++ b/drivers/dac/dac_dacx3608.c @@ -258,7 +258,7 @@ static const struct dac_driver_api dacx3608_driver_api = { &dacx3608_init, NULL, \ &dac##t##_data_##n, \ &dac##t##_config_##n, POST_KERNEL, \ - CONFIG_DAC_DACX3608_INIT_PRIORITY, \ + CONFIG_DAC_INIT_PRIORITY, \ &dacx3608_driver_api) /* diff --git a/drivers/dac/dac_mcp4725.c b/drivers/dac/dac_mcp4725.c index 0de3e1dd874..ba24c22987a 100644 --- a/drivers/dac/dac_mcp4725.c +++ b/drivers/dac/dac_mcp4725.c @@ -142,7 +142,7 @@ static const struct dac_driver_api mcp4725_driver_api = { NULL, \ NULL, \ &mcp4725_config_##index, POST_KERNEL, \ - CONFIG_DAC_MCP4725_INIT_PRIORITY, \ + CONFIG_DAC_INIT_PRIORITY, \ &mcp4725_driver_api); DT_INST_FOREACH_STATUS_OKAY(INST_DT_MCP4725); diff --git a/drivers/dac/dac_mcux_dac.c b/drivers/dac/dac_mcux_dac.c index c8884a205dc..442c3a76b79 100644 --- a/drivers/dac/dac_mcux_dac.c +++ b/drivers/dac/dac_mcux_dac.c @@ -108,7 +108,7 @@ static const struct dac_driver_api mcux_dac_driver_api = { DEVICE_DT_INST_DEFINE(n, mcux_dac_init, NULL, \ &mcux_dac_data_##n, \ &mcux_dac_config_##n, \ - POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,\ + POST_KERNEL, CONFIG_DAC_INIT_PRIORITY, \ &mcux_dac_driver_api); DT_INST_FOREACH_STATUS_OKAY(MCUX_DAC_INIT) diff --git a/drivers/dac/dac_mcux_dac32.c b/drivers/dac/dac_mcux_dac32.c index 073b8f9507c..f3420386ed1 100644 --- a/drivers/dac/dac_mcux_dac32.c +++ b/drivers/dac/dac_mcux_dac32.c @@ -114,7 +114,7 @@ static const struct dac_driver_api mcux_dac32_driver_api = { DEVICE_DT_INST_DEFINE(n, mcux_dac32_init, NULL, \ &mcux_dac32_data_##n, \ &mcux_dac32_config_##n, \ - POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,\ + POST_KERNEL, CONFIG_DAC_INIT_PRIORITY, \ &mcux_dac32_driver_api); DT_INST_FOREACH_STATUS_OKAY(MCUX_DAC32_INIT) diff --git a/drivers/dac/dac_sam.c b/drivers/dac/dac_sam.c index 18ec30fde25..4b51e810fb4 100644 --- a/drivers/dac/dac_sam.c +++ b/drivers/dac/dac_sam.c @@ -173,5 +173,5 @@ static const struct dac_sam_dev_cfg dacc_sam_config = { static struct dac_sam_dev_data dacc_sam_data; DEVICE_DT_INST_DEFINE(0, dac_sam_init, NULL, &dacc_sam_data, &dacc_sam_config, - POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, + POST_KERNEL, CONFIG_DAC_INIT_PRIORITY, &dac_sam_driver_api); diff --git a/drivers/dac/dac_sam0.c b/drivers/dac/dac_sam0.c index ba7a89b3893..99c86681338 100644 --- a/drivers/dac/dac_sam0.c +++ b/drivers/dac/dac_sam0.c @@ -108,7 +108,7 @@ static const struct dac_driver_api api_sam0_driver_api = { \ DEVICE_DT_INST_DEFINE(n, &dac_sam0_init, NULL, NULL, \ &dac_sam0_cfg_##n, POST_KERNEL, \ - CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \ + CONFIG_DAC_INIT_PRIORITY, \ &api_sam0_driver_api) DT_INST_FOREACH_STATUS_OKAY(SAM0_DAC_INIT); diff --git a/drivers/dac/dac_stm32.c b/drivers/dac/dac_stm32.c index 0e92b8fedaf..d4513c139a2 100644 --- a/drivers/dac/dac_stm32.c +++ b/drivers/dac/dac_stm32.c @@ -168,7 +168,7 @@ static struct dac_stm32_data dac_stm32_data_##index = { \ DEVICE_DT_INST_DEFINE(index, &dac_stm32_init, NULL, \ &dac_stm32_data_##index, \ &dac_stm32_cfg_##index, POST_KERNEL, \ - CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \ + CONFIG_DAC_INIT_PRIORITY, \ &api_stm32_driver_api); DT_INST_FOREACH_STATUS_OKAY(STM32_DAC_INIT)