Commit graph

1230 commits

Author SHA1 Message Date
Laczen JMS
294e2df2d9 flash_page_layout: refactor flash_page_get_info
refactor flash_page_get_info to simplify and to avoid using mixing the
usage of an off_t (offs) and an uint32_t (page_index).

Signed-off-by: Laczen JMS <laczenjms@gmail.com>
2021-07-10 14:48:22 -04:00
Abram Early
bdae64279e drivers: flash: nrf_qspi_nor: Configurable RXDELAY
The nRF QSPI has a configurable delay from the rising
clock signal to the actual sample point measured in
clock cycles. This commit exposes that delay as a DTS
parameter without modifying existing behavior.

Signed-off-by: Abram Early <abram.early@gmail.com>
2021-07-09 12:23:45 -05:00
Dominik Ermel
f36569db0d drivers/flash/nrf_qspi_nor: Fix get_parameters layout dependency
The definition of qspi_flash_get_parameters, that implements
the mandatory get_parameters API call for the driver, was incorrectly
placed within block conditionally compiled when
CONFIG_FLASH_PAGE_LAYOUT is defined.
The commit fixes the issue that was causing compilation error
when the config has not been set.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-07-09 12:19:06 -05:00
Sylvio Alves
4303cfdb3c hal: esp32: driver changes to allow HAL update
hal_espressif repository was updated from esp-idf v4.2
to esp-idf v4.3 to allow latest Espressif chips integration.
As a consequence, it added a few changes in drivers
and peripherals. To maintain bisectability, changes in this
PR cannot be split. Here are some details:

wifi: update linker script by adding libphy and new attributes.

spi: update some APIs and fixed missing wait_idle check

west.yml: esp32: update hal to new version

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2021-07-07 15:01:16 -04:00
Gerard Marull-Paretas
cc2f0e9c08 pm: use enum for device PM states
Move all PM_DEVICE_STATE_* definitions to an enum. The
PM_DEVICE_STATE_SET and PM_DEVICE_STATE_GET definitions have been kept
out of the enum since they do not represent any state. However, their
name has not been changed since they will be removed soon.

All drivers and tests have been adjusted accordingly.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-07 14:13:12 -04:00
Krishna Mohan Dani
4c38ca1625 drivers/flash: stm32: Gets maximum erase time from device tree
This commit removes the huge if condition section and is
replaced with DT APIs to get the maximum erase time of a
stm32 flash from dtsi.

Signed-off-by: Krishna Mohan Dani <krishnamohan.d@hcl.com>
2021-07-06 19:02:19 -04:00
Jordan Yates
fb76f47f86 flash: spi_nor: convert to spi_dt_spec usage
Converts the spi_nor flash driver to use `spi_dt_spec` as a
demonstration of the simplifications that the API enables.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-07-02 21:34:16 -04:00
Alexandre Bourdiol
64d2449185 drivers: flash: stm32f7: Flush ART cache before Flash erase
Similar to #32218 and #34032
Flush ART cache before erase operation
(preparing ART activation)

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
2021-06-28 14:17:40 -04:00
Alexandre Bourdiol
5e11fbfbe1 drivers: flash: stm32g4: implement data cache errata
Disable data cache to avoid the silicon errata ES0430 Rev 7 2.2.2
"Data cache might be corrupted during Flash memory read-while-write
operation"

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
2021-06-28 14:17:40 -04:00
Alexandre Bourdiol
feacc2e16e drivers: flash: stm32f4: implement data cache errata
Disable data cache to avoid the silicon errata ES0206 Rev 16 2.2.12
"Data cache might be corrupted during Flash memory read-while-write
operation"

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
2021-06-28 14:17:40 -04:00
Alexandre Bourdiol
5650609c4c drivers: flash: stm32f4: Flush ART caches before Flash erase
Similar to #32218 and #34032
Flush ART caches before erase operation
(preparing ART activation)

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
2021-06-28 14:17:40 -04:00
Fabio Baltieri
5efea4283c drivers: flash: stm32f4: Flush caches after erase
This implement the same flush cache functionality already present in the
other stm32 series flash drivers, used to avoid bus errors when writing
big chunks of data to the flash.

Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
2021-06-28 12:35:41 -04:00
Fabio Baltieri
f0c4040159 drivers: flash_stm32: enable flash_stm32l4x for STM32WL series
The flash_stm32l4x driver seems to work out of the box on the WL series.

This just adds the necessary config changes to let the driver build and
run when SOC_SERIES_STM32WLX is selected.

Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
2021-06-28 12:35:41 -04:00
Tim Lin
ef3c8507a6 ite: drivers/flash: add flash driver for it8xxx2
Add flash driver for it8xxx2. The driver can implement
flash read, write and erase that will be mapped to the
ram section for executing.

TEST="flash write 0x80000 0x10 0x20 0x30 0x40 ..."
     "flash read 0x80000 0x100"
     "flash erase 0x80000 0x1000"

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2021-06-22 15:15:20 -04:00
Krishna Mohan Dani
27435cf6e5 drivers/flash: STM32: Adding flash driver for nucleo_f207zg
This commit adds the flash driver for nucleo_f207zg platform.
This has been tested with flash test application.

Signed-off-by: Krishna Mohan Dani <krishnamohan.d@hcl.com>
2021-06-17 12:40:39 +02:00
Erwan Gouriou
fcc3177509 drivers/pinmux: stm32: Move stm32 driver from stm32/
Since we removed various series headers, move stm32 driver
under main driver/pinmux folder.
Take this change into account into various drivers.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-06-11 08:04:39 -05:00
Alexandre Bourdiol
f021fa8e80 drivers: flash: stm32f4: Remove useless definition and use CMSIS
Remove useless definiton STM32F4X_SECTOR_MASK and use CMSIS instead.

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
2021-06-10 15:53:41 -05:00
Alexandre Bourdiol
6798135694 drivers: flash: stm32f7: Remove useless definition and use CMSIS
Remove useless definiton STM32F7X_SECTOR_MASK and use CMSIS instead.
By the way fix bug as '|' should be in fact '&',
but thanks to '~' inversion, '|' is now good.

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
2021-06-10 15:53:41 -05:00
Fabio Baltieri
b06f4a5e72 drivers: flash_stm32_v1: fix a potential unaligned access
The flash write function casts a void * to flash_prg_t, which can be 2,
4 or 8 bytes long depending on the SoC. This can trigger a hard fault
exception if data is not aligned, such as when passing a constant string
from settings_save_one().

Copying the chunk of data to a temporary variable on the stack to avoid
the problem.

Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
2021-06-08 11:15:59 -05:00
Krzysztof Chruscinski
8e6898ef14 drivers: flash: nrf_qspi_nor: Fix no multithreading compilation
Fixing error introduced in 951e72b947
where ifdef was converted to IS_ENABLED. Ifdef was required because
element in the struct does not exist when multithreading is disabled.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-05-28 15:32:43 +02:00
Krzysztof Chruscinski
951e72b947 drivers: flash: nrf_qspi_nor: Fix no multithreading configuration
File was failing to compile when multithreading was off.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-05-26 11:51:23 +02:00
Arvin Farahmand
d1d494e2b7 drivers: flash: bugfix: set atmel SAM0 write-block-size
`write-block-size` property in multiple Atmel SAM SoCs was either
missing or set incorrectly.

Signed-off-by: Arvin Farahmand <arvinf@ip-logix.com>
2021-05-25 11:59:45 -05:00
Flavio Ceolin
0c607adb63 pm: device: Align state names with system states
Change device pm states to the same pattern used by system power
management.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-07 18:35:12 -04:00
Flavio Ceolin
7eba310220 power: device: void *context -> uint32_t *state
The context parameter used across device power management is
actually the power state. Just use it and avoid a lot of
unnecessary casts.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-07 16:55:31 -04:00
Saurabh Jagdhane
721e3406e6 drivers: flash: Enable FlexSPI XIP on mimxrt685_evk.
Move LUT to driver.
Update CMake to include SoC specific driver.
Fix mimxrt685_evk LUT header spacing.

Signed-off-by: Saurabh Jagdhane <saurabh.jagdhane@nxp.com>
2021-05-07 15:44:19 -05:00
Eug Krashtan
793e2c1891 drivers: flash: at45: Add Reset and WP pins
Adding Reset and Write-protect pins initialization during AT45 driver
start-up. Usually these pins are driven high when not used.
The AT45 device incorporates an internal power-on reset circuit, so
there is no initial on-off reset sequence.

