Commit Graph

1080 Commits

Author SHA1 Message Date
Declan Snyder e8cf9601c1 drivers: flash: mcx: Clear cache after erase
Cache needs to be cleared after erase in order to read back erased
values correctly.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2024-11-08 09:29:11 -06:00
Mahesh Mahadevan 9861a6a7c1 drivers: flexspi_nor: Fix Flash failures seen on FRDM-MCXN947
The flash_flexspi_nor_check_jedec() checks the lower 16-bits of
the manufacturer ID and installs a custom LUT table.
Add an exception to check for the whole 32-bits so we do not
accidentally install custom LUT for flash devices that do not
support this LUT table.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2024-11-08 09:26:24 -06:00
Jun Lin 69e85b25fe board: npcx: remove CONFIG_PINCTRL from defconfig of npcx boards
The CONFIG_PINCTRL is removed from the board's defconfig files.
Drivers which use pin control function should add "select PINCTRL"
in their Kconfig files.

Fixes #78619

Signed-off-by: Jun Lin <CHLin56@nuvoton.com>
2024-11-07 08:59:14 -08:00
Luca Burelli 33def3036a drivers/flash/soc_flash_mcux: adjust alignment logic
The current alignment logic does not work as expected if given unaligned
values, resulting in a skip of the first word. The length also has to
take into account the starting address: for example, asking for 2 bytes
at offset 3 should actually check 8 bytes.

This patch adjusts the logic so that it always includes the first and
the last word of the input area.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2024-11-07 08:32:14 -06:00
Luca Burelli 20cd3a3f09 drivers/flash/mcux: fix flash_read() operation on LPC55S36
As other targets in the LPC55xxx series, the LPC55S36 has a Flash
controller that raises ECC errors when reading erased pages directly.
To avoid this, there is special code for this platform that calls the
HAL FLASH_IsFlashAreaReadable() function. However, this in turn calls a
function at an hardcoded address in ROM that _always_ causes an
instruction fault, making the situation worse.

This patch reworks the read operation to use the FLASH_Read() HAL
function for this target to gracefully handle error conditions and
properly emulate accesses to erased pages. The preprocessor is required
since some targets do not define the FLASH_Read() function.

Fixes: #80325

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2024-11-07 08:32:14 -06:00
Daniel DeGrasse cfb7322107 drivers: flash: flash_mcux_flexspi: add support for W25Q512NW-IQ/IN
Add support for the W25Q512NW-IQ/IN with the FLEXSPI, using a custom
LUT table.

Fixes #80592

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-11-05 10:55:13 -06:00
Francois Ramu a925d60cbd drivers: flash: stm32h7 flash driver reformat code
Apply clang-format to re-format the flash_stm32h7.c driver

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2024-11-04 13:41:46 -06:00
Francois Ramu 331423d8e3 drivers: flash: stm32H7 flash driver enable clock when defined
Not all the stm32H7 have a clock enable for their flash;
only the dual-core.
For the st,stm32h7-flash-controller with "clocks" property, the driver
will enable the flash clock bit in the corresponding RCC register.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2024-11-04 13:41:46 -06:00
Lars-Ove Karlsson aaeaef0a1c drivers: flash: Removed a __packed attribute from struct jesd216_bfp
The struct jesd216_bfp was declared as __packed but later in the code
the address of a member was given to a non-packed pointer, potentially
causing reading of wrong addresses, and causing warnings with the
IAR ICCARM compiler.

After studying the JEDEC documentation JESD216F.02, section
6.4.2 JEDEC Basic Flash Parameter Header: 2nd DWORD, the struct must
be aligned to 4 so __packed is not necessary, just 4 byte alignment.

Signed-off-by: Lars-Ove Karlsson <lars-ove.karlsson@iar.com>
2024-11-01 13:54:30 -05:00
Fin Maaß 83c3b1c708 drivers: flash: spi_nor: simplify defines
simplify defines by using `DT_INST_**_OR` macros.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-10-30 09:43:18 -07:00
Fin Maaß 27aeabb5b2 drivers: flash: spi_nor: fix config struct
lots of values from the DT where not set corretly, if
`CONFIG_SPI_NOR_SFDP_RUNTIME` was
enabled. This fixes it.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-10-30 09:43:18 -07:00
Daniel DeGrasse 6bc73df06b drivers: flash: flash_mcux_flexspi: add support for W25Q512JV
Add support for the W25Q512JV with the FLEXSPI, using a custom
LUT table.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-10-25 18:51:45 +01:00
Daniel DeGrasse e8e43b60eb drivers: flash: flash_mcux_flexspi_nor: add IS25LP support
IS25LP flash chips have a similar P[6:3] register to the IS25WP series,
and need the same workaround.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-10-23 09:06:19 +09:00
Daniel DeGrasse 7ca996234f drivers: flash: flash_mcux_flexspi_nor: fix IS25WP flash support
Some NXP boards program the read parameters bits (P[6:3]) within the
IS25WP flash device during init, which will result in JESD216 probe
commands failing (as the number of dummy cycles will be incorrect). Add
handling to force these volatile bits to their default value to the
flexspi flash driver.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-10-23 09:06:19 +09:00
Daniel DeGrasse c410b020b5 drivers: flash: flash_mcux_flexspi: fix support for QE method 5
Quad enable method 5 reads status register 2 (one byte), but then writes
to 2 bytes to the status registers, so we need to shift the output
buffer in order to manage this correctly.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-10-23 09:06:19 +09:00
Daniel DeGrasse 966b4339ee drivers: flash: flash_mcux_flexspi_nor: fix quad enable sequence
Writing the quad enable bit on flash chips typically requires a write
enable instruction be issued before writing the non-volatile status
register, and the flash may remain busy briefly after programming this
bit. Add code to send the WREN instruction, and to wait for the flash to
finish programming after writing the status register.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-10-23 09:06:19 +09:00
Daniel DeGrasse e8a2832beb drivers: flash: flash_mcux_flexspi_nor: store probe lut in .data
Move the LUT used for probing to be stored in .data, instead of on the
stack. This reduces stack usage during probe by 192 bytes, which avoids
stack overflows that were occurring on some platforms.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-10-23 09:06:19 +09:00
Mert Vatansever d1678a51de drivers: flash: Add MAX32xxx flash driver
Support flash read, write, erase features.

Signed-off-by: Mert Vatansever <mert.vatansever@analog.com>
Signed-off-by: Sadik Ozer <sadik.ozer@analog.com>
2024-10-22 20:39:41 +02:00
Reto Schneider 7fa5a222a0 drivers: flash: Sort CMake and Kconfig files alphabetically
By sorting the lines alphabetically, merge conflicts can be reduced.

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2024-10-11 13:16:15 -04:00
Joakim Andersson d794d58d64 drivers: nrf_qspi_nor: Check poll period before sleep
Check that the poll period is non-zero before sleeping.

Signed-off-by: Joakim Andersson <joerchan@gmail.com>
2024-10-11 13:16:05 -04:00
Joakim Andersson 14c896b647 drivers: nrf_qspi_nor: Fix build without multithreading
Fix build of nrf_qspi_nor flash driver without multithreading enabled.
This is required for builds like mcuboot.

Signed-off-by: Joakim Andersson <joerchan@gmail.com>
2024-10-11 13:16:05 -04:00
Declan Snyder 86f65f2591 dts: nxp: Rename nxp,iap-msf1 to nxp,msf1
IAP is a reference to the method of software interaction with the flash
used in the current driver implementing support for this flash. The
DT compatible should not be named like this.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2024-10-09 18:23:39 +01:00
Chris Friedt 41e4b5323a drivers: flash: shell: add "flash copy" command
Add a flash copy command, capable of copying a region in one
flash device to a region on the same or another flash device. The
destination is erased prior to copying.

This is useful for evaluating mcuboot on devices with little
on-chip resources, or devices that are incapable of running more
elaborate image management services (e.g. via bluetooth or
networking).

Additionally, it's useful for evaluating mcuboot on devices with
one or more images stored on external spi flash.

The command syntax is
flash copy <src_dev> <dst_dev> <src_offs> <dest_offs> <size>

E.g.
flash copy flash@0 flash-controller@abcd1234 0x1234 0x5678 21012
Copied 21012 bytes from flash@0:1234 to \
  flash-controller@abcd1234:5678

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-10-08 06:02:01 -04:00
Chris Friedt ced4e16235 drivers: flash: provide a generic flash_copy() algorithm
Provide a generic flash_copy() algorithm that is capable of
copying from one flash device to another or within different
regions of the same flash device.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-10-08 06:02:01 -04:00
TOKITA Hiroshi 16c9b74e3a drivers: flash: rpi_pico: Rename to avoid conflicting with SDK
Some symbol names have been conflicted with introducing pico-sdk 2.0.0.
Rename these.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2024-10-08 06:01:23 -04:00
Yong Cong Sin 52a202309b zephyr: bulk update to DT_NODE_HAS_STATUS_OKAY
Change instances of:

DT_NODE_HAS_STATUS(<node_id>, okay)

to

DT_NODE_HAS_STATUS_OKAY(<node_id>)

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2024-10-03 17:06:52 +01:00
Florian Grandel 117a0098f3 drivers: flash: simulator: fix address resolution
The flash simulator assumes that flash is being addressed with absolute
addresses by clients. But this is not the case. Given addresses are
relative to the flash base address.

The existing code only worked because the base address was always zero.
Testing with non-zero base addresses caused a mem fault/page fault.

(Reproducible e.g. when using the NVS settings subsystem on QEMU x86
with a non-zero base address in the soc-nv-flash node.)

Fixes #79082

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2024-10-02 10:12:27 +02:00
Francois Ramu ff34d575bc drivers: flash: stm32 qspi flash driver with unprotect command
Add the write_unprotect command to the stm32 qspi flash driver
to un protect flash before any write operation to the external quad-NOR

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2024-10-01 09:52:34 +02:00
Francois Ramu 76740ae1d1 drivers: flash: qspi stm32 driver supporting requires_ulbpr
Add the support of the requires_ulbpr property when a Microchip
quad-spi flash is mounted.
Set the CONFIG_USE_MICROCHIP_QSPI_FLASH_WITH_STM32=y flag to access
the command

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2024-10-01 09:52:34 +02:00
Vidar Berg d943e22f94 drivers: flash: spi nor: Allow the init priority to be configurable
Some applications may require the SPI NOR driver to be initialized
earlier. This commit enables the user to change the default
initialization priority.

Signed-off-by: Vidar Berg <vidar.berg@nordicsemi.no>
2024-09-27 10:56:41 +01:00
Bill Waters eb19d32588 drivers: Remove CONFIG_PINCTRL in defconfig files
The CONFIG_PINCTRL setting is removed from the board
_defconfig files.  And "select PINCTRL" is added to
the appropriate driver files.

Signed-off-by: Bill Waters <bill.waters@infineon.com>
2024-09-23 18:08:14 -04:00
Declan Snyder 448485a967 drivers: soc_mcux_flash: Add flash_k4 support
Add support for flash_k4 api from the mcux SDK.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2024-09-20 15:14:11 -05:00
Alexandre Bailon 2cef27865f drivers: flash: cc13xx_cc26xx: Add support of write to flash from flash
Currently, if we try to write data from a memory mapped flash address
to the flash then we get a -EINVAL error.
This could break the settings subsystem when we use NVS backend.

In order to make it work, add a buffer and use it when we want to
write data that is located in flash address space.

This has been tested using sample/subsys/settings/

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
2024-09-18 15:32:09 +02: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
Mathieu Choplain e322fa9781 drivers: flash: stm32: add STM32WB0 flash controller
Adds a basic driver for the STM32WB0 flash controller (read/erase/write).
Extended operations are not supported by this driver.

Signed-off-by: Mathieu Choplain <mathieu.choplain@st.com>
2024-09-12 10:03:37 +02:00
Pisit Sawangvonganan 847a4eaad2 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-09-11 07:40:35 -04:00
Neil Chen 810e6a19c3 drivers: flash: support flash driver for MCXA156
Add MCXA156 romapi support in flash driver

Signed-off-by: Neil Chen <cheng.chen_1@nxp.com>
2024-09-10 12:39:18 -04:00
Duy Nguyen 5ff44120e1 Kconfig: Fix issue in KConfig of Renesas modules
Add condition for KConfig Renesas FSP hal module
Move the DUAL_BANK_MODE from SOC to flash driver KCONFIG

Signed-off-by: Duy Nguyen <duy.nguyen.xa@renesas.com>
2024-09-10 14:42:55 +01:00
Sylvio Alves 8233b70ece espressif: clean up unused code
Remove all entries that as not being used.
This also update hal to re-enable warning flags
as such as -Wno-unused-variable.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2024-09-09 13:55:39 -04:00
Jordan Yates d1abe40fb0 flash: nrf_qspi_nor: wait for erase to complete
Wait until the erase operation triggered by `qspi_erase` completes
before returning. This aligns with the behaviour of other flash drivers
like `spi_nor` and `soc_flash_nrf`.

A delay is added to the `qspi_wait_while_writing` to prevent the check
from monopolising the CPU.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-09-09 15:25:16 +03:00
Quy Tran 79fb5a391a drivers: flash: Add support for flash driver on MCK-RA8T1
Initial commit to support flash driver on MCK-RA8T1 board

Signed-off-by: Quy Tran <quy.tran.pz@renesas.com>
2024-09-06 11:28:04 -04:00
Quy Tran beba6685af drivers: flash: Add support for flash driver on EK-RA8D1
Initial commit to support flash driver on EK-RA8D1

Signed-off-by: Quy Tran <quy.tran.pz@renesas.com>
2024-09-06 11:28:04 -04:00
Duy Phuong Hoang. Nguyen e1f990c176 drivers: flash: Initial support flash driver on EK-RA8M1
Initial commit for flash driver support on board using RA8 MCUs
* drivers: flash: implementation for flash driver on EK-RA8M1
* dts: arm: add device node for flash of EK-RA8M1
* boards: arm: enable support flash driver for ek_ra8m1, update
board documentation

Signed-off-by: Quy Tran <quy.tran.pz@renesas.com>
Signed-off-by: Duy Phuong Hoang. Nguyen <duy.nguyen.xa@renesas.com>
2024-09-06 11:28:04 -04:00
Erwan Gouriou 853b6feb52 drivers: stm32: Make some config symbols menuconfig symbols
Move some STM32 drivers  related Kconfig symbols from `config`
to `menuconfig` when driver options depends on these symbols.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2024-09-05 16:58:04 -04:00
Erwan Gouriou d13f9d9b9b drivers: stm32: Select PINCTRL when required
Select PINCTRL subsystem by drivers which require it.
Prevent the need from enabling this symbol at board or soc level.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2024-09-03 14:40:55 +01:00
Jordan Yates 7b4e7ff9ed flash: spi_nor: handle SPI bus power
Automatically request and release the SPI bus before talking to the
flash chip.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-08-27 07:15:28 -04:00
Jordan Yates 986fd88416 flash: spi_nor: automatically run device runtime PM
Automatically handle device runtime PM for all flash API calls.
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>
2024-08-27 07:15:28 -04:00
Jordan Yates 6487a2a663 flash: spi_nor: remove `SPI_NOR_IDLE_IN_DPD`
Remove `SPI_NOR_IDLE_IN_DPD` to simplify the possible transition states
in the `spi_nor` driver. This option was originally added 5 years ago
when device runtime PM was in a much less mature state.

I do not believe having a separate power management implementation for
this one in-tree driver is in the interests of the project.

The behaviour of `SPI_NOR_IDLE_IN_DPD` leads to extremly suboptimal
behaviour in use cases where multiple small reads are performed
sequentially, see #69588.

Removal of this option does not break the behaviour of any existing
applications, only increases current consumption in idle by ~10uA until
device runtime PM is enabled.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-08-27 07:15:28 -04:00
Reto Schneider 2e1a87543c drivers: flash: Add Si32 support
Can be used only once the SiM3U SoC support has been added.

Developed-by: Michael Zimmermann

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2024-08-26 18:51:36 +02:00
IBEN EL HADJ MESSAOUD Marwa d7db52feb2 drivers: flash: flash_stm32: Fix log warning
Cast the argument to "unsigned long" to avoid the
warning

Signed-off-by: IBEN EL HADJ MESSAOUD Marwa <marwa.ibenelhadjmessaoud-ext@st.com>
2024-08-26 11:28:04 -04:00