Commit graph

374 commits

Author SHA1 Message Date
Kumar Gala f04490e300 drivers: flash: nrf_qspi_nor: Convert to new DT_INST macros
Convert older DT_INST_ macro use the new include/devicetree.h
DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-15 11:17:32 -05:00
Kumar Gala 8dc6f9f5dd drivers: flash: nrf: Conver to new DT macros
Convert driver from DT_FLASH_BASE_ADDRESS and DT_FLASH_DEV_NAME to use
DT_REG_ADDR and DT_INST_LABEL.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-15 06:22:40 -05:00
Kumar Gala 613dba7fac drivers: flash: stm32: Convert to new DT macros
Replace DT_FLASH_SIZE with new DT_REG_SIZE macro.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-15 06:22:40 -05:00
Kumar Gala f311c8ad60 drivers: flash: atmel sam: Fix DT_DRV_COMPAT setting
For a flash driver DT_DRV_COMPAT should be the compatible for the flash
controller and not the soc-nv-flash.  Change to driver to use the flash
controllers compatible and get the soc-nv-flash properties as a child of
that controller.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-15 06:22:40 -05:00
Kumar Gala 14b6b8b07c drivers: flash: silabs: Fix DT_DRV_COMPAT setting
For a flash driver DT_DRV_COMPAT should be the compatible for the flash
controller and not the soc-nv-flash.  Change to driver to use the flash
controllers compatible and get the soc-nv-flash properties as a child of
that controller.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-15 06:22:40 -05:00
Kumar Gala a61d2a281c drivers: flash: mcux: Fix DT_DRV_COMPAT setting
For a flash driver DT_DRV_COMPAT should be the compatible for the flash
controller and not the soc-nv-flash.  Change to driver to use the flash
controllers compatible and get the soc-nv-flash properties as a child of
that controller.

The soc_flash_mcux supports several possible compatible so handle that
as part of how we set DT_DRV_COMPAT.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-15 06:22:40 -05:00
Kumar Gala 3fa974cab0 drivers: flash: rv32m1: Fix DT_DRV_COMPAT setting
For a flash driver DT_DRV_COMPAT should be the compatible for the flash
controller and not the soc-nv-flash.  Change to driver to use the flash
controllers compatible and get the soc-nv-flash properties as a child of
that controller.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-15 06:22:40 -05:00
Peter Bigot 95baa51de8 drivers: flash: spi-nor: fix unconditional use of BE32K
The 32 KiBy bulk erase command was being invoked without respecting
the flag that indicates it's supported.  Make the invocation
conditional.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-04-14 09:13:34 -05:00
Steven Slupsky e55f1987a0 drivers: flash: sam0: fix unaligned memory read
Use the UNALIGNED_GET() macro instead of the
flash_sam0_read_unaigned_u32() function to ensure
word alignment of the source address.

Signed-off-by: Steven Slupsky <sslupsky@gmail.com>

drivers: flash: sam0:  fix whitespace

Fix checkpass whitespace error.

Signed-off-by: Steven Slupsky <sslupsky@gmail.com>
2020-04-11 15:34:21 -04:00
Ivo Clarysse db400713ba drivers/flash: shell: Add optional device argument
Update `flash` shell commands to take an optional device argument,
instead of using the chosen flash device.

Signed-off-by: Ivo Clarysse <ivo@bcdevices.com>
2020-04-09 16:36:39 +02:00
Kumar Gala c7f8b30f53 drivers: flash: openisa rv32m1: Replace DT_FLASH define
Replace DT_FLASH_SIZE with new DT_INST_REG_SIZE as we phase out
DT_FLASH define usage.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-09 08:41:09 -05:00
Kumar Gala 19e91ab9f2 drivers: flash: nxp mcux: Replace DT_FLASH define
Replace DT_FLASH_WRITE_BLOCK_SIZE with new DT_INST_NODE_HAS_PROP and
DT_INST_PROP macro as we phase out DT_FLASH define usage.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-09 08:41:09 -05:00
Kumar Gala 9a28ff317f drivers: flash: atmel_sam: Replace DT_FLASH define
Replace DT_FLASH_DEV_BASE_ADDRESS with new DT_REG_ADDR/DT_INST macro as
we phase out DT_FLASH define usage.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-09 08:41:09 -05:00
Kumar Gala 608dba486e drivers: flash: Use DT_INST_LABEL instead of DT_FLASH_DEV_NAME
Replace use of DT_FLASH_DEV_NAME with DT_INST_LABEL in drivers as we
want to phase out DT_FLASH_DEV_NAME.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-08 15:28:52 -05:00
Peter Bigot 08fea84a30 drivers: flash: sam: fix timeout units
The duration is used in math with the uptime clock, not as a timeout.
Correct value expression and rename to clarify units.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-04-07 16:39:08 -05:00
Erwan Gouriou e4589b8657 drivers: flash: stm32: Use correct driver compatible
Use valid stm32 flash driver compatibles instead of flash
area compatible.
For 'write_block_size' property, use reference to soc-nv-flash.

