Commit graph

374 commits

Author SHA1 Message Date
Anas Nashif a2fd7d70ec cleanup: include/: move misc/util.h to sys/util.h
move misc/util.h to sys/util.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 5eb90ec169 cleanup: include/: move misc/__assert.h to sys/__assert.h
move misc/__assert.h to sys/__assert.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif bd70f6f1ed cleanup: include/: move spi.h to drivers/spi.h
move spi.h to drivers/spi.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif fe051a9055 cleanup: include/: move flash.h to drivers/flash.h
move flash.h to drivers/flash.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 17ddd1714c cleanup: include/: move clock_control.h to drivers/clock_control.h
move clock_control.h to drivers/clock_control.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 52e0efac97 cleanup: include/: move stats.h to stats/stats.h
move stats.h to stats/stats.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Kumar Gala a614a026b7 dts: Rename DT_.*_GPIO_* to DT_.*_GPIOS_*
Convert DT_.*_GPIO_{CONTROLLER,PIN,FLAGS} ->
	DT_.*_GPIOS_{CONTROLLER,PIN,FLAGS)

Used the following commands to make these conversions:

git grep -l DT_.*_GPIO_CONTROLLER | xargs sed -i 's/DT_\(.*\)_GPIO_CONTROLLER/DT_\1_GPIOS_CONTROLLER/g'
git grep -l DT_.*_GPIO_PIN | xargs sed -i 's/DT_\(.*\)_GPIO_PIN/DT_\1_GPIOS_PIN/g'
git grep -l DT_.*_GPIO_FLAGS | xargs sed -i 's/DT_\(.*\)_GPIO_FLAGS/DT_\1_GPIOS_FLAGS/g'

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-06-27 13:02:34 -05:00
Charles E. Youse 57b46bbc85 soc/x86/intel_quark: remove support for Quark D2000 SoC
Removed Quark D2000 SoC files and first-order related DT bindings.

A few config options have been moved from the CONFIG_* space to
the DT_* space, as they were defined in the D2000 Kconfig files
and "leaked" into the other Quark trees.

Signed-off-by: Charles E. Youse <charles.youse@intel.com>
2019-06-25 08:06:43 -04:00
Anas Nashif f2cb20c772 docs: fix misspelling across the tree
Found a few annoying typos and figured I better run script and
fix anything it can find, here are the results...

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-19 15:34:13 -05:00
Kumar Gala a2693975d7 dts: Convert from DT_<COMPAT>_<INSTANCE>_<PROP> to DT_INST...
Change code from using now deprecated DT_<COMPAT>_<INSTANCE>_<PROP>
defines to using DT_INST_<INSTANCE>_<COMPAT>_<PROP>.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-06-14 08:02:15 -05:00
Anas Nashif 4c32258606 style: add braces around if/while statements
Per guidelines, all statements should have braces around them. We do not
have a CI check for this, so a few went in unnoticed.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-06 15:20:21 +02:00
Lyle Zhu cc2e176bb6 driver: flash: add flash driver for the RV32M1 SOC
Add driver and device tree for the flash controller for the RV32M1 SOC

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2019-06-03 10:43:47 -05:00
Erwan Gouriou 51033a5814 drivers/flash: stm32wb: Add HSEM
Add HSEM for Flash access since shared between 2 cores.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-06-03 09:38:19 -04:00
Erwan Gouriou d777413b19 drivers/flash: stm32wb: Add driver for stm32wb
Add flash driver for stm32wb

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-06-03 09:38:19 -04:00
Ryan C Johnson d9e4512d86 drivers: flash: w25q: erase operations must be erase-size aligned
- Erase operations must be aligned to the erase-size.
 - Don't need to perform an alignment check on a full erase. The offset
   is not used in this case.
 - Don't need to perform alignment check on a sector sized erase, as
   this alignment is checked on entrance to the function.
 - Removed some whitespace.

Signed-off-by: Ryan C Johnson <ryan.johnson@flex.com>
2019-05-30 08:36:14 -04:00
Jan Van Winkel 88964b99ec drivers: flash: Added native POSIX flash driver
Added native POSIX flash driver that writes flash content to a binary
file.

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2019-05-28 21:14:19 -04:00
Radoslaw Koppel 617c6fdb24 drivers/flash/flash_simulator: Allow unaligned read
This commit adds the default configuration to the flash_simualtor
to allow unaligned reads.
Disable this option when testing to increase test coverage.

Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
2019-05-28 11:24:48 +02:00
Kamil Piszczek 42b3bd91e7 drivers: flash: flash_simulator: added max len param
Added a new runtime parameter to the Flash Simulator. It can be used to
ignore part of the data that is written to the simulated flash memory.
This parameter works together with max write calls parameter.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2019-05-27 12:26:20 +02:00
Kamil Piszczek fefc62887c drivers: flash: flash_simulator: added max erase calls param
Added a new runtime parameter to the Flash Simulator. It can be used to
ignore erases to the simulated flash memory after a certain number
of flash erase calls has been executed.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2019-05-27 12:26:20 +02:00
Kamil Piszczek 4054d2bacf drivers: flash: flash_simulator: added max write calls param
Added a new runtime parameter to the Flash Simulator. It can be used to
ignore any writes to the simulated flash memory after a certain number
of flash write calls has been executed. This behaviour is useful for
simulating power down during the flash write operation.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2019-05-13 17:07:28 +02:00
Derek Hageman 4204700ae4 drivers: flash: sam0: Remove defines from dts_fixup.h
Move SAM0 flash to use the raw defines generated from the DTS
parsing.

Signed-off-by: Derek Hageman <hageman@inthat.cloud>
2019-05-03 08:46:57 -05:00
Kamil Piszczek 78a39b80aa drivers: flash: covering more flash page with stats sections
Extended the maximum possible number of sections that track statistics
for each flash page.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2019-05-01 10:33:17 -04:00
Kamil Piszczek 5fd99f5e6a drivers: flash: simulator Kconfig cleanup
Moved the default selection of Flash simulator for qemu_x86 to the board
Kconfig.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2019-04-26 04:04:19 -07:00
Piotr Mienkowski df33e5e861 flash_gecko: add support for page layout
This commit adds support for FLASH_PAGE_LAYOUT Kconfig option in the
flash_gecko driver.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2019-04-26 03:25:08 -07:00
Kamil Piszczek 5895f8d8f1 driver: flash: flash_simulator: moved part of Kconfig to DT
Moved part of the KConfig configuration to the Device Tree.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2019-04-24 13:05:11 -07:00
Kamil Piszczek 6ae532a328 drivers: flash: flash_simulator enabled by default on qemu
Enabled Flash Simulator on the QEMU x86 platform by default.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2019-04-24 13:05:11 -07:00
Kamil Piszczek 1c60416135 drivers: flash: fix flash-simulator build crash
Statistic for flash has limitation regards number of pages possible to
be counted. This path introduces check for that in source file as it is
not possible to preserve the limit in Kconfig.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2019-04-24 13:05:11 -07:00
Kamil Piszczek c837d85c2b drivers: flash: add flash_simulator driver
This commit adds a flash driver implementation that writes to RAM and
exports statistics through stats.h. It can be used to simulate flash
memory for testing purposes.

Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2019-04-24 13:05:11 -07:00
Benjamin Valentin 4d9486fc22 soc: sam0: Enable generic peripheral selection
Make sure that when e.g. CONFIG_SERIAL is set, CONFIG_UART_SAM0 is
selected automatically when the sam0 SoC family is used.

Signed-off-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
2019-04-19 14:37:17 -05:00
Andrzej Puzdrowski 279115e35e drives/flash: provide boundaries info for nRF9160
nRF9160 can't provide FICR data while operation in non-secure
domain.

This patch start using flash layout properties provides by
nrfx API for get flash properties, which resolves problem
described above.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-04-19 11:50:46 +02:00
Andrzej Puzdrowski 560b458a21 drives/flash: use nrfx for nrf
Introduce nrfx_nvmc driver into nordic flash driver implementation.
Thanks to that nrf9160 SoC becomes supported by the driver.

nrfx helps dealing with differences with interface to the NVMC
in secure and non-secure execution modes.

This patch adds NRFX_NVMC Kconfig entry for enabling nrfx_nvmc and
select it along with nordic flash driver.

Disabled UICR operation on nRF9160 for non-secure build
as UICR is not available in this mode.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-04-19 11:50:46 +02:00
Jim Paris 510a6dc5e4 drivers: flash: spi_nor.c: fix typo
This was referencing the wrong DT property, leading to build errors.

Signed-off-by: Jim Paris <jim@jtan.com>
2019-04-11 10:02:44 +02:00
Anas Nashif 3ae52624ff license: cleanup: add SPDX Apache-2.0 license identifier
Update the files which contain no license information with the
'Apache-2.0' SPDX license identifier.  Many source files in the tree are
missing licensing information, which makes it harder for compliance
tools to determine the correct license.

By default all files without license information are under the default
license of Zephyr, which is Apache version 2.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-04-07 08:45:22 -04:00
Patrik Flykt 97b3bd11a7 drivers: Rename reserved function names
Rename reserved function names in drivers/ subdirectory. Update
function macros concatenatenating function names with '##'. As
there is a conflict between the existing gpio_sch_manage_callback()
and _gpio_sch_manage_callback() names, leave the latter unmodified.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-04-03 17:31:00 -04:00
Patrik Flykt 21358baa72 all: Update unsigend 'U' suffix due to multiplication
As the multiplication rule is updated, new unsigned suffixes
are added in the code.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-28 17:15:58 -05:00
Patrik Flykt 24d71431e9 all: Add 'U' suffix when using unsigned variables
Add a 'U' suffix to values when computing and comparing against
unsigned variables.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-28 17:15:58 -05:00
Thomas Stenersen db90e24326 drivers: nrf: add support for forcing driver implementation
An external project extending the Zephyr RTOS and its drivers may have
subsystems that must use its own specific driver(s) when active. One
example is the nRF5x NVMC that must be scheduled in between radio
operations. A subsystem may also be dependent on its own drivers for
security, real-time and/or because of hardware constrains.

In order to not introduce non-Zephyr specific code into the Zephyr tree,
an option is added to disable the in-tree drivers in Zephyr. Because
Kconfig does not support a good way of de-selecting other symbols, a
variable on the form `<DRIVER>_FORCE_ALT` is added as a
dependency for each `<DRIVER>`. For example, the out-of-tree subsystem
will select `FLASH_NRF_FORCE_ALT` to disable the in-tree driver. A
solution for issue #8181 would open up for a more general solution,
however #8181 requires significant effort.

Support for out-of-tree drivers is added to Nordic drivers for
clock_control, entropy and flash.

A generic solution for this is desired. Issue #14527 is tracking that
progress.

Signed-off-by: Thomas Stenersen <thomas.stenersen@nordicsemi.no>
2019-03-20 10:27:28 -05:00
Florian Vaussard 2320973fea flash: stm32l4: disable dcache before writting
Disable the data cache before writing to Flash, in order to workaround
silicon errata 2.2.3: "Data cache might be corrupted during Flash memory
read-while-write operation". The data cache is conditionally re-enabled
once the write is completed.

This silicon bug has been encountered while stress testing the
implementation. Here are the events leading to the fault:
- Code is executing from Flash bank 1
- A write to Flash bank 2 is initiated
- The Cortex SysTick interrupt fires while waiting for Flash write
  completion

In that case, the Flash controller will perform a read-while-write
operation in order to execute the ISR code. As the data cache is enabled
by default after reset, a corruption occurs due to the silicon bug,
leading to bizarre data bus faults or unaligned access faults inside
_timer_int_handler() or one of the functions called by the ISR.

Applying the workaround devised by ST fixes the problem.

Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
2019-03-19 09:56:01 -05:00
Erwan Gouriou 652efa530f drivers/flash: stm32l4: Prepare for unaligned accesses in flash writes
On STM32L4, flash writes operations are performed 8 bytes at a time.
Though, it is possible that *data in flash_write functions is not
aligned. To avoid issues, use UNALIGNED_GET macro to access *data.

Issue has been detected using settings subsystem on STM32WB, which has
same 8bytes write block size. The patch is extended to STM32L4 series
for same reason.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-03-15 06:43:24 -05:00
Erwan Gouriou f3832a399e drivers/flash: stm32f3/stm32f1: define flash registers as volatile
On STM32F3 devices, a trick was required for normal use of registers.
This was actually an issue in flash registers defintions which should
be defined as volatile.
Fix this and additionaly, fix definition for STM32F1 which was also
lacking the volatile instruction.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-03-15 06:43:24 -05:00
Ramakrishna Pallala e1639b5345 device: Extend device_set_power_state API to support async requests
The existing device_set_power_state() API works only in synchronous
mode and this is not desirable for devices(ex: Gyro) which take
longer time (few 100 mSec) to suspend/resume.

To support async mode, a new callback argument is added to the API.
The device drivers can asynchronously suspend/resume and call the
callback function upon completion of the async request.

This commit adds the missing callback parameter to all the drivers
to make it compliant with the new API.

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
2019-03-14 14:26:15 +01:00
Thomas Stenersen a3fc1a1f53 drivers: nrf5: Don't force specific drivers from soc/arm/nordic_nrf
Redefining the config will not let another (out-of-source) driver be
chosen instead of the default. The driver is practically forced by the
soc settings. This commit moves default settings from soc/arm/nordic_nrf
into the drivers themselves.

Signed-off-by: Thomas Stenersen <thomas.stenersen@nordicsemi.no>
2019-03-12 19:42:40 +01:00
Thomas Stenersen 7516476386 kconfig: Use depend on instead of select to avoid kconfig loop
Remove use of select to "force" enabling other configs in subsys/fs
and subsys/net/l2. The forcing will cause infinite kconfig recursion.

Signed-off-by: Thomas Stenersen <thomas.stenersen@nordicsemi.no>
2019-03-12 19:42:40 +01:00
Patrik Flykt 4344e27c26 all: Update reserved function names
Update reserved function names starting with one underscore, replacing
them as follows:
   '_k_' with 'z_'
   '_K_' with 'Z_'
   '_handler_' with 'z_handl_'
   '_Cstart' with 'z_cstart'
   '_Swap' with 'z_swap'

This renaming is done on both global and those static function names
in kernel/include and include/. Other static function names in kernel/
are renamed by removing the leading underscore. Other function names
not starting with any prefix listed above are renamed starting with
a 'z_' or 'Z_' prefix.

Function names starting with two or three leading underscores are not
automatcally renamed since these names will collide with the variants
with two or three leading underscores.

Various generator scripts have also been updated as well as perf,
linker and usb files. These are
   drivers/serial/uart_handlers.c
   include/linker/kobject-text.ld
   kernel/include/syscall_handler.h
   scripts/gen_kobject_list.py
   scripts/gen_syscall_header.py

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-11 13:48:42 -04:00
Ulf Magnusson 5102f6a62e kconfig: drivers: flash: Remove redundant FLASH dependencies
These are from source'ing a file within an 'if FLASH', and then adding
another 'depends on FLASH' within it.

'if FOO' is just shorthand for adding 'depends on FOO' to each item
within the 'if'. There are no "conditional includes" in Kconfig, so
'if FOO' has no special meaning around a 'source'. Conditional includes
wouldn't be possible, because an 'if' condition could include (directly
or indirectly) forward references to symbols not defined yet.

Tip: When adding a symbol, check its dependencies in the menuconfig
('ninja menuconfig', then / to jump to the symbol). The menuconfig also
shows how the file with the symbol got included, so if you see
duplicated dependencies, it's easy to hunt down where they come from.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-09 09:56:40 -05:00
Maureen Helm 5ebf6104a2 soc: nxp_kinetis: Add HAS_MCUX_FTFX to conditionalize mcux flash driver
Adds a new config HAS_MCUX_FTFX to conditionalize the mcux flash driver
on socs that support it. Selects HAS_MCUX_FTFX on all kinetis socs
except kw40z, because even though this soc has the relevant hardware,
its CMSIS header file is not compatible with the mcux flash driver in
ext/.

