Commit graph

1299 commits

Author SHA1 Message Date
Riadh Ghaddab
a4f5d9fb31 drivers: flash: nrf_rram: add support for RRAM throttling
Some applications need to throttle RRAM writes to handle peak current
management.
Add CONFIG_NRF_RRAM_THROTTLING_DATA_BLOCK which defines the maximum
chunk length that can be written at once.
Add CONFIG_NRF_RRAM_THROTTLING_DELAY which configures the sleep delay in
microseconds after each write.

Signed-off-by: Riadh Ghaddab <riadh.ghaddab@nordicsemi.no>
2025-09-12 18:32:23 +02:00
Andre Heinemans
45abb7215c drivers: nxp: flash_mcux_flexspi: fix id check on octal spi
The jedec-id cannot be read after flash device is set to octal mode.
Fixed by moving the jedec-id comparison to
flash_flexspi_nor_check_jedec() which already reads the jedec-id when
flash device is still in single spi mode.

Signed-off-by: Andre Heinemans <andre.heinemans@nxp.com>
2025-09-12 18:30:44 +02:00
Andre Heinemans
7a2ba69a54 drivers: flash_mcux_flexspi_nor: take write-block-size from dts
Some devices supported by this driver do not have a write-block-size
of 1 such as the mt35xu01gbba. This value is assigned in the dts and can
be used instead.