fixes #23997

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-04-07 10:52:23 -04:00
Dominik Ermel 143f9bfd4e drivers/flash/nrfx: Enable partial erase of flash
When enabled, instead of erasing entire flash page at once, page will
be erased in defined time slices. Erasing single page stalls CPU
for significant time share (~80ms) and partial erase divides the
operation in to the shorter time periods, resuming CPU operation in
meantime and enabling better scheduling of time sensitive operations.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-04-06 22:12:33 -04:00
Vinayak Kariappa Chettimada 0d8eb1c5ad drivers: flash: nrf: Fix radio sync with BLE LL split controller
Delay radio abort called in the flash driver to emulate the
behavior of pre-empt timeout in Bluetooth LL split
controller. Without this, the driver aborted radio events
in its reserved time space.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-04-03 22:09:50 +02:00
Andy Ross 32bb2395c2 timeout: Fix up API usage
Kernel timeouts have always been a 32 bit integer despite the
existence of generation macros, and existing code has been
inconsistent about using them.  Upcoming commits are going to make the
timeout arguments opaque, so fix things up to be rigorously correct.
Changes include:

+ Adding a K_TIMEOUT_EQ() macro for code that needs to compare timeout
  values for equality (e.g. with K_FOREVER or K_NO_WAIT).

+ Adding a k_msleep() synonym for k_sleep() which can continue to take
  integral arguments as k_sleep() moves away to timeout arguments.

+ Pervasively using the K_MSEC(), K_SECONDS(), et. al. macros to
  generate timeout arguments.

+ Removing the usage of K_NO_WAIT as the final argument to
  K_THREAD_DEFINE().  This is just a count of milliseconds and we need
  to use a zero.

This patch include no logic changes and should not affect generated
code at all.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-03-31 19:40:47 -04:00
Oleg Zhurakivskyy b1e1f64d14 global: Replace BUILD_ASSERT_MSG() with BUILD_ASSERT()
Replace all occurences of BUILD_ASSERT_MSG() with BUILD_ASSERT()
as a result of merging BUILD_ASSERT() and BUILD_ASSERT_MSG().

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-03-31 07:18:06 +02:00
Kumar Gala 28870e7a32 drivers: atmel sam0: Convert atmel sam0 drivers to new DT_INST macros
Convert older DT_INST_ macro use in atmel sam0 drivers to the new
include/devicetree.h DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-27 11:02:57 -05:00
Kumar Gala 4d977e43ca drivers: flash: spi_nor: Convert to new DT_INST macros
Convert older DT_INST_ macro use the new include/devicetree.h
DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-27 10:05:46 -05:00
Kumar Gala 11c8de15a8 drivers: flash: spi_flash_w25qxxdv: Convert to new DT_INST macros
Convert older DT_INST_ macro use the new include/devicetree.h
DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-27 10:00:29 -05:00
Kumar Gala 63ccb98eee drivers: openisa: Convert openisa drivers to new DT_INST macros
Convert older DT_INST_ macro use in openisa drivers to the new
include/devicetree.h DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-27 05:28:37 -05:00
Thomas Schmid 7f5bdfb2a4 drivers: flash: stm32: fix warnings about format specifiers
Newlibc defines off_t as long int. Change %d format specifier
to %ld for logging of offsets.

Signed-off-by: Thomas Schmid <tom@lfence.de>
2020-03-27 10:15:03 +01:00
Kumar Gala 3af49c5b55 drivers: atmel sam: Convert atmel sam drivers to new DT_INST macros
Convert older DT_INST_ macro use in atmel sam drivers to the new
include/devicetree.h DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-26 16:31:31 -05:00
Kumar Gala 989484b4bf drivers: stm32: Convert STM32 drivers to new DT_INST macros
Convert older DT_INST_ macro use in STM32 drivers to the new
include/devicetree.h DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-26 12:22:12 -05:00
Kumar Gala 4cb0a5d992 drivers: silabs: Convert silabs drivers to new DT_INST macros
Convert older DT_INST_ macro use in silab drivers to the new
include/devicetree.h DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-26 05:26:23 -05:00
Kumar Gala 4b9fe8a24e drivers: mcux: Convert MCUX drivers to new DT_INST macros
Convert older DT_INST_ macro use in MCUX drivers to the new
include/devicetree.h DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-26 03:40:09 -05:00
Alexander Wachter 802552414c drivers: flash: stm32g4: Fix erase on wrong bank
In the default configuration of the stm32g4 is the dual bank mode.
In dual bank mode, the flash is split into two banks with 256k each.
The erase pages have a range form 0 to 127, where each page has 2k.
If one wants to erase an area above 256k, the driver has to switch
to bank 2 befor erasing. Otherwise it will erase the page moulo 127.

Signed-off-by: Alexander Wachter <alexander.wacher@leica-geosystems.com>
2020-03-24 14:25:47 -05:00
Alexander Wachter 7b9320beed drivers: flash: stm32: Introduce logs in the flash code
This commit introduces some logs in the stm32 flash implementation.
Thith the logs it is easier to locate problems when they arrise.

Signed-off-by: Alexander Wachter <alexander.wacher@leica-geosystems.com>
2020-03-24 14:25:47 -05:00
Erwan Gouriou 5cd10c70bd drivers/flash: stm32: DT_INST_0_SOC_NV_FLASH_LABEL is not dev name
Don't use DT_INST_0_SOC_NV_FLASH_LABEL as device name.
Use DT_FLASH_DEV_NAME instead

Fixes #23678

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-03-23 08:51:22 -05:00
Peter Bigot 414bdde2f0 drivers: flash: spi_nor: avoid coverity warning in untested code
Coverity doesn't invoke the build for this module with a configuration
that provides a non-zero delay for entering or releasing deep power
down, so it sees a check that a value known to be non-negative
magically became negative without being touched, and so screams about
dead code.

Refactor to make the adjustments unconditional which has the same
effect in any reasonable level of optimization while making it
slightly less obvious that the value may not change.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-03-19 17:13:52 -04:00
Carles Cufi 4b37a8f3a4 Revert "global: Replace BUILD_ASSERT_MSG() with BUILD_ASSERT()"
This reverts commit 8739517107.

Pull Request #23437 was merged by mistake with an invalid manifest.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-03-19 18:45:13 +01:00
Oleg Zhurakivskyy 8739517107 global: Replace BUILD_ASSERT_MSG() with BUILD_ASSERT()
Replace all occurences of BUILD_ASSERT_MSG() with BUILD_ASSERT()
as a result of merging BUILD_ASSERT() and BUILD_ASSERT_MSG().

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-03-19 15:47:53 +01:00
Erwan Gouriou 22af564f19 drivers: flash: flash_stm32: convert to DT_INST defines
Convert driver to use DT_INST_ defines.
Removed DT_FLASH_DEV fixup macros, except DT_FLASH_DEV_NAME
used in applications.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-03-17 11:03:10 -06:00
Dominik Ermel 94248dcb1d drivers/flash: Fix missing ticker stop on timeout
There is timeout guard, in form of k_sem_get within work_in_time_slice,
used to detect if flash operation takes longer than expected maximum
and to return error code in such case. The processing of this timeout
is missing cancellation of scheduled ticker job that would attempt to
perform another operation. This causes problem as context for ticker
is created, on stack, within erase/write_in_timeslice which
would conclude when timeout occurs, folding the stack in process.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-03-13 09:30:49 -05:00
Gerson Fernando Budke 8c6302253a drivers: flash: Kconfig.sam: Enable support to SAMV71
SAMV71 uses same driver of SAME70 and this enables the feature.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-03-10 14:43:36 +02:00
Ulf Magnusson eddd98f811 kconfig: Replace some single-symbol 'if's with 'depends on'
I think people might be reading differences into 'if' and 'depends on'
that aren't there, like maybe 'if' being needed to "hide" a symbol,
while 'depends on' just adds a dependency.

There are no differences between 'if' and 'depends on'. 'if' is just a
shorthand for 'depends on'. They work the same when it comes to creating
implicit menus too.

The way symbols get "hidden" is through their dependencies not being
satisfied ('if'/'depends on' get copied up as a dependency on the
prompt).

Since 'if' and 'depends on' are the same, an 'if' with just a single
symbol in it can be replaced with a 'depends on'. IMO, it's best to
avoid 'if' there as a style choice too, because it confuses people into
thinking there's deep Kconfig magic going on that requires 'if'.

Going for 'depends on' can also remove some nested 'if's, which
generates nicer symbol information and docs, because nested 'if's really
are so simple/dumb that they just add the dependencies from both 'if's
to all symbols within.

Replace a bunch of single-symbol 'if's with 'depends on' to despam the
Kconfig files a bit and make it clearer how things work. Also do some
other minor related dependency refactoring.

The replacement isn't complete. Will fix up the rest later. Splitting it
a bit to make it more manageable.

(Everything above is true for choices, menus, and comments as well.)

Detected by tweaking the Kconfiglib parsing code. It's impossible to
detect after parsing, because 'if' turns into 'depends on'.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-02-08 08:32:42 -05:00
Kumar Gala 0e42d4838e flash: sam: Limit flash driver to SAME70 SoCs
The SAM flash driver was developed for the SAME70 SoCs and hasn't ever
been validated on the other SAM families (SAM3X, SAM4S).  If we try and
build on one of the other SoC families we get build errors.  So limit it
to just SAME70 for now.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-02-06 19:18:51 -05:00
Kumar Gala afc449ec79 flash: sam0: Fix build issue.
Fix stale DT define that causes driver not to build.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-02-06 19:18:51 -05:00
Erwan Gouriou dbd054fbd3 drivers/flash: stm32: Fix faulty register access
Merge of conflicting PRs lead to compilation issue.
Fix this.

Fixes #22297

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-01-29 15:14:22 -06:00
Kamil Lazowski 5b4f4253c1 drivers: flash: add Nordic JEDEC QSPI NOR flash driver
Most JEDEC NOR flash devices uses not only typical SPI mode
(MISO,MOSI,SCK and CS), but also QSPI mode (IO0,IO1,IO2,IO3,SCK and CS).
QSPI mode uses more data lines and as a result provide higher
throughput. If this were not enough, Nordic chips provide
hardware acceleration for read/write/erase functions, what
gives significant performance boost.
It does a lot of things "behind the scene", i.e when user has written
some data to the flash and would like to read them back, it has to wait
until the flash is ready by reading WIP bit in Status Register.
This driver does it automatically.

Signed-off-by: Kamil Lazowski <Kamil.Lazowski@nordicsemi.no>
2020-01-29 15:15:49 +01:00
Sarvesh Patkar 4f2c107389 drivers: flash: stm32: Update flash driver implementation
Remove soc/arm/st_stm32/stm32YY/flash_registers.h files.
Change register accesses in stm32 flash drivers to use FLASH_TypeDef
from modules/hal/stm32/stm32cube/stm32YYxx/soc/stm32xxxxxx.h.

Fixes #16235

Signed-off-by: Sarvesh Patkar <psarvesh314@gmail.com>
2020-01-28 15:30:12 -06:00
Peter Bigot a539fc6b73 treewide: use full path to flash.h header
The build infrastructure should not be adding the drivers subdirectory
to the include path.  Fix the legacy uses that depended on that
addition.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-01-26 17:52:12 +01:00
Peter Bigot 0b0d2e640b treewide: use full path to clock_control/stm32_clock_control.h header
The build infrastructure should not be adding the drivers subdirectory
to the include path.  Fix the legacy uses that depended on that
addition.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-01-26 17:52:12 +01:00
Andrzej Puzdrowski 997be3d04d drivers/flash/flash_simulator: erase posix flash in initialization
After startup the native_posix flash was filed by 0x00 instead
of 0xff, which is not coherent with erased byte value which
is 0xff for the native_posix target.

Such inconsistent behavior makes for instance running
a storage system designed(or configured) for a flash device
with 0xff as erased byte values problematic.

This patch makes flash erased after new flash device file creation.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2020-01-23 10:51:42 -05:00
Andrzej Puzdrowski 68f51f66c6 doc: cleanup after NFFS removal
Patch introduce references to LittleFS instead of NFFS where it
was suitable. In other places NFFS mentions were removed

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2020-01-21 15:32:47 +01:00
Adam Kondraciuk 2ff0105954 drivers: flash: nrfx: Change write_block_size parameter to 32-bits
According to NRF product specifications the smallest write unit is
32-bits. Added parameter 'CONFIG_EMULATE_ONE_BYTE_WRITE_ACCESS'
which allows one byte flash write using more complex operation.

Signed-off-by: Adam Kondraciuk <adam.kondraciuk@nordicsemi.no>
2020-01-21 15:26:23 +01:00
Andrzej Puzdrowski 32109512f2 drivers/flash: group nRF sub-option under menuconfig
Grouped all nRF driver sub-option under SOC_FLASH_NRF
menuconfig.

