drivers: counter: Refactor drivers to use shared init priority
Refactors all of the counter drivers to use a shared driver class initialization priority configuration, CONFIG_COUNTER_INIT_PRIORITY, to allow configuring counter 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 the maxim_ds3231 and mcp7940n drivers which have a dependency on a SPI driver and must therefore initialize later than the default device priority. Signed-off-by: Maureen Helm <maureen.helm@intel.com>
This commit is contained in:
parent
e297f8ee26
commit
165963c115
28 changed files with 33 additions and 38 deletions
|
@ -10,6 +10,12 @@ menuconfig COUNTER
|
|||
|
||||
if COUNTER
|
||||
|
||||
config COUNTER_INIT_PRIORITY
|
||||
int "Counter init priority"
|
||||
default KERNEL_INIT_PRIORITY_DEVICE
|
||||
help
|
||||
Counter driver device initialization priority.
|
||||
|
||||
module = COUNTER
|
||||
module-str = counter
|
||||
source "subsys/logging/Kconfig.template.log_config"
|
||||
|
|
|
@ -9,10 +9,3 @@ config COUNTER_MAXIM_DS3231
|
|||
select POLL
|
||||
help
|
||||
Enable counter driver based on Maxim DS3231 I2C device.
|
||||
|
||||
config COUNTER_MAXIM_DS3231_INIT_PRIORITY
|
||||
int "Init priority"
|
||||
depends on COUNTER_MAXIM_DS3231
|
||||
default 65
|
||||
help
|
||||
DS3231 device driver initialization priority.
|
||||
|
|
|
@ -8,10 +8,3 @@ config COUNTER_MICROCHIP_MCP7940N
|
|||
select I2C
|
||||
help
|
||||
Enable RTC driver based on Microchip MCP7940N I2C device.
|
||||
|
||||
config COUNTER_MICROCHIP_MCP7940N_INIT_PRIORITY
|
||||
int "Init priority"
|
||||
depends on COUNTER_MICROCHIP_MCP7940N
|
||||
default 65
|
||||
help
|
||||
MCP7940N device driver initialization priority.
|
||||
|
|
|
@ -209,4 +209,4 @@ static const struct counter_driver_api api = {
|
|||
};
|
||||
|
||||
DEVICE_DEFINE(counter_cmos, "CMOS", init, NULL, NULL, &info,
|
||||
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &api);
|
||||
POST_KERNEL, CONFIG_COUNTER_INIT_PRIORITY, &api);
|
||||
|
|
|
@ -252,7 +252,7 @@ static void counter_esp32_isr(void *arg)
|
|||
counter_esp32_init, \
|
||||
NULL, &counter_data_##n, \
|
||||
&counter_config_##n, PRE_KERNEL_1, \
|
||||
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &counter_api);
|
||||
CONFIG_COUNTER_INIT_PRIORITY, &counter_api);
|
||||
|
||||
#ifdef CONFIG_COUNTER_ESP32_TG0_T0
|
||||
ESP32_COUNTER_INIT(0);
|
||||
|
|
|
@ -384,5 +384,5 @@ static struct counter_gecko_data counter_gecko_0_data;
|
|||
|
||||
DEVICE_DT_INST_DEFINE(0, counter_gecko_init, NULL,
|
||||
&counter_gecko_0_data, &counter_gecko_0_config,
|
||||
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
|
||||
PRE_KERNEL_1, CONFIG_COUNTER_INIT_PRIORITY,
|
||||
&counter_gecko_driver_api);
|
||||
|
|
|
@ -160,7 +160,7 @@ DEVICE_DT_INST_DEFINE(idx, \
|
|||
&imx_epit_config_func_##idx, \
|
||||
NULL, \
|
||||
&imx_epit_##idx##_data, &imx_epit_##idx##z_config.info, \
|
||||
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \
|
||||
PRE_KERNEL_1, CONFIG_COUNTER_INIT_PRIORITY, \
|
||||
&imx_epit_driver_api); \
|
||||
static int imx_epit_config_func_##idx(const struct device *dev) \
|
||||
{ \
|
||||
|
|
|
@ -421,7 +421,7 @@ static const struct counter_driver_api rtc_stm32_driver_api = {
|
|||
|
||||
DEVICE_DT_INST_DEFINE(0, &rtc_stm32_init, NULL,
|
||||
&rtc_data, &rtc_config, PRE_KERNEL_1,
|
||||
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &rtc_stm32_driver_api);
|
||||
CONFIG_COUNTER_INIT_PRIORITY, &rtc_stm32_driver_api);
|
||||
|
||||
static void rtc_stm32_irq_config(const struct device *dev)
|
||||
{
|
||||
|
|
|
@ -328,7 +328,7 @@ static int counter_xec_init(const struct device *dev)
|
|||
&counter_xec_dev_data_##inst, \
|
||||
&counter_xec_dev_config_##inst, \
|
||||
POST_KERNEL, \
|
||||
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \
|
||||
CONFIG_COUNTER_INIT_PRIORITY, \
|
||||
&counter_xec_api); \
|
||||
\
|
||||
static void counter_xec_irq_config_##inst(void) \
|
||||
|
|
|
@ -237,7 +237,7 @@ static const struct counter_driver_api mcux_ctimer_driver_api = {
|
|||
static struct mcux_lpc_ctimer_data mcux_lpc_ctimer_data_##id; \
|
||||
DEVICE_DT_INST_DEFINE(id, &mcux_lpc_ctimer_init, NULL, &mcux_lpc_ctimer_data_##id, \
|
||||
&mcux_lpc_ctimer_config_##id, POST_KERNEL, \
|
||||
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &mcux_ctimer_driver_api); \
|
||||
CONFIG_COUNTER_INIT_PRIORITY, &mcux_ctimer_driver_api); \
|
||||
static void mcux_lpc_ctimer_irq_config_##id(const struct device *dev) \
|
||||
{ \
|
||||
IRQ_CONNECT(DT_INST_IRQN(id), DT_INST_IRQ(id, priority), mcux_lpc_ctimer_isr, \
|
||||
|
|
|
@ -223,7 +223,7 @@ static const struct counter_driver_api mcux_gpt_driver_api = {
|
|||
&mcux_gpt_data_ ## n, \
|
||||
&mcux_gpt_config_ ## n, \
|
||||
POST_KERNEL, \
|
||||
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \
|
||||
CONFIG_COUNTER_INIT_PRIORITY, \
|
||||
&mcux_gpt_driver_api); \
|
||||
\
|
||||
static int mcux_gpt_## n ##_init(const struct device *dev) \
|
||||
|
|
|
@ -237,7 +237,7 @@ static const struct counter_driver_api mcux_rtc_driver_api = {
|
|||
static struct mcux_lpc_rtc_data mcux_lpc_rtc_data_##id; \
|
||||
DEVICE_DT_INST_DEFINE(id, &mcux_lpc_rtc_init, NULL, \
|
||||
&mcux_lpc_rtc_data_##id, &mcux_lpc_rtc_config_##id.info, \
|
||||
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \
|
||||
POST_KERNEL, CONFIG_COUNTER_INIT_PRIORITY, \
|
||||
&mcux_rtc_driver_api); \
|
||||
static void mcux_lpc_rtc_irq_config_##id(const struct device *dev) \
|
||||
{ \
|
||||
|
|
|
@ -235,7 +235,7 @@ static struct mcux_lptmr_config mcux_lptmr_config_0 = {
|
|||
DEVICE_DT_INST_DEFINE(0, &mcux_lptmr_init, NULL,
|
||||
&mcux_lptmr_data_0,
|
||||
&mcux_lptmr_config_0,
|
||||
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
|
||||
POST_KERNEL, CONFIG_COUNTER_INIT_PRIORITY,
|
||||
&mcux_lptmr_driver_api);
|
||||
|
||||
static void mcux_lptmr_irq_config_0(const struct device *dev)
|
||||
|
|
|
@ -234,7 +234,7 @@ static const struct mcux_pit_config mcux_pit_config_0 = {
|
|||
|
||||
DEVICE_DT_INST_DEFINE(0, &mcux_pit_init, NULL,
|
||||
&mcux_pit_data_0, &mcux_pit_config_0, POST_KERNEL,
|
||||
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &mcux_pit_driver_api);
|
||||
CONFIG_COUNTER_INIT_PRIORITY, &mcux_pit_driver_api);
|
||||
|
||||
static void mcux_pit_irq_config_0(const struct device *dev)
|
||||
{
|
||||
|
|
|
@ -271,7 +271,7 @@ static struct mcux_rtc_config mcux_rtc_config_0 = {
|
|||
|
||||
DEVICE_DT_INST_DEFINE(0, &mcux_rtc_init, NULL,
|
||||
&mcux_rtc_data_0, &mcux_rtc_config_0.info,
|
||||
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
|
||||
POST_KERNEL, CONFIG_COUNTER_INIT_PRIORITY,
|
||||
&mcux_rtc_driver_api);
|
||||
|
||||
static void mcux_rtc_irq_config_0(const struct device *dev)
|
||||
|
|
|
@ -150,4 +150,4 @@ static const struct counter_config_info ctr_config = {
|
|||
|
||||
DEVICE_DT_DEFINE(DT_NODELABEL(DT_COUNTER_LABEL), ctr_init,
|
||||
NULL, NULL, &ctr_config, PRE_KERNEL_1,
|
||||
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &ctr_api);
|
||||
CONFIG_COUNTER_INIT_PRIORITY, &ctr_api);
|
||||
|
|
|
@ -707,7 +707,7 @@ static const struct counter_driver_api counter_nrfx_driver_api = {
|
|||
NULL, \
|
||||
&counter_##idx##_data, \
|
||||
&nrfx_counter_##idx##_config.info, \
|
||||
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \
|
||||
PRE_KERNEL_1, CONFIG_COUNTER_INIT_PRIORITY, \
|
||||
&counter_nrfx_driver_api)
|
||||
|
||||
#ifdef CONFIG_COUNTER_RTC0
|
||||
|
|
|
@ -442,7 +442,7 @@ static const struct counter_driver_api counter_nrfx_driver_api = {
|
|||
NULL, \
|
||||
&counter_##idx##_data, \
|
||||
&nrfx_counter_##idx##_config.info, \
|
||||
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \
|
||||
PRE_KERNEL_1, CONFIG_COUNTER_INIT_PRIORITY, \
|
||||
&counter_nrfx_driver_api)
|
||||
|
||||
#ifdef CONFIG_COUNTER_TIMER0
|
||||
|
|
|
@ -442,7 +442,7 @@ static const struct counter_driver_api counter_sam0_tc32_driver_api = {
|
|||
&counter_sam0_tc32_dev_data_##n, \
|
||||
&counter_sam0_tc32_dev_config_##n, \
|
||||
PRE_KERNEL_1, \
|
||||
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \
|
||||
CONFIG_COUNTER_INIT_PRIORITY, \
|
||||
&counter_sam0_tc32_driver_api); \
|
||||
\
|
||||
static void counter_sam0_tc32_config_##n(const struct device *dev) \
|
||||
|
|
|
@ -390,7 +390,7 @@ static struct counter_sam_dev_data counter_##n##_sam_data; \
|
|||
\
|
||||
DEVICE_DT_INST_DEFINE(n, counter_sam_initialize, NULL, \
|
||||
&counter_##n##_sam_data, &counter_##n##_sam_config, \
|
||||
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \
|
||||
PRE_KERNEL_1, CONFIG_COUNTER_INIT_PRIORITY, \
|
||||
&counter_sam_driver_api); \
|
||||
\
|
||||
static void counter_##n##_sam_config_func(const struct device *dev) \
|
||||
|
|
|
@ -342,7 +342,7 @@ static const struct counter_driver_api xlnx_axi_timer_driver_api = {
|
|||
&xlnx_axi_timer_data_##n, \
|
||||
&xlnx_axi_timer_config_##n, \
|
||||
POST_KERNEL, \
|
||||
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \
|
||||
CONFIG_COUNTER_INIT_PRIORITY, \
|
||||
&xlnx_axi_timer_driver_api); \
|
||||
\
|
||||
static void xlnx_axi_timer_config_func_##n(const struct device *dev) \
|
||||
|
|
|
@ -1313,13 +1313,13 @@ static const struct ds3231_config ds3231_0_config = {
|
|||
|
||||
static struct ds3231_data ds3231_0_data;
|
||||
|
||||
#if CONFIG_COUNTER_MAXIM_DS3231_INIT_PRIORITY <= CONFIG_I2C_INIT_PRIORITY
|
||||
#error COUNTER_MAXIM_DS3231_INIT_PRIORITY must be greater than I2C_INIT_PRIORITY
|
||||
#if CONFIG_COUNTER_INIT_PRIORITY <= CONFIG_I2C_INIT_PRIORITY
|
||||
#error CONFIG_COUNTER_INIT_PRIORITY must be greater than I2C_INIT_PRIORITY
|
||||
#endif
|
||||
|
||||
DEVICE_DT_INST_DEFINE(0, ds3231_init, NULL, &ds3231_0_data,
|
||||
&ds3231_0_config,
|
||||
POST_KERNEL, CONFIG_COUNTER_MAXIM_DS3231_INIT_PRIORITY,
|
||||
POST_KERNEL, CONFIG_COUNTER_INIT_PRIORITY,
|
||||
&ds3231_api);
|
||||
|
||||
#ifdef CONFIG_USERSPACE
|
||||
|
|
|
@ -765,7 +765,7 @@ static const struct counter_driver_api mcp7940n_api = {
|
|||
&mcp7940n_data_##index, \
|
||||
&mcp7940n_config_##index, \
|
||||
POST_KERNEL, \
|
||||
CONFIG_COUNTER_MICROCHIP_MCP7940N_INIT_PRIORITY, \
|
||||
CONFIG_COUNTER_INIT_PRIORITY, \
|
||||
&mcp7940n_api);
|
||||
|
||||
DT_INST_FOREACH_STATUS_OKAY(INST_DT_MCP7904N);
|
||||
|
|
|
@ -196,7 +196,7 @@ static int dtmr_cmsdk_apb_init(const struct device *dev)
|
|||
NULL, \
|
||||
&dtmr_cmsdk_apb_dev_data_##inst, \
|
||||
&dtmr_cmsdk_apb_cfg_##inst, POST_KERNEL, \
|
||||
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \
|
||||
CONFIG_COUNTER_INIT_PRIORITY, \
|
||||
&dtmr_cmsdk_apb_api); \
|
||||
\
|
||||
static void dtimer_cmsdk_apb_config_##inst(const struct device *dev) \
|
||||
|
|
|
@ -191,7 +191,7 @@ static int tmr_cmsdk_apb_init(const struct device *dev)
|
|||
NULL, \
|
||||
&tmr_cmsdk_apb_dev_data_##inst, \
|
||||
&tmr_cmsdk_apb_cfg_##inst, POST_KERNEL, \
|
||||
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \
|
||||
CONFIG_COUNTER_INIT_PRIORITY, \
|
||||
&tmr_cmsdk_apb_api); \
|
||||
\
|
||||
static void timer_cmsdk_apb_config_##inst(const struct device *dev) \
|
||||
|
|
|
@ -2,3 +2,4 @@
|
|||
CONFIG_I2C=y
|
||||
CONFIG_COUNTER=y
|
||||
CONFIG_COUNTER_MICROCHIP_MCP7940N=y
|
||||
CONFIG_COUNTER_INIT_PRIORITY=65
|
||||
|
|
|
@ -3,6 +3,7 @@ CONFIG_PRINTK=y
|
|||
CONFIG_I2C=y
|
||||
CONFIG_COUNTER=y
|
||||
CONFIG_COUNTER_MAXIM_DS3231=y
|
||||
CONFIG_COUNTER_INIT_PRIORITY=65
|
||||
|
||||
# Minimal libc doesn't have strftime()
|
||||
CONFIG_NEWLIB_LIBC=y
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
CONFIG_I2C=y
|
||||
CONFIG_COUNTER=y
|
||||
CONFIG_COUNTER_MAXIM_DS3231=y
|
||||
CONFIG_COUNTER_INIT_PRIORITY=65
|
||||
CONFIG_BT=n
|
||||
CONFIG_ZTEST=y
|
||||
CONFIG_TEST_USERSPACE=y
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue