Commit graph

63 commits

Author SHA1 Message Date
Francois Ramu
958087f49d drivers: flash: stm32 ospi driver size and address of the external NOR
New property of the st,stm32-ospi-nor compatible gives
the external NOR flash in bits.
The property of the st,stm32-ospi compatible gives
the external NOR flash base address

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2025-06-20 14:41:41 -05:00
Martin Gysel
812d33b7ab drivers: flash_stm32_qspi: fix conditional to assing jedec_id property
the jedec_id field is only available if CONFIG_FLASH_JESD216_API is set

Signed-off-by: Martin Gysel <me@bearsh.org>
2025-06-13 10:21:00 -07:00
Francois Ramu
4278e98210 drivers: flash: stm32 octospi supports the 4Bytes address mode
Add the 4Bytes program mode to the stm32_ospi driver
to enter 4-Byte Address Mode (SPI_NOR_CMD_4BA) when flash is supporting it.
This is given by the JESD216 SFDP table.
Based on the stm32 qspi driver.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2025-05-13 12:08:51 +02:00
Armin Brauns
bd98e0199b drivers: flash_stm32_qspi: fix DT accessor for flash size
The flash size is the second part (size) of the first reg value, not the
first part (address) of a nonexistent second reg value.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2025-03-19 20:25:37 +01:00
Georgij Cernysiov
9040dee5ef drivers: flash: stm32 ospi: early init exit for memmap mode
Exit the init earlier when OSPI is in memory map mode. Avoid
unnecessary checks and prevent pin reconfiguration that might
cause line spikes. Clock check beforehand is preserved.

Remove '\n' from the LOG_DBG string.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2025-01-10 21:07:51 +01:00
Pieter De Gendt
9dd07da0a1 drivers: flash: Place API into iterable section
Add wrapper DEVICE_API macro to all flash_driver_api instances.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-12-02 22:08:48 +00:00
Georgij Cernysiov
4ec67271ab drivers: flash: stm32 ospi correct lines on writes
Correct used lines based on write opcode
regardless of the data mode.

The write opcode is set during init for all
modes and can be overwritten in DT.

Add lines correction for PP_1_1_2.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2024-09-17 09:45:42 +02:00
Georgij Cernysiov
b8bf23b707 drivers: flash: stm32 ospi: remove not required setting of writeoc
Remove dead code. The write opcode instruction
is set based on dev_data a couple of lines after.

This was supposed to be in the merged "memory map
support for other modes" PR.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2024-08-16 08:49:51 -04:00
Georgij Cernysiov
5246c16109 drivers: flash: stm32 ospi correct memory map return code
Use ENOTSUP instead of EIO to signal about not
supported configuration.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2024-08-13 14:57:59 +02:00
Georgij Cernysiov
a1e39d0b64 drivers: flash: stm32 ospi reword memory map log output
Add more clarity to memory map log output.

Use LOG_DBG instead of LOG_INF to signal about
memory map mode being enabled.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2024-08-13 14:57:59 +02:00
Georgij Cernysiov
f4b63f9644 drivers: flash: stm32 ospi extend memory map modes support
Extend memory map support to QUAD, DUAL, SPI modes.

Allow custom write opcode usage and SFDP:BFP read opcode.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2024-08-13 14:57:59 +02:00
Joakim Andersson
04e56f72c7 drivers: flash: Fix stm32 ospi and xpsi reset gpios handling
Fix compilation error when reset-gpios is enabled.
Undefined reference to dev_cfg variable.
Reset gpio duration needs to be defined, but is not in binding file.

Signed-off-by: Joakim Andersson <joerchan@gmail.com>
2024-06-12 12:51:06 -04:00
Francois Ramu
7b73a343cb drivers: flash: stm32 ospi driver aborts memmap before erase/write
This change is aborting the memoryMapped mode of the octo-flash
before erasing or writing the NOR. Operations are performed in
command mode.
Reading is always performed in MemoryMapped mode (memcopy)

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2024-05-31 09:52:54 -05:00
Francois Ramu
7593a14a0a drivers: flash: stm32 ospi drivers with Memorymapped mode
Enable the MemoryMapped Mode for the stm32 octoFlash driver
Configure the Flash in MemoryMapped to use in XiP mode.
With this mode the erase and write are not supported.
Address and size are given by the DTS register property.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2024-05-31 09:52:54 -05:00
Samuel Kleiser
d796c117ce stm32: ospi: make all clk, dqs, ncs pins configurable
The clk, dqs and ncs pins can be remapped between OSPI instances, but the
driver doesn't support it, yet. Therefore replace hard coded numbers to
device tree optional properties.

Signed-off-by: Samuel Kleiser <s.kleiser@vega.com>
2024-05-14 09:32:57 +02:00
Francois Ramu
01684df03a drivers: flash: stm32 ospi flash driver the correct erase instruction
Use the most adapted instruction for the sector erase command
It can be 0x20 or ox21 or 0x21DE in octo - DTR mode.
The value is given by the SFDP table and  filled in the erase_types
 table the during the SFDP discovery process.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2024-04-10 08:00:53 -04:00
Miika Karanki
004c4769e3 drivers: flash: stm32 ospi refactor stm32_ospi_mem_erased args
Change to use dev pointer, from where the other parameters were
available as well.

Signed-off-by: Miika Karanki <miika.karanki@vaisala.com>
2024-03-08 09:39:07 +01:00
Miika Karanki
5d9acf52a5 drivers: flash: stm32 ospi: implement non busy wait polling
HAL_OSPI_AutoPolling is checking is the status match
happened in a busy loop. That CPU intensive operation
can cause starvation of other tasks especially on flash
erase operations which can take seconds to complete.

So, replace the use of HAL_OSPI_AutoPolling with
HAL_OSPI_AutoPolling_IT. The match results
HAL_OSPI_StatusMatchCallback being called.

Signed-off-by: Miika Karanki <miika.karanki@vaisala.com>
2024-03-08 09:39:07 +01:00
Brian Juel Folkmann
2580b5af77 stm32: flash: ospi: Make erase function less chatty
Change LOG_INF to LOG_DBG in flash erase command

Signed-off-by: Brian Juel Folkmann <bju@trackunit.com>
2024-02-27 18:43:32 +01:00
Brian Juel Folkmann
f9ac97e1c8 stm32: flash: ospi: Fix erase if flash is larger than 16MB
Opcodes for erase is taken from jedec basic flash parameter table
These expects 3 byte addresses.

When running with 4 byte addresses, opcodes to be used shall be taken
from JEDEC 4-byte Address Instruction Parameter table

Signed-off-by: Brian Juel Folkmann <bju@trackunit.com>
2024-02-27 18:43:32 +01:00
Francois Ramu
0bbd7bf977 drivers: flash: stm32 ospi drivers gets address and size from DTS
Address and size are given by the DTS register property
of the ospi nor : to be used by the ospi driver.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2024-02-02 13:48:18 +01:00
Francois Ramu
c18808950a drivers: flash: stm32 ospi flash driver erase large size
Erase operation with block of 64KByte
larger size than the default 4K sector size
if the flash supports.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2024-01-02 10:09:51 +01:00
Francois Ramu
a0db07888f drivers: flash: stm32 ospi driver active wait during init
Wait with k_busy_wait instead of k_sleep during the peripheral init.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2023-11-08 15:10:29 +00:00
Brian Juel Folkmann
8b6382e68d drivers: flash: stm32 ospi: jedec_id read wrongly
Manufacturer id is skipped when reading jedec_id, due to wrong
address mode.
Before: flash_stm32_ospi: Jedec ID = [60 20 00]
After:  flash_stm32_ospi: Jedec ID = [ef 60 20]

Signed-off-by: Brian Juel Folkmann <bju@trackunit.com>
2023-09-12 16:29:47 +02:00
Dominik Ermel
d647a85fb5 drivers/flash/stm32/Xspi: Fix llvm compilation error
Fix compilation error on variable used for size of array in
OSPI and QSPI drivers.

Fixes #61804

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-08-30 10:18:57 +02:00
Daniel Leung
efe27f577a flash: rename shadow variables
Renames shadow variables found by -Wshadow.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-10 08:14:12 +00:00
Georgij Cernysiov
f09e3abbcb drivers: flash: stm32 ospi: configure ospim io ports
Allows to configure OSPI Manager IO ports with devicetree.

If properties are absent, then original default values
are preserved for compatibility.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2023-06-21 16:06:00 +02:00
Georgij Cernysiov
0ea2e7c906 drivers: flash: stm32 ospi: move STM32 OSPI node
Move `STM32_OSPI_NODE` to the top.
That allows its usage in other macros that require
OSPI bus.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2023-06-21 16:06:00 +02:00
Georgij Cernysiov
6bb603f4ee drivers: flash: stm32 ospi add ssht property
Allows to enable Sample Shifting Half-Cycle.

It is recommended to be enabled for STR mode.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2023-05-11 07:36:11 -05:00
Francois Ramu
609bb002e6 drivers: flash: stm32 ospi flash driver waits for full chip erase
Add a function to wait for the full (bulk) Nor-octoflah erase command.
When erasing the full octo-flash, the drivers waits until
the operation is ready and the external NOR mem becomes ready itself.
The full (bulk) erase operation lasts for several seconds.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2023-05-10 16:50:22 +09:00
Cyril Fougeray
1be72d9888 dma: callback with 2 status codes for successful transfers
Make use of positive status values in the DMA callback to pass
info to the DMA client after a successful DMA operation.
A completed DMA transfer uses the status 0 while a reached
water mark uses the status 1.

Signed-off-by: Cyril Fougeray <cyril.fougeray@worldcoin.org>
2023-05-08 09:57:32 +02:00
Georgij Cernysiov
091f425cd1 drivers: flash: stm32 ospi: fix jedec id read
Flash not in OPI mode doesn't require extra
dummy cycles.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2023-05-05 11:26:21 +02:00
Brian Juel Folkmann
7abcfc4e4c drivers: flash: bug fix select correct erase address mode
SPI / QSPI flash with density above 16MB must use 4 byte addressing mode
also on sector erase.

This patch selects the right addressing mode and opcode when 4 byte
addressing mode is selected

Signed-off-by: Brian Juel Folkmann <bju@trackunit.com>
2023-05-02 09:37:29 -05:00
Georgij Cernysiov
57cf528418 drivers: flash: fix stm32 ospi prescaler
Original computation seems to be based on
QSPI that has prescaler range [0, 255].
However, OSPI clock prescaler has different
value range [1, 256].

Adapt prescaler computation to valid OSPI
domain and add min value assert.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2023-04-25 12:21:59 +02:00
Francois Ramu
89636416b5 drivers: flash: stm32 ospi driver defines the dlyb-bypassed property
The delayblock is bypassed when the <dlyb-bypass> property is true.
DT_NODE_HAS_PROP tests whether the property is defined at all,
not whether a boolean property is true or false.
To get a boolean property’s truth value,
use DT_PROP(node_id, prop) instead.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2023-04-19 17:13:07 +02:00
Georgij Cernysiov
44e4b077ad drivers: flash: stm32 ospi add dlyb bypass prop
Allows to bypass delay block (DLYB).

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2023-04-13 12:15:13 +02:00
Francois Ramu
10e296f3f1 drivers: flash: stm32 ospi driver for the stm32h5x
With the stm32h5x, hal driver is xspi for octospi
Add a header file to map functions and constants.
The ospi driver of the stm32H5x serie does not support DMA yet.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2023-04-07 08:33:51 +00:00
Brian Juel Folkmann
8d11d183f6 drivers: flash: bug fix stm32 ospi flash erase
This commit fixes a bug in the STM32 ospi flash driver when attempting
to erase an area that spans more than one erase sector.
Without this fix, only the first sector is actually erased, the rest
silently fails the erase.
Issue is that the write enable latch command is only sent for the first
erase command.

