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:
Maureen Helm 2021-10-18 14:45:17 -05:00 committed by Anas Nashif
commit ed9cb841c3
27 changed files with 36 additions and 41 deletions

View file

@ -16,6 +16,12 @@ menuconfig 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-str = clock control
source "subsys/logging/Kconfig.template.log_config"

View file

@ -13,16 +13,6 @@ menuconfig CLOCK_CONTROL_BEETLE
Enable driver for Reset & Clock Control subsystem found
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
string "Clock Config Device name"
default "CLOCK_CONTROL_0"

View file

@ -15,15 +15,6 @@ menuconfig 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_FREQ := $(dt_node_int_prop_int,$(DT_STM32_HSE_CLOCK),clock-frequency)

View file

@ -247,5 +247,5 @@ DEVICE_DEFINE(clock_control_beetle, CONFIG_ARM_CLOCK_CONTROL_DEV_NAME,
NULL,
NULL, &beetle_cc_cfg,
PRE_KERNEL_1,
CONFIG_CLOCK_CONTROL_BEETLE_DEVICE_INIT_PRIORITY,
CONFIG_CLOCK_CONTROL_INIT_PRIORITY,
&beetle_clock_control_api);

View file

@ -53,5 +53,5 @@ static const struct clock_control_driver_api clk_api = {
};
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);

View file