Signed-off-by: Andre Heinemans <andre.heinemans@nxp.com>
2025-09-11 18:08:09 +01:00
Etienne Carriere
694eaf43b1 drivers: flash: restore stm32 xspi mutex on memory mapping
Fix stm32 XSPI driver to restore the bus command concurrent access
protection that was mistakenly removed on memory mapping operation
by commit e5620e07c9 ("drivers: flash: stm32 xspi flash read with
memcopy when executing").

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
2025-09-11 09:53:36 +02:00
Andrzej Głąbek
9223235a49 drivers: flash_mspi_nor: Fix XIP_DEV_CFG_MASK definition
This is a follow-up to commit cafa288197.

Bit masks should use the bitwise OR operator, not the logical one...

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2025-09-10 22:37:04 -04:00
Andrzej Głąbek
77f00f06bb drivers: flash_mspi_nor: Add support for DDR in mx25u family
When Octal IO mode is to be used with DDR in mx25u family chips,
bit 1 instead of 0 must be set in the Configuration Register 2 at
address 0.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2025-09-10 13:02:01 +02:00
Andrzej Głąbek
835d77389c drivers: flash_mspi_nor: Add support for "supply-gpios" property
Add support for supplying power to the flash chip by activation of
a GPIO specified through the "supply-gpios" property. Implementation
of gpio_reset() is also slightly modified so that it is consistent
with soft_reset() and the new power_supply() and so that all these
functions can use a common routine that performs a reset recovery
delay.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2025-09-10 13:02:01 +02:00
Andrzej Głąbek
c2b537fb6c drivers: flash_mspi_nor: Remove undesirable initial Quad disabling
Using a GPIO reset for a flash chip that has a dual function pin
(RESET# or SIO3) and is to be used in Quad mode is rather a bad idea
and so is clearing of the Quad Enable bit at every initialization
of the flash driver, since this bit is usually non-volatile, so such
operation means unnecessary wearing of the flash chip. Soft Reset
should be use instead in such case.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2025-09-10 13:02:01 +02:00
Andrzej Głąbek
ff13d4062f drivers: flash_mspi_nor: Add Soft Reset
Add implementation of the most common Soft Reset routine (sequence of
reset enable instruction 0x66 and reset instruction 0x99).

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2025-09-10 13:02:01 +02:00
Andrzej Głąbek
2fcb2158ae drivers: flash_mspi_nor: Complete handling of QER, add handling of OER
Complete implementation of quad_enable_set() by adding support for all
possible Quad Enable Requirements (QER) as specified by the SFDP JEDEC
standard (JESD216). Add also corresponding octal_enable_set() to handle
Octal Enable Requirements.

Also remove initial waiting from mxicy_mx25r_post_switch_mode() which
became unneeded, as now such waiting is done in cmd_wrsr() which is
called at the end of quad_enable_set().

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2025-09-10 13:02:01 +02:00
Andrzej Głąbek
cafa288197 drivers: flash_mspi_nor: Refactor handling of commands
- Use standard operation codes and parameters from SFDP for handling
  the used flash commands (allow to override some of them through dts
  with the `read-command`, `write-command`, and `rx-dummy` properties)
- Use all available erase types as specified by SFDP
- Allow using all IO modes
- Add support for switching to 4-byte addressing mode
- Use common functions for reading and writing of status registers
  and for enabling write operations
- Switch IO mode (between the target one and Single IO) in a common
  function that performs transfers and do it only when required for
  a given command
- Make checking of JEDEC ID at initialization optional

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2025-09-10 13:02:01 +02:00
Andrzej Głąbek
29bc5bf12c drivers: flash_mspi_nor: Get info from dts SFDP arrays
Get parameters for used flash commands and requirements for enabling
Quad and Octal modes from dts uint8-arrays containing data read from
SFDP tables for particular flash chips.
Also introduce `pre_init` quirk that allows alteration of the above
parameters or complementation of them in a specific way for particular
flash chip families.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2025-09-10 13:02:01 +02:00
Jordan Yates
455d948ed6 flash: nrf_qspi_nor: active dwell time
Asynchronously release the device after a small delay to minimise power
state transitions under multiple sequential API calls (e.g. NVS).

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-09-09 20:41:31 -04:00
Utsav Munendra
19988acd90 drivers: flash_mspi: Implement flash API get_size
Implement the Zephyr Flash Driver API for completeness.

Signed-off-by: Utsav Munendra <utsavm@meta.com>
2025-09-08 09:50:20 +02:00
Taras Zaporozhets
993b642f2e drivers: flash: sam0: Fix incorrect page write size
According to the datasheet, one page is made of 64 bytes
and one row is made of 4 pages, that is 256 bytes.
This MR fixes the incorrect page write size for sam0
and sets it to 64 bytes.

Signed-off-by: Taras Zaporozhets <zaporozhets.taras@gmail.com>
2025-09-06 10:35:25 +02:00
Tri Nguyen
1e25973c75 drivers: flash: Initial support QSPI Flash driver for Renesas RA6
Add QSPI Flash driver supports for Renesas RA6.

Signed-off-by: Tri Nguyen <tri.nguyen.wj@bp.renesas.com>
Signed-off-by: Thao Luong <thao.luong.uw@renesas.com>
Signed-off-by: Khoa Nguyen <khoa.nguyen.xh@renesas.com>
2025-09-05 12:26:44 +02:00
Diego Herranz
f1e72c4a75 drivers: flash: shell: fix KiB symbol spelling
It's Bytes rather than bits, and it's also Kibi (1024).

Signed-off-by: Diego Herranz <diegoherranz@diegoherranz.com>
2025-09-04 21:04:22 +02:00
Carles Cufi
267469b503 flash: spi_nor: Fix VLA error when building with clang
The following error is issued by clang when building with
SPI_NOR_SFDP_RUNTIME enabled:

error: fields must have a constant size:
'variable length array in structure' extension will never be supported
1379 | uint32_t dw[MIN(php->len_dw, 20)];

Instead, hardcode the array length to 20 32-bit words (it's instantiated
in the stack anyway).

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2025-09-03 21:21:27 +02:00
Erwan Gouriou
47de4d1d9e drivers: stm32: Make use of new GET_INSTANCE DMA macro
Use the new macro and factorize code when possible.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2025-09-03 11:03:31 +02:00
Erwan Gouriou
67d2281ffe drivers: stm32: Keep DMA stream offset handling internal to driver
In HAL based stm32 drivers, dma handling is done internally to HAL.
Though, in order to avoid a dma_config() call is done to ensure stream
will be set as busy in zephyr dma driver to avoid potential resource
sharing conflict.
This dma_config() call was done while taking into account
STM32_DMA_STREAM_OFFSET, which is wrong as it will prevent zephyr dma
driver to set the right stream as busy.
Fix this in impacted drivers.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2025-09-03 11:03:31 +02:00
Liam Ogletree
97752191f4 drivers: flash: Add support for Atmel AT25 SPI flash variant
The AT25XV021A variant is a flash variant of Atmel's AT25 family
that adds extra protections, requiring additional writes to the
device to program or erase data.

This commit adds a flash driver for AT25XV021A devices instead of
modifying (1) the existing AT45 SPI flash driver or (2) the
existing AT24/25 EEPROM driver because this variant poses
fundamental changes that affect all aspects of the driver.

Notably,
 - AT25XV021A includes a second status register, and the format
	and functions of the existing status register is
	changed from the existing drivers.
 - AT25XV021A requires executing page or chip erase commands
	before writing, making it incompatible with the
	existing AT24/25 EEPROM driver.
 - AT25XV021A adds a software protection layer that requires
	extra writes before executing program or erase commands.

Tested writing to and erasing from an AT25XV021A device. Tested
reading from an AT25XV021A device across page boundaries. Tested
chip erase function. Tested driver initialization from varying
initial hardware states.

Signed-off-by: Liam Ogletree <liam.ogletree@cirrus.com>
2025-09-02 21:40:07 +02:00
Erwan Gouriou
c7086c7e67 drivers: flash_stm32_xspi: Fix Dummy Cycles on MX66UM1G45G NOR at 200MHz
This commit is fixing configuration of mx66uw1g45g NOR when working
at 200MHz.
According to its specification, when running at 200MHz, this memory should
use a Number Dummy Cycles configuration of 20 (DC bits in CFGR2), which is
the device's default configuration.
Applying the 66MHz configuration as done today was preventing flash to run
at frequency higher than 100Mhz.

This commit doesn't solve the more generic problem of this driver which
is applying this 66MHz configuration universally, irrespective of the
frequency and the memory device, but fixes the configuration which was
reported broken today.

Providing a global change would require starting a clear split between XSPI
controller configuration an bus device configuration, which is what new
MSPI API intend to solve, so this will be tackled once this driver will be
available.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2025-09-02 15:54:56 +02:00
Francois Ramu
e5620e07c9 drivers: flash: stm32 xspi flash read with memcopy when executing
When the application is executed in external flash, the read operation
cannot be in indirect mode but with memcopy.
Note that writing or erasing the external flash being executed
is not possible during the execution.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2025-09-02 11:09:29 +02:00
Pieter De Gendt
8993a5ed10 drivers: flash: shell: Fix printing partitions without labels
Commit df0f74d491c851b3e7e970f898c5c2fc3aab5b80 added a shell command to be
able to print out the partitions. However the label property is optional.

Print both the name and label if available.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-09-01 23:27:28 +02:00
Marek Matej
8752465f41 drivers: flash: shell: add partition listing
Add command `flash partitions` to list all existing partitions.

Signed-off-by: Marek Matej <marek.matej@espressif.com>
2025-09-01 09:32:06 +02:00
Sylvio Alves
2802a9a6f3 drivers: flash: esp32: handle zero-length reads as no-op
Add a guard clause in flash_esp32_read() to return 0 when the
requested length is zero. This avoids unnecessary operations
and aligns with expected flash API behavior, where reading
zero bytes is treated as a no-op.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2025-08-27 05:15:19 +02:00
Erwan Gouriou
b49fa46d9d drivers: flash: stm32 o/xspi: Implement get_size()
This api was missing from these driver. Add it.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2025-08-25 17:50:11 +02:00
Erwan Gouriou
c74aaabaf6 drivers: flash: stm32 xspi: Flash has explicit erase
Select FLASH_HAS_EXPLICIT_ERASE for STM32 XSPI driver.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2025-08-25 17:50:11 +02:00
Anthony Williams
7293068571 drivers: flash: nrf_qspi_nor: Implement fix for NRF5340 Errata 159
Add a workaround for `NRF53_ERRATA_159_ENABLE_WORKAROUND`
instead of simply printing an error and failing the transaction.

Signed-off-by: Anthony Williams <anthony289478@gmail.com>
2025-08-22 12:36:27 +02:00
Rory Piper
ea1245eb92 drivers: flash_stm32h7: Fix REAL_FLASH_SIZE_KB size
For devices other than the stm32h745/747/755/757 that use
dual-core cortex-M4/cortex-M7, do not multiply flash
controller size by 2. Single-core stm32h7x devices define
their flash-controllers dtsi as a single area, not two banks.
Use the presence of the bank2-flash-size prop to determine if
this is a dual-core stm3h7x or not.

Signed-off-by: Rory Piper <rory.piper@signal-fire.com>
2025-08-21 20:11:19 +02:00
Thomas Altenbach
7436b9dd85 drivers: flash: flash_stm32_qspi: Add support for cs-high-time
This commit adds support for the new cs-high-time devicetree property.
The QUADSPI_DCR_CSHT is now configured according to the value indicated
in the devicetree, for both single and dual flash modes.

Signed-off-by: Thomas Altenbach <altenbach.thomas@gmail.com>
2025-08-21 15:46:12 +02:00
Thomas Altenbach
b147d78c2f drivers: flash: stm32_qspi: Use sample shift also in single flash mode
The QSPI 1/2 sample shift (SSHIFT) was only enabled in dual flash mode.
This feature is useful to guarantee that data is ready at the sampling
moment, even if the signals are a bit delayed due to PCB constraints.
Therefore, it should be enabled when possible (only supported in STR
mode).

Signed-off-by: Thomas Altenbach <altenbach.thomas@gmail.com>
2025-08-21 15:46:12 +02:00
Declan Snyder
b70e761d42 modules: hal_nxp: Remove HAS_MCUX_FLEXSPI/SEMC
Remove these legacy kconfig, not necessary.

The DT already has the bindings and nodes required to represent if there
is a FlexSPI and/or SEMC.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-08-15 10:10:32 +03:00
Quy Tran
56ec47c62d drivers: flash: Add flash driver support for RX with flash type 1
- Add support for flash driver on RX with flash type 1
- Add bindings for flash driver on RX

Signed-off-by: Quy Tran <quy.tran.pz@renesas.com>
2025-08-12 09:54:10 +03:00
Andrej Butok
bad99fff50 drivers: nxp: flash_mcux_flexspi: add jedec_id check
- Adds JEDEC-ID check to the flash_mcux_flexspi driver
  if it is defined in DTS.
- Avoids applying DTS settings to a different flash module.

Signed-off-by: Andrej Butok <andrey.butok@nxp.com>
2025-08-11 13:19:01 -05:00
Dawid Niedzwiecki
7ee39d1754 drivers: flash: add extended operations to Andes XIP driver
Add the extended operations to the Andes XIP flash driver.

The extended operations supports:
 - reading status registers of the flash chip
 - changing status registers of the flash chip
 - software lock of the status registers
 - modifying SPI read command used in memory-mapped mode

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2025-08-08 11:53:07 +03:00
Khoa Nguyen
8b768cec4a drivers: flash: Update modification of macro define for RA OSPI
Update modification of macro define for Renesas RA OSPI

Signed-off-by: Khoa Nguyen <khoa.nguyen.xh@renesas.com>
2025-08-08 11:52:13 +03:00
Tim Lin
ff293bb61a drivers/flash: it51xxx: Add the M1K flash driver
The flash M1K driver supports read (up to 1K), write (1K), and
erase (4K) operations, which can be accessed via DLM.
Accessible flash regions include internal e-Flash or external SPI
flash via FSCE# or FSCE1#.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2025-08-06 17:09:46 +03:00
Andrej Butok
e17918b2f8 drivers: flash_mcux_flexspi: nxp: add CONFIG_FLASH_PAGE_LAYOUT check
- Adds CONFIG_FLASH_PAGE_LAYOUT check to the flash_mcux_flexspi
  drivers.
- Saves some memory if FLASH_PAGE_LAYOUT is disabled.

Signed-off-by: Andrej Butok <andrey.butok@nxp.com>
2025-08-06 12:10:36 +03:00
Raymond Lei
33e1b869b9 drivers: nxp : flexspi: add GD nor flash support
Fix a bug in quad bit enablement.
Add LUT for Giga Device nor flash GD25Q256x.

Signed-off-by: Raymond Lei <raymond.lei@nxp.com>
2025-08-04 19:58:07 +01:00
Travis Lam
5274d66019 drivers: flash: nordic: nrf_mramc update
Remove cache invalidation after flash write,
cpu should automatically invalidate cache but
for HW erase invalidation needed due to erase
from different bus.

Signed-off-by: Travis Lam <travis.lam@nordicsemi.no>
2025-07-31 17:11:30 -04:00
Andrzej Głąbek
7efa5c87dd drivers: flash_mspi_nor: Make transfer timeout configurable
Although the value currently hard-coded in the driver (10 ms) is quite
high, it may turn out to be insufficient when there is a need to use
some very low SCK frequency, like 250 kHz.
Make the timeout value configurable per-instance, via devicetree.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2025-07-29 12:14:51 -04:00
Hanan Arshad
428eced7d0 drivers: flash: flash_rpi_pico: fix indentation and remove unused variables
Cleaned up the flash_rpi_pico driver to improve code readability and
compliance with Zephyr coding standards. Fixed inconsistent indentation
across the file and removed variables that were declared but not used.

A few improvements are credited to Manu3l0us.

Signed-off-by: Hanan Arshad <hananarshad619@gmail.com>
2025-07-27 20:11:20 -04:00
Hanan Arshad
5d36e85b99 drivers: flash: rpi_pico: add support for rp2350 flash controller
The Raspberry Pi Pico 2 uses a QMI flash controller, which differs from the
SSI controller used in the original Pico. Zephyr already has support for
the SSI controller, but lacked support for QMI.

This change adds the QMI flash controller implementation in the
flash_rpi_pico.c driver file. Additionally, the RP2350 SoC devicetree file
(rp2350.dtsi) has been updated to enable and describe the flash controller
for Pico 2.

Signed-off-by: Hanan Arshad <hananarshad619@gmail.com>
2025-07-27 20:11:20 -04:00
Travis Lam
6413185619 drivers: flash: nordic: fix nrf-mramc indentation
Fix soc_mramc_nrf_mram space indentation

Signed-off-by: Travis Lam <travis.lam@nordicsemi.no>
2025-07-24 17:02:20 +01:00
Tahsin Mutlugun
94a962e87e drivers: flash: max32: Wrap flash read to utilize ECC workaround
Use wrapper function for read operations to allow using the new HAL
function that handles ECC checks and erased page detection.

Signed-off-by: Tahsin Mutlugun <Tahsin.Mutlugun@analog.com>
2025-07-23 17:30:44 +01:00
Furkan Akkiz
0d1088875c drivers: flash: Add wrap version of flash write function
To fix MAX32690 flash problems, I created a wrap version of
MXC_FLC_Write(...) function which disables ICC before calling write
function and enables ICC after this function.

Signed-off-by: Furkan Akkiz <hasanfurkan.akkiz@analog.com>
2025-07-23 17:30:44 +01:00
Tahsin Mutlugun
41f2be9e5f drivers: flash: max32: Disable interrupts before accessing flash
Disable interrupts during flash operations to prevent unintended jumps.

Interrupts are now disabled before read, erase, and write operations to
avoid accidental jumps to other flash sections while working on a
specific section.

Signed-off-by: Tahsin Mutlugun <Tahsin.Mutlugun@analog.com>
2025-07-23 17:30:44 +01:00
Thomas Altenbach
513073b598 drivers: flash: stm32_qspi: Fix erase size for dual-flash
When dual-flash mode is enabled, any erase operation is executed on both
flash memories in parallel. This means from the flash driver's point of
view, the size of a given sector/block is twice the size of a
sector/block on a single flash memory.

For example, assuming 4-KiB sectors for each flash memory, if the flash
driver is asked to erase at address 0x0000, the erase size must be a
multiple of 8 KiB since each sector erase operation will cause a 4-KiB
sector to erased in each flash memory.

Before this commit, the doubled erase size was only considered in
'setup_pages_layout'. Now, the actual sizes of the erase operations are
properly set in the flash driver's data and are used everywhere in the
driver.

Signed-off-by: Thomas Altenbach <altenbach.thomas@gmail.com>
2025-07-23 09:32:22 +02:00
Thomas Altenbach
8c638f29fd drivers: flash: stm32_qspi: Fix page size for dual-flash
When dual-flash mode is enabled, even bytes are written to the first
flash memory and odd bytes to the second flash memory. This means, from
the flash driver's point of view, the size of a flash page is twice the
size of a single flash memory's page.

So if each flash memory has 256-byte pages, 512 bytes should be used as
page size by the flash driver. Using 256 bytes was working fine but is
suboptimal.

Signed-off-by: Thomas Altenbach <altenbach.thomas@gmail.com>
2025-07-23 09:32:22 +02:00