Signed-off-by: Eug Krashtan <eug.krashtan@gmail.com>
2021-05-07 14:57:08 -05:00
Rodrigo Brochado
037f994ed2 drivers: flash: Add workaround for anomaly 122 on nrf52840
The energy consumption on nrf52840 is unnecessarily high when
CONFIG_NORDIC_QSPI_NOR is used due to Anomaly 122. The nrf_qspi_nor
driver is unitialize after QSPI usage and initialize before using
it again.

Semaphore objects are used to allow multiple threads exclusive access
and efficient usage.

The main assumption made was that all QSPI API is stateless, in the
sense that it is not required to store any peripheral state before
uninit. Also, the QSPI driver was supposed to be synchronous, except
for the erase operation, in which the nrf signals its start, instead of
its end. While the flash is performing the erase, an uninit followed
by an init doesn't work. For that reason, polling is done before
every uninit.

Tests were made with a simple LittleFS application in a custom board
using flash MX25R3235F and another with the LittleFS flash sample
using nrf52840 DK that has a MX25R6435F. Current consumption dropped
from 630 uA to ~10uA in both cases.

Signed-off-by: Rodrigo Brochado <git.rodrigobrochado@gmail.com>
2021-05-07 10:26:21 -05:00
Andrzej Puzdrowski
df726f5afe drivers/flash/nrf_qspi_nor: fixed bad type casting
nrf_qspi_write_t was used instead of nrf_qspi_readoc_t in casting.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2021-05-06 08:32:19 -05:00
Gerard Marull-Paretas
56f1a8ce98 pm: rename PM_DEVICE_GET/SET_POWER_STATE to PM_DEVICE_STATE_GET/SET
Adjust name to be consistent with device PM naming conventions.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Gerard Marull-Paretas
dbf46b3815 pm: rename device_pm_cb to pm_device_cb
Prefix all device PM functions/data structures with pm.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Gerard Marull-Paretas
2c7b763e47 pm: replace DEVICE_PM_* states with PM_DEVICE_*
Prefix device PM states with PM.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Raphael Löffel
3abd88a64e drivers/flash: stm32h7: Fixed range validation
The range validation routine is not able to detect unaligned memory
blocks as it should.

Signed-off-by: Raphael Löffel <loeffel@rte-ag.ch>
2021-05-05 11:00:20 +02:00
Göran Weinholt
afc8c2528e drivers: flash: stm32h7x: handle ECC errors on read
The STM32H7x flash has an integrated ECC that can correct single
errors and detect double errors. When a double ECC error is detected,
the DBECCERR1/2 flag is raised and there is a bus fault.

We now mask this bus fault and check the error flags. ECC errors are
logged with the offset of the data. Single ECC errors cause a warning
to be logged and double ECC errors return -EIO.

Fixes #33140.

Signed-off-by: Göran Weinholt <goran.weinholt@endian.se>
2021-05-04 13:03:31 -05:00
Mahesh Mahadevan
cccb15e687 drivers: flash: MCUX: Split the relocate define based on target memory
Use the CODE_DATA_RELOCATION_SRAM config to indentify code relocated
to SRAM so we can setup the MPU for the SRAM region used for code
relocation.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2021-05-04 15:46:52 +02:00
Peter Bigot
5189f804a4 drivers: flash: spi_nor: unconditionally provide config pointer
Information about which block protect bits are set on power-up is not
inferable from SFDP content, so we need the devicetree config pointer
to get the has-lock property value even when SFDP data is read at
runtime.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-04-30 13:10:23 -05:00
Gerard Marull-Paretas
faeaea112e drivers: flash: remove usage of device_pm_control_nop
device_pm_control_nop is now deprecated in favour of NULL.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-04-28 10:55:35 -04:00
Thomas Stranger
4cd7ff65da drivers/flash: STM32: use clk dt definitions in h7 flash driver
This commit replaces driver hard coded clk bus and enr definitions with
definitions from device tree.

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2021-04-28 09:06:42 -05:00
Thomas Stranger
859b6d5bfe drivers/flash: STM32: Fix flash_stm32_priv definition for h7 series
This commit fixes missing pclken member if used for h7 series.
Additionally to the check if instance 0 of compatible
st_stm32_flash_controller has defined a clock,
this needs to be checked for compatible st_stm32h7_flash_controller.

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2021-04-28 09:06:42 -05:00
Peter Bigot
c26cdb7409 drivers: flash: spi-nor: add support for 4-byte addressing
Add a function that uses the JESD216 SFDP BFP DW16 Enter 4-Byte
Addressing parameter to put the device into 4-byte addressing mode if
one of the entry modes that's supported by the driver is available on
the device.

