Commit graph

1230 commits

Author SHA1 Message Date
Alexandre Bourdiol
b6b77312ee drivers: flash: flash_stm32h7x.c: manage bank1/2 discontinuity
When flash is Dualbank and flash size is lower than 512K,
then there is a discontinuity between bank1 and bank2.
Also take into account bank swap capability.

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
2021-01-12 06:48:47 -05:00
Peter Bigot
b34d055926 drivers: flash: spi_nor: correct log message
Flash size is specified in bits by SFDP and devicetree, but the stored
flash size is in bytes.  Correct the divisor.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-01-06 16:01:04 -06:00
Martin Jäger
6181184163 drivers: flash: stm32g4x: fix LOG_ERR compiler warning
off_t can be 32-bit or 64-bit depending on the platform. STM32 flash
addresses are always 32-bit so it's safe to use long here.

Signed-off-by: Martin Jäger <martin@libre.solar>
2020-12-20 12:40:19 -05:00
Kumar Gala
92d62cd839 drivers: flash: Convert DEVICE_AND_API_INIT to DEVICE_DEFINE
Convert soc nios2 qspi to DEVICE_DEFINE instead of DEVICE_AND_API_INIT
so we can deprecate DEVICE_AND_API_INIT in the future.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-12-19 19:57:52 -05:00
Kumar Gala
c17b6a2584 drivers: flash: Convert drivers to new DT device macros
Convert flash drivers from:

    DEVICE_AND_API_INIT -> DEVICE_DT_INST_DEFINE
    DEVICE_DEFINE -> DEVICE_DT_INST_DEFINE

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-12-15 18:29:51 -05:00
Erwan Gouriou
905f496603 dts: stm32h7: Remove zephyr,flash-controller support on M4 core
Flash controller support is not yet ready on M4 core.
Remove the chosen declaration to make it clear.

Additionally, generate a build error if this driver is compiled
on M4 core.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-12-14 16:47:05 +01:00
Erwan Gouriou
5664dddf53 drivers/flash: stm32h7: Cache handling is limited to M7 core
There is no cache management on M4 side of the flash controller.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-12-14 16:47:05 +01:00
Nicolas VINCENT
5b463353d7 drivers/flash: add support for stm32h7 devices
Fixes #29831: Implements flash driver for stm32h7 devices.
The driver is independant from the other stm32 families (flash_stm32.c),
only the header interface is (mainly) common.

Signed-off-by: Nicolas VINCENT <nicolas.vincent@vossloh.com>
2020-12-14 16:47:05 +01:00
Martin Jäger
b0db87193e drivers: flash: stm32g4x: Fix include for dual bank
The LL header include was missing for the functions used for STM32G474
MCUs with dual bank feature.

Signed-off-by: Martin Jäger <martin@libre.solar>
2020-12-10 16:21:35 -06:00
Alexandre Bourdiol
522cda3f7d divers: flash: flash_stm32: add flash configuration check
Add weak function to check flash configuration.
On stm32g4: single bank configuration not supported
when dual bank capable.

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
2020-12-10 13:00:04 +01:00
Alexandre Bourdiol
7f62a92917 drivers: flash: flash_stm32g4x.c: take into account bank swap
When erasing flash page, take into account a potential bank swap.

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
2020-12-10 13:00:04 +01:00
Alexandre Bourdiol
496e2cab3d drivers: flash: flash_stm32g4x.c: rework flash_stm32_block_erase_loop
Remove hardcode bank1 page limit (128) which is not always valid
(not valid for soc stm32g474rct)
Manage bank1/2 discontinuity when flash is Dualbank and
flash size is lower than 512K.

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
2020-12-10 13:00:04 +01:00
Alexandre Bourdiol
a993601179 drivers: flash: flash_stm32g4x.c: manage bank1/2 discontinuity
When flash is Dualbank and flash size is lower than 512K,
then there is a discontinuity between bank1 and bank2.

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
2020-12-10 13:00:04 +01:00
Anas Nashif
dd931f93a2 power: standarize PM Kconfigs and cleanup
- Remove SYS_ prefix
- shorten POWER_MANAGEMENT to just PM
- DEVICE_POWER_MANAGEMENT -> PM_DEVICE

