Skip to content

Commit 8876458

Browse files
committed
drivers: flash: stm32 xspi flash driver skip init when executing in place
The flash_stm32_xspi driver should not initialize the xspi, if this one is being use to execute in Place : the init is skipped This mode is identified with the CONFIG_STM32_APP_IN_EXT_FLASH Checking the memory mapped mode bit is possible when the xspi peripheral clock is not off (stm32h5 has no clock_control_get_status API) Signed-off-by: Francois Ramu <[email protected]>
1 parent 012783f commit 8876458

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

drivers/flash/flash_stm32_xspi.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -966,16 +966,6 @@ static int stm32_xspi_set_memorymap(const struct device *dev)
966966
return 0;
967967
}
968968

969-
/* Function to return true if the octoflash is in MemoryMapped else false */
970-
static bool stm32_xspi_is_memorymap(const struct device *dev)
971-
{
972-
struct flash_stm32_xspi_data *dev_data = dev->data;
973-
974-
return ((READ_BIT(dev_data->hxspi.Instance->CR,
975-
XSPI_CR_FMODE) == XSPI_CR_FMODE) ?
976-
true : false);
977-
}
978-
979969
static int stm32_xspi_abort(const struct device *dev)
980970
{
981971
struct flash_stm32_xspi_data *dev_data = dev->data;
@@ -989,6 +979,17 @@ static int stm32_xspi_abort(const struct device *dev)
989979
}
990980
#endif /* CONFIG_STM32_MEMMAP */
991981

982+
983+
#if defined(CONFIG_STM32_MEMMAP) || defined(CONFIG_STM32_APP_IN_EXT_FLASH)
984+
/* Function to return true if the octoflash is in MemoryMapped else false */
985+
static bool stm32_xspi_is_memorymap(const struct device *dev)
986+
{
987+
struct flash_stm32_xspi_data *dev_data = dev->data;
988+
989+
return READ_BIT(dev_data->hxspi.Instance->CR, XSPI_CR_FMODE) == XSPI_CR_FMODE;
990+
}
991+
#endif
992+
992993
/*
993994
* Function to erase the flash : chip or sector with possible OCTO/SPI and STR/DTR
994995
* to erase the complete chip (using dedicated command) :
@@ -2047,7 +2048,7 @@ static int flash_stm32_xspi_init(const struct device *dev)
20472048
return -ENODEV;
20482049
}
20492050

2050-
#ifdef CONFIG_STM32_MEMMAP
2051+
#ifdef CONFIG_STM32_APP_IN_EXT_FLASH
20512052
/* If MemoryMapped then configure skip init
20522053
* Check clock status first as reading CR register without bus clock doesn't work on N6
20532054
* If clock is off, then MemoryMapped is off too and we do init
@@ -2056,13 +2057,13 @@ static int flash_stm32_xspi_init(const struct device *dev)
20562057
(clock_control_subsys_t) &dev_cfg->pclken)
20572058
== CLOCK_CONTROL_STATUS_ON) {
20582059
if (stm32_xspi_is_memorymap(dev)) {
2059-
LOG_ERR("NOR init'd in MemMapped mode");
2060+
LOG_DBG("NOR init'd in MemMapped mode");
20602061
/* Force HAL instance in correct state */
20612062
dev_data->hxspi.State = HAL_XSPI_STATE_BUSY_MEM_MAPPED;
20622063
return 0;
20632064
}
20642065
}
2065-
#endif /* CONFIG_STM32_MEMMAP */
2066+
#endif /* CONFIG_STM32_APP_IN_EXT_FLASH */
20662067

20672068
/* The SPI/DTR is not a valid config of data_mode/data_rate according to the DTS */
20682069
if ((dev_cfg->data_mode != XSPI_OCTO_MODE)

0 commit comments

Comments
 (0)