Skip to content

Commit 4eedc27

Browse files
FRASTMJarmouniA
authored andcommitted
drivers: flash: stm32 xspi drivers supporting the stm32h7r/s mcu
Add the support of the stm32h7rs serie to the drivers/flash/flash_stm32_xspi driver. The stm32h7rs has no delayblock Signed-off-by: Francois Ramu <[email protected]> Signed-off-by: Abderrahmane JARMOUNI <[email protected]>
1 parent f3bdd2b commit 4eedc27

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

drivers/flash/flash_stm32_xspi.c

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ LOG_MODULE_REGISTER(flash_stm32_xspi, CONFIG_FLASH_LOG_LEVEL);
5252
#include <stm32_ll_dma.h>
5353
#endif /* STM32_XSPI_USE_DMA */
5454

55+
#if defined(CONFIG_SOC_SERIES_STM32H7RSX)
56+
#include <stm32_ll_pwr.h>
57+
#include <stm32_ll_system.h>
58+
#endif /* CONFIG_SOC_SERIES_STM32H7RSX */
59+
5560
#include "flash_stm32_xspi.h"
5661

5762
static inline void xspi_lock_thread(const struct device *dev)
@@ -190,7 +195,9 @@ static XSPI_RegularCmdTypeDef xspi_prepare_cmd(const uint8_t transfer_mode,
190195
.DQSMode = (transfer_rate == XSPI_DTR_TRANSFER)
191196
? HAL_XSPI_DQS_ENABLE
192197
: HAL_XSPI_DQS_DISABLE,
198+
#ifdef XSPI_CCR_SIOO
193199
.SIOOMode = HAL_XSPI_SIOO_INST_EVERY_CMD,
200+
#endif /* XSPI_CCR_SIOO */
194201
};
195202

196203
switch (transfer_mode) {
@@ -773,7 +780,9 @@ static int stm32_xspi_mem_reset(const struct device *dev)
773780
.DataLength = HAL_XSPI_DATA_NONE,
774781
.DummyCycles = 0U,
775782
.DQSMode = HAL_XSPI_DQS_DISABLE,
783+
#ifdef XSPI_CCR_SIOO
776784
.SIOOMode = HAL_XSPI_SIOO_INST_EVERY_CMD,
785+
#endif /* XSPI_CCR_SIOO */
777786
};
778787

779788
/* Reset enable in SPI mode and STR transfer mode */
@@ -1021,7 +1030,9 @@ static int flash_stm32_xspi_erase(const struct device *dev, off_t addr,
10211030
.DataMode = HAL_XSPI_DATA_NONE,
10221031
.DummyCycles = 0U,
10231032
.DQSMode = HAL_XSPI_DQS_DISABLE,
1033+
#ifdef XSPI_CCR_SIOO
10241034
.SIOOMode = HAL_XSPI_SIOO_INST_EVERY_CMD,
1035+
#endif /* XSPI_CCR_SIOO */
10251036
};
10261037

10271038
if (stm32_xspi_mem_ready(dev,
@@ -2042,6 +2053,12 @@ static int flash_stm32_xspi_init(const struct device *dev)
20422053
return -ENOTSUP;
20432054
}
20442055

2056+
#if defined(CONFIG_SOC_SERIES_STM32H7RSX)
2057+
LL_PWR_EnableXSPIM2();
2058+
__HAL_RCC_SBS_CLK_ENABLE();
2059+
LL_SBS_EnableXSPI2SpeedOptim();
2060+
#endif /* CONFIG_SOC_SERIES_STM32H7RSX */
2061+
20452062
/* Signals configuration */
20462063
ret = pinctrl_apply_state(dev_cfg->pcfg, PINCTRL_STATE_DEFAULT);
20472064
if (ret < 0) {
@@ -2118,15 +2135,17 @@ static int flash_stm32_xspi_init(const struct device *dev)
21182135
if (dev_cfg->data_rate == XSPI_DTR_TRANSFER) {
21192136
dev_data->hxspi.Init.MemoryType = HAL_XSPI_MEMTYPE_MACRONIX;
21202137
dev_data->hxspi.Init.DelayHoldQuarterCycle = HAL_XSPI_DHQC_ENABLE;
2121-
} else {
2122-
21232138
}
21242139
#if STM32_XSPI_DLYB_BYPASSED
21252140
dev_data->hxspi.Init.DelayBlockBypass = HAL_XSPI_DELAY_BLOCK_BYPASS;
2126-
#else
2141+
#elif !defined(CONFIG_SOC_SERIES_STM32H7RSX)
21272142
dev_data->hxspi.Init.DelayBlockBypass = HAL_XSPI_DELAY_BLOCK_ON;
21282143
#endif /* STM32_XSPI_DLYB_BYPASSED */
21292144

2145+
#if defined(CONFIG_SOC_SERIES_STM32H7RSX)
2146+
dev_data->hxspi.Init.MaxTran = 0;
2147+
dev_data->hxspi.Init.MemorySelect = HAL_XSPI_CSSEL_NCS1;
2148+
#endif /* CONFIG_SOC_SERIES_STM32H7RSX */
21302149

21312150
if (HAL_XSPI_Init(&dev_data->hxspi) != HAL_OK) {
21322151
LOG_ERR("XSPI Init failed");
@@ -2135,7 +2154,8 @@ static int flash_stm32_xspi_init(const struct device *dev)
21352154

21362155
LOG_DBG("XSPI Init'd");
21372156

2138-
#if defined(HAL_XSPIM_IOPORT_1) || defined(HAL_XSPIM_IOPORT_2)
2157+
#if defined(HAL_XSPIM_IOPORT_1) || defined(HAL_XSPIM_IOPORT_2) \
2158+
|| defined(XSPIM) || defined(XSPIM1) || defined(XSPIM2)
21392159
/* XSPI I/O manager init Function */
21402160
XSPIM_CfgTypeDef xspi_mgr_cfg;
21412161

@@ -2155,7 +2175,9 @@ static int flash_stm32_xspi_init(const struct device *dev)
21552175

21562176
#endif /* XSPIM */
21572177

2158-
#if defined(DLYB_XSPI1) || defined(DLYB_XSPI2) || defined(DLYB_OCTOSPI1) || defined(DLYB_OCTOSPI2)
2178+
#if !defined (CONFIG_SOC_SERIES_STM32H7RSX) && \
2179+
(defined(DLYB_XSPI1) || defined(DLYB_XSPI2) || defined(DLYB_OCTOSPI1) \
2180+
|| defined(DLYB_OCTOSPI2))
21592181
/* XSPI delay block init Function */
21602182
HAL_XSPI_DLYB_CfgTypeDef xspi_delay_block_cfg = {0};
21612183

@@ -2169,7 +2191,7 @@ static int flash_stm32_xspi_init(const struct device *dev)
21692191
}
21702192

21712193
LOG_DBG("Delay Block Init");
2172-
#endif /* DLYB_ */
2194+
#endif /* !CONFIG_SOC_SERIES_STM32H7RSX && DLYB_ */
21732195

21742196
#if STM32_XSPI_USE_DMA
21752197
/* Configure and enable the DMA channels after XSPI config */

0 commit comments

Comments
 (0)