This makes menuconfig cleaner.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2020-01-20 18:37:47 -05:00
Andrei Gansari b72db6b02e drivers: soc_flash_mcux enabled for LPC
soc_flash_mcux added support for IAP Flash device specific to LPC SoC
families.

Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com>
2020-01-16 08:19:46 -06:00
Erwan Gouriou fc85361cfe drivers: flash: stm32: Update SR define
Following update of stm32wb package, FLASH_FLAG_SR_ERROR
has been renamed to FLASH_FLAG_SR_ERRORS.
Update driver to fix compilation issue.


Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-01-15 08:39:05 -06:00
Benjamin Valentin fc7f458ab3 flash: sam0: Define LOCK_REGIONS in dts
The amount of lock regions differs between different sam0 MCUs.

	saml10:  2
	saml11:  4
	samd2x:	16
	saml2x: 16
	samd5x: 32

ASF does not provide a definition for this, so create a new one
in dts.

Signed-off-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
2020-01-14 11:12:33 -05:00
Benjamin Valentin cafc074d06 flash: sam0: Add support for SAME54
This adds support for the flash peripheral found in the SAME5x/SAMD5x
line of MCUs.
The peripheral is very simmilar to the one found on SAMD2x with only
a few register names changed.

Signed-off-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
2020-01-14 11:12:33 -05:00
Benoit Leforestier f256625ad4 Driver: Flash STM32: Don't use semaphore if multithreading isn't defined
In STM32 flash driver, don't use semaphore if multithreading
isn't defined.
If multithreading isn't defined, a call to sem_give function
generates a hardware fault exception.

Signed-off-by: Benoit Leforestier <benoit.leforestier@gmail.com>
2020-01-09 19:14:32 +01:00
Marco Peter 1ee99d2568 drivers: flash: Build STM32 flash support only when selected
The current configuration causes the STM32 flash support always to be
built, even if an unrelated flash driver, by example the SPI_NOR driver
is selected.
This behaviour gets especially problematic (build failure) if the flash
hardware of the given MCU is not supported (e.g. STM32F2).
The suggested change should ensure that STM32 flash support only is
built when it actually is selected.

Signed-off-by: Marco Peter <marco@peter-net.ch>
2020-01-06 08:51:18 -05:00
Laczen JMS a91df4a077 drivers/flash: nios2_qspi byte read access
Correct nios2_qspi to allow byte size read access

Signed-off-by: Laczen JMS <laczenjms@gmail.com>
2019-12-19 12:53:22 -05:00
Andrzej Puzdrowski 073e0b77d6 drivers/flash: remove NRF flash protection emulation
NRF devices hardware has flash protection which doesn't
reflect flash API definition well. So fare protection
mechanism was emulated by the software and the driver deals
with hardware flash protection on its own.
Recent change to protection behavior requirement allows
to remove flash API behavior emulation at all.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-12-15 10:35:09 -05:00
Feng Cheng ee57c8e749 drivers: flash: Add the flash driver of the stm32f1x family
Most of the code is copied from the stm32f0x family
Tested on stm32f103ze soc

Signed-off-by: Feng Cheng <i@fengch.me>
2019-12-11 12:40:33 -06:00
Ulf Magnusson 984bfae831 global: Remove leading/trailing blank lines in files
Remove leading/trailing blank lines in .c, .h, .py, .rst, .yml, and
.yaml files.

Will avoid failures with the new CI test in
https://github.com/zephyrproject-rtos/ci-tools/pull/112, though it only
checks changed files.

Move the 'target-notes' target in boards/xtensa/odroid_go/doc/index.rst
to get rid of the trailing blank line there. It was probably misplaced.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-12-11 19:17:27 +01:00
Jan Van Winkel cba129ae96 drivers/flash: Removed native posix flash driver
Removed native posix flash driver as functionality is merged with flash
simulator driver.

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2019-12-09 11:56:21 -05:00
Jan Van Winkel 8cd4a817d9 drivers/flash/flash_simulator: Added file back end for posix arch
Extended flash simulator for posix architecture to read/write data
from a binary file on the host file system.

Further enable the flash simulator by default on native_posix(_64)
boards and updated the documentation accordingly.

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2019-12-09 11:56:21 -05:00
Ulf Magnusson 87e917a925 kconfig: Remove redundant 'default n' and 'prompt' properties
Bool symbols implicitly default to 'n'.

A 'default n' can make sense e.g. in a Kconfig.defconfig file, if you
want to override a 'default y' on the base definition of the symbol. It
isn't used like that on any of these symbols though.

Also replace some

    config
    	prompt "foo"
    	bool/int

with the more common shorthand

    config
    	bool/int "foo"

