drivers: flash: stm32: Convert to use device tree
Convert STM32 flash drivers to use device tree to get the flash controller name and base address. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
parent
f5d64aafaa
commit
dc98605f4a
10 changed files with 33 additions and 16 deletions
6
arch/arm/soc/st_stm32/stm32f0/dts.fixup
Normal file
6
arch/arm/soc/st_stm32/stm32f0/dts.fixup
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
/* SoC level DTS fixup file */
|
||||||
|
|
||||||
|
#define FLASH_DEV_BASE_ADDRESS ST_STM32F0_FLASH_CONTROLLER_40022000_BASE_ADDRESS_0
|
||||||
|
#define FLASH_DEV_NAME ST_STM32F0_FLASH_CONTROLLER_40022000_LABEL
|
||||||
|
|
||||||
|
/* End of SoC Level DTS fixup file */
|
6
arch/arm/soc/st_stm32/stm32f3/dts.fixup
Normal file
6
arch/arm/soc/st_stm32/stm32f3/dts.fixup
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
/* SoC level DTS fixup file */
|
||||||
|
|
||||||
|
#define FLASH_DEV_BASE_ADDRESS ST_STM32F3_FLASH_CONTROLLER_40022000_BASE_ADDRESS_0
|
||||||
|
#define FLASH_DEV_NAME ST_STM32F3_FLASH_CONTROLLER_40022000_LABEL
|
||||||
|
|
||||||
|
/* End of SoC Level DTS fixup file */
|
6
arch/arm/soc/st_stm32/stm32f4/dts.fixup
Normal file
6
arch/arm/soc/st_stm32/stm32f4/dts.fixup
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
/* SoC level DTS fixup file */
|
||||||
|
|
||||||
|
#define FLASH_DEV_BASE_ADDRESS ST_STM32F4_FLASH_CONTROLLER_40023C00_BASE_ADDRESS_0
|
||||||
|
#define FLASH_DEV_NAME ST_STM32F4_FLASH_CONTROLLER_40023C00_LABEL
|
||||||
|
|
||||||
|
/* End of SoC Level DTS fixup file */
|
|
@ -58,7 +58,7 @@
|
||||||
|
|
||||||
/* For IMG_MANAGER */
|
/* For IMG_MANAGER */
|
||||||
#if defined(CONFIG_SOC_FLASH_STM32)
|
#if defined(CONFIG_SOC_FLASH_STM32)
|
||||||
#define FLASH_DRIVER_NAME CONFIG_SOC_FLASH_STM32_DEV_NAME
|
#define FLASH_DRIVER_NAME FLASH_DEV_NAME
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* !_ASMLANGUAGE */
|
#endif /* !_ASMLANGUAGE */
|
||||||
|
|
6
arch/arm/soc/st_stm32/stm32l4/dts.fixup
Normal file
6
arch/arm/soc/st_stm32/stm32l4/dts.fixup
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
/* SoC level DTS fixup file */
|
||||||
|
|
||||||
|
#define FLASH_DEV_BASE_ADDRESS ST_STM32L4_FLASH_CONTROLLER_40022000_BASE_ADDRESS_0
|
||||||
|
#define FLASH_DEV_NAME ST_STM32L4_FLASH_CONTROLLER_40022000_LABEL
|
||||||
|
|
||||||
|
/* End of SoC Level DTS fixup file */
|
|
@ -57,7 +57,7 @@
|
||||||
|
|
||||||
/* For IMG_MANAGER */
|
/* For IMG_MANAGER */
|
||||||
#if defined(CONFIG_SOC_FLASH_STM32)
|
#if defined(CONFIG_SOC_FLASH_STM32)
|
||||||
#define FLASH_DRIVER_NAME CONFIG_SOC_FLASH_STM32_DEV_NAME
|
#define FLASH_DRIVER_NAME FLASH_DEV_NAME
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* !_ASMLANGUAGE */
|
#endif /* !_ASMLANGUAGE */
|
||||||
|
|
|
@ -22,11 +22,4 @@ menuconfig SOC_FLASH_STM32
|
||||||
help
|
help
|
||||||
Enable STM32F0x, STM32F3x, STM32F4x OR STM32L4x series flash driver.
|
Enable STM32F0x, STM32F3x, STM32F4x OR STM32L4x series flash driver.
|
||||||
|
|
||||||
config SOC_FLASH_STM32_DEV_NAME
|
|
||||||
string "STM32 flash device name"
|
|
||||||
depends on SOC_FLASH_STM32
|
|
||||||
default "FLASH_STM32"
|
|
||||||
help
|
|
||||||
Specify the device name for the flash driver.
|
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -204,13 +204,13 @@ static int flash_stm32_write_protection(struct device *dev, bool enable)
|
||||||
|
|
||||||
static struct flash_stm32_priv flash_data = {
|
static struct flash_stm32_priv flash_data = {
|
||||||
#if defined(CONFIG_SOC_SERIES_STM32F0X)
|
#if defined(CONFIG_SOC_SERIES_STM32F0X)
|
||||||
.regs = (struct stm32f0x_flash *) FLASH_R_BASE,
|
.regs = (struct stm32f0x_flash *) FLASH_DEV_BASE_ADDRESS,
|
||||||
.pclken = { .bus = STM32_CLOCK_BUS_AHB1,
|
.pclken = { .bus = STM32_CLOCK_BUS_AHB1,
|
||||||
.enr = LL_AHB1_GRP1_PERIPH_FLASH },
|
.enr = LL_AHB1_GRP1_PERIPH_FLASH },
|
||||||
#elif defined(CONFIG_SOC_SERIES_STM32F4X)
|
#elif defined(CONFIG_SOC_SERIES_STM32F4X)
|
||||||
.regs = (struct stm32f4x_flash *) FLASH_R_BASE,
|
.regs = (struct stm32f4x_flash *) FLASH_DEV_BASE_ADDRESS,
|
||||||
#elif defined(CONFIG_SOC_SERIES_STM32L4X)
|
#elif defined(CONFIG_SOC_SERIES_STM32L4X)
|
||||||
.regs = (struct stm32l4x_flash *) FLASH_R_BASE,
|
.regs = (struct stm32l4x_flash *) FLASH_DEV_BASE_ADDRESS,
|
||||||
.pclken = { .bus = STM32_CLOCK_BUS_AHB1,
|
.pclken = { .bus = STM32_CLOCK_BUS_AHB1,
|
||||||
.enr = LL_AHB1_GRP1_PERIPH_FLASH },
|
.enr = LL_AHB1_GRP1_PERIPH_FLASH },
|
||||||
#endif
|
#endif
|
||||||
|
@ -260,6 +260,6 @@ static int stm32_flash_init(struct device *dev)
|
||||||
return flash_stm32_write_protection(dev, false);
|
return flash_stm32_write_protection(dev, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
DEVICE_AND_API_INIT(stm32_flash, CONFIG_SOC_FLASH_STM32_DEV_NAME,
|
DEVICE_AND_API_INIT(stm32_flash, FLASH_DEV_NAME,
|
||||||
stm32_flash_init, &flash_data, NULL, POST_KERNEL,
|
stm32_flash_init, &flash_data, NULL, POST_KERNEL,
|
||||||
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &flash_stm32_api);
|
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &flash_stm32_api);
|
||||||
|
|
|
@ -133,7 +133,7 @@ static const struct flash_driver_api flash_stm32_api = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct flash_stm32_dev_config flash_device_config = {
|
static const struct flash_stm32_dev_config flash_device_config = {
|
||||||
.base = (u32_t *)FLASH_R_BASE,
|
.base = (u32_t *)FLASH_DEV_BASE_ADDRESS,
|
||||||
.pclken = { .bus = STM32_CLOCK_BUS_APB1,
|
.pclken = { .bus = STM32_CLOCK_BUS_APB1,
|
||||||
.enr = LL_AHB1_GRP1_PERIPH_FLASH},
|
.enr = LL_AHB1_GRP1_PERIPH_FLASH},
|
||||||
};
|
};
|
||||||
|
@ -142,7 +142,7 @@ static struct flash_stm32_dev_data flash_device_data = {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
DEVICE_AND_API_INIT(flash_stm32, CONFIG_SOC_FLASH_STM32_DEV_NAME,
|
DEVICE_AND_API_INIT(flash_stm32, FLASH_DEV_NAME,
|
||||||
flash_stm32_init,
|
flash_stm32_init,
|
||||||
&flash_device_data,
|
&flash_device_data,
|
||||||
&flash_device_config,
|
&flash_device_config,
|
||||||
|
|
|
@ -72,7 +72,7 @@ static int shell_cmd_write_stm32(int argc, char *argv[])
|
||||||
ARG_UNUSED(argv);
|
ARG_UNUSED(argv);
|
||||||
|
|
||||||
struct device *flash_dev;
|
struct device *flash_dev;
|
||||||
flash_dev = device_get_binding(CONFIG_SOC_FLASH_STM32_DEV_NAME);
|
flash_dev = device_get_binding(FLASH_DEV_NAME);
|
||||||
|
|
||||||
/* 16K reserved to the application */
|
/* 16K reserved to the application */
|
||||||
u32_t offset = FLASH_MEM + 0x4000;
|
u32_t offset = FLASH_MEM + 0x4000;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue