Commit Graph

1080 Commits

Author SHA1 Message Date
Declan Snyder 3c5df36dda soc: nxp: Move flexspi log level change to driver
Single point of control over this kconfig's effect.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2024-08-22 09:14:24 +02:00
Declan Snyder 57d777b640 drivers: flash/memc: Source logging kconfig last
Some flash/memc drivers like flexspi will want to default the
value of the log level to off to avoid RWW hazard while XIP,
to do this, the logging template must be sourced after the driver
kconfig files so that the default value from the driver is able
to be checked, since logging template introduces an unconditional
default otherwise.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2024-08-22 09:14:24 +02:00
Francois Ramu 103f3b04f3 drivers: flash: stm32 qspi driver sends the reset cmd
Use the define to send the reset cmd at quad-flash init :
SPI_NOR_CMD_RESET_EN followed by SPI_NOR_CMD_RESET_MEM
when the st,stm32-qspi-nor has the <reset-cmd> property set.
Reports the jedecID correctly.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2024-08-20 14:52:14 -04:00
Pisit Sawangvonganan 1bcae0ea9f style: drivers: comply with MISRA C:2012 Rule 15.6
Add missing braces to comply with MISRA C:2012 Rule 15.6 and
also following Zephyr's style guideline.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-08-20 10:33:51 +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
Alberto Escolar Piedras 0e8eeb37fd drivers/flash/flash_simulator: Remove reference to native_posix
Remove references to native_posix as the it is being deprecated.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-08-16 09:20:58 +01:00
Murali Karicheri 7baf026adf drivers: flash: stm32h7: ignore STRBERR during flash write
When application code runs from M4 (resides on lower 896KiB of
the internal flash of bank2) and it does write to a block in
the upper 128KiB, write fails sometime (for example failed
1 out of 10 block write based on the tests) due to STRBERR.
As per technical reference manual section 4.7.4 of
STM32H745/755 SoC, application may ignore this error and
continue with write. So check for the flag and return okay
status for write(). Based on our tests, the application write
succeeds even when this error happens and match with document
description. So igoring this error flag is okay during write.

Signed-off-by: Murali Karicheri <murali.karicheri@sandc.com>
2024-08-13 18:19:41 -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
Richard Wheatley 188fc58c72 drivers: update AMBIQ drivers to use proper base address
REG_X_BASEADDR will be removed from all hal files.
This forces the use of the peripheral base address
Define MSPI_PORT macro for chip drivers

Signed-off-by: Richard Wheatley <richard.wheatley@ambiq.com>
2024-08-11 19:18:09 -05:00
Benedikt Schmidt f8399bd773 drivers: flash: implement RDP for STM32F7
Implement the readout protection for the STM32F7 series.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2024-08-07 19:02:49 -04:00
Benedikt Schmidt db2261b6f5 drivers: flash: reduce redundancy in RDP implementation on STM32
Reduce the redundancy in the readout protection implementation
on STM32 MCUs.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2024-08-07 19:02:49 -04:00
Arkadiusz Balys 2de6274119 drivers: flash: Do not select NRFX_RRAMC while building with TF-M
RRAMC peripheral is a secure-only peripheral, and the application
cannot use it directly. While building an application with TF-M
enabled and SOC_FLASH_NRF_RRAM the NRFX_RRAMC selection must
be forbidden.

Signed-off-by: Arkadiusz Balys <arkadiusz.balys@nordicsemi.no>
2024-08-06 15:42:44 +01:00
Erwan Gouriou ab850deb64 drivers: flash: stm32h7: Fix unused variable warning
This variable is only used under DUAL_BANK condition and a warning
is generated in !DUAL_BANK case, so move its definition accordingly.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2024-08-01 09:15:48 +01:00
Francois Ramu 87af1984f5 drivers: flash: stm32 qspi flash size in dual flash mode
When  QSPI configuration is the dual-flash, the total
flash size and erase size are doubled. This is handled
with a STM32_QSPI_DOUBLE_FLASH factor which doubles
the values of one qspi component.
Note that SFDP table is for ONE flash component.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2024-08-01 09:11:30 +01:00
Murali Karicheri d2d0289750 drivers: flash : stm32h7: Fix the offset for get_sector()
The offset is wrong when the second bank is used by M4 as the
offset is relative to the base which is 0. So add the least
significant 6 nibbles from the CONFIG_FLASH_BASE_ADDRESS to
find the sector.

