Skip to content

Commit 8b0fd92

Browse files
committed
drivers: memc: add driver for stm32 ospi psram
Add a driver for STM32 OSPI PSRAM in memory mapped mode Signed-off-by: Mario Paja <mariopaja@hotmail.com>
1 parent fdd02c5 commit 8b0fd92

File tree

7 files changed

+608
-0
lines changed

7 files changed

+608
-0
lines changed

boards/st/b_u585i_iot02a/b_u585i_iot02a-common.dtsi

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
22
* Copyright (c) 2021 Linaro Limited
33
* Copyright (c) 2024 STMicroelectronics
4+
* Copyright (c) 2025 ZAL Zentrum für Angewandte Luftfahrtforschung GmbH
45
*
56
* SPDX-License-Identifier: Apache-2.0
67
*/
@@ -9,6 +10,7 @@
910
#include <st/u5/stm32u585aiixq-pinctrl.dtsi>
1011
#include "arduino_r3_connector.dtsi"
1112
#include <zephyr/dt-bindings/input/input-event-codes.h>
13+
#include <zephyr/dt-bindings/memory-attr/memory-attr-arm.h>
1214

1315
/ {
1416
leds {
@@ -43,6 +45,13 @@
4345
volt-sensor1 = &vbat4;
4446
eeprom-0 = &eeprom0;
4547
};
48+
49+
psram: memory@90000000 {
50+
compatible = "zephyr,memory-region";
51+
reg = <0x90000000 DT_SIZE_M(8)>;
52+
zephyr,memory-region = "PSRAM";
53+
zephyr,memory-attr = <(DT_MEM_ARM(ATTR_MPU_RAM))>;
54+
};
4655
};
4756

4857
&clk_hsi48 {
@@ -126,6 +135,26 @@ stm32_lp_tick_source: &lptim1 {
126135
};
127136
};
128137

138+
&octospi1 {
139+
pinctrl-0 = <&octospim_p1_clk_pb10 &octospim_p1_ncs_pb11
140+
&octospim_p1_io0_pf8 &octospim_p1_io1_pf9
141+
&octospim_p1_io2_pf7 &octospim_p1_io3_pf6
142+
&octospim_p1_io4_ph2 &octospim_p1_io5_pi0
143+
&octospim_p1_io6_pc3 &octospim_p1_io7_pd7
144+
&octospim_p1_dqs_pe3>;
145+
pinctrl-names = "default";
146+
status = "okay";
147+
148+
memc: aps6408l: memory@0 {
149+
compatible = "st,stm32-ospi-psram-aps6408l";
150+
reg = <0>;
151+
size = <DT_SIZE_M(64)>; /* 64 Mbits */
152+
max-frequency = <DT_FREQ_M(133)>;
153+
memory-type = "apmemory";
154+
status = "okay";
155+
};
156+
};
157+
129158
&octospi2 {
130159
pinctrl-0 = <&octospim_p2_clk_pf4 &octospim_p2_ncs_pi5
131160
&octospim_p2_io0_pf0 &octospim_p2_io1_pf1

drivers/memc/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ zephyr_linker_sources_ifdef(CONFIG_MEMC_STM32_SDRAM SECTIONS memc_stm32_sdra
3030

3131
zephyr_library_sources_ifdef(CONFIG_MEMC_STM32_XSPI_PSRAM memc_stm32_xspi_psram.c)
3232
zephyr_linker_sources_ifdef(CONFIG_MEMC_STM32_XSPI_PSRAM SECTIONS memc_stm32_xspi_psram.ld)
33+
zephyr_library_sources_ifdef(CONFIG_MEMC_STM32_OSPI_PSRAM_APS6408L memc_stm32_ospi_psram_aps6408l.c)
34+
zephyr_linker_sources_ifdef(CONFIG_MEMC_STM32_OSPI_PSRAM_APS6408L SECTIONS memc_stm32_ospi_psram.ld)

drivers/memc/Kconfig.stm32

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright (c) 2020 Teslabs Engineering S.L.
2+
# Copyright (c) 2025 ZAL Zentrum für Angewandte Luftfahrtforschung GmbH
23
# SPDX-License-Identifier: Apache-2.0
34

45
config MEMC_STM32
@@ -40,3 +41,19 @@ config MEMC_STM32_XSPI_PSRAM
4041
select PINCTRL
4142
help
4243
Enable STM32 XSPI Memory Controller.
44+
45+
config MEMC_STM32_OSPI_PSRAM
46+
bool "STM32 OSPI PSRAM"
47+
select USE_STM32_HAL_OSPI
48+
select USE_STM32_LL_DLYB
49+
select USE_STM32_HAL_DMA_EX
50+
select USE_STM32_HAL_DMA
51+
select PINCTRL
52+
help
53+
Enable STM32 OSPI PSRAM Controller.
54+
55+
config MEMC_STM32_OSPI_PSRAM_APS6408L
56+
bool "STM32 OSPI APS6408L PSRAM driver"
57+
default y
58+
depends on DT_HAS_ST_STM32_OSPI_PSRAM_APS6408L_ENABLED
59+
select MEMC_STM32_OSPI_PSRAM
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (c) 2025 STMicroelectronics
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
#if DT_NODE_HAS_STATUS(DT_NODELABEL(psram), okay)
7+
GROUP_START(PSRAM)
8+
9+
SECTION_PROLOGUE(_STM32_PSRAM_SECTION_NAME, (NOLOAD),)
10+
{
11+
*(.stm32_psram)
12+
*(".stm32_psram.*")
13+
} GROUP_LINK_IN(PSRAM)
14+
15+
GROUP_END(PSRAM)
16+
#endif

0 commit comments

Comments
 (0)