Commit graph

49179 commits

Author SHA1 Message Date
Ioannis Glaropoulos 712a7951db arm: cortex_m: move static inline DWT functions in internal header
Move the DWT utility functions, present in timing.c
in an internal cortex-m header.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2021-03-03 10:38:29 +01:00
Ioannis Glaropoulos b3cd5065eb arm: cortex_m: Kconfig symbols for null pointer detection feature
Introduce the required Kconfig symbol framework for the
Cortex-M-specific null pointer dereferencing detection
feature. There are two implementations (based on DWT and
MPU) so we introduce the corresponding choice symbols,
including a choice symbol to signify that the feature
is to be disabled.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2021-03-03 10:38:29 +01:00
Kumar Gala c320bb0522 drivers: ethernet: remove stale Kconfig IRQ priority
Either get priority from devicetree (liteeth) or remove Kconfig symbols
that aren't used anywhere for IRQ priority (gecko, stm32_hal).

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-03-03 12:16:06 +03:00
Eduardo Montoya 53fd3ae573 drivers: ieee802154: nrf5: load EUI64 from UICR
Add `IEEE802154_NRF5_UICR_EUI64_ENABLE` option to allow loading EUI64
from UICR registers.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2021-03-03 10:40:29 +02:00
Dominik Ermel 32451230e2 storage/stream/flash: Failed write of reminder rewinds buffer offset
The stream_flash_buffered_write, when invoked to do flush write, will
attempt to write the tail bytes from the buffer, filling the required
minimal write block size with erase value bytes; after write it rewinds
the buffer offset, bytes_written, by number of the "filler bytes".
Doe to lack of return code processing from flash_sync call, two things
would happen to context in case of failure:
 1) the ctx->bytes_written would be rewind pass the value it had before
    function call as it gets decremented by "filler bytes" even if write
    failed;
 2) the ctx->buf_bytes offset would be accounting for added "filler
    bytes" which should not be counted as data in buffer.

Proper processing of return code has been added to remove effects
described above.

Unit tests have been expended to cover the scenarios.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-03-03 11:40:11 +03:00
Dominik Ermel 07107f92c7 storage/stream/flash: Use flash_get_parameters to get flash erase_value
The stream_flash_buffered_write used to read byte from flash, in front
of the current buffer pointer, to obtain value of errased flash;
the code has been replaced with obtaining the value from flash
parameters.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-03-03 11:40:11 +03:00
Dominik Ermel 5a1750b053 storage/stream/flash: flash_sync: Check if there is anything to write
The commit moves block that checks if flash_stream_ctx.buf_bytes
is non-zero out of CONFIG_STREAM_FLASH_ERASE specific code,  as that is
universal check and is valid also for not CONFIG_STREAM_FLASH_ERASE
code.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-03-03 11:40:11 +03:00
Dominik Ermel cfb056901c storage/stream/flash: Fix flash_sync updating bytes_written on failure
The flash_sync function is able to call, if specified, write
verification callback to check whether data flash has been correctly
written to a flash.  Part of that procedure is to read date back of
the flash and call the verification callback on the buffer;
in case if the read would fail, the flash_sync would return,
with an error code, without updating stream_flash_ctx.

The same logic should be applied to failed verification, but, due to
missing return, the stream_flash_ctx gets updated with probably
incorrectly written bytes added to total bytes_written and buf_bytes,
representing number of bytes awaiting in buffer, being zeroed.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-03-03 11:40:11 +03:00
Dominik Ermel 94968dfee4 storage/stream/flash: Don't update last erased page offset on failure
The stream_flash_erase_page would update stream_flash_ctx member
last_erased_page_start_offset, to page offset it attempted to erase,
even if such operation failed.
The commit changes this behaviour so that in case of failure the
last_erased_page_start_offset would still hold previously, successfully,
erase page offset.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-03-03 11:40:11 +03:00
Andrzej Głąbek fa20bd129d tests: drivers: build_all: Add PCAL6408A GPIO driver
Include the PCAL6408A I/O expander driver in the build_all test.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2021-03-03 11:38:03 +03:00
Andrzej Głąbek d860569d94 tests: drivers: build_all: Add fake instance of GPIO device
Such instance is needed for building drivers that use DEVICE_DT_GET()
to get the pointer to the GPIO controller device structure.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2021-03-03 11:38:03 +03:00
Andrzej Głąbek 1314ab5404 drivers: gpio: Add support for PCAL6408A I/O expander
Add GPIO driver and devicetree binding for the PCAL6408A 8-bit I2C-bus
I/O expander.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2021-03-03 11:38:03 +03:00
Carlo Caione 13ef690192 aarch64: linker: Remove unused symbols and sections
Remove unused symbols and related sections from the linker script. In
particular CONFIG_IS_BOOTLOADER and CONFIG_CODE_DATA_RELOCATION are not
currently supported on AArch64.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2021-03-03 11:22:25 +03:00
Yuval Peress 7162786f83 uart-npcx: forward poll requests to fifo when running interrupt mode
Looking at the data sheet for the npcx section 4.15.5 CR_UART Core
Registers, the UICTRL register that is used in the npcx poll
functions is invalid when running in FIFO mode. Instead, calls to
uart_npcx_poll_in and uart_npcx_poll_out should be redirected to
their respective FIFO read/fill functions (when using interrupts).

Changes:
- When calling uart_poll_in: forward the request to uart_fifo_read.
- When calling uart_poll_out: loop until uart_fifo_fill returns
  non-0 (we wrote 1 byte).

Signed-off-by: Yuval Peress <peress@chromium.org>
2021-03-02 20:33:25 -06:00
Yuval Peress 1154c49878 uart-npcx: re-organize interrupt driven functions.
Simple reorg of the function declarations. This change moves
the interrupt driven functions declared at the bottom of the
uart_npcx.c file to the top, clustered under the same ifdef.

Signed-off-by: Yuval Peress <peress@chromium.org>
2021-03-02 20:33:25 -06:00
Jose Alberto Meza a19fa8ba0c drivers: i2c: mchp: Restore I2C logging control
Fix CONFIG_I2C_LOG_LEVEL_XXX not having effect.

Signed-off-by: Jose Alberto Meza <jose.a.meza.arellano@intel.com>
2021-03-02 20:29:26 -06:00
Kumar Gala d521129c4f dma: Kconfig remove unused kconfig symbols
All dma drivers are devicetree based now so we can remove the last
bits of Kconfig associated with the old driver style.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-03-02 20:28:35 -06:00
Kumar Gala 767ba47423 drivers: spi: spi_dw: Move to devicetree detection
We can utilize the devicetree macros to determine which instances to
enable.  This will allow us to phase out the per instance Kconfig
symbols.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-03-02 20:06:38 -06:00
Kumar Gala c0d82cf434 drivers: spi: spi_dw: set op-mode to master-only always
Nothing sets the op mode to anything but master.  For now default the
mode to master-only and we can determine a devicetree property in the
future if we need to support other configurations.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-03-02 20:06:38 -06:00
Kumar Gala 1957fe2417 drivers: spi: spi_dw: determine num IRQs from devicetree
Replace Kconfig symbols SPI_DW_PORT_n_INTERRUPT_SINGLE_LINE with just
seeing how many IRQs are defined in the devicetree to determine single
or multiline interrupt support.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-03-02 20:06:38 -06:00
Kumar Gala b08c5d2bb8 drivers: spi: spi_dw: Remove clock gate support
The SoC that utilized the clock support isn't supported in Zephyr
anymore and there are no users of this code.  Remove it for now as it
should get converted to utilize devicetree if needed in the future.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-03-02 20:06:38 -06:00
James Harris 497b837aeb sys: tell compiler about impossible aliasing in dlist APIs
The compiler was inserting additional redundant loads in many
`sys_dlist_*` APIs, in case writes aliased with previous reads.

However, these additional reads are unnecessary, as the only cases
where the aliasing would matter would be a violation of the `dlist`
API contract (e.g. if node->next == node but node->prev != node).

This is decidedly a micro-optimization.

Signed-off-by: James Harris <james.harris@intel.com>
2021-03-02 19:39:24 -05:00
Mikkel Jakobsen c5caa9b916 tests: drivers: dac_api: add frdm_k22f board support
Add support for running the DAC API test case on the NXP FRDM-K22F
development board.

Signed-off-by: Mikkel Jakobsen <mikkel.aunsbjerg@prevas.dk>
2021-03-02 16:27:47 -06:00
Mikkel Jakobsen 41225ceac6 tests: drivers: dac_loopback: add frdm_f22f board support
Add support for running the DAC loopback test case on the NXP
FRDM-K22F development board.

Signed-off-by: Mikkel Jakobsen <mikkel.aunsbjerg@prevas.dk>
2021-03-02 16:27:47 -06:00
Mikkel Jakobsen 5cdbe07b53 samples: drivers: dac: add support for frdm_k22f board
Add support for the NXP FRDM-K22F development board to the DAC driver
sample.

Signed-off-by: Mikkel Jakobsen <mikkel.aunsbjerg@prevas.dk>
2021-03-02 16:27:47 -06:00
Mikkel Jakobsen 9f45cb65f2 boards: frdm_k22f: enable DAC0
Enable DAC0 on the NXP FRDM-K22F development board.

Signed-off-by: Mikkel Jakobsen <mikkel.aunsbjerg@prevas.dk>
2021-03-02 16:27:47 -06:00
Mikkel Jakobsen b5c09de995 soc: nxp: k2x: enable DAC driver
Enable the driver for the Kinetis Digital-to-Analog (DAC) modules
present in the NXP Kinetis K2x SoC series.

Signed-off-by: Mikkel Jakobsen <mikkel.aunsbjerg@prevas.dk>
2021-03-02 16:27:47 -06:00
Mikkel Jakobsen 2d9770d66f dts: nxp: k2x: add device tree node for DAC0 and DAC1
Add device tree nodes for the Digital-to-Analog (DAC) modules present
in the NXP Kinetis K2x series.

Signed-off-by: Mikkel Jakobsen <mikkel.aunsbjerg@prevas.dk>
2021-03-02 16:27:47 -06:00
Alexander Kozhinov 22cb54174a dts: arm: st: f4: stm32f446re
add uart5 to SoC

Signed-off-by: Alexander Kozhinov <AlexanderKozhinov@yandex.com>
2021-03-02 16:24:26 -06:00
Kumar Gala 5d02978640 audio: intel_dmic: get dma properties from devicetree
Move to using devicetree to get dma controller and dma channel
information.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-03-02 14:59:17 -05:00
Kumar Gala fa6a9f7ae8 boards: intel_s1000_crb: Add dma channels to dmic device
Add dma channel info to devicetree

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-03-02 14:59:17 -05:00
Peter Bigot 291b9b5dae Revert "drivers/timer/hpet: Extend qemu workaround"
This reverts commit 4ae44dd712.

See: https://github.com/zephyrproject-rtos/zephyr/issues/32724

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-03-02 14:51:29 -05:00
James Harris 6543e06914 kernel: sched: avoid unnecessary lock in z_impl_k_yield
`z_impl_k_yield` unlocked sched_spinlock, only to lock it again
immediately, do a little bit more work, then unlock it again.
This causes performance issues on SMP, where `sched_spinlock`
is often fairly highly contended and cores often end up spinning
for quite a while waiting to retake the lock in `z_swap_unlocked`.

Instead directly pass the spinlock key to `z_swap` and avoid the
extra lock+unlock.

Signed-off-by: James Harris <james.harris@intel.com>
2021-03-02 14:35:21 -05:00
Enjia Mai 702f89d885 tests: common: add test case for testing errno
Add test case for testing errno, shows it works properly.

Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
2021-03-02 14:29:58 -05:00
Meng xianglin 80ec588e46 test: thread_api: refine test coverage of thread_api
Add new test cases for some interfaces in thread.c

Signed-off-by: Meng xianglin <xianglinx.meng@intel.com>
2021-03-02 14:28:24 -05:00
James Harris 2cd0f66515 kernel: sched: change to 3-way thread priority comparison
`z_is_t1_higher_prio_than_t2` was being called twice in both the
context-switch fastpath and in `z_priq_rb_lessthan`, just to
dealing with priority ties. In addition, the API was error-prone
(and too much in the fastpath to be able to assert its invarients)
- see also #32710 for a previous example of this API breaking
and returning a>b but also b>a.

Replacing this with a direct 3-way comparison `z_cmp_t1_prio_with_t2`
sidesteps most of these issues. There is still a concern that
`sgn(z_cmp_t1_prio_with_t2(a,b)) != -sgn(z_cmp_t1_prio_with_t2(b,a))`
but I don't see any way to alleviate this aside from adding an
assert to the fastpath.

Signed-off-by: James Harris <james.harris@intel.com>
2021-03-02 14:27:14 -05:00
Nicolas Pitre 7babb12ccb aarch64: restore natural order in struct __esf
The funky order was necessary when registers were stored using a
sequence of `stp x(n), x(n+1), [sp, #-16]!`. Now that absolute offsets
are being used, we can restore natural ordering.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2021-03-02 21:04:15 +03:00
Kumar Gala 72ffe59ef9 devicetree: deprecate DT_IO_CHANNELS_LABEL APIs
Mark all variants of the DT_IO_CHANNELS_LABEL APIs:
* DT_IO_CHANNELS_LABEL_BY_IDX
* DT_IO_CHANNELS_LABEL_BY_NAME
* DT_IO_CHANNELS_LABEL
* DT_INST_IO_CHANNELS_LABEL_BY_IDX
* DT_INST_IO_CHANNELS_LABEL_BY_NAME
* DT_INST_IO_CHANNELS_LABEL

As deprecated in favor of utilizing:

