drivers: clock_control: Refactor drivers to use shared init priority
Refactors all of the clock control drivers to use a shared driver class initialization priority configuration, CONFIG_CLOCK_CONTROL_INIT_PRIORITY, to allow configuring clock control drivers separately from other devices. This is similar to other driver classes like I2C and SPI. Most drivers previously used CONFIG_KERNEL_INIT_PRIORITY_OBJECTS or CONFIG_KERNEL_INIT_PRIORITY_DEVICE, therefore the default for this new option is the lower of the two, which means earlier initialization. The even lower defaults for STM32 and Arm Beetle are preserved by SoC-family level overrides. Signed-off-by: Maureen Helm <maureen.helm@intel.com>
This commit is contained in:
parent
365853a213
commit
ed9cb841c3
27 changed files with 36 additions and 41 deletions
|
@ -16,6 +16,12 @@ menuconfig CLOCK_CONTROL
|
||||||
|
|
||||||
if CLOCK_CONTROL
|
if CLOCK_CONTROL
|
||||||
|
|
||||||
|
config CLOCK_CONTROL_INIT_PRIORITY
|
||||||
|
int "Clock control init priority"
|
||||||
|
default KERNEL_INIT_PRIORITY_OBJECTS
|
||||||
|
help
|
||||||
|
Clock control driver device initialization priority.
|
||||||
|
|
||||||
module = CLOCK_CONTROL
|
module = CLOCK_CONTROL
|
||||||
module-str = clock control
|
module-str = clock control
|
||||||
source "subsys/logging/Kconfig.template.log_config"
|
source "subsys/logging/Kconfig.template.log_config"
|
||||||
|
|
|
@ -13,16 +13,6 @@ menuconfig CLOCK_CONTROL_BEETLE
|
||||||
Enable driver for Reset & Clock Control subsystem found
|
Enable driver for Reset & Clock Control subsystem found
|
||||||
in STM32F4 family of MCUs
|
in STM32F4 family of MCUs
|
||||||
|
|
||||||
config CLOCK_CONTROL_BEETLE_DEVICE_INIT_PRIORITY
|
|
||||||
int "Clock Control Device Priority"
|
|
||||||
default 1
|
|
||||||
depends on CLOCK_CONTROL_BEETLE
|
|
||||||
help
|
|
||||||
This option controls the priority of clock control
|
|
||||||
device initialization. Higher priority ensures that the device
|
|
||||||
is initialized earlier in the startup cycle. If unsure, leave
|
|
||||||
at default value 1
|
|
||||||
|
|
||||||
config ARM_CLOCK_CONTROL_DEV_NAME
|
config ARM_CLOCK_CONTROL_DEV_NAME
|
||||||
string "Clock Config Device name"
|
string "Clock Config Device name"
|
||||||
default "CLOCK_CONTROL_0"
|
default "CLOCK_CONTROL_0"
|
||||||
|
|
|
@ -15,15 +15,6 @@ menuconfig CLOCK_CONTROL_STM32_CUBE
|
||||||
|
|
||||||
if CLOCK_CONTROL_STM32_CUBE
|
if CLOCK_CONTROL_STM32_CUBE
|
||||||
|
|
||||||
config CLOCK_CONTROL_STM32_DEVICE_INIT_PRIORITY
|
|
||||||
int "Clock Control Device Priority"
|
|
||||||
default 1
|
|
||||||
help
|
|
||||||
This option controls the priority of clock control
|
|
||||||
device initialization. Higher priority ensures that the device
|
|
||||||
is initialized earlier in the startup cycle. If unsure, leave
|
|
||||||
at default value 1
|
|
||||||
|
|
||||||
DT_STM32_HSE_CLOCK := $(dt_nodelabel_path,clk_hse)
|
DT_STM32_HSE_CLOCK := $(dt_nodelabel_path,clk_hse)
|
||||||
DT_STM32_HSE_CLOCK_FREQ := $(dt_node_int_prop_int,$(DT_STM32_HSE_CLOCK),clock-frequency)
|
DT_STM32_HSE_CLOCK_FREQ := $(dt_node_int_prop_int,$(DT_STM32_HSE_CLOCK),clock-frequency)
|
||||||
|
|
||||||
|
|
|
@ -247,5 +247,5 @@ DEVICE_DEFINE(clock_control_beetle, CONFIG_ARM_CLOCK_CONTROL_DEV_NAME,
|
||||||
NULL,
|
NULL,
|
||||||
NULL, &beetle_cc_cfg,
|
NULL, &beetle_cc_cfg,
|
||||||
PRE_KERNEL_1,
|
PRE_KERNEL_1,
|
||||||
CONFIG_CLOCK_CONTROL_BEETLE_DEVICE_INIT_PRIORITY,
|
CONFIG_CLOCK_CONTROL_INIT_PRIORITY,
|
||||||
&beetle_clock_control_api);
|
&beetle_clock_control_api);
|
||||||
|
|
|
@ -53,5 +53,5 @@ static const struct clock_control_driver_api clk_api = {
|
||||||
};
|
};
|
||||||
|
|
||||||
DEVICE_DT_DEFINE(DT_NODELABEL(clock), clk_init, NULL, NULL, NULL,
|
DEVICE_DT_DEFINE(DT_NODELABEL(clock), clk_init, NULL, NULL, NULL,
|
||||||
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
|
PRE_KERNEL_1, CONFIG_CLOCK_CONTROL_INIT_PRIORITY,
|
||||||
&clk_api);
|
&clk_api);
|
||||||
|
|
|
@ -248,7 +248,7 @@ DEVICE_DT_DEFINE(DT_NODELABEL(rtc),
|
||||||
NULL,
|
NULL,
|
||||||
&esp32_clock_config0,
|
&esp32_clock_config0,
|
||||||
PRE_KERNEL_1,
|
PRE_KERNEL_1,
|
||||||
CONFIG_KERNEL_INIT_PRIORITY_OBJECTS,
|
CONFIG_CLOCK_CONTROL_INIT_PRIORITY,
|
||||||
&clock_control_esp32_api);
|
&clock_control_esp32_api);
|
||||||
|
|
||||||
BUILD_ASSERT((CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC) ==
|
BUILD_ASSERT((CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC) ==
|
||||||
|
|
|
@ -227,7 +227,7 @@ DEVICE_DT_DEFINE(DT_NODELABEL(rtc),
|
||||||
NULL,
|
NULL,
|
||||||
&esp32_clock_config0,
|
&esp32_clock_config0,
|
||||||
PRE_KERNEL_1,
|
PRE_KERNEL_1,
|
||||||
CONFIG_KERNEL_INIT_PRIORITY_OBJECTS,
|
CONFIG_CLOCK_CONTROL_INIT_PRIORITY,
|
||||||
&clock_control_esp32_api);
|
&clock_control_esp32_api);
|
||||||
|
|
||||||
BUILD_ASSERT((CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC) ==
|
BUILD_ASSERT((CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC) ==
|
||||||
|
|
|
@ -1788,4 +1788,4 @@ static const struct litex_clk_device ldev_init = {
|
||||||
|
|
||||||
DEVICE_DT_DEFINE(DT_NODELABEL(clock0), &litex_clk_init, NULL,
|
DEVICE_DT_DEFINE(DT_NODELABEL(clock0), &litex_clk_init, NULL,
|
||||||
NULL, &ldev_init, POST_KERNEL,
|
NULL, &ldev_init, POST_KERNEL,
|
||||||
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &litex_clk_api);
|
CONFIG_CLOCK_CONTROL_INIT_PRIORITY, &litex_clk_api);
|
||||||
|
|
|
@ -397,5 +397,5 @@ DEVICE_DT_INST_DEFINE(0,
|
||||||
&lpc11u6x_syscon_init,
|
&lpc11u6x_syscon_init,
|
||||||
NULL,
|
NULL,
|
||||||
&syscon_data, &syscon_config,
|
&syscon_data, &syscon_config,
|
||||||
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_OBJECTS,
|
PRE_KERNEL_1, CONFIG_CLOCK_CONTROL_INIT_PRIORITY,
|
||||||
&lpc11u6x_clock_control_api);
|
&lpc11u6x_clock_control_api);
|
||||||
|
|
|
@ -647,5 +647,5 @@ DEVICE_DT_INST_DEFINE(0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL, &xec_config,
|
NULL, &xec_config,
|
||||||
PRE_KERNEL_1,
|
PRE_KERNEL_1,
|
||||||
CONFIG_KERNEL_INIT_PRIORITY_OBJECTS,
|
CONFIG_CLOCK_CONTROL_INIT_PRIORITY,
|
||||||
&xec_clock_control_api);
|
&xec_clock_control_api);
|
||||||
|
|
|
@ -155,5 +155,5 @@ DEVICE_DT_INST_DEFINE(0,
|
||||||
&mcux_ccm_init,
|
&mcux_ccm_init,
|
||||||
NULL,
|
NULL,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
|
PRE_KERNEL_1, CONFIG_CLOCK_CONTROL_INIT_PRIORITY,
|
||||||
&mcux_ccm_driver_api);
|
&mcux_ccm_driver_api);
|
||||||
|
|
|
@ -101,5 +101,5 @@ DEVICE_DT_INST_DEFINE(0,
|
||||||
&mcux_ccm_init,
|
&mcux_ccm_init,
|
||||||
NULL,
|
NULL,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
|
PRE_KERNEL_1, CONFIG_CLOCK_CONTROL_INIT_PRIORITY,
|
||||||
&mcux_ccm_driver_api);
|
&mcux_ccm_driver_api);
|
||||||
|
|
|
@ -68,5 +68,5 @@ DEVICE_DT_INST_DEFINE(0,
|
||||||
&mcux_mcg_init,
|
&mcux_mcg_init,
|
||||||
NULL,
|
NULL,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
|
PRE_KERNEL_1, CONFIG_CLOCK_CONTROL_INIT_PRIORITY,
|
||||||
&mcux_mcg_driver_api);
|
&mcux_mcg_driver_api);
|
||||||
|
|
|
@ -79,7 +79,7 @@ static const struct clock_control_driver_api mcux_pcc_api = {
|
||||||
NULL, \
|
NULL, \
|
||||||
NULL, &mcux_pcc##inst##_config, \
|
NULL, &mcux_pcc##inst##_config, \
|
||||||
PRE_KERNEL_1, \
|
PRE_KERNEL_1, \
|
||||||
CONFIG_KERNEL_INIT_PRIORITY_OBJECTS, \
|
CONFIG_CLOCK_CONTROL_INIT_PRIORITY, \
|
||||||
&mcux_pcc_api);
|
&mcux_pcc_api);
|
||||||
|
|
||||||
DT_INST_FOREACH_STATUS_OKAY(MCUX_PCC_INIT)
|
DT_INST_FOREACH_STATUS_OKAY(MCUX_PCC_INIT)
|
||||||
|
|
|
@ -127,5 +127,5 @@ DEVICE_DT_INST_DEFINE(0,
|
||||||
&mcux_scg_init,
|
&mcux_scg_init,
|
||||||
NULL,
|
NULL,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
|
PRE_KERNEL_1, CONFIG_CLOCK_CONTROL_INIT_PRIORITY,
|
||||||
&mcux_scg_driver_api);
|
&mcux_scg_driver_api);
|
||||||
|
|
|
@ -103,5 +103,5 @@ DEVICE_DT_DEFINE(NXP_KINETIS_SIM_NODE,
|
||||||
&mcux_sim_init,
|
&mcux_sim_init,
|
||||||
NULL,
|
NULL,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
|
PRE_KERNEL_1, CONFIG_CLOCK_CONTROL_INIT_PRIORITY,
|
||||||
&mcux_sim_driver_api);
|
&mcux_sim_driver_api);
|
||||||
|
|
|
@ -121,7 +121,7 @@ DEVICE_DT_INST_DEFINE(n, \
|
||||||
&mcux_lpc_syscon_clock_control_init, \
|
&mcux_lpc_syscon_clock_control_init, \
|
||||||
NULL, \
|
NULL, \
|
||||||
NULL, NULL, \
|
NULL, NULL, \
|
||||||
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \
|
PRE_KERNEL_1, CONFIG_CLOCK_CONTROL_INIT_PRIORITY, \
|
||||||
&mcux_lpc_syscon_api);
|
&mcux_lpc_syscon_api);
|
||||||
|
|
||||||
DT_INST_FOREACH_STATUS_OKAY(LPC_CLOCK_INIT)
|
DT_INST_FOREACH_STATUS_OKAY(LPC_CLOCK_INIT)
|
||||||
|
|
|
@ -237,5 +237,5 @@ DEVICE_DT_INST_DEFINE(0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL, &pcc_config,
|
NULL, &pcc_config,
|
||||||
PRE_KERNEL_1,
|
PRE_KERNEL_1,
|
||||||
CONFIG_KERNEL_INIT_PRIORITY_OBJECTS,
|
CONFIG_CLOCK_CONTROL_INIT_PRIORITY,
|
||||||
&npcx_clock_control_api);
|
&npcx_clock_control_api);
|
||||||
|
|
|
@ -722,7 +722,7 @@ static const struct nrf_clock_control_config config = {
|
||||||
|
|
||||||
DEVICE_DT_DEFINE(DT_NODELABEL(clock), clk_init, NULL,
|
DEVICE_DT_DEFINE(DT_NODELABEL(clock), clk_init, NULL,
|
||||||
&data, &config,
|
&data, &config,
|
||||||
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
|
PRE_KERNEL_1, CONFIG_CLOCK_CONTROL_INIT_PRIORITY,
|
||||||
&clock_control_api);
|
&clock_control_api);
|
||||||
|
|
||||||
static int cmd_status(const struct shell *shell, size_t argc, char **argv)
|
static int cmd_status(const struct shell *shell, size_t argc, char **argv)
|
||||||
|
|
|
@ -221,7 +221,7 @@ static const struct clock_control_driver_api rcar_cpg_mssr_api = {
|
||||||
NULL, \
|
NULL, \
|
||||||
NULL, &rcar_mssr##inst##_config, \
|
NULL, &rcar_mssr##inst##_config, \
|
||||||
PRE_KERNEL_1, \
|
PRE_KERNEL_1, \
|
||||||
CONFIG_KERNEL_INIT_PRIORITY_OBJECTS, \
|
CONFIG_CLOCK_CONTROL_INIT_PRIORITY, \
|
||||||
&rcar_cpg_mssr_api);
|
&rcar_cpg_mssr_api);
|
||||||
|
|
||||||
DT_INST_FOREACH_STATUS_OKAY(RCAR_MSSR_INIT)
|
DT_INST_FOREACH_STATUS_OKAY(RCAR_MSSR_INIT)
|
||||||
|
|
|
@ -72,7 +72,7 @@ static const struct clock_control_driver_api rv32m1_pcc_api = {
|
||||||
NULL, \
|
NULL, \
|
||||||
NULL, &rv32m1_pcc##inst##_config, \
|
NULL, &rv32m1_pcc##inst##_config, \
|
||||||
PRE_KERNEL_1, \
|
PRE_KERNEL_1, \
|
||||||
CONFIG_KERNEL_INIT_PRIORITY_OBJECTS, \
|
CONFIG_CLOCK_CONTROL_INIT_PRIORITY, \
|
||||||
&rv32m1_pcc_api);
|
&rv32m1_pcc_api);
|
||||||
|
|
||||||
DT_INST_FOREACH_STATUS_OKAY(RV32M1_PCC_INIT)
|
DT_INST_FOREACH_STATUS_OKAY(RV32M1_PCC_INIT)
|
||||||
|
|
|
@ -726,5 +726,5 @@ DEVICE_DT_DEFINE(DT_NODELABEL(rcc),
|
||||||
NULL,
|
NULL,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
PRE_KERNEL_1,
|
PRE_KERNEL_1,
|
||||||
CONFIG_CLOCK_CONTROL_STM32_DEVICE_INIT_PRIORITY,
|
CONFIG_CLOCK_CONTROL_INIT_PRIORITY,
|
||||||
&stm32_clock_control_api);
|
&stm32_clock_control_api);
|
||||||
|
|
|
@ -734,5 +734,5 @@ DEVICE_DT_DEFINE(DT_NODELABEL(rcc),
|
||||||
NULL,
|
NULL,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
PRE_KERNEL_1,
|
PRE_KERNEL_1,
|
||||||
CONFIG_CLOCK_CONTROL_STM32_DEVICE_INIT_PRIORITY,
|
CONFIG_CLOCK_CONTROL_INIT_PRIORITY,
|
||||||
&stm32_clock_control_api);
|
&stm32_clock_control_api);
|
||||||
|
|
|
@ -414,5 +414,5 @@ DEVICE_DT_DEFINE(DT_NODELABEL(rcc),
|
||||||
NULL,
|
NULL,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
PRE_KERNEL_1,
|
PRE_KERNEL_1,
|
||||||
CONFIG_CLOCK_CONTROL_STM32_DEVICE_INIT_PRIORITY,
|
CONFIG_CLOCK_CONTROL_INIT_PRIORITY,
|
||||||
&stm32_clock_control_api);
|
&stm32_clock_control_api);
|
||||||
|
|
|
@ -595,5 +595,5 @@ DEVICE_DT_DEFINE(DT_NODELABEL(rcc),
|
||||||
NULL,
|
NULL,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
PRE_KERNEL_1,
|
PRE_KERNEL_1,
|
||||||
CONFIG_CLOCK_CONTROL_STM32_DEVICE_INIT_PRIORITY,
|
CONFIG_CLOCK_CONTROL_INIT_PRIORITY,
|
||||||
&stm32_clock_control_api);
|
&stm32_clock_control_api);
|
||||||
|
|
|
@ -16,4 +16,8 @@ config NUM_IRQS
|
||||||
config SYS_CLOCK_HW_CYCLES_PER_SEC
|
config SYS_CLOCK_HW_CYCLES_PER_SEC
|
||||||
default 24000000
|
default 24000000
|
||||||
|
|
||||||
|
config CLOCK_CONTROL_INIT_PRIORITY
|
||||||
|
default 1
|
||||||
|
depends on CLOCK_CONTROL
|
||||||
|
|
||||||
endif # SOC_SERIES_BEETLE
|
endif # SOC_SERIES_BEETLE
|
||||||
|
|
|
@ -25,6 +25,10 @@ config CLOCK_CONTROL_STM32_CUBE
|
||||||
default y
|
default y
|
||||||
depends on CLOCK_CONTROL
|
depends on CLOCK_CONTROL
|
||||||
|
|
||||||
|
config CLOCK_CONTROL_INIT_PRIORITY
|
||||||
|
default 1
|
||||||
|
depends on CLOCK_CONTROL
|
||||||
|
|
||||||
config UART_STM32
|
config UART_STM32
|
||||||
default y
|
default y
|
||||||
depends on SERIAL
|
depends on SERIAL
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue