Commit graph

969 commits

Author SHA1 Message Date
Daniel DeGrasse daf6de7b99 drivers: flash: flexspi_mx25um513: enforce write size limit in DTR mode
Per the MX25UM51325G datasheet, all page programs in OPI DTR mode need to
start at an even address, and be of even length. Update the minimum
write size reported by the driver and check all writes when OPI DTR mode
is enabled, so that subsystems using the flash driver can align to this
requirement.

Fixes #63639

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2023-10-10 11:18:57 +02:00
Kelly Helmut Lord 12fa534089 drivers: flash: shell: adjusted load command prompt
Adjusted the prompt of the load command to make it more obvious that
the user is being prompted for keyboard input.

Signed-off-by: Kelly Helmut Lord <helmut@helmutlord.com>
2023-09-29 16:28:40 +02:00
Stefan Petersen 58ca047fa7 dts: stm32h7: flash-controller: Add default STM32 as compatible
Add "st,stm32-flash-controller" as compatible for STM32H7 so that
what is defined for STM32 in general  is also defined for STM32H7.
Already most of the other STM32 versions have this addition.

Also removed the specific STM32H7 flag check in
/flash/driver/Kconfig.stm32.

Signed-off-by: Stefan Petersen <spe@ciellt.se>
2023-09-29 09:47:46 +02:00
Dominik Ermel 1f3605de21 drivers/flash/nrf: Workaround for nrf91 errata 7
Fix UICR read access.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-09-28 15:33:52 +02:00
Gerard Marull-Paretas 0660719346 drivers: nrf: select PINCTRL
Drivers for nRF SoCs using pinctrl did not select PINCTRL. This means
boards are forced to enable PINCTRL.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-09-20 08:57:09 +02:00
Andrew Sonzogni 9ae9ee7ec4 drivers: flash: stm32: change undefined variable causing build error
Replace an undefined variable.

Signed-off-by: Andrew Sonzogni <andrew@safehear.fr>
2023-09-14 14:35:58 +02:00
J.P. Hutchins d7313388c9 drivers: flash: fix hw write protect before sw
This change sets write-protect pin disabled BEFORE SW write-protect disable
and  write-protect pin enabled AFTER SW write-protect enable.

Signed-off-by: J.P. Hutchins <jp@intercreate.io>
2023-09-13 12:07:27 +02:00
J.P. Hutchins b403fdee00 drivers: flash: cleanup #ifs; fix missing ;
Fixes made running tests/drivers/flash

Signed-off-by: J.P. Hutchins <jp@intercreate.io>
2023-09-13 12:07:27 +02:00
J.P. Hutchins a9ac01c457 drivers: flash: add LOG_ERR for pin init
-ENODEV returned in 4 cases, logs can distinguish

Signed-off-by: J.P. Hutchins <jp@intercreate.io>
2023-09-13 12:07:27 +02:00
J.P. Hutchins 19ba93c896 drivers: flash: implement wp-gpios and hold-gpios
Adds the wp-gpios & hold-gpios from jedec,spi-nor compatible to spi_nor.c.

Signed-off-by: J.P. Hutchins <jp@intercreate.io>
2023-09-13 12:07:27 +02: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
Jamie McCrae 72167f2acf drivers: flash: nrf_qspi_nor: Add support for XIP at boot
Adds support for forcing XIP support at boot time, and reduces the
init priority of the driver so that it inits earlier.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-09-12 09:35:21 +02:00
Laczen JMS c64e806b63 flash: correct missing erase handler
flash_handlers was missing the required z_vrfy_flash_erase function

Signed-off-by: Laczen JMS <laczenjms@gmail.com>
2023-09-05 11:40:43 +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
Fabio Baltieri 755bdf80c6 drivers: flash: spi_nor: fix build when a reset gpio is present
Fix a few issues with the reset-gpio functionality in spi_nor, missing
header, missing semicolon, unnecessary and not working condition on a
struct field that is not a pointer.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-28 16:01:23 +02:00
Mulin Chao f942b44c56 soc: arm: npcx: move workaround methods for npcx series to its soc.c
Move workaround methods for npcx series to soc init functions. If
there's no workaround for this series, drop its soc.c file directly.

Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
2023-08-28 08:22:10 +01:00
Jun Lin df0646ed6e driver: flash: npcx: add support for npcx4 series
This CL introduces new Flash Interface Unit (FIU) hardware in npcx4
series. The different operations of npcx9 and npcx4 FIU include:

1. 4-byte mode support for DRA mode move to SPI_DEV reg
2. To access the second flash in DRA mode, we need to configure
   SPI_DEV_SEL field in BURST_CFG additionally.

Signed-off-by: Jun Lin <CHLin56@nuvoton.com>
2023-08-24 10:42:33 +01:00
Vincent Geneves 3b3528cd90 drivers: flash: spi_nor: Add reset pin
Add Reset pin initialization during Spi NOR driver start-up. Toggle
the pin to reset the device.

Signed-off-by: Vincent Geneves <vgeneves@kalray.eu>
2023-08-21 09:52:54 -05:00
Tomislav Milkovic 96869ff3ff drivers: flash: flash_stm32h7x: Fix STM32H7 unaligned read access
Due to source data pointer having no alignment constraint,
extra care needs to be taken when reading source data
as dword

Signed-off-by: Tomislav Milkovic <tomislav.milkovic95@gmail.com>
2023-08-18 12:13:41 +02:00
Dominik Ermel 0538041cd6 drivers: flash: nrf_qspi_nor: Process ret of qspi_device_init
Commit slters z_impl_nrf_qspi_nor_xip_enable to not call
qspi_device_init in case when xip_enabled has the same value
as requested.
In case when qspi_device_init returns non-zero no further actions
are taken and xip_enabled will not be to set requested value.

Fixes #59535.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-08-17 20:38:11 +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
Madhurima Paruchuri 3bc694dd8d drivers: flash: npcx: Fix offset alignment check bug
Removed single offset alignment check mechanism and replaced it with
offset alignment check for each iteration

Signed-off-by: Madhurima Paruchuri <mparuchuri@google.com>
2023-08-07 13:08:27 +02:00
Joshua Crawford ea2dd9fc65 drivers: flash: spi_nor: select largest valid erase operation
The spi_nor erase op selection was based on the alignment of the end of
the region to be erased. This prevented larger erase operations being
selected in many cases

Closes #60904

Signed-off-by: Joshua Crawford <joshua.crawford@levno.com>
2023-08-04 10:46:39 +02:00
Madhurima Paruchuri 9fab38dd04 drivers: flash: npcx: Update erase function to allow 0x1000 byte erase size
Modify the NPCX driver erase method to allow 0x1000 byte size erases
along with 0x10000 byte size erases based on input parameters

Signed-off-by: Madhurima Paruchuri <mparuchuri@google.com>
2023-08-03 10:29:14 +02:00
Wei-Tai Lee b69aea9f89 drivers: flash: add Andes qspi-nor driver
Add flash driver for Andes qspi.

Signed-off-by: Wei-Tai Lee <wtlee@andestech.com>
2023-08-03 10:28:02 +02:00
Florian Vaussard 8bac51be1e drivers: flash: stm32: add a weak flash_stm32_valid_range()
Most implementations have the same logic, with only a different write
block size. Now that we are using write-block-size from the device tree,
it is possible to use a default implementation that can be overridden if
necessary.

Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
2023-07-28 09:02:17 +00:00
Florian Vaussard 4c9e42925e drivers: flash: stm32l5: use write-block-size when writing
STM32L5 have a write block size of 8, but STM32U5 and STM32H5 have a
write block size of 16. Convert write_dword() and
flash_stm32_write_range() to write write-block-size data at a time.

Fixes #60724

Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
2023-07-28 09:02:17 +00:00
Florian Vaussard 199486546a drivers: flash: stm32l5: use write-block-size when validating
STM32L5 have a write block size of 8, but STM32U5 and STM32H5 have a
write block size of 16. Use write-block-size from the device tree
instead of hardcoding this value when validating the range of write
operations.

Fixes #60724

Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
2023-07-28 09:02:17 +00:00
Manuel Argüelles 6d0a876525 drivers: flash: add NXP S32 QSPI flash NOR driver
Add support for flash NOR memory devices on a NXP S32 QSPI bus. The
driver uses a fixed LUT configuration assuming a default standard page
size and erase types, and allows to select between multiple read/program
instructions/modes. It is also possible to read the flash device
characteristics from the device at run-time as long as the memory is
JESD216 compatible, providing more flexibility.

Signed-off-by: Manuel Argüelles <manuel.arguelles@nxp.com>
2023-07-26 09:44:14 +02:00
Marek Matej 6b57b3b786 soc: xtensa,riscv: esp32xx: refactor folder structure
Refactor the ESP32 target SOCs together with
all related boards. Most braking changes includes:

- changing the CONFIG_SOC_ESP32* to refer to
  the actual soc line (esp32,esp32s2,esp32s3,esp32c3)
- replacing CONFIG_SOC with the CONFIG_SOC_SERIES
- creating CONFIG_SOC_FAMILY_ESP32 to embrace all
  the ESP32 across all used architectures
- introducing CONFIG_SOC_PART_NUMBER_* to
  provide a SOC model config
- introducing the 'common' folder to hide all
  commonly used configs and files.
- updating west.yml to reflect previous changes in hal

Signed-off-by: Marek Matej <marek.matej@espressif.com>
2023-07-25 18:12:33 +02:00
cyliang tw ecbaac60bd drivers: flash: support for Nuvoton numaker series FMC
Add Nuvoton numaker series flash memory controller(FMC) with erase,
 read & write features of soc-flash. Also update Nuvoton manifest
 to include zephyrproject-rtos/hal_nuvoton#6.

Signed-off-by: cyliang tw <cyliang@nuvoton.com>
2023-07-21 10:41:40 +00:00
Mulin Chao f34fff91bc driver: flash: npcx: introduce npcx flash driver
This CL attempts to implement npcx's flash driver instead of the
original one (npcx spi driver plus spi_nor flash driver).

Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
2023-07-20 16:22:47 +02:00
Marcin Zapolski 820bc9267e drivers: flash: stm32l4: Fix STM32L4Q5 support in flash driver
Add STM32L4Q5xx to the list of MCUs that have 4kB flash pages,
instead of 2kB.

Signed-off-by: Marcin Zapolski <mz4pol@gmail.com>
2023-07-19 09:51:18 +00:00
Andrzej Głąbek 41c33d7f32 drivers: flash: nrf_qspi_nor: Fix writing from unaligned RAM buffers
Flash API states that drivers should support write requests without
any restrictions on location or alignment of the source buffer.
Due to hardware limitations of the QSPI peripheral, the nrf_qspi_nor
driver currently fails to perform a write from a RAM buffer that is
not word-aligned. Fix this by using in such case the same mechanism
that is used when the source buffer is located in the internal flash
(copy data to a buffer located on stack).
Also correct the length parameter for writes from this stack-based
buffer to be the actual data chunk length, not always the size of
the buffer (as for CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE > 4
this may lead to overwriting of some data located next in the flash).

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2023-07-13 12:09:02 +02:00
Guillaume Gautier cbf9f3d4c2 drivers: flash: stm32: add stm32wba support
Add Flash STM32WBA support

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2023-07-11 15:05:05 +02:00
Alberto Escolar Piedras 2d3c53f705 flash simulator: Refactor native part so it works with emb libC
Refactor the part of the flash simulator that interacts with the
host when build for native platforms, so it is possible to use
it also with the embedded libCs.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-07-10 09:50:56 +02:00
Jordan Yates b0db69d622 drivers: flash: spi_nor: exit DPD in all cases
Exit DPD on init in all cases, even when `CONFIG_SPI_NOR_IDLE_IN_DPD` is
not enabled.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-07-05 14:13:43 +02:00
Jordan Yates ec44816ae7 drivers: flash: spi_nor: support device PM
Support device power management in spi_nor driver. Only use
SUSPEND/RESUME if `CONFIG_SPI_NOR_IDLE_IN_DPD` is not enabled to avoid
state conflicts.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-07-05 14:13:43 +02:00
Francois Ramu 06b8f4b994 drivers: flash: stm32 qspi driver with read SFDP ID from quadflash
This commit adds the jedec216 read sfdp and Read ID
function API. The qspi commands are issued to the
quad flash device.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2023-06-23 10:51:06 +00:00
Lucas Tamborrino 8acedc61d1 drivers: flash: esp32xx: use K_NO_WAIT when in ISR
Avoid timeout when taking semaphores in ISR.

