drivers: eeprom: Refactor drivers to use shared init priority

Refactors all of the EEPROM drivers to use a shared driver class
initialization priority configuration, CONFIG_EEPROM_INIT_PRIORITY, to
allow configuring EEPROM 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 at2x and emul drivers which have dependencies on SPI,
I2C, or flash drivers and must therefore initialize later than the
default device priority.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
This commit is contained in:
Maureen Helm 2021-10-28 16:48:46 -05:00 committed by Christopher Friedt
commit 32b4950c61
11 changed files with 19 additions and 15 deletions

View file

@ -27,6 +27,9 @@ config I2C
config EEPROM_AT24
default y
config EEPROM_INIT_PRIORITY
default 75
endif # EEPROM
endif # SHIELD_LMP90100_EVB

View file

@ -17,6 +17,9 @@ config I2C
config EEPROM_AT24
default y
config EEPROM_INIT_PRIORITY
default 75
endif # EEPROM
endif # SHIELD_X_NUCLEO_EEPRMA2

View file

@ -14,6 +14,12 @@ module = EEPROM
module-str = eeprom
source "subsys/logging/Kconfig.template.log_config"
config EEPROM_INIT_PRIORITY
int "EEPROM init priority"
default KERNEL_INIT_PRIORITY_DEVICE
help
EEPROM driver device initialization priority.
config EEPROM_SHELL
bool "Enable EEPROM shell"
default y
@ -49,11 +55,6 @@ config EEPROM_AT25
help
Enable support for Atmel AT25 (and compatible) SPI EEPROMs.
config EEPROM_AT2X_INIT_PRIORITY
int "AT2X EEPROM init priority"
default 75
depends on EEPROM_AT2X
source "drivers/eeprom/Kconfig.lpc11u6x"
source "drivers/eeprom/Kconfig.stm32"
source "drivers/eeprom/Kconfig.eeprom_emu"

View file

@ -10,8 +10,3 @@ config EEPROM_EMULATOR
performed to the EEPROM is maximized by using a flash area that is
larger than the EEPROM area and by storing only changes to the EEPROM
data.
config EEPROM_EMULATOR_INIT_PRIORITY
int "EEPROM emulator init priority"
default 75
depends on EEPROM_EMULATOR

View file

@ -629,7 +629,7 @@ static const struct eeprom_driver_api eeprom_at2x_api = {
DEVICE_DT_DEFINE(INST_DT_AT2X(n, t), &eeprom_at2x_init, \
NULL, &eeprom_at##t##_data_##n, \
&eeprom_at##t##_config_##n, POST_KERNEL, \
CONFIG_EEPROM_AT2X_INIT_PRIORITY, \
CONFIG_EEPROM_INIT_PRIORITY, \
&eeprom_at2x_api)
#define EEPROM_AT24_DEVICE(n) EEPROM_AT2X_DEVICE(n, 24)

View file

@ -809,6 +809,6 @@ static const struct eeprom_driver_api eeprom_emu_api = {
DEVICE_DT_INST_DEFINE(n, &eeprom_emu_init, \
NULL, &eeprom_emu_##n##_data, \
&eeprom_emu_##n##_config, POST_KERNEL, \
CONFIG_EEPROM_EMULATOR_INIT_PRIORITY, &eeprom_emu_api); \
CONFIG_EEPROM_INIT_PRIORITY, &eeprom_emu_api); \
DT_INST_FOREACH_STATUS_OKAY(EEPROM_EMU_INIT)

View file

@ -117,4 +117,4 @@ static const struct eeprom_lpc11u6x_config eeprom_config = {
DEVICE_DT_INST_DEFINE(0, &eeprom_lpc11u6x_init, NULL, NULL,
&eeprom_config, POST_KERNEL,
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &eeprom_lpc11u6x_api);
CONFIG_EEPROM_INIT_PRIORITY, &eeprom_lpc11u6x_api);

View file

@ -269,7 +269,7 @@ static int eeprom_sim_init(const struct device *dev)
DEVICE_DT_INST_DEFINE(0, &eeprom_sim_init, NULL,
NULL, &eeprom_sim_config_0, POST_KERNEL,
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &eeprom_sim_api);
CONFIG_EEPROM_INIT_PRIORITY, &eeprom_sim_api);
#ifdef CONFIG_ARCH_POSIX

View file

@ -124,4 +124,4 @@ static const struct eeprom_stm32_config eeprom_config = {
DEVICE_DT_INST_DEFINE(0, &eeprom_stm32_init, NULL, NULL,
&eeprom_config, POST_KERNEL,
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &eeprom_stm32_api);
CONFIG_EEPROM_INIT_PRIORITY, &eeprom_stm32_api);

View file

@ -5,4 +5,5 @@ CONFIG_EMUL=y
CONFIG_I2C=y
CONFIG_I2C_EMUL=y
CONFIG_EEPROM_AT24=y
CONFIG_EEPROM_INIT_PRIORITY=75
CONFIG_EMUL_EEPROM_AT2X=y

View file

@ -3,3 +3,4 @@ CONFIG_TEST_USERSPACE=y
CONFIG_EEPROM=y
CONFIG_EEPROM_SIMULATOR=y
CONFIG_EEPROM_EMULATOR=y
CONFIG_EEPROM_INIT_PRIORITY=75