See the 'Style recommendations and shorthands' section in
https://docs.zephyrproject.org/latest/guides/kconfig/index.html.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-12-09 16:14:50 +01:00
Andrei Gansari 6d1e10635d drivers: flash_handlers fixes stray semicolon
z_vrfy_flash_get_page_count defined as a function prototype in place of
a real function due to a stray semicolon.

Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com>
2019-11-28 13:39:00 -05:00
Andrzej Puzdrowski dbe56337a0 drivers/flash: nRF driver uses relative addresses
So fare all nRF flash memories had flash base address at 0.
nRF flash driver was implemented in such way that it
really used absolute addresses, while convention are relative
addresses (for flash_map as well), which was not visible as start
address offset was 0.
It will become visible on nRF53 which has networking flash
with non-zero base address.

This patch switch nRF flash driver to use relative addresses for flash.
UICR absolute addressing is kept.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-11-21 13:35:28 +01:00
Peter A. Bigot 2d4d6f05e6 drivers: spi_nor: improve documentation and validation on flash layout size
The smallest region that can be erashed is one sector, so setting
SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=2048 will fail at runtime when the
flash page API is used to erase a single (or misaligned) page.  Add a
compile-time check that the requested layout page size is erasable.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-11-09 15:26:06 +01:00
Peter A. Bigot 98a344fe21 drivers: spi_nor: support deep-power-down mode
Add internal API to enter and exit deep power-down mode.  Add Kconfig
option to return to DPD whenever device is not active.

When device power management becomes more mature it should be possible
to implement it, which would allow use of DPD without having to enter
and exit DPD between consecutive transactions.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-11-09 15:26:06 +01:00
Peter A. Bigot c2e9441ad5 drivers: spi_nor: refactor device mutex management
Convert the LOCK/UNLOCK macros to acquire/release functions in
preparation for extending those steps to include power management.

Also commit to always allocating a semophore, and use a more clean
way of conditionalizing the operations.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-11-09 15:26:06 +01:00
Peter A. Bigot e4c3729ba7 drivers: spi_nor: generalize support for ULBPR instruction
Replace the hard-coded check for JEDEC IDs with a property that must
be set in the devicetree entry.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-11-09 15:26:06 +01:00
Henrik Brix Andersen 30fc72a50e drivers: flash: native_posix: remove unused mutex
Remove unused mutex in the flash_native_posix driver.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2019-11-08 18:59:02 +01:00
Erwan Gouriou 0e4dc5f33a drivers/flash: stm32f4: Return error on Dual Bank configuration
Some stm32f4 1MB SoCs support optional Dual Bank configuration.
This is not yet supported by stm32f4 driver, so report an
error when configuration is detected

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-11-05 16:37:25 -06:00
Erwan Gouriou fb979e7ca7 drivers/flash: stm32f4: Offset SNB from sector 12 on 2MB parts
On 2MB parts, on sector 12 and above SNB is offset by 4.

Fixes #20016

Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-11-05 16:37:25 -06:00
Ulf Magnusson bd6e04411e kconfig: Clean up header comments and make them consistent
Use this short header style in all Kconfig files:

    # <description>

    # <copyright>
    # <license>

    ...

Also change all <description>s from

    # Kconfig[.extension] - Foo-related options

to just

    # Foo-related options

It's clear enough that it's about Kconfig.