This enables flash operations inside interrupted context
such as exceptions, allowing operations like saving core
dump to flash for instance.

Signed-off-by: Lucas Tamborrino <lucas.tamborrino@espressif.com>
2023-06-21 16:06:06 -04: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
Daniel Leung 26ecaba4af drivers: syscalls: use zephyr_syscall_header
This adds a few line use zephyr_syscall_header() to include
headers containing syscall function prototypes.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-06-17 07:57:45 -04:00
Daniel DeGrasse 095d453d7a drivers: flash: flash_mcux_flexspi_*: copy LUT to ram when updating
Copy the LUT to SRAM before updating it. This avoids the application
reading LUT entries from FlexSPI while trying to write them to FlexSPI
configuration registers, which could result in invalid LUT entries being
added.

This update is applied to all in tree flash FlexSPI drivers, although
the failure has only been observed with the flash_mcux_flexspi_nor
driver.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2023-05-25 21:37:18 -05:00
Marek Matej 4796746b5e soc: esp32: MCUboot support
This make MCUboot build as Zephyr application.
Providing optinal 2nd stage bootloader to the
IDF bootloader, which is used by default.
This provides more flexibility when building
and loading multiple images and aims to
brings better DX to users by using the sysbuild.
MCUboot and applications has now separate
linker scripts.

Signed-off-by: Marek Matej <marek.matej@espressif.com>
2023-05-25 16:15:54 +02:00
Francois Ramu dced627c28 drivers: flash stm32 qspi driver dma callback for positive statuses
Like other stm32 drivers, especially the stm32 flash ospi,
the DMA callback accepts a null or positive status.
It returns an error in case of negative.
BTW it also sets variable as unused, like stm32 flash ospi does.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2023-05-25 13:33:58 +00:00
Carlo Caione 6f3a13d974 barriers: Move __ISB() to the new API
Remove the arch-specific ARM-centric __ISB() macro and use the new
barrier API instead.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-05-24 13:13:57 -04:00
Carlo Caione cb11b2e84b barriers: Move __DSB() to the new API
Remove the arch-specific ARM-centric __DSB() macro and use the new
barrier API instead.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-05-24 13:13:57 -04:00
Jeppe Odgaard 6b0a4cc204 drivers: flash: fix memcpy and invalidate dcache in hyperflash
Replace memcpy usage in write since it is not linked to non-external
flash which might cause read-while-write issues.
Move the function that invalidated the data cache inside the critical
section to avoid context switch before it is invalidated.

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2023-05-22 10:15:03 +02:00
Daniel DeGrasse e58d0c3bb5 drivers: flash: hyperflash driver no longer stores controller data in ROM
Store controller reference in RAM, to avoid flash access in critical
section.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2023-05-22 10:15:03 +02:00
Jeppe Odgaard 0ad95994c1 drivers: flash: check xip before configure device in hyperflash init
Check memc_flexspi_is_running_xip before calling
memc_flexspi_set_device_config in hyperflash init.
This aligns with the nor flash driver.

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2023-05-22 10:15:03 +02:00
Jeppe Odgaard ecd2f51386 drivers: flash: fix hyperflash write operations
Hyperflash write operations resulted in invalid writes. This commit
fixes the issue by temporarily lowering the clock during writes.
This aligns with the mcux-sdk-examples.

Fixes https://github.com/zephyrproject-rtos/zephyr/issues/53855

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2023-05-22 10:15:03 +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
Sreeram Tatapudi 861a7639ab drivers: flash: Fix kconfig dependency
- Update KCONFIG for flash driver to depend on
DT_HAS_FIXED_PARTITIONS_ENABLED, since that is necessary for the
driver implementation

Signed-off-by: Sreeram Tatapudi <sreeram.praveen@infineon.com>
2023-05-10 16:49:59 +09:00
Andrzej Głąbek 0b573a1f38 drivers: spi_flash_at45: Fix erasing of first two sectors
Most available AT45 flash chips have their first two sectors shorter
than the consecutive ones. Usually, the first sector is marked as 0a
and has its size equal to eight pages (one block) and the second one
(usually 0b) is the complement to the size of a regular sector.
This commits modifies the driver so that erasing of these first two
sectors is performed correctly. This modified behavior is configurable
with a new DT property so that it is still possible to also use legacy
AT45 chips that do not feature such sector split. Such legacy chips
usually also do not support the chip erase and sector erase commands,
so two more DT properties are introduced to cover that.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2023-05-09 12:22:15 +02:00
Sreeram Tatapudi 98858f1e6a drivers: flash: Add Infineon CAT1 Flash driver
- Added initial version of Infineon CAT1 Flash driver
- Added binding file for infineon,cat1-flash-controller.yaml
- Added overlays for subsys/nvs and drivers/flash_shell
to support cy8cproto_063_ble, cy8cproto_062_4343w boards
- Defined erase-block-size in PSoC6 MPN dtsi.

Signed-off-by: Sreeram Tatapudi <sreeram.praveen@infineon.com>
2023-05-08 11:16:09 +02:00
Alberto Escolar Piedras 3e70063f94 drivers: nrf5 flash: Fix for simulation
Use new nrfx hal function to memcpy from flash
instead of accessing the array directly.
That function is inlining a memcpy for real targets,
so there is no practical difference for those.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-05-08 10:08:35 +02: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
Laczen JMS d496a17bb6 flash_simulator: add ability to use memory region
Add the ability for the flash simulator to store its contents in a
memory region.

