Commit graph

760 commits

Author SHA1 Message Date
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
Franciszek Zdobylak 64feccf23d drivers: flash: shell: Add flash shell tools
This commit adds two new commands to flash shell tools: flash load and
flash page_info.

Signed-off-by: Franciszek Zdobylak <fzdobylak@internships.antmicro.com>
2022-10-06 22:35:57 +00:00
Andriy Gelman 072a428f78 drivers: flash: Add xmc4xxx flash drivers
Add xmc4xxx flash drivers.

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2022-10-03 13:56:49 +02:00
Peter Marheine 5eb75b81f7 arm: rename default RAM region from 'SRAM' to 'RAM'
It's useful for RAMABLE_REGION to have a uniform name when
CODE_DATA_RELOCATION is supported, because otherwise the build system
needs to be aware of how the region name differs between architectures.
Since architectures tend to prefer one of 'SRAM' or 'RAM' for that
region, prefer to use 'RAM' as the more general term.

Signed-off-by: Peter Marheine <pmarheine@chromium.org>
2022-10-03 10:09:53 +02:00
Andrzej Puzdrowski 102583ab7f drivers/flash: move JESD216 option into FLASH
This option is part of FLASH API configuration.
I moved it where it belongs.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2022-09-16 08:41:40 +00:00
Xinyang Tan 904181a6a9 drivers: flash: spi_nor: fix driver initialization error
Fix the issue that the initialization will fail when both
CONFIG_SPI_NOR_SFDP_RUNTIME and CONFIG_SPI_NOR_IDLE_IN_DPD are enabled.
The cause of this problem is simply calling the wrong function.

Fixes #33015

Signed-off-by: Xinyang Tan <xinyang.tan@delve.com>
2022-09-14 16:13:35 +01:00
Francois Ramu b6ee1dfe6e drivers: flash: octo spi for stm32 with DMA
Introducing the dma transfer (also through dmamux)
to transfer data to/from the NOR octo-flash
With a DMAMUX, the DMA channel is given by the DTS.
Note that STM32U5X does not support DMA here.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2022-09-08 10:07:21 +00:00
HaiLong Yang 51363ae7c2 drivers: flash: introduce gd32 fmc driver
This supports three types GD32 FMC flash memory. GD32 FMC v1,
GD32 FMC v2 and GD32 FMC v3.

GD32 FMC v1 for small flash memory, flash size can be up to 512KB.

GD32 FMC v2 for large flash memory, flash size can be up to 3072KB.

GD32 FMC v3 not use page but sector as minimum block, flash size can
be up to 3072KB.

Signed-off-by: HaiLong Yang <hailong.yang@brainco.cn>
2022-09-08 10:13:05 +02:00
Gerard Marull-Paretas 8081d7f2a4 drivers: s/DT_CHILD(DT_DRV_INST(n), ...)/DT_INST_CHILD(n, ...)
Use instance version of DT_CHILD when possible.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-09-06 08:45:25 -07:00
Vinayak Kariappa Chettimada 3e5ea793b7 drivers: flash: nrf: Fix ticker stop user id value
Ticker stop callback are executing in ULL_HIGH priority,
correct the value to 1U instead of 0U which is for LLL
execution context of the Bluetooth Controller.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-05 17:36:48 +02:00