Signed-off-by: Murali Karicheri <murali.karicheri@sandc.com>
2024-07-30 18:26:20 +01:00
Murali Karicheri 188fe4d5d1 drivers: flash: stm32h7: support flash controller driver on M4
Currently flash controller driver builds and runs only on M7.
This patch supports enablement of the driver on M4 CPUs. The
main issue in using the driver on M4 is that LL_GetFlashSize()
to read the flash size works only on M7 as the internal register
is not accessible from M4. So to use the driver on M4, add a dt
property, bank2-flash-size, to configure flash size of bank2.
this will allow gradual support of flash controller driver
on M4 of all supported STMH7 boards by defining the above
dt property and testing it. Currently this is verified only
on STM32H747i-disco board.

Signed-off-by: Murali Karicheri <murali.karicheri@sandc.com>
2024-07-30 18:26:20 +01:00
Sreeram Tatapudi eebc998a5a drivers: flash: Support for IFX QSPI Flash driver
Initial version

Signed-off-by: Sreeram Tatapudi <sreeram.praveen@infineon.com>
2024-07-29 14:14:10 +02:00
Stefan Petersen 840e93fd60 drivers: flash: spi_nor: Print flash size properly when < 1 MiByte
When using SPI-NOR SFDP autodeteection, the flash size printed to
the log is rounded to 1 MiByte. If flash is smaller than 1 MiByte
it is printed as 0 MiByte.

With this patch smaller flash sizes are printed in kiByte, for instance
512 kiByte is printed correctly.

Signed-off-by: Stefan Petersen <spe@ciellt.se>
2024-07-27 20:47:39 +03:00
Jordan Yates 7b18cc112c flash: nrf_qspi_nor: don't auto call `pm_device_runtime_enable`
Device drivers should not be calling `pm_device_runtime_enable` on
themselves, it should be left up to the application. If automatic
enablement is desired, `zephyr,pm-device-runtime-auto` exists as a
devicetree property.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-07-27 15:16:23 +03:00
Jordan Yates 0b935295c6 flash: nrf_qspi_nor: remove `PM_DEVICE_RUNTIME` guards
The `pm_device_runtime_get` and `pm_device_runtime_put` functions work
correctly regardless of whether `PM_DEVICE_RUNTIME` is enabled or not.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-07-27 15:16:23 +03:00
Jordan Yates db87eface2 flash: nrf_qspi_nor: remove excessive semaphore
The `count` semaphore was being used as an atomic counter, so replace
it with an atomic variable, which is a simpler solution and enables
removing the conditionals with `PM_DEVICE_RUNTIME`.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-07-27 15:16:23 +03:00
Fin Maaß ba5b4ae817 drivers: flash: spi_nor: doc: correct comment
the durations in the spi_nor_config struct
are in milliseconds not in microseconds.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-07-27 10:48:33 +03:00
Ben Marsh 74c871dce2 build: Prefix missed generated syscall includes
PR #63973 namespaced generated headers with zephyr/, including generated
syscall headers.

Since then, some new generated syscall header includes have been added
without the zephyr/ prefix, breaking builds when
CONFIG_LEGACY_GENERATED_INCLUDE_PATH is disabled.

This commit adds the zephyr/ prefix to includes for generated syscall
headers where it has been missed.

Signed-off-by: Ben Marsh <ben.marsh@helvar.com>
2024-07-11 18:24:58 -04:00
Jordan Yates 91f8c1aea9 everywhere: replace `#if IS_ENABLED()` as per docs
Replace `#if IS_ENABLED()` with `#if defined()` as recommended by the
documentation of `IS_ENABLED`.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-06-28 07:20:32 -04:00
Dominik Ermel 89fdc35c51 drivers/flash/spi_nor: Fix missing check for return value
Add check for returned value from the call to spi_nor_cmd_write
in spi_nor_write.

Fixes #74775

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-06-27 10:52:48 +02:00
Francois Ramu b40c037233 drivers: flash: stm32 xspi driver supports the MemoryMapped mode
Adding the support of the memoryMapped mode
to the flash_stm32_xspi driver through the CONFIG_STM32_MEMMAP
That will allow XiP from the external octo_flash
Erase and Write operation must Abort operations.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2024-06-24 12:45:34 -04:00
Martin Tverdal b9aae1388c drivers/flash/nrf_rram: increase flash timeout multipler rram
Erasing rram is very similar to partial erase on flash.
So we should use the same multiplier as there, 1.5.
0.1 multipler is way to low and was causing timeouts.

Signed-off-by: Martin Tverdal <martin.tverdal@nordicsemi.no>
2024-06-24 08:28:13 -04:00
Jordan Yates 07870934e3 everywhere: replace double words
Treewide search and replace on a range of double word combinations:
    * `the the`
    * `to to`
    * `if if`
    * `that that`
    * `on on`
    * `is is`
    * `from from`

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-06-22 05:40:22 -04:00
Dominik Ermel 97a97c744a drivers/flash: Fix typos and incorrect description
Fixing typos.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-06-19 09:34:19 +02:00
Dominik Ermel 33f8039d95 drivers/flash: Fix flash_fill write chunk calculation
Fix incorrect last chunk calculation.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-06-19 09:34:19 +02:00
Swift Tian 5d24b6d37d drivers: fix Kconfig.mspi for issue #74349
Fix the Kconfig.mspi under flash and memc so that it don't litter.

Signed-off-by: Swift Tian <swift-tian@qq.com>
2024-06-18 19:55:35 -04:00
Swift Tian ece0c9b0d3 drivers: mspi: Add ATXP032 NOR flash driver
The ATXP032 is a NOR flash device that supports up to ~100MHz
octal SDR/DDR with 4MB nonvolatile memory.
The device driver uses MSPI bus API and could be used across different
SoC controllers that implement the MSPI bus API.

Signed-off-by: Swift Tian <swift.tian@ambiq.com>
2024-06-14 21:07:00 -04:00
Swift Tian eccc2ba8c4 drivers: flash: Add a flash emulator
Add a flash emulator that uses MSPI API to emulate a flash device
on MSPI bus.

Signed-off-by: Swift Tian <swift.tian@ambiq.com>
2024-06-14 21:07:00 -04:00
Guillaume Gautier fe05606630 drivers: flash: select ncs line for stm32 xspi
Add support to select the nCS line for XSPI from the device tree.
Disable the nCS override.
This setting only works with series that have an XSPIM (so not H5)

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2024-06-14 15:44:38 +02:00
Francois Ramu b014150508 drivers: flash: stm32h7 flash driver supports the stm32h7rs serie
Add the support of the stm32h7rs serie to the flash stm32h7 driver
Remap Flash registers to the stm32h7rs serie.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2024-06-14 11:13:54 +02:00
Riku Karjalainen ff0635d700 drivers: flash: stm32: fix flash write error handling
The stm32 flash driver returns success even though
writing failed when instruction cache was enabled.
Fix by not overriding error code when re-enabling
instruction cache.

Signed-off-by: Riku Karjalainen <riku.karjalainen@vaisala.com>
2024-06-14 11:11:33 +02:00
Pisit Sawangvonganan fea0859b86 drivers: flash: stm32_qspi: make `cmd_write_en` definition as static const
Refactor the `QSPI_CommandTypeDef cmd_write_en` definition to
a `static const` local variable to eliminate redundant definitions.

This change enhances performance by reducing runtime overhead associated
with initializing `cmd_write_en` in multiple functions.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-06-13 05:34:29 -04:00
Francois Ramu ac48369731 drivers: flash: stm32 xspi driver with DMA support
Add the commands to read and write to/from the xSPI with gpDMA
On the stm32h5 device, the one request for xspi instance

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2024-06-12 12:53:41 -04:00
Francois Ramu be55b2c263 drivers: flash: stm32 xspi flash driver with clock domain
Configure the xspi clocks domain by the clock domain
as defined by the DTS
Up to 3 possible clock confg : xspix, xspi_ker, xspi_mgr

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2024-06-12 12:53:41 -04: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
Georgij Cernysiov 6be31f5243 drivers: flash: stm32: move memmap config
Move STM32_MEMMAP outside of SOC_FLASH_STM32.

That allows memory-mapped application to
be built without internal flash controller.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2024-06-10 14:58:52 +03:00
Vinayak Kariappa Chettimada 0e7c25fee4 drivers: flash: flash_shell: Fix unused variables
Fix unused variable compilation warnings.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-06-07 12:59:07 +02:00
Francois Ramu f6a9e0aef2 drivers: flash: stm32 qspi driver in Dual Flash Mode when MemoryMapped
Configure the quad-spi in DualFlash Mode when enabling the MemoryMapped
then reading is possible with memcopy.
DUAL flash mode is possible on stm32 series with QUADSPI_CR_DFM

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2024-06-06 15:22:06 -05:00
Dominik Ermel 459517badc drivers/flash/spi_nor: Fix DPD exit
Incorrectly placed preprocessor conditions caused exit_dpd
when there has been no instance of a device with
dpd_wakeup_sequence parameter.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Signed-off-by: Jan Tore Guggedal <jantore.guggedal@nordicsemi.no>
2024-06-04 16:28:59 -05:00
Henrik Brix Andersen c56134ebff drivers: flash: flash_util: params may be unused
The params variable may be unused depending on the Kconfig options enabled.

Fixes: #73697

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2024-06-04 10:14:01 +02:00
Dominik Ermel 7e658607fc drivers: flash: shell: Add support for devices without erase
Shell will now work with devices that do not implement erase callback.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-06-04 08:00:46 +02:00
Dominik Ermel 56142dcc73 drivers: flash: Mark numaker series RMC as no_explicit_erase
The device is based on ReRAM and does not require erase.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-06-04 08:00:46 +02:00
Dominik Ermel 0c10b20cc8 drivers: nrf_qspi_nor: Mark driver with FLASH_HAS_EXPLICIT_ERASE
All QSPI connected NOR Flash devices require erase prior to
write.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-06-04 08:00:46 +02:00
Dominik Ermel 294187b576 flash/spi_nor: Mark driver with FLASH_HAS_EXPLICIT_ERASE
Sets the Kconfig CONFIG_FLASH_HAS_EXPLICIT_ERASE.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-06-04 08:00:46 +02:00
Dominik Ermel 3c24e1a530 drivers/flash/Ambiq: Set erase capabilities, depending on SoC
The commit selects HAS_NO_EXPLICIT_ERASE for Apollo4,
with MRAM, and HAS_EXPLICIT_ERASE for Apollo3 which has Flash,
for a driver that shares code between SoCs.

In case of Apollo4 the no_explicit_erase capability is set to
true, while it remains false for Apollo3.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-06-04 08:00:46 +02:00
Dominik Ermel ea627fda7e drivers/flash: Add explict erase capability with proper values
Add explicit_erase capability and set proper value to it,
depending on type of a device.
Select FLASH_HAS_EXPLICIT_ERASE by devices that have program-erase
characteristics and FLASH_HAS_NO_EXPLICIT_ERASE, where needed.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-06-04 08:00:46 +02:00
Dominik Ermel 0e970c8362 drivers/flash/nrf_mram: Set no explicit erase capability to true
NRF MRAM does not require erase prior to re-programming already
written area.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-06-04 08:00:46 +02:00
Dominik Ermel 127bc5e35e drivers/flash/nrf_rram: Set no explicit erase capability to true
NRF RRAM does not require erase prior to re-programming already
written area.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-06-04 08:00:46 +02:00
Dominik Ermel 6d75bc519b drivers/flash/nrf: Mark driver as FLASH_HAS_EXPLICIT_ERASE
Select CONFIG_FLASH_HAS_EXPLICIT_ERASE for the NRF driver.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-06-04 08:00:46 +02:00
Dominik Ermel ff81b52448 drivers/flash_simulator: Add support for non-erase device
The commit adds support for testing non-explicite-erase
device on Flash Simulator. This is addition to already supported
explicit erase before write, aka Flash, type of device behaviour.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-06-04 08:00:46 +02:00
Dominik Ermel b8d073c572 drivers/flash: Add flash_fill() and flash_flatten()
The commit adds two new API calls:
 - flash_fill - that allows to fill selected part of device with
   specified value;
 - flash_flatten - that allows to erase or fill device with
   erase_value, depending on whether driver for the device provides
   erase callback.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-06-04 08:00:46 +02:00
Dominik Ermel b3c9f957c6 drivers/flash: Add explicit_erase property
The commit adds and no_explicit_erase capability to flash_parameters,
that indicates whether device is program-erase type device; such
devices, like Flash type devices, require erase prior to writing
random data at any previously programmed location.
This capability should only be set by drivers.

The flash_params_get_erase_cap() function has been added, for parsing
flash_parameters object to obtain erase capabilities of device.
The function returns capabilities as combination of bits representing
them. Currently it will return:
 0 -- no erase capabilities
 FLASH_ERASE_C_EXPLICIT -- erase required before write of random data.
Additional capabilities have been reserved but are not yet used.

There are following Kconfig options added:
 FLASH_HAS_EXPLICIT_ERASE
 FLASH_HAS_NO_EXPLICIT_ERASE
that should be selected by device driver to indicate whether
devices served by driver needs erase prior to write.
The above Kconfigs are used to figure out whether app is built
for hardware that requires erase prior to write.
They can be also used to detect that it is attempted to build
some subsystem that will not work with provided hardware, for example
file system that has not been prepared to work with devices that
do not require erase.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-06-04 08:00:46 +02: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
Yong Cong Sin bbe5e1e6eb build: namespace the generated headers with `zephyr/`
Namespaced the generated headers with `zephyr` to prevent
potential conflict with other headers.

Introduce a temporary Kconfig `LEGACY_GENERATED_INCLUDE_PATH`
that is enabled by default. This allows the developers to
continue the use of the old include paths for the time being
until it is deprecated and eventually removed. The Kconfig will
generate a build-time warning message, similar to the
`CONFIG_TIMER_RANDOM_GENERATOR`.

Updated the includes path of in-tree sources accordingly.

Most of the changes here are scripted, check the PR for more
info.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-28 22:03:55 +02:00
Robert Hancock 1af474b575 flash: spi_nor: error-checking fixes
Check the return values of commands such as spi_nor_cmd_* and
spi_nor_wait_until_ready and ensure they are propagated back to the
caller on error.

Signed-off-by: Robert Hancock <robert.hancock@calian.com>
2024-05-24 07:51:20 -04:00
Dominik Ermel deabfa3c3a drivers/flash/spi_nor: Fix and rework spi_nor_set_address_mode
The commit removes unneeded check for enter_4byte_addr_exist in
the function, as the utility function is supposed to set the address
by parsing enter_4byte_addr parameter, while the enter_4byte_addr_exist
used to exist only for DTS entries that directly set enter-4byte-addr
parameters for a flash node.

The change also moves LOG_DBG reporting enter_4byte_addr before
it is processed, to allow logging what actually function will be working
with, before it does so.

The enter_4byte_addr_exist is removed as it is no longer used anywhere.

Setting of data->flag_access_32bit has been moved in the same code block
as call to the spi_nor_cmd_write, as it can be only consequence of
successful call to that function.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-05-24 07:50:25 -04:00
Mike J. Chen 3656c1b14c spi_nor: remove unneeded enter_dpd() at end of spi_nor_configure()
This block of code was in the original commit that added
CONFIG_SPI_NOR_IDLE_IN_DPD but later modifications
added acquire_device() and release_device() calls
earlier in spi_nor_configure() and the release_device()
function will have already done the enter_dpd().

Signed-off-by: Mike J. Chen <mjchen@google.com>
2024-05-23 11:53:45 -04:00
Alberto Escolar Piedras 0ec5c9c27b drivers/flash/ nrf RRAM: Support simulated targets
In simulated targets the RRAM is not allocated
starting at address 0x0, but on an area allocated
at runtime.
Let's support this, to enable running the
real RRAM driver for simulated targets.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-05-22 13:44:54 -05:00
Daniel DeGrasse 1de7574d3a drivers: flash: flash_mcux_flexspi_nor: better handle legacy SFDP tables
Implement more robust handling for legacy SFDP tables, which may not
implement some of the JEDEC defined DWORDS for SFDP data. Instead of
failing to probe/initialize the flash when these DWORDS are not defined
in the basic flash parameter table, revert to sane defaults for SPI
flash.