This allows filesystems on the flash simulator to survive a reboot.
And allows subsystems (e.g. coredump) to store their info on ram while
using the (existing) flash partition backend.

Add a example (for nucleo_f411re) that shows how to configure the flash
simulator for hardware (cfg discussion #54166).

Signed-off-by: Laczen JMS <laczenjms@gmail.com>
2023-05-04 20:49:57 +02:00
Frank Buss e34a784b5a drivers: flash: 4 byte address mode fix, if write enable is required
This fixes this bug:
https://github.com/zephyrproject-rtos/zephyr/issues/57498
If bit 1 is set, then a write enable is required before
sending the 0xb7 instruction to enable the 4 byte address
mode, which this PR implements.

Signed-off-by: Frank Buss <fb@frank-buss.de>
2023-05-04 10:45:19 +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
Lucas Tamborrino b24d9ca7a6 drivers: flash: esp32s3: Add spiflash support
Add support for spiflash to esp32s3

Signed-off-by: Lucas Tamborrino <lucas.tamborrino@espressif.com>
2023-04-28 10:08:16 +02:00
Andrzej Głąbek 7b8170dd27 drivers: flash: nrf_qspi_nor: Mark device as busy when locked
Mark the device as busy when it is locked to perform a flash operation
so that the PM subsystem does not try to suspend it. Also refuse to run
a PM action when the device is busy (in case `qspi_nor_pm_action()` is
called directly, not by the PM subsystem).

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2023-04-25 08:46:50 -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
Alberto Escolar Piedras bdb8024df3 drivers: flash simulator: Add more options for POSIX arch
For the POSIX architecture, add options to:
* Clear the flash content at boot
* To delete the file on exit
* To just keep the flash in RAM instead of a file in disk

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-04-21 16:23:45 +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
Gerard Marull-Paretas 1eb683a514 device: remove redundant init functions
Remove all init functions that do nothing, and provide a `NULL` to
*DEVICE*DEFINE* macros.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-19 10:00:25 +02:00
Andrzej Głąbek 8fba8aa535 drivers: flash: nrf_qspi_nor: Add custom API function to allow XIP
Normally, the driver deactivates the QSPI peripheral for periods when
no QSPI operation is performed. This is done to avoid increased current
consumption when the peripheral is idle. For the same reason, the base
clock on nRF53 Series SoCs (HFCLK192M) is configured for those periods
with the default /4 divider that cannot be used otherwise. However,
when XIP accesses are used, the driver must be prevented from doing
both these things as that would make XIP to fail. Hence, a function
is provided so that applications can inform the driver that XIP is
needed and the above idle actions should be suppressed.
This function (`nrf_qspi_nor_xip_enable()`) replaces the old one
(`nrf_qspi_nor_base_clock_div_force()`) that was intended for similar
purpose but after deactivation of the peripheral was introduced in
commit 95d867e8ed it became useless.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2023-04-17 16:43:16 +02:00
Gerard Marull-Paretas 667eeb11fb shell: fix MISRA 5.7 violations on struct shell
MISRA Rule 5.7 requires uniqueness of tag identifiers. Shell is
frequently problematic because many code uses `const struct shell
*shell`. This causes CI noise every time one of these shell files is
edited, so let's update all of them with `const struct shell *sh`
instead.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-14 12:21:08 +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
Gerard Marull-Paretas 0ebe14beb4 sys: util: migrate all files to DIV_ROUND_UP
ceiling_fraction is deprecated, use DIV_ROUND_UP.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-11 12:00:37 +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
Pieter De Gendt 6b532ff43e treewide: Update clock control API usage
Replace all (clock_control_subsys_t *) casts with (clock_control_subsys_t)

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-04-05 10:55:46 +02:00
Francois Ramu 64f6503eba drivers: flash: stm32 qspi driver with a valid dma and its channel
Fix the dma instance when a DMAMUX is enabled.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2023-04-04 10:08:07 -05:00
Patryk Duda 78ce5784eb drivers: flash: Add ex ops for STM32 option/control register block
Introduce flash extended operations that can be used to disable access
to option and control registers until reset. Disabling access to these
registers improves system security, because flash content (or protection
settings) can't be changed even when exploit was found.

On STM32 devices, registers can be locked until reset by writing wrong
key during unlock procedure. It triggers a bus fault, so during the
procedure we need to ignore faults and clear bus fault pending bit.

Please note that option register disabling was implemented for devices
that have OPTCR register (F2, F4, F7 and H7). Implementation on other
devices requires more testing, since documentation is not precise
enough. Disabling control register was implemented for devices that
have CR register.

Signed-off-by: Patryk Duda <pdk@semihalf.com>
2023-03-28 15:43:16 +00:00
Patryk Duda 417368e63d drivers: flash: Add support for defining custom RDP1 byte value
This patch makes possible to choose custom byte which should be used
to enable non-permanent readout protection (RDP1). Actually, any byte
except 0xAA and 0xCC (which are used by RDP0 and RDP2 respectively)
can be used to enable RDP1 but in multi-image environment, some other
image could check if RDP1 is enabled by comparing it to some hardcoded
value.

If property is not defined, 0x55 will be used to enable RDP1. The
default value comes from STM32 HAL.

Signed-off-by: Patryk Duda <pdk@semihalf.com>
2023-03-28 15:43:16 +00:00
Patryk Duda d652da5acb drivers: flash: Introduce readout protection support for STM32F4
This patch adds flash readout protection support for STM32F4 devices
family. These devices can enable protection on entire flash content.

Readout protection functionality was exposed as vendor extended
operation. To change readout protection state, caller should provide a
structure which describes desired RDP state.

Enabling readout protection permanently or disabling readout protection
(changing from level 1 to level 0) is guarded by
CONFIG_FLASH_STM32_READOUT_PROTECTION_PERMANENT_ALLOW and
CONFIG_FLASH_STM32_READOUT_PROTECTION_DISABLE_ALLOW respectively.

Signed-off-by: Patryk Duda <pdk@semihalf.com>
2023-03-28 15:43:16 +00:00
Patryk Duda b6078cc906 drivers: flash: Introduce write protection support for STM32F4
This patch adds sector write protection support for STM32F4 devices
family. These devices can protect flash content with sector precision.

Write protection functionality was exposed as vendor extended operation.
To change write protection state, caller should provide mask of enabled
and disabled sectors.

Function responsible for locking/unlocking option bytes was implemented
for all STM32 devices supported by this driver.

Signed-off-by: Patryk Duda <pdk@semihalf.com>
2023-03-28 15:43:16 +00:00
Francois Ramu a62fc404be drivers: flash: stm32 flash drivers supports the new stm32h5 serie
Introduce the stm32h5 serie to the the existing flash driver
It is based on the stm32l5 model.
 Add a function to check if the flash is in dual
or single bank mode.
Some stm32 devices can map 2 or 1 flash banks.
Adapt the FLASH register names for the stm32h5 mcu.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2023-03-28 15:07:51 +02:00
Henrik Brix Andersen c41dd36de2 drivers: kconfig: unify menuconfig title strings
Unify the drivers/*/Kconfig menuconfig title strings to the format
"<class> [(acronym)] [bus] drivers".

Including both the full name of the driver class and an acronym makes
menuconfig more user friendly as some of the acronyms are less well-known
than others. It also improves Kconfig search, both via menuconfig and via
the generated Kconfig documentation.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-03-28 15:06:06 +02:00
Vinayak Kariappa Chettimada 643723479f drivers: flash: nRF: Move sync ticker to Subsys Bluetooth Controller
Move the SoC Flash nRF sync ticker implementation into
Bluetooth Controller Subsystem folder, as internal headers
are included.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-03-21 12:33:32 +01:00
Zack Cornelius a3288252ff drivers: flash: nrf_qspi_nor: Add runtime PM
Add PM_DEVICE_RUNTIME support to nordic QSPI NOR flash driver, putting
the QSPI peripheral and flash ship into DPD if available

Signed-off-by: Zack Cornelius <zcornelius@securityesys.com>
2023-03-20 16:29:47 +01:00
Patryk Duda 8a85f0e87f drivers: flash: Introduce API function for flash extended operations
Besides of standard flash operations like write or erase, flash
controllers also support additional features like write protection or
readout protection. These features are not available in every flash
controller, what's more controllers can implement it in a different way.

It doesn't make sense to add a separate flash API function for every
flash controller feature, because it could be unique (supported on small
number of flash controllers) or the API won't be able to represent the
same feature on every flash controller.

Extended operation interface provides flexible way for supporting flash
controller features. Code space is divided equally into Zephyr codes
(MSb == 0) and vendor codes (MSb == 1). This way we can easily add
extended operations to the drivers without cluttering the API or
problems with API incompatibility. Extended operation can be promoted
from vendor codes to Zephyr codes if the feature is available in most
flash controllers and can be represented in the same way.

Signed-off-by: Patryk Duda <pdk@semihalf.com>
2023-03-14 11:17:13 +01:00
Gerard Marull-Paretas 27b73a116f soc: arm: nordic_nrf: replace NRF_DT_CHECK_PIN_ASSIGNMENTS
Since PINCTRL and pinctrl-0 is now required, there's no point in doing
extra validation at driver level. Modify the macro to just check that
sleep state is present when needed, since it was the only remaining
assertion that was not covered. Renamed the macro to make it more clear
what it does: NRF_DT_CHECK_NODE_HAS_PINCTRL_SLEEP

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-02-28 08:42:05 -08:00
Gerard Marull-Paretas 708a00d587 drivers: flash: nrf_qspi_nor: drop -pin support
Driver will now use pinctrl only.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-02-28 08:42:05 -08:00
Pieter De Gendt a6ff01cc3d drivers: flash: spi: Move to using select in Kconfig for SPI bus
Move to using 'select SPI' instead of 'depends on SPI'
(see commit df81fef for more details)

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-02-27 14:35:15 +01:00
Francois Ramu 9363a9319e drivers: flash: stm32 qspi Enter 4-Byte Address Mode
No need to read back the CR (NOR flash config or control register)
to check if entering the 4-Byte Address Mode is effective.
The action of this command is immediate and the result
(bit field of the CR) is NOR flash vendor-specific.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2023-02-24 09:13:44 +01:00
Emil Gydesen ab6a26ab17 flash: flash_shell: Fix check_arr size
The check_arr used the TEST_ARR_SIZE value for the size, but
has been removed and replaced with CONFIG_FLASH_SHELL_BUFFER_SIZE.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-20 19:41:17 +09:00
Dominik Ermel a33186a8f9 drivers: flash: spi_nor: Return EINVAL when erase out of range
Fixes spi_nor_erase to return -EINVAL instead of -ENODEV
when erase requested is out of flash range.
This makes the SPI NOR return the same error as all other errors.

Fixes #54897

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-02-20 10:54:00 +01:00
Hein Wessels e2c9d30578 drivers: flash: shell: default test repeat parameter when not supplied
Previously when the repeat argument wasn't supplied to the shell
command it would falsely seem to succeed, even though the
test was never run. Instead of displaying an error message this
rather overrides the repeat to 1, so that the test is run once.

Signed-off-by: Hein Wessels <heinwessels93@gmail.com>
2023-02-20 09:49:22 +01:00
Hein Wessels 636a1615b3 drivers: flash: shell: add verify step to cmd_test
Previously cmd_test could falsely give the indication that the
flash driver is functioning properly, because the written data
isn't validated and could have silently failed.

This commit adds a verify step to ensure the data was written successfully.

Signed-off-by: Hein Wessels <heinwessels93@gmail.com>
2023-02-20 09:49:22 +01:00
Jamie McCrae 3c9d529899 flash: flash_shell: Add flash read/write/erase speed test commands
Adds commands which can be used for timing flash device tasks and
outputting a rough speed.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-02-20 09:48:24 +01:00
Maciej Zagrabski 7ca8accdc6 drivers: flash: fix uninitialised layout_size
Requesting page layout triggers filling bank array
only once, and returns pre-filled array on consequential calls.
But ignores array size.

Remember size of this array as well.

Fixes #54563

Signed-off-by: Maciej Zagrabski <mzi@trackunit.com>
2023-02-08 19:01:32 +09:00
Mario Jaun e3c1747d80 drivers: flash: stm32_qspi: handle 4-byte addressing only chips
Correctly initialize driver if flash chip supports 4-byte addressing
only.

Signed-off-by: Mario Jaun <mario.jaun@gmail.com>
2023-01-27 23:31:39 +09:00
Michael Larson 0267612305 drivers: flash: spi_nor: Fix spi_nor_sfdp_read conditional
spi_nor_sfdp_read is now called from spi_nor_process_sfdp for the
CONFIG_SPI_NOR_SFDP_RUNTIME case and that could be defined without
CONFIG_FLASH_JESD216_API being defined

Signed-off-by: Michael Larson <larson@whisper.ai>
2023-01-27 01:21:52 +09:00
Francois Ramu 05da8d7a7a drivers: flash: stm32 page layout size differs in stm32u5 or stm32l5
Adjust the size of the stm32_flash_layout[] table depending on the
bank configuration of the stm32u5 or stm32l5 devices.
That will avoid div by zero error in flash_get_page_info()
if the layout_size is not correct.
Assign the *layout_size only once with the correct value : 3 or 1.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2023-01-27 01:05:44 +09: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
Nickolas Lapp be2906a64c NRF_QSPI_NOR: Exit DPD mode regardless of CONFIG_PM_DEVICE.
A call to exit_dpd mode for the nrf QSPI nor flash should always be
made, even if the currently executing image is compiled with
CONFIG_PM_DEVICE=n, because a previously executing image could have set
the device into DPD mode, and a call to exit_dpd is required for proper
functionality. Call `exit_dpd` regardless of the setting of
CONFIG_PM_DEVICE during QSPI nor initialization.

Signed-off-by: Nickolas Lapp <nickolaslapp@gmail.com>
2023-01-23 10:10:49 +00:00
Daniel DeGrasse 47271ce8be treewide: update usage of zephyr_code_relocate
Update usage of zephyr_code_relocate to follow new API. The old method
of relocating a file was the following directive:

zephyr_code_relocate(file location)

The new API for zephyr_code_relocate uses the following directive:

zephyr_code_relocate(FILES file LOCATION location)

update in tree usage to follow this model. Also, update the NXP HAL SHA,
as NXP's HAL uses this macro as well.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2023-01-17 18:08:37 +01:00
Francois Ramu 302983fd7d drivers: flash: stm32 qspi 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.
The HAL_QSPI_Init() accepts Init.FlashSize where "FlashSize+1
is effectively the number of address bits
required to address the flash memory."
To get 64MBytes = 2^26, the value of the Init.FlashSize must be 25.
and bit written to the DCR = 25.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2023-01-11 09:39:47 +01: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
Mathis Raemy c4b07e8321 drivers: flash: bug fix inline function was not inlined
During flash operation, you have to disable XiP which force function
to be located in RAM. On top of that, the function `flash_put_cmd_addr`
is time critical so we need to declare as inline. For some reason,
sometimes the function was not really inline. Changed it to
ALWAYS_INLINE fixed the bug.

Signed-off-by: Mathis Raemy <mathis.raemy@gmail.com>
2023-01-10 09:26:37 +01:00
Marco Peter ec3857dbcf drivers: flash: stm32: Use consistent log priorities
Any error erasing the flash might want to log
the event with "ERROR" priority.

Signed-off-by: Marco Peter <marco.peter@joylab.ch>
2023-01-09 19:19:49 +01:00
Erwan Gouriou af0576b7ea drivers: flash: stm32: Remove useless Kconfig
SOC_FLASH_STM32_V1 is not used anymore.
Remove it

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2023-01-08 19:49:12 +01:00
Erwan Gouriou cc1601fde7 driver: flash: stm32: Use compat information to select file to build
Now that compatible is directly linked with driver version,
use DT compat based Kconfig flag to build the correct flash driver
version.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2023-01-08 19:49:12 +01:00
Erwan Gouriou a934cce35b drivers: flash: stm32: Rename v1 driver into f1x
Instead of introducing a vX driver version, use series name.
With this commit F0, F1, F3, L0 and L1 series are using F1 flash driver.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2023-01-08 19:49:12 +01:00
Erwan Gouriou 4b67b98830 drivers: flash: stm32: Fix CmakeLists issue
Missing "x" prevents to find the right file.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2023-01-03 11:18:55 -05:00
Yonatan Schachter abe50cc929 rpi_pico: Fix DTC warnings concerning the flash
The addresses of the flash and flash controller of the RP2040
SoC were mixed up. There was no clear distinction between the
flash and the flash controller, which was unclear but also
caused a DTC warning.
This commit makes the distinction clearer: The SSI peripheral at
0x18000000 is the flash controller, and the flash itself starts
at 0x10000000. The flash driver and rpi_pico.dts were fixed
accordingly.

Signed-off-by: Yonatan Schachter <yonatan.schachter@gmail.com>
2023-01-03 13:37:23 +01:00
Erwan Gouriou cbef00587b drivers: flash: stm32: Rename _l5_u5.c driver to _l5x.c
This will simplify addition of new series that share the same driver.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2023-01-03 11:01:44 +01:00
Emilio Benavente 39762716d4 boards: arm: rtxxx: moving the instances FLASH_MCUX_FLEXSPI_XIP
This Kconfig is moved to the soc level since it determines
the flexspi clock initialization for XIP.

Signed-off-by: Emilio Benavente <emilio.benavente@nxp.com>
2022-12-22 11:07:08 +01:00
Erwan Gouriou 66d4c64966 all: Fix "#if IS_ENABLED(CONFIG_FOO)" occurrences
Clean up occurrences of "#if IS_ENABLED(CONFIG_FOO)" an replace
with classical "#if defined(CONFIG_FOO)".

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-12-21 10:09:23 +01:00
Erwan Gouriou 39e6d62b66 drivers: flash: stm32: Kconfig clean up
FLASH_PAGE_LAYOUT and FLASH_HAS_PAGE_LAYOUT are systematically
selected, whatever the series.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-12-19 18:15:45 +01:00
Andrzej Głąbek 5def5e6edf drivers: nrf_qspi_nor: Avoid using QSPI with HFCLK192M divided by 4
The nRF5340 product specification states that the QSPI peripheral
supports 192 MHz and 96 MHz PCLK192M frequency, thus the default /4
divider for HFCLK192M (from which PCLK192M is derived) can only be
used when the QSPI peripheral is idle. Correct the shim accordingly
and improve related comments.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-12-19 18:11:59 +01:00
Cyril Fougeray 00ceb258d3 drivers: flash: clear stm32 status register errors
In case of errors in the status register and to
unblock Flash, it is advised to clear the errors.

Signed-off-by: Cyril Fougeray <cyril.fougeray@worldcoin.org>
2022-12-15 14:31:37 +00:00
Bartosz Bilas e077fb73ec drivers: tests: replace usage of spi_is_ready with spi_is_ready_dt
`spi_is_ready` function is being deprecated in favor of
`spi_is_ready_dt` so let's replace the old usage in the tree.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2022-12-07 09:40:23 -06:00
Peter Maxwell Warasila 55ce3026c9 drivers: flash: stm32l5_u5: refactor flash_stm32_page_layout() for clarity
While diagnosing a problem on the STM32U585 in this function in
flash_stm32l5_u5.c, I had difficulty sussing out the flow of the
function and conditional logic.

This refactor seeks to improve clarity through a simplified flow control
using an early return to short circuit logic on subsequent calls to the
function and slightly more thorough comments.

Tested using tests/drivers/flash on the b_u585i_iot02a and in a
proprietary application and board which uses the STM32U585 and littlefs.

Signed-off-by: Peter Maxwell Warasila <madmaxwell@soundcomesout.com>
2022-11-30 17:30:36 +01:00
Peter Maxwell Warasila ed3ad75a7a drivers: flash: stm32l5_u5: fix L5/U5 difference in FLASH_PAGE_NB
In flash_stm32_page_layout, the FLASH_PAGE_NB macro is used to set the
page count in the flash layout returned to the caller. On STM32L5
platforms this is defined in stm32l5xx_hal_flash.h to be (FLASH_SIZE /
FLASH_PAGE_SIZE). However, on STM32U5 platforms the macro is defined in
the soc headers (such as stm32u585xx.h) define the macro as
(FLASH_BANK_SIZE / FLASH_PAGE_SIZE). This results in the flash layout
only reflecting the first bank on STM32U5 platforms with the maximum 2
MB of flash.

This commit resolves this discrepancy by directly calculating the number
of pages by dividing FLASH_SIZE by FLASH_PAGE_SIZE.

Tested on a proprietary board using the STM32U585 which mounts a
littlefs partition in the last 256 kB of its 2 MB of flash.

Signed-off-by: Peter Maxwell Warasila <madmaxwell@soundcomesout.com>
2022-11-30 17:30:36 +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
Patryk Duda b9f495282e drivers: flash: Do not unlock CR at the end of initialization
Unlocking CR at the end of initialization was added in commit
a9183cd518. It was probably copied
from previous flash driver implementation.

Unlocking and locking CR in write and erase functions was added in
commit 6e4cdb0c99. Since we always unlock
the register before writing or erasing, and lock it after the operation
is finished, there is no need to unlock it after initialization.

Signed-off-by: Patryk Duda <pdk@semihalf.com>
2022-11-29 09:50:28 +01:00
Attie Grande 5f9cab9e80 drivers: flash: sam0: Resolve write issues in the first row
Previously, while writing close to the start of flash (i.e: in the first
row), the write was never committed - due to zero being used as the
"empty buffer" marker.

This patch also incorporates some performance improvements, as well as
observing any errors reported by `flash_sam0_commit()`.

Fixes #52309

Signed-off-by: Attie Grande <attie.grande@argentum-systems.co.uk>
2022-11-28 10:49:09 +01: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
Gregers Gram Rygg f9b5138097 drivers: flash: spi_nor: add macronix high performance mode
Add property mxicy,mx25r-power-mode to jedec,spi-nor binding for
controlling low power/high performance mode on Macronix MX25R* Ultra Low
Power flash devices.

- "low-power" configures the flash in ultra low power mode.
- "high-performance" configures the flash in high performance mode.

Signed-off-by: Gregers Gram Rygg <gregers.gram.rygg@nordicsemi.no>
2022-11-15 14:58:26 +01:00
Yonatan Schachter f633b17c7c drivers: flash: Add flash driver for rpi_pico series
Add a flash driver for the rpi_pico

Signed-off-by: Yonatan Schachter <yonatan.schachter@gmail.com>
2022-11-15 12:12: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
Gregers Gram Rygg c9e07fc385 drivers: flash: spi_nor: fix flash busy during init
After a soft-reset of the host controller the flash device is not reset.
This can cause the flash device to still be busy writing or erasing when
the host controller boots and initializes the flash. The often results
in errors and the flash device not being initialized.

This fix polls the status register until the WIP flag is off before
initializing the flash device.

Fixes #51713

Signed-off-by: Gregers Gram Rygg <gregers.gram.rygg@nordicsemi.no>
2022-11-10 11:11:11 +01:00
Tim Lin 0789442132 ITE: soc: chip_chipregs: Access registers using structure method
Access registers using structure method.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2022-11-09 10:44:29 +01:00
Tim Lin b3f46ccaec ITE: cleanup: soc: chip_chipregs: Rename the structure name of register
Rename the structure of flash_it8xxx2_regs to smfi_it8xxx2_regs.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2022-11-09 10:44:29 +01:00
Kamil Serwus cad62fae61 soc: atmel: add base support for C2x SOC
Adds Atmel SAMC20 and SAMC21 soc. C series is based on Cortex-M0+.
C21 contains CAN interface.

The init routines are same for SAMC20 and SAMC21. They use one
clock OSC48M without configuration.

The code is inspirated from atmel_sam0/samd21.

Signed-off-by: Kamil Serwus <kserwus@gmail.com>
2022-11-04 16:03:01 +01:00
Pieter De Gendt 1ccd609376 drivers: flash: spi_flash_at45: Add device_is_ready for GPIO outputs
Verify that the GPIO port is ready before configuring.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2022-11-02 16:12:14 -05:00
Pieter De Gendt 850e6bd23e drivers: flash: spi_flash_at45: Use gpio_pin_set_dt helper
Replace occurrences of gpio_pin_set with the _dt helper.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2022-11-02 16:12:14 -05:00
Peter Marheine d4549ed808 it8xxx2: generalize ILM support
Executing code out of RAM on IT8xxx2 requires that the relevant
addresses be mapped onto the CPU's instruction memory bus, referred to
by ITE documentation as Instruction Local Memory (ILM). ILM mappings
configure blocks of RAM to be used for accesses to chosen addresses when
performing instruction fetch, instead of the memory that would normally
be accessed at that address.

ILM must be used for some chip features (particularly Flash
self-programming, to execute from RAM while writing to Flash), and has
historically been configured in the Flash driver. The RAM for that was
hard-coded as a single 4k block in the linker script.  Configuring ILM
in the flash driver is confusing because it is used by other SoC code as
well, currently in code that cannot depend on the Flash being functional
or in hand-selected functions that seem performance-critical.

This change moves ILM configuration to a new driver and dynamically
allocates RAM to ILM in the linker script, allowing software use of the
entire 64k RAM depending on configuration.  This makes ILM configuration
more discoverable and makes it much easier to correctly support the
CODE_DATA_RELOCATION feature on this SoC.

Signed-off-by: Peter Marheine <pmarheine@chromium.org>
2022-10-21 20:31:47 +02:00
Gerard Marull-Paretas 4010ac103e include: add missing zephyr/irq.h include
Some files were using the IRQ APIs, e.g. irq_lock() without including
zephyr/irq.h.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-20 22:52:09 +09:00
Gerard Marull-Paretas b1a0d0ae86 include: add missing zephyr/kernel.h
Some files were using the Kernel APIs/types without including
zephyr/kernel.h.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-20 22:52:09 +09:00
Andriy Gelman 890e84a6aa drivers: flash: soc_flash_xmc4xxx: Add missing kernel.h header
Fixes build of flash_shell sample after commit
a6a4400b86.
west build -p -b xmc45_relax_kit samples/drivers/flash_shell

Also include stdint.h.

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2022-10-20 15:41:39 +02: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
Cyril Fougeray 9bc639dd59 drivers: flash: stm32: allow to overwrite zeros
On stm32g0, stm32g4, stm32l4, stm32l5, stm32u5,
and stm32wbx, it is allowed to write a zeroed dword
on unerased flash.

Signed-off-by: Cyril Fougeray <cyril.fougeray@worldcoin.org>
2022-10-17 10:14:32 +02:00
Andrzej Puzdrowski 1c3b9c91c8 drivers/flash/gd32_vX: add missing kernel header
Added missing zephyr/kernel.h inclusion

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2022-10-17 14:39:39 +09:00
Kyle Cooke 9892af1464 drivers: flash: soc_flash_nrf: Account for ticker in timeout
We have been encountering timeout issues when erasing large flash
 sections (before receiving an image via mcuboot) from this semaphore
 take:
5af0fbc2e3/drivers/flash/soc_flash_nrf_ticker.c (L225-L233)

I think this is because this constant is based on the time taken to erase
 the chip but doesn't take account of the fact it is being done by a
 ticker. If I understand correctly the ticker is a timeshare mechanism
 so the actual max erase time is some factor based on how much time is
 given to the task by the ticker.

This multiplies the max timeout by 1.5

Signed-off-by: Kyle Cooke <cookekyle97@gmail.com>
2022-10-13 16:06:08 +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
Gerard Marull-Paretas 6a0f554ffa include: add missing kernel.h include
Some files make use of Kernel APIs without including kernel.h, fix this
problem.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-11 18:05:17 +02:00
Gerard Marull-Paretas acc8cb4bc8 include: add missing irq.h include
Some modules use the IRQ API without including the necessary headers.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-11 18:05:17 +02:00
Gerard Marull-Paretas e63b0bb3fe include: add missing errno.h include
With the incoming removal of kernel.h/types.h from init.h, lots of files
start to show compile errors because they relied on indirect
definitions, including errno.h.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-11 18:05:17 +02:00
Ole Morten Haaland 667a3f9de9 qspi: stm32: Add support for reset cmd on init
If the flash is used in 4-byte addressing, reading SFDP will fail after
a system reset if the flash isn't power cycled or hardware reset, since
Zephyr will try to use 3-byte addressing while the flash (still) expects
4-byte addressing.

This commit adds the ability to send a reset command to the flash as part
of initialization, which complements the existing reset-gpio
functionality, and is useful on low-pincount flashes which do not have a
hardware reset.

Signed-off-by: Ole Morten Haaland <omh@icsys.no>
2022-10-11 11:14:46 +02:00
Dipak Shetty e97e24e7a6 drivers: flash_mcux_flexspi_nor: Add block erase
Change reduces time consumed when a block needs to be erased.
The change was tested on a mimxrt1060_evk board.

Signed-off-by: Dipak Shetty <dipak.shetty@zeiss.com>
2022-10-10 13:23:12 -05:00