Skip to content

Commit 331423d

Browse files
FRASTMmmahadevan108
authored andcommitted
drivers: flash: stm32H7 flash driver enable clock when defined
Not all the stm32H7 have a clock enable for their flash; only the dual-core. For the st,stm32h7-flash-controller with "clocks" property, the driver will enable the flash clock bit in the corresponding RCC register. Signed-off-by: Francois Ramu <[email protected]>
1 parent 5c52991 commit 331423d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/flash/flash_stm32h7x.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,8 +702,10 @@ void flash_stm32_page_layout(const struct device *dev,
702702

703703
static struct flash_stm32_priv flash_data = {
704704
.regs = (FLASH_TypeDef *) DT_INST_REG_ADDR(0),
705+
#if DT_NODE_HAS_PROP(DT_INST(0, st_stm32h7_flash_controller), clocks)
705706
.pclken = { .bus = DT_INST_CLOCKS_CELL(0, bus),
706707
.enr = DT_INST_CLOCKS_CELL(0, bits)},
708+
#endif
707709
};
708710

709711
static const struct flash_driver_api flash_stm32h7_api = {
@@ -718,6 +720,8 @@ static const struct flash_driver_api flash_stm32h7_api = {
718720

719721
static int stm32h7_flash_init(const struct device *dev)
720722
{
723+
#if DT_NODE_HAS_PROP(DT_INST(0, st_stm32h7_flash_controller), clocks)
724+
/* Only stm32h7 dual core devices have the clocks property */
721725
struct flash_stm32_priv *p = FLASH_STM32_PRIV(dev);
722726
const struct device *const clk = DEVICE_DT_GET(STM32_CLOCK_CONTROL_NODE);
723727

@@ -726,12 +730,12 @@ static int stm32h7_flash_init(const struct device *dev)
726730
return -ENODEV;
727731
}
728732

729-
/* enable clock */
733+
/* enable clock : enable the RCC_AHB3ENR_FLASHEN bit */
730734
if (clock_control_on(clk, (clock_control_subsys_t)&p->pclken) != 0) {
731735
LOG_ERR("Failed to enable clock");
732736
return -EIO;
733737
}
734-
738+
#endif
735739
flash_stm32_sem_init(dev);
736740

737741
LOG_DBG("Flash initialized. BS: %zu",

0 commit comments

Comments
 (0)