Perform the transition if SFDP data is provided (either by devicetree
or at runtime), or if a special devicetree property provides the entry
mode descriptor.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-04-27 14:21:15 +02:00
Peter Bigot
6c4312605c drivers: flash: jesd216: improve support for address size selection
Add a helper function to decode the address byte support data from the
SFDP BFP.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-04-27 14:21:15 +02:00
Peter Bigot
e0f514f670 drivers: flash: spi_nor: support 32-bit addresses in access method
Support both 24-bit and 32-bit address values when constructing the
device command.  Note that some commands require 24-bit address
regardless of mode, and some require 32-bit addresses regardless of
mode, so provide command-specific overrides of a generic (but not yet
configurable) default address size.

With this we no longer need a special interface for READ_SFDP which
uses a 24-bit address but with a wait state introduced by clocking out
a fifth command byte.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-04-27 14:21:15 +02:00
Peter Bigot
cde962e789 drivers: flash: spi_nor: refactor to allow more access options
This driver abstracts most access through a generic function that
supports both read and write with and without address components in
the command.  Rework this so that instead of distinct arguments
specifying the combination of features there's a flag set that will
allow more combinations to be specified.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-04-27 14:21:15 +02:00
Krishna Mohan Dani
5de1b09cc0 drivers/flash: STM32: Adding condition to enable HSI clock for L1 series.
This commit adds changes to enable HSI clock for stm32l1 series.

Signed-off-by: Krishna Mohan Dani <krishnamohan.d@hcl.com>
2021-04-23 14:59:06 +02:00
Krishna Mohan Dani
3374bc128a drivers/flash: STM32: Getting clock settings from DT.
This commit uses DT APIs to get the flash clock settings.

Signed-off-by: Krishna Mohan Dani <krishnamohan.d@hcl.com>
2021-04-23 14:59:06 +02:00
Francois Ramu
bce0d52664 drivers: flash: stm32wb: Flush caches after erase
This commit fixes sporadic kernel panics when writing big data chunks
to the flash. (data bus errors). Just like the stm32g4 does.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2021-04-20 12:44:14 +02:00
Francois Ramu
3620f3fcee drivers: flash: stm32g0: Flush caches after erase
This commit fixes sporadic kernel panics when writing big data chunks
to the flash. (data bus errors). Just like the stm32g4 does
but on instruction cache.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2021-04-20 12:44:14 +02:00
Peter Bigot
67808279fb drivers: flash: spi_nor: support devices that default to protect blocks
Some SPI NOR devices, particularly Atmel and SST, power-up with block
protect bits set in the status register.  These bits must be cleared
before any erase or program operation can succeed.  However, blindly
clearing bits in SR is wrong as some of these are non-volatile and
control chip behavior, including quad-enable.

Add a devicetree flag to identify device-specific BP bits in the status
register that should be cleared on startup only for devices that need
them, and when set do the clear during initialization.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-04-16 12:23:06 +02:00
Peter Bigot
060204a6ae drivers: flash: spi_nor: document caller requirements
Add the standard note to two functions that require the caller to have
first acquired the device.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-04-16 12:23:06 +02:00
Peter Bigot
01fbe40fd4 drivers: flash: spi_nor: clean up ready detection
Reads would wait until the device was ready before issuing the first
command; writes and erases did not.  Fix this documenting and changing
so that wait-for-ready is invoked only where needed, i.e. to confirm
that a WRITE_STATUS, ERASE, or PROGRAM operation has completed before
proceeding to allow more commands to be submitted.  This matches Linux
spi_nor driver behavior.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-04-16 12:23:06 +02:00
Pieter De Gendt
3ee5f427e6 drivers: flash: mcux flexspi nor: copy data to RAM buffer on write
This feature prevents issues when trying to write data to the flash
device that is located on or addressed at the same flash device.

An example is the mcuboot logic that writes a magic number to
the secondary partition header.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2021-04-15 16:26:39 -05:00