Skip to content

Commit

Permalink
drivers: flash: flash_stm32: convert to DT_INST defines
Browse files Browse the repository at this point in the history
Convert driver to use DT_INST_ defines.
Removed DT_FLASH_DEV fixup macros, except DT_FLASH_DEV_NAME
used in applications.

Signed-off-by: Erwan Gouriou <[email protected]>
  • Loading branch information
erwango authored and galak committed Mar 17, 2020
1 parent f289a6f commit 22af564
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 20 deletions.
4 changes: 2 additions & 2 deletions drivers/flash/flash_stm32.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ static int flash_stm32_write_protection(struct device *dev, bool enable)
}

static struct flash_stm32_priv flash_data = {
.regs = (FLASH_TypeDef *) DT_FLASH_DEV_BASE_ADDRESS,
.regs = (FLASH_TypeDef *) DT_INST_0_SOC_NV_FLASH_BASE_ADDRESS,
#if defined(CONFIG_SOC_SERIES_STM32L4X) || \
defined(CONFIG_SOC_SERIES_STM32F0X) || \
defined(CONFIG_SOC_SERIES_STM32F1X) || \
Expand Down Expand Up @@ -327,6 +327,6 @@ static int stm32_flash_init(struct device *dev)
return flash_stm32_write_protection(dev, false);
}