Fixes #72051

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-05-16 18:56:33 -04:00
Armin Brauns 846007676a drivers/flash: enable memory-mapped mode for STM32 QSPI
This puts the QSPI peripheral into memory-mapped mode when
CONFIG_STM32_MEMMAP is set. Writes and erase put it back into indirect
write mode.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2024-05-16 15:52:01 +02:00
Francois Ramu cb7ed8d97d drivers: flash: stm32 flash driver has a Kconfig STM32_MEMMAP
This CONFIG_STM32_MEMMAP is for enabling the MemoryMapped mode
on external octo or quad spi memory.
In this case, the flash_stm32_read is done in mem map mode
the flash_stm32_erase is not available.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2024-05-16 15:52:01 +02:00
Francois Ramu c8cd57fe9e drivers: flash: stm32 qspi driver when Dual-Flash not supported
Some stm32 devices with quadspi (like stm32l47x or stm32l48x)
does not support Dual-Flash Mode. Avoid building error even if
the &quadspi node has a <flash-id>  property defined.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2024-05-16 11:00:27 +02:00
Francois Ramu 182c5475e2 drivers: flash: stm32 flash driver for xspi instance
Introduce a XSPI driver to cover the common XSPI peripherals
of the stm32 mcu: X is for single or quad or octo or hexa
SPI bus access to external memories
DMA not supported in this version

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2024-05-15 10:56:04 +02:00
Dawid Niedzwiecki 27c3378285 drivers: flash: stm32: select extended operations correctly
Select that the STM32 driver has extended operations feature when
the FLASH_STM32_BLOCK_REGISTERS is set.

It allows using only block registers extended operation.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2024-05-15 09:26:55 +02:00
Daniel DeGrasse 4f65595b24 drivers: flash: flash_mcux_flexspi_nor: reduce LUT usage
FLEXSPI nor driver uses several LUTs for "scratch" commands during the
SFDP probe phase that are not needed once the flash is configured. Set a
second "end" marker we can use to configure the FLEXSPI MEMC driver, so
that we can indicate the true number of LUTs needed by this driver when
init is completed.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-05-14 18:21:57 -04: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
Mateusz Michalek a859191413 drivers: flash: RRAMC regions
Adding definition of regions granularity to Kconfig.

Signed-off-by: Mateusz Michalek <mateusz.michalek@nordicsemi.no>
2024-05-13 09:53:05 -05:00
Aaron Ye 6d4ed7e192 drivers: flash: flash_ambiq: add Apollo3 SOC support
This commit adapts the Ambiq flash controller to support the Apollo3
SOC (e.g. Apollo3 Blue, Apollo3 Blue Plus).
Also uses the Zephyr common IRQ API to replace the Ambiq HAL ones.

Signed-off-by: Aaron Ye <aye@ambiq.com>
2024-05-10 13:30:33 +02:00
Dominik Ermel d954060626 drivers: flash: rram: Select NRFX_RRAMC
Select NRFX_RRAMC for RRAM driver.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-05-08 14:59:56 -05:00
Wei-Tai Lee 5b83b7a472 drivers: flash: andes_qspi: fix accessing error variable
Fix accessing error variable when using FLASH_ANDES_QSPI_SFDP_RUNTIME.

Signed-off-by: Wei-Tai Lee <wtlee@andestech.com>
2024-05-01 10:26:21 +02:00
Wei-Tai Lee 71f4d1b98e drivers: flash: andes_qspi: fix shadow variable error
Make the variables naming more specific.

Signed-off-by: Wei-Tai Lee <wtlee@andestech.com>
2024-05-01 10:26:21 +02:00
Fin Maaß 6801ec0e30 drivers: flash: esp32: correct return values
The esp_flash*() functions don't return
negative errno codes, so it's return value
should not be used for the flash api functions.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-04-30 18:01:59 +02:00
Sebastian Bøe 99f94295eb drivers: nrf: rram: Support TF-M
Non-secure images cannot reference NRF_RRAMC_NS because NRF_RRAMC_NS
does not exist.

TF-M will configure RRAMC according to these Kconfig's before booting
the non-secure image so we ifdef out this code.

Also, rewrite the implementation of commit_changes to also work when
the commit task is not available.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2024-04-25 17:58:40 -04:00
Dominik Ermel 22a7d2d8fb drivers/flash_simulator: Fix FLASH_SIMULATOR_DOUBLE_WRITES help
Fix incorrect note that write only allows to change value of
bit to zero, where proper information is that change is only allowed
from erase-value to the opposite.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-04-24 19:42:44 +00:00
Dominik Ermel 8b109b6649 drivers/flash_simulator: Fix write for 0x00 erase value
The commit adds missing binary or in write operation.
Assuming that program-erase devices only allow switching bits
from erase-value to opposite, in case of 0x00 erase value device
only ones can be written.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-04-24 19:42:44 +00:00
Pisit Sawangvonganan 6d99f3797a drivers: flash: spi_nor: clean up unnecessary code
This commit removes unnecessary usage of the `ARG_UNUSED` macro and
unnecessary initialization of the `ret` variable where its value is
guaranteed to be overwritten by subsequent operations.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-04-19 17:55:25 +00:00
Dominik Ermel a7909bc596 drivers/flash/nordic_qspi_nor: Add missing FLASH_HAS_PAGE_LAYOUT
The Kconfig for device has not been missing the FLASH_HAS_PAGE_LAYOUT.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-04-19 16:55:01 +00: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
Dominik Ermel 5a0ecb9641 flash: Move dependency on FLASH_PAGE_LAYOUT where it belongs
The commit adds dependency on Kconfig FLASH_PAGE_LAYOUT to subsystems
that really require it:
 FCB, NVS, LittleFS