Signed-off-by: Brian Juel Folkmann <bju@trackunit.com>
2023-01-26 09:39:59 +00:00
Francois Ramu
4500dba078 drivers: flash: stm32 ospi driver correct device size
The find_lsb_set is giving the position of the first '1' found,
starting from 1. "Bits are numbered starting at 1
from the least significant bit."
So that the find_lsb_set(64MBytes) is 27.
To get 64MBytes = 2^26, the value of the Init.DeviceSize must be 26.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2023-01-11 09:39:47 +01:00
Francois Ramu
2cca8b54a3 drivers: flash: stm32 ospi driver prepare sfdp command
Change the stm32_ospi_read_sfdp to have AddressSize
prepared in one single condition.
Add more debug msg.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2023-01-11 09:39:47 +01:00
Francois Ramu
acd582e456 drivers: flash: stm32 ospi flash driver for stm32l4plus mcus
Adaptation of the ospi nor flash driver for stm32l4 plus
where the peripheral is slighty different.
Configure the OSPIM peripheral for mcu embeddingthis peripheral
in front their octospi instances.
Add LOG for read access command like for write access.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2022-11-29 09:32:22 +00:00
Francois Ramu
0da1323b95 drivers: flash: stm32 ospi can read the SFDP table from the DTS
When the SFDP table is provided by the DeviceTree with sfdp-bfp property
It is NOT read from the octoFlash.
If no table exists in the DTS and flash read SPDP fails,
the device init fails.
Availability of this sfdp_read API is conditional
on selecting CONFIG_FLASH_JESD216_API.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2022-11-22 14:26:57 +00:00
Francois Ramu
6143579c85 drivers: flash: stm32 ospi driver with read ID from octoflash
This commit adds the jedec216 read JEDEC ID function API.
The ospi commands are issued to the octo flash device or
by the DTS jedec-id property.
Availability of this API is conditional
on selecting CONFIG_FLASH_JESD216_API.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2022-11-22 14:26:57 +00:00
Francois Ramu
9fbe27bc32 drivers: flash: ospi for stm32 mcu
Fixes command configuration to have samples/drivers/spi_flash
passed on stm32l562 and stm32u585 disco kits.
In OctoSPI STR/DTR and SPI/STR modes,
to determine the address_width, checking the jesd216_bfp_addrbytes
on JESD216_SFDP_BFP_DW1_ADDRBYTES_VAL_3B4B or _VAL_4B.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2022-11-22 14:26:57 +00:00
Francois Ramu
e24c5256ba drivers: flash: stm32 octospi NOR flash with DMA on stm32u5x
This commit set the stm32 octospi drivers for the stm32u5x
when DMA (GPDMA) is transferring.
Valid for octospi1 or octospi2.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2022-11-22 12:00:00 +00:00
Guillaume Gautier
2604951989 drivers: flash: Use dts to configure STM32 OSPI manager clock
Instead of calling __HAL_RCC_OSPIM_CLK_ENABLE() to enable the OSPI
manager clock, we now use a new clock binding in the dts.

In order to avoid confusion between the different clocks, the driver
is modified to select the clock based on their names instead of indexes.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2022-11-10 11:28:18 +00:00
Gerard Marull-Paretas
178bdc4afc include: add missing zephyr/irq.h include
Change automated searching for files using "IRQ_CONNECT()" API not
including <zephyr/irq.h>.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-17 22:57:39 +09:00
Guillaume Gautier
aba432348b drivers: Cleans variable scopes for STM32 drivers
Fix the scope of some variables in various STM32 drivers including:
 - SDMMC
 - DMA
 - OSPI/QSPI Flash
 - Interrupt controller

The variables are set static instead of global and const if appropriate.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2022-10-12 18:41:48 +02:00
Francois Ramu
b6ee1dfe6e drivers: flash: octo spi for stm32 with DMA
Introducing the dma transfer (also through dmamux)
to transfer data to/from the NOR octo-flash
With a DMAMUX, the DMA channel is given by the DTS.
Note that STM32U5X does not support DMA here.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2022-09-08 10:07:21 +00:00
Erwan Gouriou
54302ac67d drivers: flash: stm32 ospi: Limit bytes read from DT SFDP table
In case SFDP table is provided via device tree, take care not reading
more than expected by the function caller as the result is written
in a structure which size is predefined by one specific byte in the
table, and could be smaller than the table size.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-09-05 10:17:21 +02:00