Skip to content

Commit 4a09c29

Browse files
committed
drivers/flash: stm32: Add qspi-nor flash-controller
Add support for DMA based STM32 QSPI NOR flash controller. Driver configures both NOR flash and also QSPI hardware block. Reuses existing jesd216 library. QSPI hardware block handling is done through the use of Cube HAL API. This requires the use of HAL interface also for DMA besides zephyr DMA driver. Zephyr DMA driver is used only for IRQ routing while HAL driver handles the IP block. To achieve this it is required to: -Configure both Cube and Zephyr drivers at init. -Inform Zephyr driver that current channel handling will be done by another instance and only a limited configuration should be done. For this last part, a unused parameter is overridden in order to transmit the information. Signed-off-by: Erwan Gouriou <[email protected]> Signed-off-by: Piotr Mienkowski <[email protected]>
1 parent d64b51b commit 4a09c29

File tree

6 files changed

+964
-0
lines changed

6 files changed

+964
-0
lines changed

drivers/dma/dma_stm32.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,18 @@ DMA_STM32_EXPORT_API int dma_stm32_configure(const struct device *dev,
252252
/* give channel from index 0 */
253253
id = id - STREAM_OFFSET;
254254

255+
/* Check potential DMA override */
256+
if (config->linked_channel == 0x7F) {
257+
/* DMA channel is overridden by HAL DMA
258+
* Retain that the channel is busy and proceed to the minimal
259+
* configuration to properly route the IRQ
260+
*/
261+
stream->busy = true;
262+
stream->dma_callback = config->dma_callback;
263+
stream->user_data = config->user_data;
264+
return 0;
265+
}
266+
255267
if (id >= dev_config->max_streams) {
256268
LOG_ERR("cannot configure the dma stream %d.", id);
257269
return -EINVAL;

drivers/flash/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ zephyr_library_sources_ifdef(CONFIG_SOC_FLASH_SAM flash_sam.c)
1616
zephyr_library_sources_ifdef(CONFIG_SOC_FLASH_NIOS2_QSPI soc_flash_nios2_qspi.c)
1717
zephyr_library_sources_ifdef(CONFIG_SOC_FLASH_GECKO flash_gecko.c)
1818
zephyr_library_sources_ifdef(CONFIG_SOC_FLASH_RV32M1 soc_flash_rv32m1.c)
19+
zephyr_library_sources_ifdef(CONFIG_FLASH_STM32_QSPI flash_stm32_qspi.c)
1920

2021
if(CONFIG_SOC_FLASH_STM32)
2122
if(CONFIG_SOC_SERIES_STM32H7X)

drivers/flash/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ source "drivers/flash/Kconfig.nor"
7272

7373
source "drivers/flash/Kconfig.stm32"
7474

75+
source "drivers/flash/Kconfig.stm32_qspi"
76+
7577
source "drivers/flash/Kconfig.sam0"
7678

7779
source "drivers/flash/Kconfig.sam"

drivers/flash/Kconfig.stm32_qspi

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# STM32 Quad SPI flash driver configuration options
2+
3+
# Copyright (c) 2020 Piotr Mienkowski
4+
# Copyright (c) 2020 Linaro Limited
5+
# SPDX-License-Identifier: Apache-2.0
6+
7+
DT_COMPAT_ST_STM32_QSPI_NOR := st,stm32-qspi-nor
8+
9+
config FLASH_STM32_QSPI
10+
bool "STM32 Quad SPI Flash driver"
11+
depends on SOC_FAMILY_STM32
12+
default $(dt_compat_enabled,$(DT_COMPAT_ST_STM32_QSPI_NOR))
13+
select USE_STM32_HAL_QSPI
14+
select USE_STM32_HAL_DMA
15+
select DMA
16+
select FLASH_HAS_DRIVER_ENABLED
17+
select FLASH_JESD216
18+
select FLASH_PAGE_LAYOUT
19+
select FLASH_HAS_PAGE_LAYOUT
20+
help
21+
Enable QSPI-NOR support on the STM32 family of processors.

0 commit comments

Comments
 (0)