and use PM_ as the prefix for all PM related Kconfigs

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-12-09 15:18:29 -05:00
Kumar Gala
06a5946266 drivers: Convert to use new DEVICE_DT_INST_* macros
Move users that are DEVICE_DT_DECLARE(DT_DRV_INST(n, ...)) to
DEVICE_DT_INST_DECLARE(n, ...) and similar for DEVICE_DT_DEFINE.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-12-09 14:06:48 -06:00
Anas Nashif
2a19ad8068 Revert "drivers/flash: add support for stm32h7 devices"
This reverts commit 0964331df2.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-12-07 19:02:48 -05:00
Nicolas VINCENT
0964331df2 drivers/flash: add support for stm32h7 devices
Fixes #29831: Implements flash driver for stm32h7 devices.
The driver is independant from the other stm32 families (flash_stm32.c),
only the header interface is (mainly) common.

Signed-off-by: Nicolas VINCENT <nicolas.vincent@vossloh.com>
2020-12-07 16:16:11 -05:00
Peter Bigot
01da5ab1fc drivers: flash: spi_nor: fix bound for parameter headers
The exclusive bound for parameter headers needs to be incremented as
the nph parameter is not the number of parameter headers: 0 means one
header.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-01 17:57:20 -05:00
Peter Bigot
13048b1a5a drivers: flash: convert spi-nor drivers to dt device defines
Use the devicetree node as the source of object name and other
information used when defining the device structure.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-01 15:19:22 -05:00
Fabio Utzig
294ca18f09 drivers: flash: stm32l1: add initial L1x support
Enable L1x flash erase/program using the stm32_v1 driver.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2020-11-30 15:49:15 -06:00
Martin Jäger
004bee1fa8 drivers: flash: stm32: use generic LL headers
Use generic LL headers instead of depending on soc.h.

Signed-off-by: Martin Jäger <martin@libre.solar>
2020-11-30 15:50:03 +01:00
Peter Bigot
bc33ef4d42 drivers: flash: nrf_qspi_nor: remove multithreading dependency
Replace semaphores with an atomic ready flag when used without
multithreading enabled.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-11-28 07:20:27 -05:00
Andrzej Puzdrowski
832a896988 drivers/flash/nrf_qspi_nor: determine RAM source using nrfx
The driver was using CONFIG_SRAM_BASE_ADDRESS as the value used to
recognize whether source buffer is in RAM. This label provide the
base address of the image SRAM, and not the base of actual HW SRAM.

This patch uses nrfx_is_in_ram() instead.

fixes #29467

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2020-11-17 16:51:08 -05:00
Gerson Fernando Budke
3f4c1c9df2 drivers: flash: spi nor: Add missing flash layout conf
The at45 and nor spi flash drivers needs flash layout to work.
Probably tested were conducted with SoC that already selects
the FLASH_HAS_PAGE_LAYOUT for internal flash drivers.  This add
the missing dependency.