* DT_IO_CHANNELS_CTLR_BY_IDX
* DT_IO_CHANNELS_CTLR_BY_NAME
* DT_IO_CHANNELS_CTLR
* DT_INST_IO_CHANNELS_CTLR_BY_IDX
* DT_INST_IO_CHANNELS_CTLR_BY_NAME
* DT_INST_IO_CHANNELS_CTLR

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-03-02 11:28:30 -06:00
Kumar Gala ea98cc3c87 sensors: grove: temp: Convert to use DEVICE_DT_GET
Replace device_get_binding with DEVICE_DT_GET for getting access
to the io-channels/adc controller device.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-03-02 11:28:30 -06:00
Kumar Gala ae75e604d6 sensors: grove: light: Convert to use DEVICE_DT_GET
Replace device_get_binding with DEVICE_DT_GET for getting access
to the io-channels/adc controller device.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-03-02 11:28:30 -06:00
Kumar Gala afffb3b17e sensors: nxp_kinetis_temp: Convert to use DEVICE_DT_GET
Replace device_get_binding with DEVICE_DT_GET for getting access
to the io-channels/adc controller device.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-03-02 11:28:30 -06:00
Kumar Gala 774ea5ad5b samples: board: nrf: battery: Convert to use DEVICE_DT_GET
Replace device_get_binding with DEVICE_DT_GET for getting access
to the io-channels/adc controller device.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-03-02 11:28:30 -06:00
Kumar Gala 707f0391cb devicetree: io-channels: add marcos to obtain the node identifier
Added helper macros to obtain the node identifier from an
io-channels phandle.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-03-02 11:28:30 -06:00
Katsuhiro Suzuki def53e3205 drivers: timer: reduce max cycles of riscv machine timer
If next_timeout() returns INT_MAX and pass it to
z_clock_set_timeout(), and machine goes to freeze or slow down.
Bad scenario as follows:

- If an argument int32_t ticks is set large value 0xffffffff,
    ticks = MAX(MIN(ticks - 1, (int32_t)MAX_TICKS), 0);
  replaces it into MAX_TICKS.
- uint32_t cyc will be set near by 0xffffffff
  (this is 0xfffd7280 in 100 ticks per second).
- Add adjustment to cyc, adjustment max value is MAX_CYC.
  (cyc = 0xffff14fd)
- Over 0x80000000 value of uint32_t is considered as negative
  value of int32_t.
    if ((int32_t)(cyc + last_count - now) < MIN_DELAY)
  This condition is always true.
- Because cyc += CYC_PER_TICK will get overflow, driver sets mtimecmp
  near value of current mtime.
  (cyc = 0x00007fc0)
- Next timer interrupt will happen soon after return from interrupt
  handler.
- By repeating these events, machine cannot go to next instruction,
  and it's going to freeze or slow down.

Signed-off-by: Katsuhiro Suzuki <katsuhiro@katsuster.net>
2021-03-02 11:39:04 -05:00
Raveendra Padasalagi eefec6ff05 boards: arm: bcm958402m2_m7: Enable PCIE Ep driver
Enable PCIE EP driver.

Signed-off-by: Raveendra Padasalagi <raveendra.padasalagi@broadcom.com>
2021-03-02 10:03:34 -06:00
Raveendra Padasalagi b71bdad7bb drivers: pcie: endpoint: Use DEVICE_DT_INST_GET() API
Replace current use of DEVICE_GET() with DEVICE_DT_INST_GET().

Signed-off-by: Raveendra Padasalagi <raveendra.padasalagi@broadcom.com>
2021-03-02 10:03:34 -06:00
Jian Kang 088acda054 kernel: mailbox: Add some testcases for mailboxs
Add some testcases to tesing different condition of mailbox
API. Check API robust in different input parameters is handled.
such as invoke API to get data with NULL input.

Signed-off-by: Jian Kang <jianx.kang@intel.com>
2021-03-02 10:47:07 -05:00
Ningx Zhao 8fe9f523e7 tests: poll: code coverage improve
Some poll source code is tested in workq
so the negative testcase code is also placed in workq.

Signed-off-by: Ningx Zhao <ningx.zhao@intel.com>
2021-03-02 10:42:09 -05:00
Ying ming ef763543d8 test: heap : improve coverage to kernel/mempool.c
Add some testcase to improve coverage of mempool.c

Signed-off-by: Ying ming <mingx.ying@intel.com>
2021-03-02 10:29:43 -05:00
Vinayak Kariappa Chettimada 21e83e40ad Bluetooth: controller: Fix ticker job_guard
Move the ticker job_guard reset to after
ticker_job_compare_update, so that the ticks_current and
ticks_slot_previous are updated before ticker_worker gets
to execute. Without this fix, there is a possibility that
ticker_worker will use incorrect ticks_slot_previous and
ticks_current value under race conditions.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-03-02 15:51:48 +01:00