and removes direct selection from '*.conf' files where no longer
needed.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-04-10 10:01:40 +02:00
Lukas Gehreke 5f6a68a03b drivers: flash: Added buffered write for addresses in flash on rp2040
It is impossible to perform flash reads during a flash write. When the
data to write to flash lies in the flash itself, it is buffered in ram
before writing.

Signed-off-by: Lukas Gehreke <lk.gehreke@gmail.com>
2024-04-05 10:56:21 -05:00
Lucas Tamborrino fe57a12cf2 drivers: esp32: update to hal_espressif v5.1
Modify necessary drivers to meet updated hal.

Signed-off-by: Lucas Tamborrino <lucas.tamborrino@espressif.com>
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2024-04-05 13:39:53 +02:00
Bartosz Sokolski f4d55e7f68 drivers: nrf_qspi_nor: Add option for 2bit IO
Add missing NRF_QSPI_READOC_READ2IO option handling
to enable 2bit IO

Signed-off-by: Bartosz Sokolski <bartosz.sokolski@nordicsemi.no>
2024-03-26 10:47:20 -04:00
Jordan Yates 71c3c955c1 drivers: flash: spi_nor: use `pm_device_driver_init`
Use `pm_device_driver_init` to ensure that init is run correctly
regardless of the power state.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2024-03-26 10:45:34 -04:00
Dominik Ermel 6266dc11a9 drivers: flash: spi nor: Fix missing init of hold pin
There has been missing line initializing the hold pin,
which caused SPI NOR device init to fail with -ENODEV,
if property defining such pin has been present in device
definition.

Fixes #70661

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-03-25 13:26:55 -05:00
Mahesh Mahadevan 68ed426751 drivers: flash: Update mcux driver to add support for MCX flash
Add support for the MCX flash

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2024-03-22 14:25:31 +00:00
Mehdi Zemzem adedf14c42 drivers: flash: spi nor: Add MultInstance support
Modify the SPI Nor driver to be able to have multiple instances at
the same time.

This patch is heavily inspired by the at45 driver.
It was tested on the nRF5340 DK by using the external spi memory two times.
Macros were improved by de-nordic

Signed-off-by: Mehdi Zemzem <mehdi.zemzem2@gmail.com>
2024-03-21 10:07:53 +00:00
Andrzej Głąbek cb6f44c3b9 drivers: nrf_qspi_nor: Handle anomaly 159 on nRF5340
The nrfx_qspi driver in nrfx 3.4.0 started checking conditions that
could trigger anomaly 159 on nRF5340 so make sure that QSPI transfers
are only performed with properly configured clocks (PCLK192M undivided
and HCLK128M divided by 2).

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2024-03-14 15:35:06 +01:00
Gustavo Silva 722e04da3c flash: stm32: configurable write block sizes
Add new devicetree bindings for F4 and L1 series for configuration of
block size used in flash write operations.

Allow byte-size write operations in `flash_stm32f1x.c`. This file is
being shared between F0, F1, F3, L0 and L1 series. L0 and L1 series
allows for single byte writes.

Signed-off-by: Gustavo Silva <gustavograzs@gmail.com>
2024-03-11 18:57:43 +00:00
cyliang tw 47ed29bf49 drivers: flash: support for Nuvoton numaker series RMC
Add Nuvoton numaker series flash memory controller(RMC) with erase,
 read & write features of soc-flash.

Signed-off-by: cyliang tw <cyliang@nuvoton.com>
2024-03-11 14:22:55 +01: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
Grzegorz Swiderski f91323ee5d drivers: flash: Add flash driver for MRAM
Basic driver utilizing the flash API for NVM operations on the nRF54H20.

Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
2024-03-08 09:36:04 +01:00