@@ -743,6 +743,13 @@ static int stm32_xspi_config_mem(const struct device *dev)
743
743
return - EIO ;
744
744
}
745
745
746
+ if (stm32_xspi_read_cfg2reg (& dev_data -> hxspi ,
747
+ XSPI_OCTO_MODE , XSPI_DTR_TRANSFER , reg ) != 0 ) {
748
+ /* Check the configuration has been correctly done on SPI_NOR_REG2_ADDR1 */
749
+ LOG_ERR ("XSPI flash config read failed" );
750
+ return - EIO ;
751
+ }
752
+
746
753
LOG_INF ("XSPI flash config is OCTO / DTR" );
747
754
}
748
755
@@ -846,7 +853,7 @@ static int stm32_xspi_set_memorymap(const struct device *dev)
846
853
const struct flash_stm32_xspi_config * dev_cfg = dev -> config ;
847
854
struct flash_stm32_xspi_data * dev_data = dev -> data ;
848
855
XSPI_RegularCmdTypeDef s_command = {0 }; /* Non-zero values disturb the command */
849
- XSPI_MemoryMappedTypeDef s_MemMappedCfg ;
856
+ XSPI_MemoryMappedTypeDef s_MemMappedCfg = { 0 } ;
850
857
851
858
/* Configure octoflash in MemoryMapped mode */
852
859
if ((dev_cfg -> data_mode == XSPI_SPI_MODE ) &&
@@ -939,6 +946,13 @@ static int stm32_xspi_set_memorymap(const struct device *dev)
939
946
/* Enable the memory-mapping */
940
947
s_MemMappedCfg .TimeOutActivation = HAL_XSPI_TIMEOUT_COUNTER_DISABLE ;
941
948
949
+ #ifdef XSPI_CR_NOPREF
950
+ s_MemMappedCfg .NoPrefetchData = HAL_XSPI_AUTOMATIC_PREFETCH_ENABLE ;
951
+ #ifdef XSPI_CR_NOPREF_AXI
952
+ s_MemMappedCfg .NoPrefetchAXI = HAL_XSPI_AXI_PREFETCH_DISABLE ;
953
+ #endif /* XSPI_CR_NOPREF_AXI */
954
+ #endif /* XSPI_CR_NOPREF */
955
+
942
956
ret = HAL_XSPI_MemoryMapped (& dev_data -> hxspi , & s_MemMappedCfg );
943
957
if (ret != HAL_OK ) {
944
958
LOG_ERR ("%d: Failed to enable memory mapped" , ret );
@@ -2031,12 +2045,19 @@ static int flash_stm32_xspi_init(const struct device *dev)
2031
2045
}
2032
2046
2033
2047
#ifdef CONFIG_STM32_MEMMAP
2034
- /* If MemoryMapped then configure skip init */
2035
- if (stm32_xspi_is_memorymap (dev )) {
2036
- LOG_DBG ("NOR init'd in MemMapped mode" );
2037
- /* Force HAL instance in correct state */
2038
- dev_data -> hxspi .State = HAL_XSPI_STATE_BUSY_MEM_MAPPED ;
2039
- return 0 ;
2048
+ /* If MemoryMapped then configure skip init
2049
+ * Check clock status first as reading CR register without bus clock doesn't work on N6
2050
+ * If clock is off, then MemoryMapped is off too and we do init
2051
+ */
2052
+ if (clock_control_get_status (DEVICE_DT_GET (STM32_CLOCK_CONTROL_NODE ),
2053
+ (clock_control_subsys_t ) & dev_cfg -> pclken [0 ])
2054
+ == CLOCK_CONTROL_STATUS_ON ) {
2055
+ if (stm32_xspi_is_memorymap (dev )) {
2056
+ LOG_ERR ("NOR init'd in MemMapped mode" );
2057
+ /* Force HAL instance in correct state */
2058
+ dev_data -> hxspi .State = HAL_XSPI_STATE_BUSY_MEM_MAPPED ;
2059
+ return 0 ;
2060
+ }
2040
2061
}
2041
2062
#endif /* CONFIG_STM32_MEMMAP */
2042
2063
0 commit comments