@ -248,7 +248,7 @@ DEVICE_DT_DEFINE(DT_NODELABEL(rtc),
NULL,
&esp32_clock_config0,
PRE_KERNEL_1,
CONFIG_KERNEL_INIT_PRIORITY_OBJECTS,
CONFIG_CLOCK_CONTROL_INIT_PRIORITY,
&clock_control_esp32_api);
BUILD_ASSERT((CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC) ==

View file

@ -227,7 +227,7 @@ DEVICE_DT_DEFINE(DT_NODELABEL(rtc),
NULL,
&esp32_clock_config0,
PRE_KERNEL_1,
CONFIG_KERNEL_INIT_PRIORITY_OBJECTS,
CONFIG_CLOCK_CONTROL_INIT_PRIORITY,
&clock_control_esp32_api);
BUILD_ASSERT((CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC) ==

View file

@ -1788,4 +1788,4 @@ static const struct litex_clk_device ldev_init = {
DEVICE_DT_DEFINE(DT_NODELABEL(clock0), &litex_clk_init, NULL,
NULL, &ldev_init, POST_KERNEL,
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &litex_clk_api);
CONFIG_CLOCK_CONTROL_INIT_PRIORITY, &litex_clk_api);

View file

@ -397,5 +397,5 @@ DEVICE_DT_INST_DEFINE(0,
&lpc11u6x_syscon_init,
NULL,
&syscon_data, &syscon_config,
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_OBJECTS,
PRE_KERNEL_1, CONFIG_CLOCK_CONTROL_INIT_PRIORITY,
&lpc11u6x_clock_control_api);

View file

@ -647,5 +647,5 @@ DEVICE_DT_INST_DEFINE(0,
NULL,
NULL, &xec_config,
PRE_KERNEL_1,
CONFIG_KERNEL_INIT_PRIORITY_OBJECTS,
CONFIG_CLOCK_CONTROL_INIT_PRIORITY,
&xec_clock_control_api);

View file

@ -155,5 +155,5 @@ DEVICE_DT_INST_DEFINE(0,
&mcux_ccm_init,
NULL,
NULL, NULL,
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
PRE_KERNEL_1, CONFIG_CLOCK_CONTROL_INIT_PRIORITY,
&mcux_ccm_driver_api);

View file

@ -101,5 +101,5 @@ DEVICE_DT_INST_DEFINE(0,
&mcux_ccm_init,
NULL,
NULL, NULL,
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
PRE_KERNEL_1, CONFIG_CLOCK_CONTROL_INIT_PRIORITY,
&mcux_ccm_driver_api);

View file

@ -68,5 +68,5 @@ DEVICE_DT_INST_DEFINE(0,
&mcux_mcg_init,
NULL,
NULL, NULL,
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
PRE_KERNEL_1, CONFIG_CLOCK_CONTROL_INIT_PRIORITY,
&mcux_mcg_driver_api);

View file

@ -79,7 +79,7 @@ static const struct clock_control_driver_api mcux_pcc_api = {
NULL, \
NULL, &mcux_pcc##inst##_config, \
PRE_KERNEL_1, \
CONFIG_KERNEL_INIT_PRIORITY_OBJECTS, \
CONFIG_CLOCK_CONTROL_INIT_PRIORITY, \
&mcux_pcc_api);
DT_INST_FOREACH_STATUS_OKAY(MCUX_PCC_INIT)

View file

@ -127,5 +127,5 @@ DEVICE_DT_INST_DEFINE(0,
&mcux_scg_init,
NULL,
NULL, NULL,
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
PRE_KERNEL_1, CONFIG_CLOCK_CONTROL_INIT_PRIORITY,
&mcux_scg_driver_api);

View file

@ -103,5 +103,5 @@ DEVICE_DT_DEFINE(NXP_KINETIS_SIM_NODE,
&mcux_sim_init,
NULL,
NULL, NULL,
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
PRE_KERNEL_1, CONFIG_CLOCK_CONTROL_INIT_PRIORITY,
&mcux_sim_driver_api);

View file

@ -121,7 +121,7 @@ DEVICE_DT_INST_DEFINE(n, \
&mcux_lpc_syscon_clock_control_init, \
NULL, \
NULL, NULL, \
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \
PRE_KERNEL_1, CONFIG_CLOCK_CONTROL_INIT_PRIORITY, \
&mcux_lpc_syscon_api);
DT_INST_FOREACH_STATUS_OKAY(LPC_CLOCK_INIT)

View file

@ -237,5 +237,5 @@ DEVICE_DT_INST_DEFINE(0,
NULL,
NULL, &pcc_config,
PRE_KERNEL_1,
CONFIG_KERNEL_INIT_PRIORITY_OBJECTS,
CONFIG_CLOCK_CONTROL_INIT_PRIORITY,
&npcx_clock_control_api);

View file

@ -722,7 +722,7 @@ static const struct nrf_clock_control_config config = {
DEVICE_DT_DEFINE(DT_NODELABEL(clock), clk_init, NULL,
&data, &config,
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
PRE_KERNEL_1, CONFIG_CLOCK_CONTROL_INIT_PRIORITY,
&clock_control_api);
static int cmd_status(const struct shell *shell, size_t argc, char **argv)

View file

@ -221,7 +221,7 @@ static const struct clock_control_driver_api rcar_cpg_mssr_api = {
NULL, \
NULL, &rcar_mssr##inst##_config, \
PRE_KERNEL_1, \
CONFIG_KERNEL_INIT_PRIORITY_OBJECTS, \
CONFIG_CLOCK_CONTROL_INIT_PRIORITY, \
&rcar_cpg_mssr_api);
DT_INST_FOREACH_STATUS_OKAY(RCAR_MSSR_INIT)

View file

@ -72,7 +72,7 @@ static const struct clock_control_driver_api rv32m1_pcc_api = {
NULL, \
NULL, &rv32m1_pcc##inst##_config, \
PRE_KERNEL_1, \
CONFIG_KERNEL_INIT_PRIORITY_OBJECTS, \
CONFIG_CLOCK_CONTROL_INIT_PRIORITY, \
&rv32m1_pcc_api);
DT_INST_FOREACH_STATUS_OKAY(RV32M1_PCC_INIT)

View file

@ -726,5 +726,5 @@ DEVICE_DT_DEFINE(DT_NODELABEL(rcc),
NULL,
NULL, NULL,
PRE_KERNEL_1,
CONFIG_CLOCK_CONTROL_STM32_DEVICE_INIT_PRIORITY,
CONFIG_CLOCK_CONTROL_INIT_PRIORITY,
&stm32_clock_control_api);

View file

@ -734,5 +734,5 @@ DEVICE_DT_DEFINE(DT_NODELABEL(rcc),
NULL,
NULL, NULL,
PRE_KERNEL_1,
CONFIG_CLOCK_CONTROL_STM32_DEVICE_INIT_PRIORITY,
CONFIG_CLOCK_CONTROL_INIT_PRIORITY,
&stm32_clock_control_api);

View file

@ -414,5 +414,5 @@ DEVICE_DT_DEFINE(DT_NODELABEL(rcc),
NULL,
NULL, NULL,
PRE_KERNEL_1,
CONFIG_CLOCK_CONTROL_STM32_DEVICE_INIT_PRIORITY,
CONFIG_CLOCK_CONTROL_INIT_PRIORITY,
&stm32_clock_control_api);

View file

@ -595,5 +595,5 @@ DEVICE_DT_DEFINE(DT_NODELABEL(rcc),
NULL,
NULL, NULL,
PRE_KERNEL_1,
CONFIG_CLOCK_CONTROL_STM32_DEVICE_INIT_PRIORITY,
CONFIG_CLOCK_CONTROL_INIT_PRIORITY,
&stm32_clock_control_api);

View file

@ -16,4 +16,8 @@ config NUM_IRQS
config SYS_CLOCK_HW_CYCLES_PER_SEC
default 24000000
config CLOCK_CONTROL_INIT_PRIORITY
default 1
depends on CLOCK_CONTROL
endif # SOC_SERIES_BEETLE

View file

@ -25,6 +25,10 @@ config CLOCK_CONTROL_STM32_CUBE
default y
depends on CLOCK_CONTROL
config CLOCK_CONTROL_INIT_PRIORITY
default 1
depends on CLOCK_CONTROL
config UART_STM32
default y
depends on SERIAL