Fixes #28094.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-11-17 16:44:03 -05:00
Justin Brederveld
28297adde4 drivers: flash: stm32f4: Don't invert an already inverted mask
Clearing the PSIZE bits in the FLASH CR should not invert the mask
defined in stm32f4xx_hal_flash.h (#define CR_PSIZE_MASK 0xFFFFFCFFU)

Signed-off-by: Justin Brederveld <jmbrederveld@gmail.com>
2020-11-12 08:56:06 -06:00
Ievgenii Meshcheriakov
03b57ac058 drivers: sock_flash_nrf: Report errors to log
Report errors using logging subsystem so it is easier to
see the error location while debugging code.

Signed-off-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@nordicsemi.no>
2020-11-11 08:30:50 -05:00
Andrzej Głąbek
be02edb050 drivers/flash/nrf_qspi_nor: Add support for nRF53 Series SoCs
Improve the way the nrf_qspi_nor driver configures the SCK frequency,
to properly support QSPI also on nRF53 Series SoCs that use a different
base clock frequency (96 MHz).
Add also a relevant configuration in the spi_flash sample so that it
can run on the nRF5340 DK.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2020-11-10 21:01:37 +02:00
Ievgenii Meshcheriakov
5cb09fe0fb drivers: flash: Restore write protection in flash_shell
Restore the flash write proectction after disabling it for
flash write and erase shell commands.

Signed-off-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@nordicsemi.no>
2020-10-02 12:06:28 -04:00
Ievgenii Meshcheriakov
4fc093ee58 drivers: flash_shell: Fix write protection in the test command
Flash drivers are free to re-enable write protection after a write or
erase operation is complete. Therefore write protection has to be
disabled before any such operation.

Signed-off-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@nordicsemi.no>
2020-10-02 12:06:28 -04:00
Ievgenii Meshcheriakov
cf523e449e drivers: flash: Pass bool to flash_write_protection_set()
The second argument of this foonction is a bool, so passing 0 and 1
is incorrect.

Coccinelle script:

    @@
    expression e;
    @@
    flash_write_protection_set(e,
    (
    - 0
    + false
    |
    - 1
    + true
    )
     )

Signed-off-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@nordicsemi.no>
2020-10-02 12:06:28 -04:00
Stephan Walter
381cac1a35 drivers: nrf_qspi: fix devicetree opcode references
The condition used to detect presence of optional devicetree
properties that specify read and write opcodes was inadvertently
changed to something that will never be true.  Update the check and
the property extraction to restore the original behavior.

Fixes #28635.

Signed-off-by: Stephan Walter <stephan@walter.name>
2020-09-23 13:27:46 -05:00
Ievgenii Meshcheriakov
b7c9d9d34f drivers/flash/soc_flash_nrf: Enable ticker radio sync only with Zephyr LL
Ticker API is part of Zephyr software BLE Link Layer.

Signed-off-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@nordicsemi.no>
2020-09-21 13:06:16 +02:00
Ievgenii Meshcheriakov
d27c32efc3 drivers/flash/soc_flash_nrf: Rename config option SOC_FLASH_NRF_RADIO_SYNC
Call it SOC_FLASH_NRF_RADIO_SYNC_TICKER so it is not too generic.

Signed-off-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@nordicsemi.no>
2020-09-21 13:06:16 +02:00
Ievgenii Meshcheriakov
70c5371666 drivers/flash/soc_flash_nrf: Name flash sync choice
Named choice is needed in order to be able to extend it
in other modules.

Closes: #28559

Signed-off-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@nordicsemi.no>
2020-09-21 13:06:16 +02:00
Andrzej Puzdrowski
285d8786ee drivers/flash/nrf_qspi_nor: corrects write-block-size to 4B
The driver is able to write with 32-bits word alignment of size
and offset, apart form sub-word writes for which it can write
part of word to aligned offset (which is a hack).

fixes #26729

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2020-09-10 12:10:26 -05:00
Andrzej Puzdrowski
6167dbc195 drivers/flash/soc_flash_nrf: remove timeslice terminology from driver
timeslice terminology were used in connection with synchronization
using ll BLE ticker.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2020-09-04 16:08:42 +02:00
Andrzej Puzdrowski
affbafac26 drivers/flash/soc_flash_nrf: introduce synchronization api usage
Rework ticker synchronization using newly introduced
radio synchronization API.
In kconfig synchronization using ll ticker become choice
option.

If CONFIG_SOC_FLASH_NRF_PARTIAL_ERASE is enabled the erase
timing is changed so intervals become similar to slots duration.
Previously interval was always ~90 ms, which looks like it was kept
so disproportional by oversight while the partial erase was
introduced.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2020-09-04 16:08:42 +02:00
Andrzej Puzdrowski
4c2432fdd4 drivers/flash/soc_flash_nrf: implement ticker synch backend
Extract synchronization procedures using LL BLE controller
ticker to newly added synchronization API.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2020-09-04 16:08:42 +02:00
Andrzej Puzdrowski
f8fd2ba519 drivers/flash/soc_flash_nrf: introduce radio synchronization API
Introduced API which allows to decouple radio synchronization
mechanism from NVMC driver.
New API will allows to replace synchronization mechanism if required.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2020-09-04 16:08:42 +02:00
Marin Jurjevic
d73e438ee4 drivers: spi_flash_at45: Replace hardcoded sector size
Replace hardcoded sector size value in sample with sector-size
property added in dts binding file

Signed-off-by: Marin Jurjevic <marin.jurjevic@hotmail.com>
2020-09-04 11:58:22 +02:00
Kumar Gala
94353845f5 drivers: flash: stm32wb: Fix build error
When building flash shell sample we get:

flash_stm32wbx.c:23:10: fatal error: shci.h: No such file or directory
   23 | #include "shci.h"

Fix this by adding ifdef protection around inclusion of shci.h.

Fixes #28036

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-09-04 11:53:02 +02:00
Alexandre Bourdiol
51d4b4d5f4 drivers: flash: stm32wb: rework dualcore flash operation
Implement algorithm described in STM32 AN5289
with implementation proposed in STM32 Cube Application:
BLE_RfWithFlash

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
2020-09-02 14:13:49 +02:00
Tomasz Bursztyka
e1c118f019 drivers: flash: Fix device instance const qualifier loss in NRF QSPI
Passing the device's data is sufficient to be used by the HAL callback
function.

Fixes #27399

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-09-02 13:48:13 +02:00
Tomasz Bursztyka
e18fcbba5a device: Const-ify all device driver instance pointers
Now that device_api attribute is unmodified at runtime, as well as all
the other attributes, it is possible to switch all device driver
instance to be constant.

A coccinelle rule is used for this:

@r_const_dev_1
  disable optional_qualifier
@
@@
-struct device *
+const struct device *

@r_const_dev_2
 disable optional_qualifier
@
@@
-struct device * const
+const struct device *

Fixes #27399

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-09-02 13:48:13 +02:00
Peter Bigot
77aa89bcb5 drivers: flash: remove W25QXXDV driver
The spi_flash_w25qxxdv driver has been superseded by the generic
spi_nor driver for over a year.  The only non-refactoring change to
the W25Q driver in the last 18 months was done to support a backport
to 1.14.

All devices supported by spi_flash_w25qxxdv driver are expected to be
supported by the spi_nor driver, using the standard `jedec,spi-nor`
devicetree compatible.  No in-tree devicetree files make use of this
driver.

Remove the confusion about which driver to select by removing the
unmaintained redundant driver.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-08-27 17:39:21 +02:00
Peter A. Bigot
368cf2fc45 drivers: flash: spi_nor: support serial flash API
Expose the internal JESD216 function used to read data from the SFDP
region, and another function to read the JEDEC ID.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-08-17 13:38:14 -04:00
Peter A. Bigot
6a1a246825 drivers: flash: add API to read JEDEC ID from compatible drivers
Some flash drivers are capable of issuing a JESD216 READ_SFDP command
to read serial flash discoverable parameters.  Allow applications and
utilities access to API that reads the JEDEC ID from those devices.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-08-17 13:38:14 -04:00
Peter A. Bigot
4eb8d9dd9e drivers: flash: add API to access SFDP region of serial flash devices
Some flash drivers are capable of issuing a JESD216 READ_SFDP command
to read serial flash discoverable parameters.  Allow applications and
utilities access to that capability where it's supported.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-08-17 13:38:14 -04:00
Peter A. Bigot
67e795107e drivers: flash: spi_nor: support multiple config sources
This commit reworks the SPI NOR driver to be more flexible in how
flash device configuration is obtained.  Three alternatives are
supported:

* MINIMAL takes only the flash size from devicetree.  The erase sizes
  are hard-coded to the traditionally supported instructures.

* DEVICETREE requires that the data from the device's JESD216 Basic
  Flash Parameters table be provided through devicetree.  This
  supports multiple page sizes and erase configurations, and lays a
  foundation for significant enhancements in the future including
  4-byte address, sleeping while waiting for operation completion, and
  other features that are described by JESD216 parameters.

* RUNTIME requires nothing from the devicetree node, instead reading
  the Basic Flash Parameters from the device at runtime.  It extends
  DEVICETREE by allowing the same firmware to run on boards with
  different flash chips.

For MINIMAL and DEVICETREE the JEDEC ID from the devicetree node is
checked against the value read at runtime to confirm that the device
configuration is accurate.

The default SFDP source is MINIMAL.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-08-17 13:38:14 -04:00
Peter A. Bigot
810920f8d5 drivers: flash: spi_nor: read erase support and page size from SFDP
Use the new SFDP infrastructure to read the supported erase type sizes
and commands from the Basic Flash Parameters block.  This removes the
need for explicit reference to most block sizes from this driver.

We're also seeing devices where the page size is not 256 bytes.
Accommodate them.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-08-17 13:38:14 -04:00