DEVICE_AND_API_INIT(stm32_flash, DT_FLASH_DEV_NAME,
DEVICE_AND_API_INIT(stm32_flash, DT_INST_0_SOC_NV_FLASH_LABEL,
stm32_flash_init, &flash_data, NULL, POST_KERNEL,
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &flash_stm32_api);
3 changes: 1 addition & 2 deletions soc/arm/st_stm32/stm32f0/dts_fixup.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@
#define DT_CAN_1_CLOCK_BUS DT_ST_STM32_CAN_40006400_CLOCK_BUS
#define DT_CAN_1_CLOCK_BITS DT_ST_STM32_CAN_40006400_CLOCK_BITS

#define DT_FLASH_DEV_BASE_ADDRESS DT_ST_STM32F0_FLASH_CONTROLLER_40022000_BASE_ADDRESS
#define DT_FLASH_DEV_NAME DT_ST_STM32F0_FLASH_CONTROLLER_40022000_LABEL
#define DT_FLASH_DEV_NAME DT_INST_0_ST_STM32F0_FLASH_CONTROLLER_LABEL

#define DT_USB_BASE_ADDRESS DT_ST_STM32_USB_40005C00_BASE_ADDRESS
#define DT_USB_IRQ DT_ST_STM32_USB_40005C00_IRQ_USB
Expand Down
3 changes: 1 addition & 2 deletions soc/arm/st_stm32/stm32f1/dts_fixup.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@
#define DT_CAN_1_CLOCK_BUS DT_ST_STM32_CAN_40006400_CLOCK_BUS
#define DT_CAN_1_CLOCK_BITS DT_ST_STM32_CAN_40006400_CLOCK_BITS

#define DT_FLASH_DEV_BASE_ADDRESS DT_ST_STM32F1_FLASH_CONTROLLER_40022000_BASE_ADDRESS
#define DT_FLASH_DEV_NAME DT_ST_STM32F1_FLASH_CONTROLLER_40022000_LABEL
#define DT_FLASH_DEV_NAME DT_INST_0_ST_STM32F1_FLASH_CONTROLLER_LABEL

/* End of SoC Level DTS fixup file */
3 changes: 1 addition & 2 deletions soc/arm/st_stm32/stm32f3/dts_fixup.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@
#define DT_SPI_4_CLOCK_BITS DT_ST_STM32_SPI_FIFO_40013C00_CLOCK_BITS
#define DT_SPI_4_CLOCK_BUS DT_ST_STM32_SPI_FIFO_40013C00_CLOCK_BUS

#define DT_FLASH_DEV_BASE_ADDRESS DT_ST_STM32F3_FLASH_CONTROLLER_40022000_BASE_ADDRESS
#define DT_FLASH_DEV_NAME DT_ST_STM32F3_FLASH_CONTROLLER_40022000_LABEL
#define DT_FLASH_DEV_NAME DT_INST_0_ST_STM32F3_FLASH_CONTROLLER_LABEL

#define DT_USB_BASE_ADDRESS DT_ST_STM32_USB_40005C00_BASE_ADDRESS
#define DT_USB_IRQ DT_ST_STM32_USB_40005C00_IRQ_USB
Expand Down
3 changes: 1 addition & 2 deletions soc/arm/st_stm32/stm32f4/dts_fixup.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,7 @@
#define DT_I2S_6_DMA_FEATURES_RX \
DT_ST_STM32_I2S_40015400_RX_DMAS_FEATURES

#define DT_FLASH_DEV_BASE_ADDRESS DT_ST_STM32F4_FLASH_CONTROLLER_40023C00_BASE_ADDRESS
#define DT_FLASH_DEV_NAME DT_ST_STM32F4_FLASH_CONTROLLER_40023C00_LABEL
#define DT_FLASH_DEV_NAME DT_INST_0_ST_STM32F4_FLASH_CONTROLLER_LABEL

#ifdef DT_ST_STM32_OTGFS_50000000_BASE_ADDRESS
#define DT_USB_BASE_ADDRESS DT_ST_STM32_OTGFS_50000000_BASE_ADDRESS
Expand Down
3 changes: 1 addition & 2 deletions soc/arm/st_stm32/stm32f7/dts_fixup.h
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,7 @@

#define DT_RTC_0_NAME DT_INST_0_ST_STM32_RTC_LABEL

#define DT_FLASH_DEV_BASE_ADDRESS DT_ST_STM32F7_FLASH_CONTROLLER_40023C00_BASE_ADDRESS
#define DT_FLASH_DEV_NAME DT_ST_STM32F7_FLASH_CONTROLLER_40023C00_LABEL
#define DT_FLASH_DEV_NAME DT_INST_0_ST_STM32F7_FLASH_CONTROLLER_LABEL

#define DT_CAN_1_BASE_ADDRESS DT_ST_STM32_CAN_40006400_BASE_ADDRESS
#define DT_CAN_1_BUS_SPEED DT_ST_STM32_CAN_40006400_BUS_SPEED
Expand Down
3 changes: 1 addition & 2 deletions soc/arm/st_stm32/stm32g0/dts_fixup.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

#define DT_NUM_IRQ_PRIO_BITS DT_ARM_V6M_NVIC_E000E100_ARM_NUM_IRQ_PRIORITY_BITS

#define DT_FLASH_DEV_BASE_ADDRESS DT_ST_STM32G0_FLASH_CONTROLLER_40022000_BASE_ADDRESS
#define DT_FLASH_DEV_NAME DT_ST_STM32G0_FLASH_CONTROLLER_40022000_LABEL
#define DT_FLASH_DEV_NAME DT_INST_0_ST_STM32G0_FLASH_CONTROLLER_LABEL

#define DT_PWM_STM32_3_DEV_NAME DT_ST_STM32_PWM_40000400_PWM_LABEL
#define DT_PWM_STM32_3_PRESCALER DT_ST_STM32_PWM_40000400_PWM_ST_PRESCALER
Expand Down
3 changes: 1 addition & 2 deletions soc/arm/st_stm32/stm32g4/dts_fixup.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@
#define DT_UART_STM32_LPUART_1_CLOCK_BUS DT_ST_STM32_LPUART_40008000_CLOCK_BUS
#define DT_UART_STM32_LPUART_1_HW_FLOW_CONTROL DT_ST_STM32_LPUART_40008000_HW_FLOW_CONTROL

#define DT_FLASH_DEV_BASE_ADDRESS DT_ST_STM32G4_FLASH_CONTROLLER_40022000_BASE_ADDRESS
#define DT_FLASH_DEV_NAME DT_ST_STM32G4_FLASH_CONTROLLER_40022000_LABEL
#define DT_FLASH_DEV_NAME DT_INST_0_ST_STM32G4_FLASH_CONTROLLER_LABEL

#define DT_I2C_1_BASE_ADDRESS DT_ST_STM32_I2C_V2_40005400_BASE_ADDRESS
#define DT_I2C_1_EVENT_IRQ_PRI DT_ST_STM32_I2C_V2_40005400_IRQ_EVENT_PRIORITY
Expand Down
3 changes: 1 addition & 2 deletions soc/arm/st_stm32/stm32l4/dts_fixup.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@
#define DT_SPI_3_CLOCK_BITS DT_ST_STM32_SPI_FIFO_40003C00_CLOCK_BITS
#define DT_SPI_3_CLOCK_BUS DT_ST_STM32_SPI_FIFO_40003C00_CLOCK_BUS

#define DT_FLASH_DEV_BASE_ADDRESS DT_ST_STM32L4_FLASH_CONTROLLER_40022000_BASE_ADDRESS
#define DT_FLASH_DEV_NAME DT_ST_STM32L4_FLASH_CONTROLLER_40022000_LABEL
#define DT_FLASH_DEV_NAME DT_INST_0_ST_STM32L4_FLASH_CONTROLLER_LABEL

#if defined(DT_ST_STM32_USB_40006800_BASE_ADDRESS)
#define DT_USB_BASE_ADDRESS DT_ST_STM32_USB_40006800_BASE_ADDRESS
Expand Down
3 changes: 1 addition & 2 deletions soc/arm/st_stm32/stm32wb/dts_fixup.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@

#define DT_RTC_0_NAME DT_INST_0_ST_STM32_RTC_LABEL

#define DT_FLASH_DEV_BASE_ADDRESS DT_ST_STM32WB_FLASH_CONTROLLER_58004000_BASE_ADDRESS
#define DT_FLASH_DEV_NAME DT_ST_STM32WB_FLASH_CONTROLLER_58004000_LABEL
#define DT_FLASH_DEV_NAME DT_INST_0_ST_STM32WB_FLASH_CONTROLLER_LABEL

#define DT_I2C_1_BASE_ADDRESS DT_ST_STM32_I2C_V2_40005400_BASE_ADDRESS
#define DT_I2C_1_EVENT_IRQ_PRI DT_ST_STM32_I2C_V2_40005400_IRQ_EVENT_PRIORITY
Expand Down

0 comments on commit 22af564

Please sign in to comment.