The <description> cleanup was done with this command, along with some
manual cleanup (big letter at the start, etc.)

    git ls-files '*Kconfig*' | \
        xargs sed -i -E '1 s/#\s*Kconfig[\w.-]*\s*-\s*/# /'

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-04 17:31:27 -05:00
Ulf Magnusson 975de21858 kconfig: Global whitespace/consistency cleanup
Clean up space errors and use a consistent style throughout the Kconfig
files. This makes reading the Kconfig files more distraction-free, helps
with grepping, and encourages the same style getting copied around
everywhere (meaning another pass hopefully won't be needed).

Go for the most common style:

 - Indent properties with a single tab, including for choices.

   Properties on choices work exactly the same syntactically as
   properties on symbols, so not sure how the no-indentation thing
   happened.

 - Indent help texts with a tab followed by two spaces

 - Put a space between 'config' and the symbol name, not a tab. This
   also helps when grepping for definitions.

 - Do '# A comment' instead of '#A comment'

I tweaked Kconfiglib a bit to find most of the stuff.

Some help texts were reflowed to 79 columns with 'gq' in Vim as well,
though not all, because I was afraid I'd accidentally mess up
formatting.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-01 15:53:23 +01:00
Ulf Magnusson 677f1e6db9 kconfig: Turn pointless/confusing 'menuconfig's into 'config's
Defining a symbol with 'menuconfig' just tells the menuconfig to display
any dependent symbols that immediately follow it in a separate menu.
'menuconfig' has no effect on symbol values.

Making a symbol that doesn't have any dependent symbols after it a
'menuconfig' should be avoided, because then you end up with an empty
menu, which is shown as e.g.

    [*] Enable foo ---

This is how it would be shown if there were children but they all
happened to be invisible as well.

With a regular 'config', it turns into

    [*] Enable foo

Change all pointless 'menuconfig's to 'config's.

See the section on 'menuconfig' on the Kconfig - Tips and Best Practices
page as well.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-10-22 13:53:06 -05:00
Ulf Magnusson 38866eb3f1 drivers: spi_nor: Remove unused SPI_NOR_{PAGE,SECTOR}_SIZE symbols
Unused since commit 2a590d3fa5 ("drivers/spi_nor: remove configurability
of page/sector/block sizes"). The help texts already say they're unused,
but it probably doesn't hurt to remove them as well.

Found with a script.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-10-21 08:17:50 -05:00
Adam Kondraciuk d7dbb572e3 drivers: flash: nrfx: Modify flash address validation
Modifications in 'is_regular_addr_valid()' function which didn't work
properly when flash base address was different than 0x00000000.
Added calculating address bounds with respect to flash base address.

Signed-off-by: Adam Kondraciuk <adam.kondraciuk@nordicsemi.no>
2019-10-14 21:05:23 +02:00
Richard Osterloh c68e027c28 drivers: flash: Add STM32G4X flash support
Add flash driver support for STM32G4X SoC series.

Signed-off-by: Richard Osterloh <richard.osterloh@gmail.com>
2019-10-04 18:44:24 -07:00
Pavlo Hamov 9bb7da060b drivers: flash: add omitted dependency
FLASH_SHELL must depend on the base SHELL

Signed-off-by: Pavlo Hamov <pavlo_hamov@jabil.com>
2019-10-04 09:19:44 -05:00
Timo Teräs 52453082f8 drivers: spi_nor: support Microchip SPI flash global unblock
Microchip SPI flash require Global unblock command before writing
is allowed.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
2019-09-25 17:41:31 +02:00
Anas Nashif 5a058dc29e drivers: flash: remove qmsi flash driver
No users of this driver after dropping quark platforms.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-09-18 11:06:18 -05:00
Andy Ross 075c94f6e2 kernel: Port remaining syscalls to new API
These calls are not accessible in CI test, nor do they get built on
common platforms (in at least one case I found a typo which proved the
code was truly unused).  These changes are blind, so live in a
separate commit.  But the nature of the port is mechanical, all other
syscalls in the system work fine, and any errors should be easily
corrected.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-09-12 11:31:50 +08:00
Erwan Gouriou 0381e8cbe9 drivers/flash: stm32l4: Handle pages_per_bank for all variants
Variable pages_per_bank has been introduced to ease page erase
in dual bank configurations. This has been implemented using
FLASH_OPTR_DUALBANK definition.
It happen that this was not taking into account L4+ series that
use FLASH_OPTR_DBANK instead of FLASH_OPTR_DUALBANK. This lead
to compilation issue for this driver in case of L4+ series.
So, this patch is adding the support of FLASH_OPTR_DBANK definition.

Besides, FLASH_OPTR_DUALBANK (as FLASH_OPTR_DBANK) are actually
defining availability of an option byte to configure use of Dual
Bank. So besides of its definition, its value in flash OPTR register
should be checked to ensure Dual Bank configuration is used.
This patch is taking this into account by adding the check of this
byte. Error -ENOTSUP is returned in case Single Bank is configured
since it has not be validated yet (in case Dual Bank is possible but
not configured).

Fixes #18246 for nucleo_l4r5zi

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-08-17 20:05:21 +02:00
Ulf Magnusson cc8cf88e2c drivers: flash: Remove redundant FLASH dep. from FLASH_NATIVE_POSIX
FLASH_NATIVE_POSIX is defined in drivers/flash/Kconfig.native_posix,
which is source'd within an 'if FLASH' in drivers/flash/Kconfig.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-08-07 04:26:48 -04:00
Ulf Magnusson 2d8982d21b drivers: flash: Remove redundant FLASH dep. from FLASH_SIMULATOR
FLASH_SIMULATOR is defined in drivers/flash/Kconfig.simulator, which is
source'd within an 'if FLASH' in drivers/flash/Kconfig.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-08-07 04:26:27 -04:00
Peter A. Bigot d60d16d4cd drivers/spi_nor: de-pessimize reads
SPI NOR devices require that writes be performed within only one page at
a time.  There is no such limitation on reads.  Remove the code that
forced reads to be performed in 256-byte chunks.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-08-05 13:27:49 +02:00
Peter A. Bigot 86dcf3c173 drivers/spi_nor: fix writes across page boundaries
The code failed to increment the address after completing a partial
write, causing writes that cross a page boundary overwrite at a page
level.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-08-05 13:27:49 +02:00
Piotr Mienkowski 707a111ca8 drivers: fix printf formatting in flash drivers
This commit fixes following issues in printf formatting used by flash
drivers:
- cast values of type off_t to long to remove warnings generated when
  compiling with Newlib.
- use 'z' modifier (as in "%zu") to print values of type size_t
- prefix all hex numbers with '0x'

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2019-08-01 11:33:17 -07:00
Anas Nashif 578ae40761 boards: remove quarl_se_c1000
This board and SoC was discontinued some time ago and is currently not
maintained in the zephyr tree.
Remove all associated configurations and variants from the tree.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-07-29 21:30:25 -07:00
Ioannis Konstantelias 4fffe790be drivers: flash: stm32l4x: Support SOCs with < 1MB
Up to now, the only SOC that was supported in the STM32L496 series was
STM32L496XG with flash of 1MB. With the recent support of STM32L496XE,
this implementation is not correct. This patch adds support for the
other SOCs that come with flashes of 512KB and 256KB.

Signed-off-by: Ioannis Konstantelias <ikonstadel@gmail.com>
2019-07-29 09:53:58 -04:00
Peter A. Bigot 794e0109d6 drivers/spi_nor: enable logging API
Just register it.  For now it's only used in one place where it was
needed to identify a problem.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-07-24 09:20:56 -04:00
Peter A. Bigot 660149b500 drivers/spi_nor: fix writes across page boundaries
The previous code limited the length of a write to the size of a page,
but did not check whether the starting position was far enough into the
page that the write would still cross a page boundary.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-07-24 09:20:56 -04:00
Peter A. Bigot fa10a9640b dts/spi-nor: use bytestring for JEDEC ID
This was always intended to be a bytestring rather than an array, but
full support was missing.  Since that has been addressed switch it to
the preferred format.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-07-24 09:20:56 -04:00
Peter A. Bigot eb3858cbbd drivers/spi_nor: allow application control of flash layout page size
The driver historically used the erase block size (64 KiBy) as the page
size.  There are other viable "sector" sizes, and for some applications
this one may be too large.  Allow the application to specify the desired
flash page size.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-07-24 09:20:56 -04:00
Peter A. Bigot 50550e02c0 drivers/spi_nor: remove write-block-size devicetree property
Devices using this driver do not require any special alignment for
writes.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-07-24 09:20:56 -04:00
Peter A. Bigot 2a590d3fa5 drivers/spi_nor: remove configurability of page/sector/block sizes
The JEDEC API defines the hardware page, sector, and block sizes.
Deprecate the Kconfig settings, remove the `erase-size-block` property,
and add `has-be32k` to indicate that 32K-byte erase is supported.
Rework the driver to use the constants instead of configured values.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-07-24 09:20:56 -04:00
Andrzej Puzdrowski 428c281bc6 drivers/flash/flash_simulator: fix flash size calculation
Flash size calculation was don with assumption that flash page size
is always 1 KB and flash size was parameterized with such granularity.

This patch correct this bug.

Flash pages number under statistic can't be calculated via preprocessor
anymore - thus are parameterized via Kconfig.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-07-17 13:49:26 -07:00
Andrzej Puzdrowski 891ccdc182 drivers/flash/flash_simulator: switch to use DT_FLASH_SIM labels
It Need to start using DT_FLASH_SIM_xxx labels after sim_flash was
un-chosen as zephyr,flash.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-07-17 13:49:26 -07:00
Francois Ramu bfc2ea6dd5 drivers: flash: Add STM32G0XX flash support
Add flash support for STM32G0X SoC series.

Signed-off-by: Philippe Retornaz <philippe@shapescale.com
Signed-off-by: Francois Ramu <francois.ramu@st.com>
2019-07-05 10:35:55 -05:00
Ioannis Konstantelias a1d815ea9b drivers: flash: stm32: Fix insufficient wait time
flash_erase cannot erase a page from the STM32xx SOC flash. It seems
that the erase wait time is not enough and against to what the SOC's
datasheet states. As a result this patch doubles the wait time.

Signed-off-by: Ioannis Konstantelias <ikonstadel@gmail.com>
2019-07-05 10:29:10 +02:00