This change also prevents enabling the mcux flash driver on lpc and imx
rt boards.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2019-03-06 21:19:25 -06:00
Ulf Magnusson 40436f730b kconfig: Use a short consistent prompt style
Same change as in commit 8cf8db3a73 ("Kconfig: Use a short, consistent
style for prompts"), fixing stuff that got introduced since then.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-02-27 09:23:30 +01:00
Krzysztof Chruscinski 3605e48c44 shell: Modify subcommands to use SHELL_STATIC_SUBCMD_SET_CREATE
It is planned to deprecate SHELL_CREATE_STATIC_SUBCMD_SET macro
which is replaced by SHELL_STATIC_SUBCMD_SET_CREATE.

Additionally, removed irrelevant comments about alphabetical
ordering which is no longer needed.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2019-02-20 07:31:35 -05:00
Erwan Gouriou 9a07a2850b drivers/flash: Rework CMakeLists.txt for stm32 drivers
Optimize CMake rules for STM23 series driver build.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-02-19 07:45:50 -06:00
Erwan Gouriou 82403f68e2 drivers/flash: Move STM32F3 to generic STM32 series driver
A common driver is shared between stm32 chips, which was not the case
for stm32f3 series. As a consequence stm32f3 was not maintained
equally and was missing features such as flash layout or dts based
configuration.
Besides, drivers had some flows such as wrong bus clock and
missing HSI clock activation which lead to issues on boards not
using HSI as main clock.
As a consequence this commit moves stm32f3 series flash driver to
common stm32 flash drivers.

Fixes #4197

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-02-19 07:45:50 -06:00
Sebastian Bøe 1312ca7cc2 kconfig: flash: Move nrf code into it's own file
Cleanup the Kconfig code for the flash driver. Platform-specific
options should be in their own Kconfig files to be consistent and to
not pollute the common configuration.

To this end we move the nrf options into it's own file.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-02-15 14:12:48 -05:00
Sebastian Bøe 1f27a456cd kconfig: flash: Move mcux code into it's own file
Cleanup the Kconfig code for the flash driver. Platform-specific
options should be in their own Kconfig files to be consistent and to
not pollute the common configuration.

To this end we move the mcux options into it's own file.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-02-15 14:12:48 -05:00
Sebastian Bøe ae846dce75 kconfig: flash: Move nios code into it's own file
Cleanup the Kconfig code for the flash driver. Platform-specific
options should be in their own Kconfig files to be consistent and to
not pollute the common configuration.

To this end we move the nios2 options into it's own file.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-02-15 14:12:48 -05:00
Rajavardhan Gundi 95e8a582b4 drivers: flash: spi_nor.c: Correct the calculation of SECTORS_COUNT
The patch 44758977f8 made a change where
SECTORS_COUNT was not calculated properly. This patch corrects it.

Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
2019-02-14 22:18:25 -05:00
Carlos Stuart 75f77db432 include: misc: util.h: Rename min/max to MIN/MAX
There are issues using lowercase min and max macros when compiling a C++
application with a third-party toolchain such as GNU ARM Embedded when
using some STL headers i.e. <chrono>.

This is because there are actual C++ functions called min and max
defined in some of the STL headers and these macros interfere with them.
By changing the macros to UPPERCASE, which is consistent with almost all
other pre-processor macros this naming conflict is avoided.

All files that use these macros have been updated.

Signed-off-by: Carlos Stuart <carlosstuart1970@gmail.com>
2019-02-14 22:16:03 -05:00
Kumar Gala 7b4ee6bd45 flash: spi_nor: Convert FLASH_{WRITE,ERASE}_BLOCK_SIZE to DT_
Convert generic FLASH_{WRITE,ERASE}_BLOCK_SIZE to driver specific
generated define DT_JEDEC_SPI_NOR_0_{WRITE,ERASE}_BLOCK_SIZE.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-08 22:39:07 -06:00
Kumar Gala b0308f7fcd flash: flash_gecko: Convert FLASH_WRITE_BLOCK_SIZE to DT_
Convert generic FLASH_WRITE_BLOCK_SIZE to driver specific generated
define DT_SOC_NV_FLASH_0_WRITE_BLOCK_SIZE.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-08 22:39:07 -06:00
Kumar Gala 73f2466f00 flash: flash_sam: Convert FLASH_{WRITE,ERASE}_BLOCK_SIZE to DT_
Convert generic FLASH_{WRITE,ERASE}_BLOCK_SIZE to driver specific
generated define DT_SOC_NV_FLASH_0_{WRITE,ERASE}_BLOCK_SIZE.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-08 22:39:07 -06:00
Kumar Gala 590b5a08a2 flash: soc_flash_mcux: Convert FLASH_ERASE_BLOCK_SIZE to DT_
Convert generic FLASH_ERASE_BLOCK_SIZE to driver specific generated
define DT_SOC_NV_FLASH_0_ERASE_BLOCK_SIZE.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-08 22:39:07 -06:00
Kumar Gala f6c7e9a997 flash: flash_stm32: Convert FLASH_WRITE_BLOCK_SIZE to DT_
Convert generic FLASH_WRITE_BLOCK_SIZE to driver specific generated
define DT_SOC_NV_FLASH_0_WRITE_BLOCK_SIZE.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-08 22:39:07 -06:00
Anas Nashif 5846697591 flash: shell: fix dependency on FLASH_PAGE_LAYOUT
Fix dependency, it should depend on FLASH_PAGE_LAYOUT rather than
FLASH_HAS_PAGE_LAYOUT.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-02-04 17:55:40 -05:00
Peter A. Bigot e7303cb09a boards: nrf52840_pca10056: add bindings for on-board serial flash
This board has an on-board 64 Mibit serial flash from Macronix.  Add
bindings to access it.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-02-01 04:21:40 -06:00
Peter A. Bigot 44758977f8 drivers: flash: spi-nor: update towards device-tree support
Use the jedec,spi-nor bindings to configure as much of the device as can
be expressed by device tree.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-02-01 04:21:40 -06:00
Aurelien Jarno 8a7e7407d0 drivers: flash: SAM E70: fix warnings when built with newlib
off_t is int with the minimal libc and long with the newlib libc. The
log messages are assuming that off_t is int, therefore this causes
warnings when building with newlib.

Fix that by casting the offset to the "longer" type, ie long.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-01-30 10:27:09 -06:00
Kumar Gala f054ba2b65 flash: w25qxxdv: Convert to new DT_<COMPAT>_<INSTANCE> defines
Convert w25qxxdv driver to use new defines so we can remove the
dts_fixup.h code for it.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-01-28 10:40:31 -06:00
Rajavardhan Gundi f5b60eeca8 Kconfig: spi_nor: Remove Erase configuration from Kconfig
Configuration of Erase command is specified in DTS. Hence
the corresponding changes in Kconfig are removed.

Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
2019-01-16 21:22:56 -05:00
Rajavardhan Gundi 74895bc099 dts: spi_nor: Rename DT_SPI_NOR_SPI_SLAVE to DT_SPI_NOR_SPI_SLAVE_ID
The "_ID" suffix for DT_SPI_NOR_SPI_SLAVE better represents what it
is used for.

Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
2019-01-16 21:22:56 -05:00
Rajavardhan Gundi 7d428bb0a8 flash: spi_nor: Remove Kconfig parameter for SPI_NOR_SECTORS
Number of sectors is now calculated from the flash density
i.e. (Flash size)/(sector size).

Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
2019-01-16 21:22:56 -05:00
Rajavardhan Gundi 75f6f1b279 drivers: flash: spi_nor: Enable Flash Page Layout and Map
This patch enables the support for FLASH_PAGE_LAYOUT and
FLASH_MAP for the generic spin nor flash driver.

Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
2019-01-16 21:22:56 -05:00
Rajavardhan Gundi f885fd15bf DTS: flash: spi_nor: use DT_ for freq and other parameters
Use DT_ instead of CONFIG_ for spi freq, spi bus name, flash device
name and flash base address.

Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
2019-01-16 21:22:56 -05:00
Varun Sharma 77c643a5a3 drivers: Modify drivers to use DEVICE_AND_API_INIT()
Modified drivers to use DEVICE_AND_API_INIT() instead of DEVICE_INIT()

This will make sure driver_api,is populated at build time and is exposed
to user space

Signed-off-by: Varun Sharma <varun.sharma@intel.com>
2019-01-15 10:39:34 -08:00
Jan Van Winkel a6b286ced4 flash: Remove shell context from flash shell
Remove external declared shell context from flash shell

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2019-01-09 16:33:15 -05:00
Jan Van Winkel ea3ca125bb flash: Use flash page layout size in flash shell
Use the page size retrieved via page layout in flash erase
shell command in case erase size is not given.

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2019-01-09 16:33:15 -05:00
Kumar Gala a4c3feced4 dts: flash: w25qxxdv: Add Device Tree Support for SPI FLASH w25qxxdv
Convert the w25qxxdv driver to use device tree for SPI device params.
Updated the Arduino 101 config to use device tree to specify the SPI
flash.  Update the arduino_101_sss to drop Kconfig support for the
w25qxxdv flash.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-01-09 10:26:10 -06:00
Piotr Mienkowski aa2c27d007 soc: silabs_exx32: Add independent Kconfig options for HAL libraries
Zephyr gecko drivers depend on libraries provided by the vendor. The
same libraries may also be used directly by the application code or
RAIL library. To facilitate the latter use case scenario this commit
adds Kconfig options to independently enable compilation of vendor
HAL library modules.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2019-01-08 13:31:42 -06:00
Olivier Martin 7031d5bdda drivers: flash: w25qxxdv: write across programming pages
Until now spi_flash_wb_write/read functions were only supporting
buffers that fit into a W25Q page (even if there were not checking
the offset was page aligned).
This change allows these function to read/write multiple W25Q page.
This change is required as the caller of these functions are not
aware of flash page size.

Signed-off-by: Johannes Hutter <johannes@proglove.de>
Signed-off-by: Olivier Martin <olivier.martin@proglove.de>
Signed-off-by: Michael Wendland <michael@proglove.de>
2019-01-07 16:09:04 -05:00
Olivier Martin 4bc4bbf350 drivers: flash: w25q: Allow to skip SYNC_LOCK/SYNC_UNLOCK
The next commit will use this new
spi_flash_wb_write_protection_set_with_lock() in
spi_flash_wb_write() that already hold the lock.
To prevent a lock we need to skip the SYNC_LOCK when we want
to disable write protection.

Signed-off-by: Olivier Martin <olivier.martin@proglove.de>
2019-01-07 16:09:04 -05:00
Vinayak Kariappa Chettimada 87fe440f01 Bluetooth: controller: Prepare to introduce LL split architecture
Preparation to introduce the Upper Link Layer (ULL) and
Lower Link Layer (LLL) split architecture.

- Move SoC dependent HAL to vendor specific folder.
- Preparation to split data structures into ULL and LLL
  types.
- Added more role and state conditional compilations.
- Added some work-in-progress implementation of advertising
  extensions, will be used as inspiration in the new split
  architecture work.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-01-07 13:42:01 +01:00
Jan Van Winkel 3a8c2b8ad8 flash: Remove NRF dependency from flash shell
Removed dependency to NRF_FICR CODEPAGESIZE from flash shell erase
command

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2019-01-07 11:10:34 +01:00
Maureen Helm 011a88c744 ext: mcux: Update to MCUXpresso SDK 2.5.0
Updates the MCUXpresso SDK to version 2.5.0 for applicable SoCs.
Wireless (KW*) and legacy (KL25) SoCs were not included in this
MCUXpresso SDK release and are therefore not updated here.

New in this release is SoC-level and board-level support for external
xip flash in the i.MX RT family.

For RT1050, we are now using the MCUXpresso SDK for the EVKB version of
the board, which correponds to an upgrade from A0 to A1 silicon.
However, we don't yet have Kconfigs in place to support A1 silicon part
numbers, and therefore add a simple cmake hack to convert A0 part
numbers to A1 part numbers.

The SDK flash driver interface also changed slightly in this release,
and thus the zephyr flash shim driver is updated accordingly.

Origin: MCUXpresso SDK
License: BSD 3-Clause
URL: mcux.nxp.com
Purpose: Provide device header files and bare metal peripheral drivers
for Kinetis, LPC, and i.MX SoCs.
Maintained-by: External

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2019-01-03 17:25:28 -05:00
Andrzej Puzdrowski 3f422e2efe drivers: flash: fix the regular access range check
The check was susceptible for overflow.
This patch corrects this malfunction.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-12-19 17:47:08 +01:00
Andrzej Puzdrowski cd4fbdeac8 drivers: flash: support NRF UICR operations
Nordic UICR are non-volatile memory registers for
configuring user-specific settings. Basically it is subset of flash
memory available in the SoC.

Add support for operations on NVM which belongs to UICR.
UICR are written or read as ordinary flash memory.
For erasing UICR it is required to call erase with UICR start
address and its size (this is caused by what hardware supported).

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-12-19 17:47:08 +01:00
Aurelien Jarno 6752b5df3f drivers: flash: add driver for STM32F7x series
This patch adds a flash driver for the STM32F7x series, inspired from
the STM32F4x one. It has been tested on the STM32F723, but should also
work on other SoCs of the family.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2018-12-17 08:15:59 -06:00
Aurelien Jarno 48d1fbb352 drivers: flash: stm32: pass offset and len to flash_stm32_flush_caches
On SoC families using a Cortex-M7, it is possible to flush only specific
cache lines. Therefore pass the offset and len so that the flush can be
done with more granularity.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2018-12-17 08:15:59 -06:00
Aurelien Jarno 123b832a02 drivers: flash: stm32: don't flush i-cache after an erase
In general synchronisation between memory and the instruction cache
should be done explicitly, for example this is how it is done for RAM.
It is also done that way for flash writes in the current STM32 flash
driver.

However in case of flash erases, the current STM32 flash driver flushes
the i-cache. It probably doesn't make a big difference for the
Cortex-M3/M4 families as the cache is very small. That said it might
have bigger impact on families based on Cortex-M7 as it has between 4KB
and 16KB of i-cache, that will be added latter in this patch serie.

This patch therefore remove the i-cache flush in
flash_stm32_flush_caches.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2018-12-17 08:15:59 -06:00
Aurelien Jarno 551f9c38b8 drivers: flash: stm32: always define flash_stm32_flush_caches
This reduces the amount of #ifdef and keep all of them at the same
place. The empty function is then optimized-out by the compiler.

At the same time change the negative test by a positive one to simplify
adding new entries.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2018-12-17 08:15:59 -06:00
Aurelien Jarno 8e356dbc88 drivers: flash: stm32: improve timeout handling
The timeout handling in the STM32 flash driver is currently a counter
in the busy check loop. This doesn't scale well across the whole STM32
family:
- The duration of the loop depends on the CPU speed, the activation of
  caches.
- The duration of the longest flash operation (a sector erase as the
  driver doesn't support mass erase) can varies a lot mostly depending
  on the sector size, 2K on F0 and L4 families or 128K on the F4 family.

In addition the timeout can change depending if the writing thread is
prempted or not.

Fix that by defining a timeout in ms depending on the family, and using
k_uptime_get to get a precise measurement of the time.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2018-12-17 08:15:59 -06:00
Anas Nashif 1b48a7a715 drivers: flash_mcux: remove inclusion of sys+log.h
Stray inclusion of old sys_log.h. Nothing uses it in that driver.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-12-10 20:38:09 -05:00
Erwan Gouriou 9062e97a45 drivers: stm32: check clock_control_on return value
Check clock_control_on return value now that it is checking appropriate
bus is used in the request.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2018-12-07 11:31:48 -05:00
Ramakrishna Pallala a4f933677b drivers: flash: Nios-II QSPI Coccinelle issue
Fixed Coccinelle warning "Unsigned expression compared with zero".

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
2018-12-07 10:42:01 -05:00
Jakub Rzeszutko 3064ca4f2f shell: creating new module for help functionality
1. Created new shell module: shell_help.
2. Simplified command handlers with new shell print macros.
3. Removed help functions from command handlers.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-12-05 15:15:44 +01:00
Jakub Rzeszutko 5451ff2848 shell: remove "options" concept
Removing help "options" from shell API.

Currently SHELL_OPT macro is not used by users. What is more
commit: a89690d10f ignores possible options created in
command handler by the user. As a result they are not printed
in help message.

Second, currntly implemented "options" in command handlers options are
implemented without SHELL_OPT macro.

And last but not least this change will allow to implement
help handler in a way that user will not need to think about calling
functions printing help in a command handler.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-12-05 15:15:44 +01:00
Patrik Flykt 8ff96b5a57 drivers: Add 'U' to unsigned variable assignments
Add 'U' to a value when assigning it to an unsigned variable.
MISRA-C rule 7.2

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-12-04 22:51:56 -05:00
Rajavardhan Gundi 7765c1adaf drivers: flash: spi_nor: Remove unused block_size parameter
Only page and sector size is used by the driver.

Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
2018-12-02 09:27:16 -05:00
Rajavardhan Gundi 826a7cdca8 drivers: flash: spi_nor: Remove page alignment requirement for R/W
For flash R/W, the start address need not be aligned on a page size.

Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
2018-12-02 09:27:16 -05:00
Himanshu Jha 3bff9b1b50 drivers: flash_gecko: remove unnecessary variable
Remove an unnecessary local variable to store the
return value, instead return directly thereby saving
few bits of memory.

Found using Coccinelle.

Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
2018-11-28 11:54:01 -08:00
Rajavardhan Gundi 4b3f3ab056 drivers: flash: spi_nor: Correct the return values for R/W
Fixed the return values for read and write APIs for spin_nor.c
which were not inline with what the corresponding interfaces
were meant to return.

Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
2018-11-24 07:58:05 -05:00
Olivier Martin 184753a4e6 drivers: flash: w25q: Add support for page layout
We use the sector size rather than the page size as some
modules that consumes the flash page layout (such as FCB)
assume the page size is the minimal size they can erase.

Signed-off-by: Olivier Martin <olivier.martin@proglove.de>
2018-11-21 05:08:10 -06:00
Aurelien Jarno 6194b7676c drivers: flash: add flash driver support for Atmel SAM E70
This patch adds a flash driver for the Atmel SAM E70 SoC. The driver has
been kept simple by considering that the flash is only composed of 8-KiB
blocks. Indeed an area at the beginning of the flash might be erased
with a smaller granularity, and the other blocks can also be erased with
a higher granularity. It also only handles the global read/write
protection, not the 128-KiB lock regions. A write error is returned if
a region is locked.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2018-11-20 14:11:07 -05:00
Savinay Dharmappa 87e5493167 drivers: flash: add a generic spi nor flash driver
This driver is inspired from the w25qxxdv SPI NOR flash driver which was
already implementing the CFI (Common Flash Interface) for its purpose.
To handle other NOR flash a flash id table (as Linux do) which contains
the geometry for a few SPI NOR flash based on their JEDEC ID has been
introduced.
We currently support the following flash:
 - W25Q80
 - W25Q16
 - W25Q32
 - S25FL216K
 - MX25UM512

The read and write functions are able to handle more then one page at a
time and return the number of bytes read or write.
Also because every NOR flash expect to disable the write protection
before writing or erasing, the write enable command is now part of the
write and erase functions.

Signed-off-by: Sebastien Bourdelin <sebastien.bourdelin@savoirfairelinux.com>
Signed-off-by: Savinay Dharmappa <savinay.dharmappa@intel.com>
2018-11-13 18:49:03 -05:00
Andrzej Głąbek 20202902f2 dts_fixups: Use DT_ prefix in all defined labels not related to Kconfig
These changes were obtained by running a script  created by
Ulf Magnusson <Ulf.Magnusson@nordicsemi.no> for the following
specification:

1. Read the contents of all dts_fixup.h files in Zephyr
2. Check the left-hand side of the #define macros (i.e. the X in
   #define X Y)
3. Check if that name is also the name of a Kconfig option
   3.a If it is, then do nothing
   3.b If it is not, then replace CONFIG_ with DT_ or add DT_ if it
       has neither of these two prefixes
4. Replace the use of the changed #define in the code itself
   (.c, .h, .ld)

Additionally, some tweaks had to be added to this script to catch some
of the macros used in the code in a parameterized form, e.g.:
- CONFIG_GPIO_STM32_GPIO##__SUFFIX##_BASE_ADDRESS
- CONFIG_UART_##idx##_TX_PIN
- I2C_SBCON_##_num##_BASE_ADDR
and to prevent adding DT_ prefix to the following symbols:
- FLASH_START
- FLASH_SIZE
- SRAM_START
- SRAM_SIZE
- _ROM_ADDR
- _ROM_SIZE
- _RAM_ADDR
- _RAM_SIZE
which are surprisingly also defined in some dts_fixup.h files.

Finally, some manual corrections had to be done as well:
- name##_IRQ -> DT_##name##_IRQ in uart_stm32.c

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2018-11-13 10:44:42 -06:00
Piotr Mienkowski d9e2171aa9 drivers: flash_gecko: Add flash driver for SiLabs Gecko SoCs
Tested with SLWSTK6061A / BRD4250B wireless starter kit.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2018-11-08 17:56:44 -05:00
Jakub Rzeszutko 147122e77f shell: examples unification
Updating examples according to new return value of function
shell_cmd_precheck.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-10-19 13:35:56 +02:00
Anas Nashif 3aa2a1c6db flash: make flash shell generic
This shell command was tied to bluetooth and the bluetooth shell and
also had messages all related to nordic ICs.
Make it generic and put it under drivers/flash/ so it can be included by
anyone and independently of bluetooth.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-10-19 11:49:18 +02:00
Anas Nashif 518ec097eb drivers: soc_flash_nios2_qspi: fix logging formatting
Fix formatting in logging messages. Remove newline.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-10-10 15:46:52 -04:00
Anas Nashif ffb75da2ea drivers: flash: move to new logger
Move drivers to new logger and change samples enabling logging in
prj.conf.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-10-10 10:22:01 -04:00
Anas Nashif 6b8bbc7d07 drivers: flash: fix Kconfig dependencies
Use top level conditional and remove 'depends on FLASH'

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-10-10 10:22:01 -04:00
Pushpal Sidhu 5bc5bb2c7f flash: stm32l4x: Correct getting page number from STM32L4R/S devices
These devices increase the page size from 2k (standard STM32L4) to 4K,
so we must account for this.

Signed-off-by: Pushpal Sidhu <psidhu.devel@gmail.com>
2018-10-08 12:52:00 -04:00
Mark Ruvald Pedersen d67096da05 portability: Avoid void* arithmetics which is a GNU extension
Under GNU C, sizeof(void) = 1. This commit merely makes it explicit u8.

Pointer arithmetics over void types is:
 * A GNU C extension
 * Not supported by Clang
 * Illegal across all ISO C standards

See also: https://gcc.gnu.org/onlinedocs/gcc/Pointer-Arith.html

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2018-09-28 07:57:28 +05:30
Vinayak Kariappa Chettimada 9da6a85c8c drivers: flash: nrf5: Use faster write interval with BT sync
Use a lower slot duration than the used erase slot duration
to speed up the interval of write operations when in sync
with active Bluetooth connections.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2018-09-21 13:15:54 +02:00
Flavio Ceolin 67ca176754 headers: Fix headers across the project
Any word started with underscore followed by and uppercase letter or a
second underscore is a reserved word according with C99.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-17 15:49:26 -04:00
Flavio Ceolin 0866d18d03 irq: Fix irq_lock api usage
irq_lock returns an unsigned int, though, several places was using
signed int. This commit fix this behaviour.

In order to avoid this error happens again, a coccinelle script was
added and can be used to check violations.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-08-16 19:47:41 -07:00
Ulf Magnusson 8cf8db3a73 Kconfig: Use a short, consistent style for prompts
Consistently use

    config FOO
            bool/int/hex/string "Prompt text"

instead of

    config FOO
            bool/int/hex/string
            prompt "Prompt text"

(...and a bunch of other variations that e.g. swapped the order of the
type and the 'prompt', or put other properties between them).

The shorthand is fully equivalent to using 'prompt'. It saves lines and
avoids tricking people into thinking there is some semantic difference.

Most of the grunt work was done by a modified version of
https://unix.stackexchange.com/questions/26284/
how-can-i-use-sed-to-replace-a-multi-line-string/26290#26290, but some
of the rarer variations had to be converted manually.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-15 04:10:10 -07:00
Ulf Magnusson ec3eff57e0 Kconfig: Use the first default with a satisfied condition
Up until now, Zephyr has patched Kconfig to use the last 'default' with
a satisfied condition, instead of the first one. I'm not sure why the
patch was added (it predates Kconfiglib), but I suspect it's related to
Kconfig.defconfig files.

There are at least three problems with the patch:

  1. It's inconsistent with how Kconfig works in other projects, which
     might confuse newcomers.

  2. Due to oversights, earlier 'range' properties are still preferred,
     as well as earlier 'default' properties on choices.

     In addition to being inconsistent, this makes it impossible to
     override 'range' properties and choice 'default' properties if the
     base definition of the symbol/choice already has 'range'/'default'
     properties.

     I've seen errors caused by the inconsistency, and I suspect there
     are more.

  3. A fork of Kconfiglib that adds the patch needs to be maintained.

Get rid of the patch and go back to standard Kconfig behavior, as
follows:

  1. Include the Kconfig.defconfig files first instead of last in
     Kconfig.zephyr.

  2. Include boards/Kconfig and arch/<arch>/Kconfig first instead of
     last in arch/Kconfig.

  3. Include arch/<arch>/soc/*/Kconfig first instead of last in
     arch/<arch>/Kconfig.

  4. Swap a few other 'source's to preserve behavior for some scattered
     symbols with multiple definitions.

     Swap 'source's in some no-op cases too, where it might match the
     intent.

  5. Reverse the defaults on symbol definitions that have more than one
     default.

     Skip defaults that are mutually exclusive, e.g. where each default
     has an 'if <some board>' condition. They are already safe.

  6. Remove the prefer-later-defaults patch from Kconfiglib.

Testing was done with a Python script that lists all Kconfig
symbols/choices with multiple defaults, along with a whitelist of fixed
symbols. The script also verifies that there are no "unreachable"
defaults hidden by defaults without conditions

As an additional test, zephyr/.config was generated before and after the
change for several samples and checked to be identical (after sorting).

This commit includes some default-related cleanups as well:

  - Simplify some symbol definitions, e.g. where a default has 'if FOO'
    when the symbol already has 'depends on FOO'.

  - Remove some redundant 'default ""' for string symbols. This is the
    implicit default.

Piggyback fixes for swapped ranges on BT_L2CAP_RX_MTU and
BT_L2CAP_TX_MTU (caused by confusing inconsistency).

Piggyback some fixes for style nits too, e.g. unindented help texts.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-10 12:38:28 -07:00
Olivier Martin a07d98a62f drivers: flash: w25q: Fix typo
'commands' was mispelled in all the file 'spi_flash_w25qxxdv_defs.h'

Signed-off-by: Olivier Martin <olivier.martin@proglove.de>
2018-07-17 08:27:04 -04:00
Ulf Magnusson 00f363e4c8 drivers: flash: Kconfig: Remove redundant 'default n' 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, and is
inconsistent.

This will make the auto-generated Kconfig documentation have "No
defaults. Implicitly defaults to n." as well, which is clearer than
'default n if ...'

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-07-03 17:11:31 -04:00
Jamie McCrae 23ce6f44b5 drivers: flash: w25qxxdv: Add options for delay and device ID
Adds support for configuring the CS toggling delay and using a
different device ID so that compatible flash chips can also be
used by this driver.

Signed-off-by: Jamie McCrae <jamie.mccrae@lairdtech.com>
2018-06-22 12:27:40 -04:00
Johannes Hutter 392da5baee drivers: flash: w25qxxdv: Avoid locking when not threaded
When using CONFIG_MULTITHREADING=n, the semaphore primitives are
non-functional and useless. Remove their usage when this option is
enabled.

Signed-off-by: Johannes Hutter <johannes@proglove.de>
2018-06-18 12:31:06 -04:00
Carles Cufi 408ea1464b drivers: flash: nrf: Avoid locking when not threaded
When using CONFIG_MULTITHREADING=n, the semaphore primitives are
non-functional and useless. Remove their usage when this option is
enabled.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-06-16 12:03:22 +02:00
Tomasz Bursztyka 2fe51996db drivers/flash: Remove irrelevant option in w25qxxdv driver
CONFIG_SPI_FLASH_W25QXXDV_MAX_DATA_LEN is a left-over from old SPI API
usage. Now, there is no limit (besides the flash size) in SPI data
transaction.

Fixes #8327

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-06-14 14:41:52 -04:00
Tomasz Bursztyka a88a98665b drivers/flags: W25QXXDW internal erase logic fix
The old way of erasing was not completely moved to the new SPI access
function, thus always sending useless dummy bytes that could lead to
error (aka: erasing more than requested).

Fixes #8065

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-06-04 08:25:42 -04:00
Tomasz Bursztyka 002031d87f drivers/flash: Cleaning up Kconfig
Splitting to dedicated Kconfig for w25qxxdv and qmsi.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-05-29 16:21:08 -04:00
Tomasz Bursztyka a6d8378377 drivers/flash: A support for SPI gpio-cs logic into w25qxxdv driver
Up to SPI API user code to handle providing the right SPI GPIO-CS
parameters now.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-05-29 16:21:08 -04:00
Adithya Baglody 5f5e9fb968 drivers: flash: Remove usage of zephyr_library_ifdef
Phasing out the usage of this cmake macro from the drivers/flash
folder.

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2018-05-28 13:23:13 -04:00
Andrew Boie 8345e5ebf0 syscalls: remove policy from handler checks
The various macros to do checks in system call handlers all
implictly would generate a kernel oops if a check failed.
This is undesirable for a few reasons:

* System call handlers that acquire resources in the handler
  have no good recourse for cleanup if a check fails.
* In some cases we may want to propagate a return value back
  to the caller instead of just killing the calling thread,
  even though the base API doesn't do these checks.

These macros now all return a value, if nonzero is returned
the check failed. K_OOPS() now wraps these calls to generate
a kernel oops.

At the moment, the policy for all APIs has not changed. They
still all oops upon a failed check/

The macros now use the Z_ notation for private APIs.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-05-17 23:34:03 +03:00
Adithya Baglody b0db28b512 drivers: Cmake: Add __ZEPHYR_SUPERVISOR__ macro for driver files.
Normally a syscall would check the current privilege level and then
decide to go to _impl_<syscall> directly or go through a
_handler_<syscall>.
__ZEPHYR_SUPERVISOR__ is a compiler optimization flag which will
make all the system calls from the driver files directly link
to the _impl_<syscall>. Thereby reducing the overhead of checking the
privileges.

In the previous implementation all the source files would be compiled
by zephyr_source() rule. This means that zephyr_* is a catchall CMake
library for source files that can be built purely with the include
paths, defines, and other compiler flags that all zephyr source
files uses. This states that adding one extra compiler flag for only
one complete directory would fail.
This limitation can be overcome by using zephyr_libray* APIs. This
creates a library for the required directories and it also supports
directory level properties.
Hence we use zephyr_library* to create a new library with
macro _ZEPHYR_SUPERVISOR_ for the optimization.

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2018-05-15 17:48:18 +03:00
Leandro Pereira c200367b68 drivers: Perform a runtime check if a driver is capable of an operation
Driver APIs might not implement all operations, making it possible for
a user thread to get the kernel to execute a function at 0x00000000.

Perform runtime checks in all the driver handlers, checking if they're
capable of performing the requested operation.

Fixes #6907.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2018-04-26 02:57:12 +05:30
Henrik Brix Andersen 8c5b16cc79 drivers: flash: atmel sam0: Fix compilation without page layout support
The sam0 flash driver has support for retrieving flash page layout
information.  This commit fixes compilation when
CONFIG_FLASH_PAGE_LAYOUT is disabled.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2018-04-12 17:26:54 -05:00
David Leach 51a2090780 newlib: Fix compiler warning when using Newlib
- There is a mismatch when interfacing with external code where a
  uint32_t is defined as a parameter and internal Zephyr code attempts
  to use u32_t. If NewLib is used, the typedef for u32_t is
  'unsigned int' which is not a portable match to uint32_t as
  'unsigned int' is not a common size across architectures so gcc will
  output a warning.
- The mcux flash code calls NXP supplied functions that expect a
  uint32_t.
- openthread.c ot_state_changed_handler has a uint32_t flag as a
  parameter.

Signed-off-by: David Leach <david.leach@nxp.com>
2018-04-11 16:57:12 +03:00
Tomasz Bursztyka 16cb7ab883 drivers/flash: Switch W25QXXDV driver to new SPI API
This saves quite some memory.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-04-04 19:02:35 +02:00
Tomasz Bursztyka 324265420b api/spi: Disable legacy API by default
Let's start deprecation work of the SPI legacy API.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-04-04 19:02:35 +02:00
Carles Cufi 8aa9a37902 drivers: flash: nrf: Rename nrf5 to nrf
With upcoming ICs that are not in the nRF5x family, rename the flash
driver and all its dependencies from nrf5 to nrf.

Should also fix the issue introduced by f49150cab6 which broke the
assignment of the flash device due to a partial rename.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-03-20 20:07:09 +01:00
Carles Cufi f49150cab6 arch: arm: nrf: Rename nrf5 SoC Family to nrf
Upcoming Nordic ICs that share many of the peripherals and architecture
with the currently supported nRF5x ones are no longer part of the nRF5
family. In order to accomodate that, rename the SoC family from nrf5 to
nrf, so that it can contain all of the members of the wider Nordic
family.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-03-20 11:57:14 +01:00
Ilya Tagunov 48a5fbcaa9 drivers: flash: stm32f0: remove CONFIG_FLASH_PAGE_SIZE
STM32F0 flash driver already uses FLASH_PAGE_SIZE from HAL
in flash layout part, so CONFIG_FLASH_PAGE_SIZE is redundant
and confusing.

Signed-off-by: Ilya Tagunov <tagunil@gmail.com>
2018-03-18 17:02:53 -04:00
Andrzej Puzdrowski c788f84f25 drivers: flash: move FLASH_HAS_PAGE_LAYOUT Kconfig from arch
Keyword FLASH_HAS_PAGE_LAYOUT is related to flash and should
be declared in its Kconfig.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-03-08 10:18:57 +01:00
Andrzej Puzdrowski 80a99fa450 subsys: storage: flash_map: enable only if any flash driver is enable
It was possible to have enable flash module while no flash driver
implementation was enabled. This cause coverity issues and unnecessary
initialization call.

This pat introduce FLASH_HAS_DRIVER_ENABLED Kconfig keyword which is
selected once any flash driver is enabled. flash_map switch its
dependency to this keyword.


Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-03-08 10:18:57 +01:00
Ramakrishna Pallala 43d323ee9e drivers: flash: Fix Nios-II QSPI flash Coverity issue
Fix Coverity "Memory - corruptions (ARRAY_VS_SINGLETON)"
issue by type casting word_to_write to u8_t pointer and
adding a length check before memcpy operation.

Coverity CID: 182779

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
2018-03-06 10:36:39 -08:00
Vinayak Kariappa Chettimada 3637d50c25 drivers: flash: nRF5x: Fix co-operation with Bluetooth controller
Fixed incorrect comparison of FLASH_SLOT in microseconds
with ticks elapsed.

This caused Bluetooth controller to try scheduling events
beyond the acceptable soft real-time design limits, due to
the CPU halted for flash erase operation.

Fixes #6229.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-02-16 12:03:05 +01:00
Vinayak Kariappa Chettimada 4c123a5162 Bluetooth: controller: Refactor ticker integration into hal
Refactor ticker execution context dependency out into HAL
folder. This decouples ticker from mayfly, enabling porting
towards a more tasklet (if and when kernel gets the support)
style execution contexts type implementation support.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-02-13 13:26:37 +01:00
Marti Bolivar 4e6e7374c4 flash: mcux: implement software write protection (HACK)
Write protection is currently not supported by the mcux flash
driver. This prevents it from working with the DFU subsystem, which
checks the error codes from the write protect routine. Hack it for now
with a semaphore.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-02-06 15:39:45 -06:00
Ramakrishna Pallala c02a2bed61 drivers: flash: Add Nios-II QSPI flash driver
Add Altera Nios-II QSPI Flash controller driver which has
has 1024 blocks or sectors wich each sector size being 64K bytes.
This driver supports flash erase, write, read and lock operations.

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
2018-02-05 06:30:50 -08:00
Maureen Helm 262595f09f drivers: flash: Implement flash page layout api in mcux driver
Uses the new flash erase-block-size dts property to implement the flash
page layout api in the mcux flash driver.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2018-01-31 16:43:40 -06:00
Kumar Gala a394693d2f drivers: flash: NXP k6x/kw2xd: Convert to use device tree
Convert NXP k6x and kw2xd flash driver to use device tree to get the
flash controller name from device tree.  We introduce yaml bindings for
the "nxp,kinetis-ftfe" and "nxp,kinetis-ftfl" devices.

Fixes: #5788

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-01-29 16:34:49 -06:00
Kumar Gala 2dfee62a5e drivers: flash: atmel sam0: Convert to use device tree
Convert Atmel SAM0 flash driver to use device tree to get the flash
controller name and base address.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-01-27 21:09:28 -06:00
Kumar Gala dc98605f4a drivers: flash: stm32: Convert to use device tree
Convert STM32 flash drivers to use device tree to get the flash
controller name and base address.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-01-26 09:25:57 -06:00
Kumar Gala 26e4da52cf arm: nordic: flash: Use FLASH_DEV_NAME define
We want to move to use a common FLASH_DEV_NAME across the various flash
drivers. So samples, tests, or other code can be a bit more generic.  So
replace CONFIG_SOC_FLASH_NRF5_DEV_NAME with FLASH_DEV_NAME.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-01-25 15:23:00 -06:00
Andrzej Puzdrowski ff7dfc4fb4 dts: bindings: add support for the flash driver name
So far, DT did not support the flash driver name.
Any flash-controller should have the appropriate
flash driver that should be identified by its name.

This path adds generic support for extract the description
from the flash-controller node,
adds implementation of this property for all nrf5x targets.


Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-01-23 12:29:50 -06:00
Erwan Gouriou 5ef0019a24 drivers: flash: stm32: get write block size from device tree
In flash driver init, write_block_size could be initialized
with FLASH_WRITE_BLOCK_SIZE which is generated from device
tree parsing (dts property: "write-block-size")
Fixes #5305
If not defined, generate a compilation error.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2018-01-19 12:16:00 -06:00
Michael Hope cd92dd139b flash: add a driver for the internal flash on the SAM0 series.
The SAM0 has a 64 byte page (the programing unit) with 4 pages to a
row (the erase unit).  This driver implements a read/modify/write to
emulate the byte level writes used by NFFS.

Signed-off-by: Michael Hope <mlhx@google.com>
2018-01-11 19:03:52 -05:00
Carles Cufi 7d764b35f3 cmake: Use path-corrected version of ZEPHYR_BASE
Instead of accessing the environment variable ZEPHYR_BASE every time we
require accessing the source code root, use an intermediate variable
that has OS path separators correctly set to '/' to avoid issues on
Windows.

Note: This removes the ZEPHYR_SOURCE_DIR CMake variable. External
applications using that will need to change to use the new ZEPHYR_BASE
variable.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-01-11 14:59:03 -05:00
Andrzej Puzdrowski d095963e73 drivers: flash: Assert implementation of Flash Page Layout
Some drivers doesn't implement flash API page layout extension
which is causing the application crash once the API was calling.
This patch introduce system termination for this in those drivers
which doesn't implement extension. This will help to discover this
problem early.

It is not done by preprocessor check because it is possible to have
enabled a driver which support and a driver which doesn't support
this API simultaneously.

Now FLASH_PAGE_LAYOUT configuration option is accessible only in case
that at last one driver which implements mentioned API is enabled.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2017-12-12 14:23:50 -06:00
Neil Armstrong 32cb3f0220 flash: stm32: add support for STM32F0 flash controller
Add the STM32F0 Embedded Flash support in the flash_stm32 driver
interface.
The STM32F0 has a particularity or use the HSI as clock source
for the flash controller interface, so this clock must be
enabled directly in the case HSE or another clock is used by
the system clock.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2017-12-12 12:36:08 -06:00
Neil Armstrong 958acd1b4e flash: stm32l4x: fix build
Fix build since current file directly is no more in the include path.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2017-12-04 10:53:12 -06:00
Michael Hope 21b94bacd9 flash: minor documentation improvements.
This patch makes minor improvements to the flash documentation:

* spi -> SPI
* Capitialise the first word in a sentance
* Adding the, and, all, etc where appropriate.

Signed-off-by: Michael Hope <mlhx@google.com>
2017-11-28 12:25:19 -05:00
Sebastian Bøe 0829ddfe9a kbuild: Removed KBuild
Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00
Sebastian Bøe 12f8f76165 Introduce cmake-based rewrite of KBuild
Introducing CMake is an important step in a larger effort to make
Zephyr easy to use for application developers working on different
platforms with different development environment needs.

Simplified, this change retains Kconfig as-is, and replaces all
Makefiles with CMakeLists.txt. The DSL-like Make language that KBuild
offers is replaced by a set of CMake extentions. These extentions have
either provided simple one-to-one translations of KBuild features or
introduced new concepts that replace KBuild concepts.

This is a breaking change for existing test infrastructure and build
scripts that are maintained out-of-tree. But for FW itself, no porting
should be necessary.

For users that just want to continue their work with minimal
disruption the following should suffice:

Install CMake 3.8.2+

Port any out-of-tree Makefiles to CMake.

Learn the absolute minimum about the new command line interface:

$ cd samples/hello_world
$ mkdir build && cd build
$ cmake -DBOARD=nrf52_pca10040 ..

$ cd build
$ make

PR: zephyrproject-rtos#4692
docs: http://docs.zephyrproject.org/getting_started/getting_started.html

Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00
Andrew Boie b7442a0a6b drivers: fix handler filenames
Fixes: #4654

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-10-31 12:51:22 -07:00
Andrew Boie 66aefcfcf4 drivers: flash: add system calls
The page_layout API returns pointers to kernel memory and is not
exposed to user mode. This is fine for flash_get_page_count()
and flash_get_page_info APIs since these copy the values, but some
redesign work will be needed to get flash_page_foreach() working in
user mode since we do not want the callback running in a privileged
state.

Due to the way that (even unimplemented) system call prototypes are
generated, the definition of struct flash_pages_info needed to be
moved outside of the #ifdef.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-10-30 13:20:19 -07:00
Sebastian Bøe b7eaeb9f0a cleanup: Use quote include instead of system include
When the header file is located in the same directory as the source
file it is better to use a relative quote-include, e.g.

than a system include like

Avoiding the use of system includes in these cases is beneficial
because;

* The source code will be easier to build because there will be fewer
system include paths.

* It is easier for a user to determine where a quote-include header
  file is located than where a system include is located.

* You are less likely to encounter aliasing issues if the list of
  system include paths is minimized.

Authors:
Anas Nashif
Sebastian Bøe

Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-10-28 07:11:53 -04:00
Leandro Pereira 5e2303d54e drivers: flash: stm32f4x: rc should be declared as int
`rc` gets assigned values from function returning `int` and not
`u32_t`.

Fixes #4051.

Coverity-ID: 177219
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-10-24 00:15:11 +02:00
Andrzej Puzdrowski 296a355af5 drivers: flash: Add write-block-size values for SoCs
Write-block-size values were filled for nRF5, STM32, QMSI, MCUX and
w25qxxdv devices.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2017-10-11 11:19:15 -05:00
Marti Bolivar 4f8081b5e4 drivers: flash: add flash_page_foreach()
This patch adds a routine which can be used to iterate over all flash
pages on the device.

This can be also done by using flash_get_page_info_by_idx(), but that
would add an unnecessary loop over the layout array for each page.

Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
2017-10-06 22:12:23 -04:00
Marti Bolivar c0672938da flash: stm32: stm32l4: add page layout support
L4 parts have a constant page size, so just rely on the HAL defines
that provide it, along with a read to the register which contains this
SoC's total size.

Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
2017-09-11 11:41:57 -04:00
Marti Bolivar 32482e9cb8 flash: stm32: stm32f4: add page layout support
Add flash page layout support for STM32F4 SoCs.

This almost eliminates the need for flash_map.h, except for
STM32F4X_SECTOR_MASK, so delete the file and move the define into the
F4 implementation, to keep things simple.

Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
2017-09-11 11:41:57 -04:00
Marti Bolivar 4fea6dfe76 flash: stm32: clean up L4/F4 internal API
This is a prep work commit for adding flash page layout support.

The internal flash APIs for STM32 on L4 and F4 are a bit
inconsistent. Some routines take a pointer to the private data, others
don't. Those that do take it as a last argument instead of a
first. Additionally, some APIs are declared in flash_stm32.h that
aren't ever used by the family-specific files.

Clean this up by making everything take a struct device*, and marking
routines static in the common driver code when possible.

Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
2017-09-11 11:41:57 -04:00
Andrzej Puzdrowski a7863f2362 Drivers: flash: nrf5: Implement flash layout APIs
Added implementation of the flash layout API for the nRF5x series.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2017-09-11 11:41:57 -04:00
Andrzej Puzdrowski ce9f0b571e Drivers: flash: New API to obtain the flash layout
Added an internal function to obtain the flash page layout in
run-length encoded format. The API is simple and allows the actual
public API implementations to be simple and maintainable.
This feature can be enabled by using the FLASH_PAGE_LAYOUT Kconfig
option. This API is required for the implementation of flash file
system.

Added a public API to get flash page information (size and start offset)
by offset within the flash and by index of the page.
Added a generic implementation of the internal flash_get_page_info API.
Added an additional public API call to get the total count of pages in
the flash memory and its generic implementation.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2017-09-11 11:41:57 -04:00
Andrzej Kaczmarek 8f5420ff23 drivers: flash: Fix write_op unaligned access
data_addr is not guaranteed to be word-aligned so we need to read it in
a safe way, otherwise this can trigger hardfault on nRF51.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2017-08-17 10:54:37 -04:00
Andrzej Kaczmarek 246f4ee7db drivers: flash: Fix checking for radio idle state
ll_radio_state_is_idle() returns bool, not an error value - this means
it is non-zero on success.

Jira: ZEP-2445

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2017-08-14 11:08:17 -04:00
Carles Cufi d5c13a7530 Bluetooth: controller: Rename Kconfig prefix
Rename the BT_CONTROLLER prefix used in all of the Kconfig variables
related to the Bluetooth controller to BT_CTLR.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-08-14 15:44:56 +03:00
Johan Hedberg 2975ca0754 Bluetooth: Kconfig: Rename CONFIG_BLUETOOTH_* to CONFIG_BT_*
The API name space for Bluetooth is bt_* and BT_* so it makes sense to
align the Kconfig name space with this. The additional benefit is that
this also makes the names shorter. It is also in line with what Linux
uses for Bluetooth Kconfig entries.

Some Bluetooth-related Networking Kconfig defines are renamed as well
in order to be consistent, such as NET_L2_BLUETOOTH.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-08-09 11:14:19 +03:00
Leandro Pereira 732424f065 drivers, net: Clean up semaphore initialization
Change the common "init with 0" + "give" idiom to "init with 1".  This
won't change the behavior or performance, but should decrease the size
ever so slightly.

This change has been performed mechanically with the following
Coccinelle script:

    @@
    expression SEM;
    expression LIMIT;
    expression TIMEOUT;
    @@

    - k_sem_init(SEM, 0, LIMIT);
    - k_sem_give(SEM);
    + k_sem_init(SEM, 1, LIMIT);

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-07-27 15:23:07 -04:00
Andrzej Puzdrowski 8b7a8448ab Drivers: flash: NRF5x: synchronous mode for co-operation with BLE radio
In added mode flash operation are performed in timeslice
(in radio idle time).
Kconfig for mode enabling CONFIG_SOC_FLASH_NRF5_RADIO_SYNC.

Erase and write API implementations were rewritten and preserved against
concurrent execution.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-06-28 12:29:50 +02:00
Kumar Gala 4b82e2bc75 flash: stm32l4x: Cleanup use of C99 types
We introduced some see C99 types, so convert them over to the Zephyr
types.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-06-22 13:47:28 -04:00
Michel Jaouen e9153979f0 flash: stm32: distinguish read/write for flash range valid
L4 write access requires 64 bits alignment
while L4 read access does not require any alignment.
To support specific check according to read/write,erase
a parameter is added to stm32_valid_range.

Signed-off-by: Michel Jaouen <michel.jaouen@st.com>
2017-06-16 16:18:12 -04:00
Michel Jaouen 8ba73a79b3 flash: stm32: fix for l4 writing wrong data
L4 have 64 bits write access.
The cast to 64 bits data address in write_dword
requires 3 right shifts on i (byte index) else the
data taken are wrong for i different from 0

Signed-off-by: Michel Jaouen <michel.jaouen@st.com>
2017-06-16 16:18:12 -04:00
Neil Armstrong a9183cd518 flash: Rework and add flash device support for STM32L4x SoCs
The STM32L4x SoCs embeds a slightly different embedded flash controller
from the STM32F4x SoCs.

This particular controller has the following properties :
 - Up to 2 512KiB banks divided in 2KiB pages
 - Flash can be accessed in any sizes
 - Flash must be written in 64bit aligned 64bit double-words

The drivers/flash/flash_stm32f4x.c is refactored into a new common
drivers/flash/flash_stm32.c and drivers/flash/flash_stm32l4x.c is
created with the STM32L4x specific functions.

To ease the refactoring and keep common functions, the STM32L4x flash
headers are slightly modified to match the hardware reference naming
and solve compilation issues.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2017-05-19 10:06:48 -04:00
Neil Armstrong 7a8452c38b flash_stm32f4: bits were badly unset in erase and write functions
A typo was present ion the erase and write function were bit were
uncorrectly unset but all other bit except the mask were unset.
The code still worked because the two typos fixed themselves.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2017-05-19 10:06:48 -04:00
Neil Armstrong 6da68d214e flash_stm32f4: RDERR is not present on STM32F407
The RDERR bit is not present on F4x5 and F4x7 SoCs, so only use it when
available in the HAL.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2017-05-19 10:06:48 -04:00
David B. Kinder 93e4d7258d spell: fix Kconfig help typos: /boards /drivers
Fix misspellings in Kconfig help text

Change-Id: I3ae28a5d23d8e266612114bc0eb8a6e158129dc7
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-04-21 21:31:30 +00:00
Kumar Gala ccad5bf3e3 drivers: convert to using newly introduced integer sized types
Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99
integer types.

Jira: ZEP-2051

Change-Id: I08f51e2bfd475f6245771c1bd2df7ffc744c48c4
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-21 10:06:48 -05:00
Michael R Rosen ce4f942011 flash: enable flash bank 1 for arc on quark se c1000
Change-Id: Ide95d7f21290b1effb759b1f2e7a014ce21ef1bf
Signed-off-by: Michael R Rosen <michael.r.rosen@intel.com>
2017-04-14 01:35:40 +00:00
Jorge Ramirez-Ortiz 29a8e0292e flash/stm32: driver for STM32F4x series
Change-Id: I0f90bcda7a694de81c594a6616da0faf40306702
Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
2017-02-22 18:08:57 -06:00
Jorge Ramirez-Ortiz 28e60ef7ed flash/nrf5: fix invalid write access
Requesting a flash_write with a length of 0 results in a flash
position being written. Instead we should return 0 unless there is
some other input parameter that is invalid.

Change-Id: Ife6e6e2314bbee2bde7d0b69db3122ca00c361e0
Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
2017-02-15 00:08:33 +00:00
Erwan Gouriou 726d4dc437 drivers: stm32: clean up after stm23cube based clock control
After activation of cube based driver support on L4 and F3 series,
this commits performs the clean up of F3 and L4 relative code to
native clock control drivers.
Indirectly, it makes pwm driver supported de facto on F3 series

Change-Id: Idac17103a9b5ef6eab540719343cc8f5865f15fa
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2017-02-10 14:47:41 -06:00
Erwan Gouriou 221087a72e flash: update stm32 flash_f3x to support LL clock control driver
After introducing STM32Cube based clock control driver for
stm32 family, update stm32f3xx flash driver to support it.
Clean up will be done afterwards.

Change-Id: I3260bb063f714fa29adbc71d8036f20479a99b34
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2017-02-10 14:47:41 -06:00
Juan Solano ee623d21de drivers: Remove unnecessary CONFIG_SYS_POWER_DEEP_SLEEP
This commit removes unnecessary CONFIG_SYS_POWER_DEEP_SLEEP protection
in shim drivers as QMSI 1.4 has introduced empty context save/restore
functions that can be called in Quark D2000, therefore keeping common
code at the shim driver level for Quark SE and D2000.

Change-Id: Ia2a466327f999668c6511c0193014e9151bff6ae
Signed-off-by: Juan Solano <juanx.solano.menacho@intel.com>
2017-02-10 16:27:32 +00:00
Kuo-Lang Tseng 74f7da1bb4 drivers: QMSI SOC flash: simplify driver reentrancy code using IS_ENABLED
This is one the series patches that simplifies the driver code by
using the IS_ENABLED macro. This removes the need of the const
variable and the wrapper functions on semaphore APIs.

Jira: ZEP-1251

Change-Id: I59802cf9f482337656b0fdc4b272f3b1ddc6cbda
Signed-off-by: Kuo-Lang Tseng <kuo-lang.tseng@intel.com>
2017-02-08 19:07:42 +00:00
Maureen Helm ec5ee8b33d flash: Update mcux shim to new mcux version
The newer version of mcux changes its flash api slightly, so update the
Zephyr shim accordingly.

Change-Id: I0c974fc3e82b9f40372c636f0b805ed143be2198
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-01-30 11:02:35 -06:00
Erwan Gouriou 8890b73b6e license: Replace Apache boilerplate with SPDX tag
Apply JIRA: ZEP-1457 to STM32F3X family porting patchset.

Change-Id: I352267a47847143e557a4016de12bb9a14a20067
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-01-23 15:15:53 -06:00
Adam Podogrocki 61cc74c425 flash/stm32: flash driver for STM32F3x series microcontrollers
Change-Id: I0b41a50507a09a513a67d13374323d831a0ec86a
Signed-off-by: Adam Podogrocki <adam.podogrocki@rndity.com>
2017-01-23 15:15:52 -06:00
David B. Kinder ac74d8b652 license: Replace Apache boilerplate with SPDX tag
Replace the existing Apache 2.0 boilerplate header with an SPDX tag
throughout the zephyr code tree. This patch was generated via a
script run over the master branch.

Also updated doc/porting/application.rst that had a dependency on
line numbers in a literal include.

Manually updated subsys/logging/sys_log.c that had a malformed
header in the original file.  Also cleanup several cases that already
had a SPDX tag and we either got a duplicate or missed updating.

Jira: ZEP-1457

Change-Id: I6131a1d4ee0e58f5b938300c2d2fc77d2e69572c
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-01-19 03:50:58 +00:00
Maureen Helm e17adf377b flash: Rename ksdk to mcux
Renames the ksdk soc flash driver to mcux.

Change-Id: I835e36f25d8bc3e3aa6286718452528174378907
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-01-12 09:46:26 -06:00
Flavio Santes 501dd224ad drivers: Add the ARG_UNUSED macro
Add the ARG_UNUSED macro to avoid compiler warnings.

Change-Id: Ia62125b5e93671aa0ab0891c92ae9fa06fadb09b
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-12-21 12:54:52 +00:00
Anas Nashif a9e879e273 logging: move sys_log to subsys/logging
Move logging out of misc/ to its own subsystem. Anything related to
logging and any new logging features or backends could be added here
instead of the generic location in misc/ which is overcrowded with
options that are not related to eachother.

Jira: ZEP-1467
Change-Id: If6a3ea625c3a3562a7a61a0ba5fd7e6ca75518ba
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-12-19 19:58:39 +00:00
Flavio Santes b04cdcd6e6 drivers: Remove legacy nanokernel.h include
This commit replaces the nanokernel.h include by kernel.h.

Change-Id: Ib42fbf2d9f77a73c0831f569b3dbbfb342ea2e1d
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-12-04 14:59:37 -06:00
Baohong Liu a282872c78 drivers: spi_flash: add erase boundary check and correct an error
Add spi flash erase boundary check. The erase boundary must be
4K-aligned. So, the flash chip will round down an non-4K aligned
address to the nearest 4K boundary automatically. As a result of
this, the erase area will start from a different address (if the
API caller specifies an non-4K alighed address), even though the
size of the erased area is the same as what is specified by the
API caller. Let's add a boundary check to make sure the starting
address (from the API caller) is 4K aligned.

Correct an error in the highest address check. Because of the
error, the erase api call will fail if the flash's highest
address byte is involved.

Jira: ZEP-1277 ZEP-1278

Change-Id: I8b6be57cc8f636f94e5fe67d5a492841a8555005
Signed-off-by: Baohong Liu <baohong.liu@intel.com>
2016-11-12 01:37:00 +00:00
Baohong Liu 8cc98d71cd drivers: flash: update to unified kernel
Use new semaphore APIs from unified kernel.

Change-Id: I430a239afdb49bfbbd7829442bbdd17c7d736663
Signed-off-by: Baohong Liu <baohong.liu@intel.com>
2016-11-10 01:59:24 +00:00
Andrew Boie 0b474eef9c kernel: deprecate old init levels
PRIMARY, SECONDARY, NANOKERNEL, MICROKERNEL init levels are now
deprecated.

New init levels introduced: PRE_KERNEL_1, PRE_KERNEL_2, POST_KERNEL
to replace them.

Most existing code has instances of PRIMARY replaced with PRE_KERNEL_1,
SECONDARY with POST_KERNEL as SECONDARY has had a longstanding bug
where the documentation specified SECONDARY ran before the kernel started
up, but actually ran afterwards.

Change-Id: I771bc634e9caf7f17dbf214a270bc9967eed7d32
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-11-09 17:59:44 +00:00
Jorge Ramirez-Ortiz 27ecd5d8f3 drivers: flash: SoC KSDK
This KSDK flash shim driver supports the device in the FRDM K64F
platform (enabled with this commit).

WARNING: the driver disables the system interrupts for potentially
long periods of time. This is required to avoid Read-While-Write
issues since most platforms run in XIP mode.

For more detailed information see the link below:
http://cache.freescale.com/files/32bit/doc/app_note/AN4695.pdf

Change-Id: I70f8d09080251033ce2f45be0c2eb95c19fded08
Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
2016-11-07 18:43:16 +00:00