Commit graph

4132 commits

Author SHA1 Message Date
Krzysztof Chruscinski 1fb8364c4c lib: os: cbprintf: Reduce stack usage when no optimization
Use single fixed size on stack array instead of compile time fitting.
When compiler is optimizing it can pick smallest array but with no
optimization there is an increased stack usage.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-05-19 11:04:39 +02:00
Reto Schneider 79935d5324 settings: Remove duplicated comment
Has been here since the very first implementation of this functionality.

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2022-05-18 10:54:59 +02:00
Nicolas Pitre 6051ea7d3c riscv: clarify stack size and alignment parameters
The StackGuard area is used to save the esf and run the exception code
resulting from a StackGuard trap. Size it appropriately.

Remove redundancy, clarify documentation, etc.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-05-18 10:54:53 +02:00
Nicolas Pitre 1e006e3777 kernel/thread_stack.h: fix Z_THREAD_STACK_SIZE_ADJUST usage coherency
There are legitimate cases where both ARCH_THREAD_STACK_SIZE_ADJUST()
and ARCH_THREAD_STACK_RESERVED() may be defined at the same time.
It is important for the former to be exposed to the later in that case,
so add K_THREAD_STACK_RESERVED to the argument instead of the result.

Similarly for Z_THREAD_STACK_OBJ_ALIGN() which needs the adjusted size
to provide the proper result. That's what K_THREAD_STACK_LEN() does
already anyway, so fold Z_THREAD_STACK_SIZE_ADJUST() into the definition
of Z_THREAD_STACK_OBJ_ALIGN() directly.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-05-18 10:54:53 +02:00
Jonas Otto a36995e2a3 ring_buffer: fix designated initializer order in RING_BUF_DECLARE
Change order of designated initializers for ring_buf struct in the
RING_BUF_DECLARE macro, to match the order in the struct definition.
This fixes compilation when using C++, which requires using the same
order as in the struct definition.
Fixes #45697

Signed-off-by: Jonas Otto <jonas@jonasotto.com>
2022-05-18 10:53:57 +02:00
Adrian Bonislawski 7d76dc53d5 drivers: dma: return einval if specified channel not found
chan_filter is used when a specified channel is required
so a specified channel needs to be returned,
otherwise it should return einval instead of the last channel tried

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
2022-05-18 10:53:22 +02:00
Reto Schneider e4340c1dfc fcb: Remove superfluous comma
It is obviously an error to have two consecutive commas.

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2022-05-18 10:53:05 +02:00
Carlo Caione 11f0bb9d1a ipc: static_vrings: Add -ENOMEM case
Sometimes it is important to know when the backend fails to send out
data because no memory / buffers are available. Return -ENOMEM in that
case.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-05-16 16:56:33 +02:00
Sjors Hettinga ae31773ddd drivers: net: loopback: Add counting of number of dropped packets
When the loopback drops driver packets, the number of dropped
packets is counted and can be requested externally.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-05-16 16:55:51 +02:00
Asbjørn Sæbø bf361aff21 Bluetooth: Gatt: Replace callback in gatt subscription callback.
Add a "subscribe" callback in the bt_gatt_subscribe params, and
deprecate the "write" callback.

The purpose of this is to be able to return the subscription
parameters in the callback.  The write callback
- (in principle) returns write parameters
- in fact returns nothing - the pointer is set to NULL

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-05-16 16:54:27 +02:00
Jordan Yates e83e9b08b5 pm: device_runtime: return -ENOTSUP if PM not supported
Return `-ENOTSUP` on calls to device_runtime functions if the underlying
device does not support power management.

Fixes #45648.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-05-15 21:34:46 +02:00
Martin Jäger 2554f04464 doc: services: storage: add flash_img API
Doxygen comments were existing, but they were not rendered anywhere in
the docs. The code is located under DFU, but I think it makes sense
to document it under storage, next to similar flash-related APIs.

Signed-off-by: Martin Jäger <martin@libre.solar>
2022-05-15 21:33:54 +02:00
Emil Gydesen 54fac0323c Bluetooth: ISO: Expose can_send and can_recv in bt_iso_chan_get_info
The application can get the information about can_send
and can_recv in the bt_iso_chan_get_info function.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-15 21:32:19 +02:00
Emil Gydesen b88b25adac Bluetooth: ISO: Extract and store information about RX and TX
Instead of relying only on the `tx` and `rx` qos pointers,
we extract further information from the
bt_hci_evt_le_cis_established event to properly determine if we
can actually send or receive data.

This is useful to help determine which data paths to setup,
and whether to reject requests to send.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-15 21:32:19 +02:00
Andrzej Głąbek 3e0679f01c include: drivers: adc: Add macros for reading channel configs from DT
Add macros that allow reading configuration for ADC channels from
child nodes of ADC controllers in devicetree.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-05-13 12:46:06 -07:00
Andrzej Głąbek 77edc2c852 dts: Include ADC DT binding headers from nRF SoC dtsi files
Add inclusions of header files with devicetree related ADC definitions
to the nRF SoC dtsi files so that those definitions can be used also
for nRF SoC based boards.
Provide definitions of nRF ADC and SAADC analog inputs suitable
for use in devicetree.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-05-13 12:46:06 -07:00
Yasushi SHOJI bc35b1340c doc: uart: Make sure uart_poll_in is non-blocking
The documentation has wrongly stated that the function uart_poll_in() is
also a blocking function.  The uart_poll_out() is indeed a blocking
function but uart_poll_in() has never been since day one.

Make it clear that the uart_poll_in() is a NON-blocking function, and
uart_poll_out() IS a blocking.

This fixes #45468.

Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
2022-05-13 10:03:31 -07:00
Mariusz Skamra 2d87443a4a Bluetooth: has: Add support for Read Presets Request operation
This extends client implementation with Read Presets Request operation
support.
The implementation can maintain up to BT_L2CAP_TX_BUF_COUNT control
point requests so that user could perform/queue another Control Point
Operation if one is ongoing. E.g. preset can be selected from Read Preset
Response notification context or perform multiple operations if EATT
enabled.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-05-13 08:46:21 -07:00
Reto Schneider 233afcb719 doc: SETTINGS_REGISTER_STATIC got renamed
Renaming this reference got forgotten in
5f19c8160a [subsys/settings: Update
bluetooth module]

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2022-05-13 10:12:20 -05:00
Christoph Coenen b3dfc244ad arch: arm: Add support for multiple zero-latency irq priorities
Add the ability to have multiple irq priority levels which are not
masked by irq_lock() by adding CONFIG_ZERO_LATENCY_LEVELS.

If CONFIG_ZERO_LATENCY_LEVELS is set to a value > 1 then multiple zero
latency irqs are reserved by the kernel (and not only one). The priority
of the zero-latency interrupt can be configured by IRQ_CONNECT.

To be backwards compatible the prio argument in IRQ_CONNECT is still
ignored and the target prio set to zero if CONFIG_ZERO_LATENCY_LEVELS
is 1 (default).

Implements #45276

Signed-off-by: Christoph Coenen <ccoenen@baumer.com>
2022-05-13 08:38:28 -05:00
Jordan Yates 0976bdb3c9 devicetree: additional STRING_TOKEN macros
Add a variety of missing `DT_INST` and `_OR` variants for working with
`STRING_TOKEN` and `STRING_UPPER_TOKEN` macros.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-05-13 14:17:08 +02:00
Keith Packard 4fc00cae7a kernel: Allow Zephyr to use libc's internal errno
For a library which already provides a multi-thread aware errno, use
that instead of creating our own internal value.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-05-12 19:06:48 -04:00
Flavio Ceolin 87b4759663 toolchain: xtensa: Define __sync_synchronize
This builtin gcc function is not available in xcc compiler.

Adding a memory compiler barrier as it is done in compiler_barrier.
compiler_barrier() and __sync_synchronize() are not the same, the
former is a sw barrier while the latter can be a hw barrier
like (mfence/sfence) in X86.

I didn't find anything equivalent for xtensa so just implementing a
SW barrier.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-05-12 16:11:39 -04:00
Francois Ramu c16de1580f include: bindings: new bindings for the ospi flash controller
The new octoSPI flash controller driver
requires parameter to configure the peripheral
especially matching the data mode and the transfer rate

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2022-05-12 14:56:25 -05:00
Daniel Leung 52d0ed002c logging: missing func doc for param package_flags in log_msg2.h
This adds the missing "@param package_flags" for
z_log_msg2_runtime_create() and z_log_msg2_runtime_vcreate().

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-05-12 15:25:59 -04:00
Gerard Marull-Paretas 83cfd295b9 drivers: mipi_dsi: initial support for MIPI-DSI drivers
Add initial support for MIPI-DSI drivers.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2022-05-12 09:26:50 -05:00
Chay Guo 33bdfc46b7 drivers: dma: extended dma_slot bitwidth from 7bits to 8-bits
NXP i.MXRT11xx devices have up to 202 dma slots(peripheral dma requests).
Extended dma_slot to 8-bits to support more dma requests.

Signed-off-by: Chay Guo <changyi.guo@nxp.com>
2022-05-12 09:21:57 +02:00
Henrik Brix Andersen 9bd97eb0b8 drivers: can: add CAN_MODE_FD
Add support for enabling/disabling CAN-FD frame transmission/reception at
run-time.

Fixes: #45303

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-05-11 10:47:54 +02:00
Henrik Brix Andersen 3f97d11afd drivers: can: convert enum can_mode to a bit field
Convert the can_mode enum to a bit field to prepare for future extensions
(CAN-FD mode, transmitter delay compensation, one-shot mode, 3-samples
mode, ...).

Rename the existing modes:
- CAN_NORMAL_MODE   -> CAN_MODE_NORMAL
- CAN_SILENT_MODE   -> CAN_MODE_LISTENONLY
- CAN_LOOPBACK_MODE -> CAN_MODE_LOOPBACK

These mode names align with the Linux naming for CAN control modes.

The old CAN_SILENT_LOOPBACK_MODE can be set with the bitmask
(CAN_MODE_LISTENONLY | CAN_MODE_LOOPBACK).

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-05-11 10:47:54 +02:00
Henrik Brix Andersen 85c2c9147b drivers: can: always define CAN-FD syscalls
Always define the CAN-FD related syscalls but only define the
syscall implementations when CONFIG_CAN_FD_MODE is enabled.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-05-11 10:47:54 +02:00
Henrik Brix Andersen 2f7c01ba21 drivers: can: rename API functions from timing_*_data to timing_data_*
Rename the CAN data phase API functions to timing_data_* for consistency:
- can_get_timing_min_data() -> can_get_timing_data_min()
- can_get_timing_max_data() -> can_get_timing_data_max()
- .timing_min_data -> timing_data_min
- .timing_max_data -> timing_data_max

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-05-11 10:47:54 +02:00
Henrik Brix Andersen 18890828b8 drivers: can: split CAN classic and CAN-FD syscalls
Split CAN classic and CAN-FD syscalls into two:
- can_set_timing() -> can_set_timing() + can_set_timing_data()
- can_set_bitrate() -> can_set_bitrate() + can_set_bitrate_data()

Fixes: #45303

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-05-11 10:47:54 +02:00
Daniel DeGrasse f354e00a2c include: dt-bindings: add lpc pin control definitions
add pin control definitions for LPC11u6x to LPU11u6x pinctrl binding.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-05-10 17:27:44 -05:00
Evgeniy Paltsev 48301dde0f ARC: ARCv3: add HS5x support
Add HS5x CPU support - ARCv3 32bit ISA.

Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
2022-05-10 14:12:25 -04:00
Evgeniy Paltsev bac430ce1e ARC: asm-compat: add missing parts for ARCv3 32 & 64 bit
Add missing definitions for
 * MWDT toolchain, ARCv3 64 bit
 * MWDT toolchain, ARCv3 32 bit
 * GNU toolchain, ARCv3 32 bit

Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
2022-05-10 14:12:25 -04:00
Emil Gydesen 83c7baf34a Bluetooth: Audio: Add recv_info to audio recv callback
The audio stream receive callback now contains a
recv_info struct, which contain crucial information
such as timestamps and packet validity.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-10 18:56:28 +02:00
Emil Gydesen 6191a76f55 Bluetooth: Audio: Add _DIR_ infix to BT_AUDIO_SINK/SOURCE
The values represent an enum, and it makes sense for the
enum values to follow the enum type name, so an
_DIR_ infix was added to the values.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-10 18:56:00 +02:00
Emil Gydesen 19d7420f07 Bluetooth: Audio: Standadize the use of enum bt_audio_dir
Many functions and struct fields had the directory/type
value, but named in different ways and stored in different ways.

This change updates all uses of it to use the same name
and type.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-10 18:56:00 +02:00
Emil Gydesen 6b41e9991d Bluetooth: Audio: Rename enum bt_audio_pac_type
The enum bt_audio_pac_type does not fully
represent the what the value is used for.

The typical use of it is not for just published
audio capabilities (PAC), but rather describes the
type, or direction, of audio endpoints.

For the unicast client, the type/direction is
relative to the unicast server.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-10 18:56:00 +02:00
Erwan Gouriou 988fe8d5a2 include/dt-bindings/clock: stm32: Add clock sources bindings
Add clock sources bindings on F0/F3/G0/G4/L0/L1/L4/WB/WL series.
Due to inconsistencies, some common bindings are now split:
F1 -> F0/F1/F3
L4 -> L4/G4/WB
Update .dtsi files when required

In a first step, allowed sources are limited to already supported
clocks: LSI/LSE/HSI/HSE/MSI/PCLK/PLLCLK/SYSCLK
Support for other clocks such as HSI48, SAIXCLK, ... is left for a
next step.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-05-10 18:42:30 +02:00
Erwan Gouriou e579027d20 include/dt-bindings/clock: stm32: Factorize Clock source binding accessors
Rename and factorize clock source bindings accessors by moving them
in common header file stm32_clock_control and remove them from
include/dt-bindings/clock/stm32XY_clock.h files

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-05-10 18:42:30 +02:00
Erwan Gouriou 424f937c2b drivers/clock_control: stm32u5: Add support for optional clocks config
This change updates stm32u5 driver to support configuration of
optional clocks on peripherals.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-05-10 18:42:30 +02:00
Erwan Gouriou c9f5113d80 include/dt-bindings/clock: Add stm32u5 clock bindings
This new binding allows to work on providing stm32u5 specific
alternate and complementary device clocks.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-05-10 18:42:30 +02:00
Erwan Gouriou ceb6ecc740 dts/arm/st: stm32h7: Add perck clock-mux node
Add perck clock-mux node as disabled by default and
the include bindings helping to select it.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-05-10 18:42:30 +02:00
Erwan Gouriou 07b095556e include/drivers/clock_control: stm32: Add _DT_CLOCK helpers
Add a DT based macros to be used by stm32 device drivers to
populate pclken[] arrays at build time.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-05-10 18:42:30 +02:00
Erwan Gouriou 833eda84d3 drivers/clock_control: stm32h7: Add support for alt clocks
Add support for alternate clocks configuration.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-05-10 18:42:30 +02:00
Erwan Gouriou cf5436ce13 include/drivers: clock_control.h: Add configure() to api
Add configure() function to clock_control API.
This function allows caller to configure a given clock.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-05-10 18:42:30 +02:00
Matt Campbell 2d937f0683 lib: os: mpsc_pbuf: null check notify_drop callback
Allow the user of a mpsc_pbuf to not use the notify_drop callback by
setting it to NULL.

signed-off-by: Matt Campbell <matt@silvertree.io>
2022-05-10 18:32:26 +02:00
Gerard Marull-Paretas d342e4c4c1 linker: update files with <zephyr/...> include prefix
Linker files were not migrated with the new <zephyr/...> prefix.  Note
that the conversion has been scripted, refer to #45388 for more details.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-09 12:45:29 -04:00
Daniel DeGrasse e2fe582d62 drivers: sdhc: Add SD response type masks
Add SD response type masks, to allow drivers to mask out the
SPI or SD native mode response type based on the SD host controller
mode they use.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-05-09 08:46:29 -05:00
Emil Gydesen 9defebbfd3 Bluetooth: Audio: broadcast_sink_sync array of stream pointers
Change bt_audio_broadcast_sink_sync to use an array of pointers
to bt_audio_streams, instead of an array of streams. This makes
the API more flexible, as well consistent with the broadcast
source and unicast APIs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-09 09:28:14 +02:00
Emil Gydesen 5628b29b01 Bluetooth: Audio: broadcast_source_create array of stream pointers
The bt_audio_broadcast_source_create function will now
take an array of stream pointers, instead of an array
of streams. This is to make the API more flexible as
well as more consistent with the unicast API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-09 09:28:14 +02:00
Emil Gydesen 6e60451e09 Bluetooth: Audio: Change array of unicast streams to array of pointers
In bt_audio_unicast_group_create, bt_audio_unicast_group_add_streams
and bt_audio_unicast_group_remove_streams to use an array
of pointers, instead of an array of streams.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-09 09:28:14 +02:00
Mariusz Skamra 2314aa2977 Bluetooth: has: Add Preset Changed operation support
This extends implementation with sending Preset Changed
notification/indication when preset changes its availability or is
added or deleted.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-05-09 09:27:09 +02:00
Pete Dietl 9f95c8f570 drivers: pinctrl: Fix unused parameter warnings when compiling with -Wextra
Since the pinctrl header file can be included by user-created drivers,
an application developer including this file and only applying
-Wextra to the application source files will see many warnings.

-Wold-style-declaration warning is also emitted if 'static' is not
at the beginning of a declaration.

Signed-off-by: Pete Dietl <petedietl@gmail.com>
2022-05-09 09:26:46 +02:00
Ole Morten Haaland 5b1b05225a net: wifi: Pass ssid as const
There shouldn't be any reason to be able to modify the passed in SSID,
and having this non-const gives application warnings if passing a
constant string.

Signed-off-by: Ole Morten Haaland <omh@icsys.no>
2022-05-06 20:18:38 +02:00
Gerard Marull-Paretas fb9b3bcd93 include: migrate includes to <zephyr/...>
In order to bring consistency in-tree, migrate all includes within
include directory to the new prefix <zephyr/...>. Note that the
conversion has been scripted, refer to zephyrproject-rtos#45388 for more
details.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-06 20:03:00 +02:00
Jaska Uimonen 6b40cae845 drivers: dai: add fifo depth parameter to dai properties
The fifo depth parameter was missing as it was not visible in original
sof driver interface (which the dai interface is based on). So add it to
properties as it might be used by apps using future alh and dmic drivers.

Signed-off-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
2022-05-06 08:22:59 -04:00
Jordan Yates 1ef647f396 kernel: add k_can_yield helper function
Implements a function that application and driver code can use to check
whether it is valid to yield (or block) in the current context. This
check is required for functions that can feasibly be run from multiple
contexts. The primary intended use case is power management transition
functions, which can be run by application code explicitly or
automatically in the idle thread by system PM.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-05-06 11:33:10 +02:00
Tim Lin 4cf45f4770 ITE: drivers/pinmux: Remove it8xxx2 pinmux driver
Remove the driver related it8xxx2 pinmux.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2022-05-06 11:32:40 +02:00
Tim Lin efaeed6cb2 ITE: drviers/pinctrl: Add pinctrl driver for IT8XXX2
Add pinctrl driver for ITE IT8XXX2.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2022-05-06 11:32:40 +02:00
Vinayak Kariappa Chettimada 16868409e3 Bluetooth: Add defines for primary and periodic advertising intervals
Add HCI defines for Primary Advertising Interval minimum and
maximum, Periodic Advertising Interval minimum and maximum
values.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-06 11:31:44 +02:00
Gerard Marull-Paretas 8c2a732067 types: mode to include/zephyr
With the new <zephyr/> include prefix, the "types" header ended up being
located in <zephyr/zephyr/types.h>, ie weird. Code that hasn't migrated
to <zephyr/zephyr/types.h> (no occurences in tree) will be automatically
prepared for the removal of the legacy include path. Most applications
will not be impacted as both include and include/zephyr are now in the
include path, and they'll be already prepared for the future.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-05 14:26:05 -05:00
Henrik Brix Andersen 1dc3b237fa drivers: pinctrl: add OpenISA RV32M1 pinctrl driver
Add OpenISA RV32M1 pinctrl driver.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2022-05-05 13:34:39 -05:00
Bradley Bolen 88ba97fea4 arch: arm: aarch32: cortex_a_r: Add shared FPU support
This adds lazy floating point context switching.  On svc/irq entrance,
the VFP is disabled and a pointer to the exception stack frame is saved
away.  If the esf pointer is still valid on exception exit, then no
other context used the VFP so the context is still valid and nothing
needs to be restored.  If the esf pointer is NULL on exception exit,
then some other context used the VFP and the floating point context is
restored from the esf.

The undefined instruction handler is responsible for saving away the
floating point context if needed.  If the handler is in the first
irq/svc context and the current thread uses the VFP, then the float
context needs to be saved.  Also, if the handler is in a nested context
and the previous context was using the FVP, save the float context.

Signed-off-by: Bradley Bolen <bbolen@lexmark.com>
2022-05-05 12:03:27 +09:00
Bradley Bolen 7c1e399179 arch: arm: aarch32: Create a fpu stack frame
Grouping the FPU registers together will make adding FPU support for
Cortex-A/R easier later.  It provides the ability to get the sizeof and
offsetof FPU registers easier.

Signed-off-by: Bradley Bolen <bbolen@lexmark.com>
2022-05-05 12:03:27 +09:00
Bradley Bolen 3f7162fc07 arch: arm: aarch32: Rearrange exception stack frame
Cortex-A/R use a descending stack frame and the hardware does not help
with the stacking.  This led to some less than desirable workarounds in
the exception code where the basic stack frame was saved twice.
Rearranging the order of the exception stack frame removes that problem
and provides a clearer path to saving CPU context in a fully descending
manner.

Signed-off-by: Bradley Bolen <bbolen@lexmark.com>
2022-05-05 12:03:27 +09:00
Krzysztof Chruscinski 07322b85c9 lib: os: cbprintf: Add function for converting package
Extend package copying functionality by adding function for converting
a package. Function gets callback+context pair and converted package
is part by part passed to that callback. Contrary to typical sprintf
callback which works on chars, callback works with buffers.

Existing cbprintf_package_copy function is implemented as static
inline and uses new cbprintf_package_convert API.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-05-04 18:56:55 -04:00
Mariusz Skamra e6b73b08e6 Bluetooth: gatt: Update bt_gatt_is_subscribed documentation
This updates the documentation of bt_gatt_is_subscribed function that
can take a bitfield of BT_GATT_CCC_NOTIFY and BT_GATT_CCC_INDICATE.
This might be useful if one wants to test if peer is subscribed, but
does not matter which method was used.

The gatt.c implementation handles API usage already, because it performs
bitwise AND:
if (bt_conn_is_peer_addr_le(conn, cfg->id, &cfg->peer) &&
    (ccc_value & ccc->cfg[i].value)) {
	return true;
}

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-05-04 18:56:36 -04:00
Tom Burdick 6913da9ddd logging: cAVS HDA based logger
Adds a log backend that maintains a ringbuffer in coordination
with cAVS HDA.

The DMA channel is expected to be given some time after the logger
starts so a seperate step to initialize the dma channel is required.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-05-04 18:56:13 -04:00
Matthias Freese 07bf22cc94 include: zepyhr: drivers: adc: extend gain values
Added new gain values for external ADC IC.

Signed-off-by: Matthias Freese <m.freese@web.de>
2022-05-04 09:56:48 -05:00
Juha Heiskanen 3bf30ef292 net: lwm2m: LwM2M RD client start and stop update
Added return code for for lwm2m_rd_client_start() & lwm2m_rd_client_stop().

lwm2m_rd_client_start() return -EINPROGRESS when start is in progress and
0 for success.

lwm2m_rd_client_stop() return -EPERM when context is unknown and
0 for success.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-05-04 09:44:29 -05:00
Andy Ross e931b7ba47 arch/x86: Use EFI console as default printk handler
Where we have access to a bootstrap UEFI environment, it's productive
to use that console as the default printk handler.  That avoids the
bringup hassle of trying to configure UART settings blindly, as has
been customary.  It also emits nice text to the framebuffer on devices
with no serial port or other debug harness at all.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2022-05-04 11:34:55 +03:00
Herman Berget d8357a2216 Bluetooth: Host: Add testing function bt_eatt_reconfigure
The function sends L2CAP reconfigure requests to reconfigure all
connected EATT channels.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-05-04 10:35:31 +03:00
Jan Peters 253cec5c95 drivers: counter: add driver for NXP QTMR counters
The driver is implemented using the MCUXpresso SDK.

Signed-off-by: Jan Peters <peters@kt-elektronik.de>
2022-05-03 20:41:23 -05:00
Bernardo Perez Priego cfe4d51b4f drivers: sensor: Add adc-comparator binding and implementation for NPCX
Comparator will monitor signal though ADC channel, based on
user configuration, callback will be triggered.
This will enable comparator functionality for nuvoton MCU utilizing its
ADC threshold detection feature. Implementation is exported through
sensor trigger API. Use of CONFIG_ADC_CMP_NPCX is required.

Signed-off-by: Bernardo Perez Priego <bernardo.perez.priego@intel.com>
2022-05-03 08:51:53 -05:00
Guennadi Liakhovetski 17eb313a1b sparse: add an address space and a __sparse_force annotation
We want to use a sparse address space to identify invalid conversions
between cached and uncached address aliases. This patch adds a
__sparse_cache sparse annotation for that. Where those conversions
must be done that has to be supported by using the __sparse_force
sparse attribute. To avoid compiler complains about unknown
attributes we add a -Wno-attributes flag when building with sparse
support.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2022-05-03 09:37:08 +02:00
Andy Ross b4e9ef0691 kernel/sched: Defer IPI sending to schedule points
The original design intent with arch_sched_ipi() was that
interprocessor interrupts were fast and easily sent, so to reduce
latency the scheduler should notify other CPUs synchronously when
scheduler state changes.

This tends to result in "storms" of IPIs in some use cases, though.
For example, SOF will enumerate over all cores doing a k_sem_give() to
notify a worker thread pinned to each, each call causing a separate
IPI.  Add to that the fact that unlike x86's IO-APIC, the intel_adsp
architecture has targeted/non-broadcast IPIs that need to be repeated
for each core, and suddenly we have an O(N^2) scaling problem in the
number of CPUs.

Instead, batch the "pending" IPIs and send them only at known
scheduling points (end-of-interrupt and swap).  This semantically
matches the locations where application code will "expect" to see
other threads run, so arguably is a better choice anyway.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2022-05-02 10:23:13 -05:00
Carlo Caione 55dc21ffb9 openamp: Bump to v2022.04.0
Bump OpenAMP to v2022.04.0 and fix Zephyr terminology linked to OpenAMP.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-05-02 08:44:17 -05:00
Francois Ramu 23ea7efd9a include: drivers: stm32 dma give the STREAM OFFSET to count channels
This defines the constant for the STM32_DMA_STREAM_OFFSET
to be 0 or 1 when counting the first DMA channel
depending on the stm32 soc and DMA peripheral version.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2022-05-02 10:57:15 +02:00
Ole Morten Haaland fc6f40964c net: if: Add method to set default interface
This complements the Kconfig possibility, and allows setting an
interface as default on runtime. Changing the default interface also
works around limitations when trying to use an offloaded interface
together with a native one.

Signed-off-by: Ole Morten Haaland <omh@icsys.no>
2022-05-02 10:57:05 +02:00
Daniel DeGrasse d90a16f591 include: sd: Add SD subsystem header files
Add SD subsystem headers. SD subsystem contains generic header for SD
initialization, and headers for SDIO and SDMMC cards.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-04-29 14:21:36 -05:00
Daniel DeGrasse 3f3a59377d drivers: sdhc: Add SD host controller driver API
Add api for SD host controller driver. SD host controller driver
supports the following operations:

- reset: reset host controller state
- request: send SD command and data via SDHC
- set_io: set I/O settings (voltage, clocks, etc..) on SDHC
- get_card_present: check for card presence
- execute_tuning: run tuning process for UHS cards
- card_busy: check if SD card bus is busy
- get_host_props: get host controller properties

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-04-29 14:21:36 -05:00
Daniel DeGrasse c8041e87c9 include: sd: Add SD specification definition
SD specification definition required for SD host controller headers.
Add header file with SD specification definitions.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-04-29 14:21:36 -05:00
Benedikt Schmidt 86469b1d0b drivers: clock_control: Make LSE driving configurable
Make the LSE driving capability configurable for the STM32 series.
Fixes #44737.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2022-04-29 16:11:34 +02:00
Nicolas Pitre 5e002e8d7d riscv: linker: align end of ROM area to a "page" boundary for QEMU
QEMU does its dynamic instruction translation in 4096-byte-sized chunks.
Therefore it doesn't vet PMP access for each instruction prefetch but
for the whole "page" at once. If the end of the ROM area lands in the
middle of such a page with a corresponding PMP entry then any instruction
access within that page will fault even if it is located in the PMP
mapped portion.

To work around this QEMU peculiarity, we simply align the end of the ROM
area to a page boundary.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-04-29 15:30:00 +02:00
Nicolas Pitre ec9c2ec2d8 riscv: pmp: rename CONFIG_PMP_SLOT
The plural form is clearer.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-04-29 15:30:00 +02:00
Nicolas Pitre 554f24661f riscv: pmp: remove previous implementation
Overall diffstat with the new PMP code in place:

 18 files changed, 866 insertions(+), 1372 deletions(-)

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-04-29 15:30:00 +02:00
Nicolas Pitre 7a55bda7e1 riscv: pmp: add new usermode support
The idea here is to compute the PMP register set on demand i.e. upon
scheduling in the affected threads, and only if changes occurred.
A simple sequence number is used to stay in sync with the latest update.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-04-29 15:30:00 +02:00
Nicolas Pitre 68b8f0e5ce riscv: pmp: new stackguard implementation
Stackguard uses the PMP to prevents many types of stack overflow by
making any access to the bottom stack area raise a CPU exception. Each
thread has its set of precomputed PMP entries and those are written to
PMP registers at context switch time.

This is the code to set it up. It will be connected later.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-04-29 15:30:00 +02:00
Krzysztof Chruscinski 3ee5c57934 shell: Add new way of adding subcommands
Added macro SHELL_SUBCMD_SET_CREATE which creates a set of subcommands.
SHELL_SUBCMD_ADD and SHELL_SUBCMD_COND_ADD can be used from any file to
add command to the set. This approach allows to have subcommands added
from multiple files.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-04-29 14:54:08 +02:00
Juha Heiskanen f20eeebbd1 net: lwm2m: DTLS session cache enable and queue mode update
Enabled DTLS session cache for support session resume.
Fixed LwM2M queue mode for close connection and reconnect automatically.
Re-connect will do Registration update before it send queued data.
Session resume is helping a case when NAT change address and cause less
network traffic.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-04-29 08:57:30 +02:00
Carlo Caione 69b28bfd07 pm: policy: Consider substates for state lock functions
Extend the current pm_policy_state_lock_*() functions to support
substates.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-04-28 16:32:23 +02:00
Guennadi Liakhovetski 462bd8abc2 sparse: fix all errors
sparse complains about cbprintf incompatible callback type and
incorrect size of struct __va_list. Add exceptions to silence those
errors.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2022-04-28 08:54:21 -04:00
Robert Lubos 4896a23aea net: sockets: Fix TLS option overlap
Two TLS features developed in parallel resulted in the same option
number being assigned to two options. In this case give preference to
TLS_NATIVE, since it was longer in the tree.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-04-28 13:30:42 +02:00
Robert Lubos 7ad2e604bb net: sockets: tls: Add options to control session caching on a socket
Introduce TLS socket options, which allow to configure session caching
on a socket.

The cache can be enabled on a socket with TLS_SESSION_CACHE option.
Once cache is enabled on a socket, the session will be stored for re-use
after a sucessfull handshake. If a socket is attempting to connect to a
host for which session is stored, the session will be resumed and mbed
TLS will attempt to use a simplified handshake procedure.
The server-side management of sessions is fully controlled by mbed TLS
after session caching is enabled on a socket.

The other TLS_SESSION_CACHE_PURGE option allows to clear all of the
cache entries, releasing the memory allocated for sessions.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-04-28 11:31:07 +02:00
Gerard Marull-Paretas ae91933c4a drivers: pwm: always use nanoseconds for set
In order to be consistent with what is possible in Devicetree, always
take a period in nanoseconds. Other scales or units may be specified by
using, e.g., the PWM_MSEC() macros (all of them converting down to
nanoseconds). This change then deletes the "_nsec" and "_usec" versions
of the pwm_set call.

Note that this change limits the period to UINT32_MAX nanoseconds,
~4.3s. PWM is, in generali, used with periods below the second so it
should not be a problem.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-04-28 11:29:38 +02:00
Gerard Marull-Paretas 7d43c68b4d drivers: pwm: add pwm_dt_spec and associated helpers
Similar to other APIs, this patch introduces the pwm_dt_spec structure
and associated helpers, e.g. PWM_DT_SPEC_GET() or pwm_set_cycles_dt().

The pwm_dt_spec reduces the boilerplate code needed when using
Devicetree. For example, if we have:

led: led {
    ...
    pwms = <&pwm0 1 PWM_POLARITY_NORMAL>;
    ...
};

One can do now in the application:

struct pwm_dt_spec led = PWM_DT_SPEC_GET(DT_NODELABEL(led));

pwm_set_usec_dt(&led, LED_PERIOD_USEC, LED_PULSE_USEC);

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-04-28 11:29:38 +02:00
Gerard Marull-Paretas 95b56cdffd drivers: pwm: remove _pin from API calls
In a first place, the PWM API operates on "channels", not "pins". While
the API calls could have been changed by _channel, this patch takes the
approach of just dropping _pin. The main reason is that all API calls
operate by definition on a channel basis, so it is a bit redundant to
make this part of the name. Because the `_dt` variants of the calls are
going to be introduced soon, the change to `_channels` + `_dt` would
make API function names quite long.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-04-28 11:29:38 +02:00
Gerard Marull-Paretas b317ce8597 drivers: pwm: s/pwm/channel
All PWM API functions take a "pwm" parameter that indicates the selected
PWM channel. The variable name (pwm) and its documentation "PWM pin" is
misleading. This patch changes it to "channel" in line with the
terminology used in Devicetree (see DT_PWMS_CHANNEL... family of
macros).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-04-28 11:29:38 +02:00
Keith Packard f623571a73 riscv: Initialize TP register when starting threads
Set TP in exception context so that it gets loaded into the CPU when
first running the thread. Set TP for secondary cores to related idle TLS
area.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-04-28 11:09:01 +09:00
Keith Packard 8b55af51db arch/arm: Make MPU stack guard large enough to hold an exception frame
When a stack overflow is caught by an MPU region, the stack pointer will
end up inside that area when the exception is handled. Handling the
exception involves pushing an exception frame onto the same stack. If
there's not enough space remaining below the faulting SP value, the
memory region below the stack will get corrupted.

We protect against this by making the stack guard larger than the 0x20
bytes necessary to hold an exception frame. To avoid lots of conditional
complexity here, the guard is set to 0x40 bytes if the MPU minimum size
is not larger than 0x20 bytes.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-04-28 11:09:01 +09:00
Andy Ross 64a3159dee arch/xtensa: Optimize cache management on context switch
Making context switch cache-coherent in SMP is hard.  The
KERNEL_COHERENCE handling was conservatively invalidating the stack
region of a thread that was being switched in.  This was because it
might have (1) run on this CPU in the past, but (2) run most recently
on a different CPU.  In that case we might have stale data still in
our local dcache!

But this has performance impact in the (very common!) case of a thread
being switched out briefly and then back in (e.g. k_sleep() for a
small duration).  It will come back having lost all of its cached
stack context, and will have to fetch all that information back from
shared SRAM!

Treat this by tracking a "last_cpu" for each thread in the arch part
of the thread struct.  If we're coming back to the same CPU we left,
we know we can skip the invalidate.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2022-04-27 18:54:10 -04:00
Fabio Baltieri 82634eda93 dt: pwm: add support for specifying frequency in Hz and kHz
Add a pair of dt macros for specifying the pwm frequency in hertz or
kilohertz: PWM_HZ and PWM_KHZ. This is then converted in period
nanoseconds so it works as expected with the other definitions.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-04-27 09:31:19 -05:00
Anas Nashif 462b13e16e Revert "ztest: Fix userspace ztests in new API"
This reverts commit 900b6723e7.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-26 18:55:32 -04:00
Erwan Gouriou dda9170ba3 include/zephyr/dt-bindings/clock: stm32g0: Fix APB bus address mix up
APB1 and APB2 bus addresses were mixed up.
Fix this

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-04-26 13:40:34 -05:00
Yuval Peress 900b6723e7 ztest: Fix userspace ztests in new API
Update the new API to use K_USER as the flags for both
CONFIG_USERSPACE and CONFIG_TEST_USERSPACE. Also, fix the linker
script to properly include the suites, tests, and rules.

Fixes #44108

Signed-off-by: Yuval Peress <peress@google.com>
2022-04-26 14:29:18 -04:00
Daniel Leung c6f6dd0ddd linker: split common-rom.ld into smaller snippets
This splits common-rom.ld into smaller snippets so that these
chunks can be placed at different locations if so desired.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-04-26 14:26:53 -04:00
Emil Gydesen c972ffddac Bluetooth: ISO: Add additional information for ISO streams
Add all information from the ISO established events
and provide the information in the get_info function.

The use cases of each field heavily depends on what
the ISO streams are used for.

Most, if not all, of the field can be used by the
higher layers to improve quality and/or reliability
of e.g. audio streams that use ISO.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-04-26 11:35:45 +02:00
Emil Gydesen a796927961 Bluetooth: Audio: Make PACS location optional
Make the PACS location characteristic optional, and
also optionally writable.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-04-26 09:00:48 +02:00
Krzysztof Chruscinski acbdbb15dd logging: Fix cbprintf package alignement
Fix alignment fo the cbprintf package withing the log message.
Aligning tests to pass.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-04-25 11:45:39 -07:00
Pete Dietl d92e3b88ba drivers: CAN: Fix unused parameter warnings when compiling with -Wextra
Since the CAN header file is included directly by application code,
an application developer including this file and only applying
-Wextra to the application source files will see many warnings.

Signed-off-by: Pete Dietl <petedietl@gmail.com>
2022-04-24 19:49:04 +02:00
Erwan Gouriou d67b341282 include: Move stm32 clock dt-bindings to include/zephyr/dt-bindings/clock
Fix STM32 clock dt-bindings location as they were added during
the shift of bt-bindings location from include to include/zephyr.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-04-24 19:47:54 +02:00
Bartosz Bilas 536fe6a948 drivers: spi: mark old spi_cs_control fields deprecated
Since gpio_dt_spec is finally available within spi_cs_control
struct, mark the old fields deprecated in order to use
gpio_dt_spec struct.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Co-authored-by: Jordan Yates <jordan.yates@data61.csiro.au>
Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
Co-authored-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2022-04-22 09:45:53 +02:00
Aleksandr Khromykh a7bb928420 Bluetooth: Mesh: subscription on fixed group addresses
There is errata clarification (Errata ID:18700)
about subscriptions on fixed group addresses.
It is possible to subscribe models on non primary elements
on any fixed group address except all nodes address.
Devices should be able to receive messages on fixed addresses
even if they do not support the feature
to which the fixed group address belongs.

Signed-off-by: Aleksandr Khromykh <Aleksandr.Khromykh@nordicsemi.no>
2022-04-22 09:44:00 +02:00
Yuval Peress 3b5c61d618 include: Update references for devicetree.h
Use zephyr/ prefix for devicetree.h includes.

Issue #41543

Signed-off-by: Yuval Peress <peress@google.com>
2022-04-21 07:40:54 -05:00
Yuval Peress 9d58ea8470 include: update references to <device.h>
Use prefix zephyr/ for device.h includes

Issue #41543

Signed-off-by: Yuval Peress <peress@google.com>
2022-04-21 07:40:54 -05:00
Yuval Peress c35012e122 include: Update references to <cache.h>
Use prefix zephyr/ for cache.h includes.

Issue #41543

Signed-off-by: Yuval Peress <peress@google.com>
2022-04-21 07:40:54 -05:00
Yuval Peress bf6ca7f2e2 include: Update zephyr.h includes to use zephyr/ prefix
Issue #41543

Signed-off-by: Yuval Peress <peress@google.com>
2022-04-21 07:40:54 -05:00
Erwan Gouriou b636e4c799 drivers/clock_control: stm32 common: Use new bus clock bindings
Make use of new bus clocks bindings and make subsequent code
simplifications.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-04-21 14:09:44 +02:00
Erwan Gouriou 5202d40520 include/drivers/clock_control: stm32: Missing PLL macro on some compats
STM32_PLL_ENABLED symbol is missing on F0/F1 and L0/L1 compatibles.
Fix that.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-04-21 14:09:44 +02:00
Erwan Gouriou 83eb9c462b include/drivers/clock_control: stm32: Some HSE clocks are pure fixed-clocks
On STM32WB HSE clock is defined with "fixed-clock" compatible.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-04-21 14:09:44 +02:00
Erwan Gouriou f6db7afb60 drivers/clock_control: stm32 common: Use DT macros for bus prescalers
Simplify and clean up driver code using STM32 clocks DT based macros.

Added STM32_FLASH_PRESCALER macro for this purpose.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-04-21 14:09:44 +02:00
Erwan Gouriou 30f0af97f8 drivers/clock_control: stm32 common: Factorize flash latency setting
Make use of LL_SetFlashLatency in all cases to update flash latency.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-04-21 14:09:44 +02:00
Erwan Gouriou 0c60fcd40d drivers/clock_control: stm32u5: Use new clock bindings
This change updates stm32u5 driver to make use of new clock bindings.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-04-21 14:09:44 +02:00
Erwan Gouriou 3069130245 include/drivers: stm32_clock_control: Avoid non defined PLL outputs
On some series (H7, U5), it is possible define clock configuration
with disabled PLL outputs.
In that case, it is legit that matching pll property is not available.
Define corresponding STM32_PLLX_Y_DIVISOR macros using DT_PROP_OR
to avoid build issues in case prop is not available.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-04-21 14:09:44 +02:00
Erwan Gouriou 61a9016f88 drivers/clock_control: stm32h7: Change clock bus bindings values
Set bus binding values using registers offset values.
As a consequence update driver to take this into account
in clock_on and clock_off functions.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-04-21 14:09:44 +02:00
Carlo Caione 1dcea253d2 shared_multi_heap: Rework framework
Entirely rework the shared_multi_heap framework. Refer to the
documentation for more information.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-04-21 13:15:26 +02:00
Jordan Yates d8f186aa4a arch: common: semihost: add semihosting operations
Add an API that utilizes the ARM semihosting mechanism to interact with
the host system when a device is being emulated or run under a debugger.

RISCV is implemented in terms of the ARM implementation, and therefore
the ARM definitions cross enough architectures to be defined 'common'.

Functionality is exposed as a separate API instead of syscall
implementations (`_lseek`, `_open`, etc) due to various quirks with
the ARM mechanisms that means function arguments are not standard.

For more information see:
https://developer.arm.com/documentation/dui0471/m/what-is-semihosting-

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>

impl
2022-04-21 13:04:52 +02:00
Peter Mitsis a30cf39975 kernel: update k_thread_state_str() API
When threads are in more than one state at a time, k_thread_state_str()
returns a string that lists each of its states delimited by a '+'.
This in turn necessitates a change to the API that includes both a
pointer to the buffer to use for the string and the size of the buffer.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2022-04-20 20:20:13 -04:00
Yuval Peress 72f81021b2 include: move include files to correct location
Files should not be in the root include/ directory but instead under
the zephyr/ prefix path.

Issue #41543

Signed-off-by: Yuval Peress <peress@google.com>
2022-04-20 15:27:09 -04:00
Maxim Kolchurin 329cff8ab4 stm32: dt-bindings: fix AFIO_MAPR SPI3_REMAP0/1 bit pos
set SPI3_REMAP0/1 bit of AFIO_MAPR register to right position

Signed-off-by: Maxim Kolchurin <maxim.kolchurin@gmail.com>
2022-04-20 09:04:31 -05:00
Pete Dietl a12aca2483 drivers: uart: Fix unused parameter warnings when compiling with -Wextra
Since the UART header file is included directly by application code,
an application developer including this file and only applying
-Wextra to the application source files will see many warnings.

Signed-off-by: Pete Dietl <petedietl@gmail.com>
2022-04-20 09:01:43 -05:00
Asbjørn Sæbø b0d5db147b Bluetooth: Audio: Media control - pass structs by reference
Changes the media_proxy API to pass structs by reference instead of by
value.

Also pass structs by reference in internal functions in media player
and in media controller test.

Add pointer checks to the public API implementation where
user/application code provides structs by reference.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-04-20 15:51:01 +02:00
Asbjørn Sæbø fa5b8a1e38 Bluetooth: Audio: MCC - pass structs by reference
Changes the media control client API to pass structs by reference
instead of by value.

Also change internals of test to pass struct by reference.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-04-20 15:51:01 +02:00
Jordan Yates 855f4b9c96 Bluetooth: hci: correct ext adv cmd definition
Update the definition of the set extended advertising data command to be
a variable array instead of hardcoded to the maximum length. This
conforms to the definition from the Bluetooth specification and allows
the corresponding code to be slightly cleaner.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-04-20 15:49:54 +02:00
Robert Lubos e2fe8e7307 net: socket: Add option to create native TLS sock with offloaded TCP
In some cases (for examples when offloaded socket implementation does
not implement TLS functionality) it could be desired to create a native
TLS socket with an underlying offloaded socket.

This cannot be achieved with SO_BINDTODEVICE option only, as TLS socket
type is not really associated with a particular interface - it either
has to be offloaded, or a fully native socket is created (native TLS on
a native interface).

In order to address the problem, introduce TLS_NATIVE socket option.
This option instructs the socket dispatcher layer to create a native TLS
socket. As with the socket dispatcher the underlying socket
implementation is not decided during TLS socket creation, therefore it's
possible to use SO_BINDTODEVICE to choose either native or offloaded
interface for the underlying socket.

Additionally remove NET_SOCKETS_OFFLOAD_TLS Kconfig option, as it's no
longer needed with an runtime option to select whether to offload TLS or
not.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-04-20 11:27:05 +02:00
Robert Lubos 7946988b16 net: sockets: Add separate macro for registering offloaded sockets
Add a separate macro for registering offloaded sockets implementation,
along with information in the structure whether the implementation is
offloaded or not. This allows to differentiate between native and
offloaded socket implementations, which is critical for binding socket
API with an interface.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-04-20 11:27:05 +02:00
Robert Lubos fa8ba73833 net: if: Connect interface with offloaded socket implementation
Instead of keeping a boolean informing whether a network interface is
offloaded at socket layer or not, keep a pointer to a function which
allows to create an offloaded socket. Native interfaces keep this as
NULL, while for offloaded interfaces it allows to connect an offloaded
socket implementation with an interface.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-04-20 11:27:05 +02:00
Anas Nashif c9d0248867 kernel: introduce convinience apu to pin thread to a cpu
Add an API that clears cpu mask from a thread and sets it to a specific
CPU.

This is the equivelent of:

        k_thread_cpu_mask_clear(&thread);
	k_thread_cpu_mask_enable(&thread, cpu_idx);

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-19 13:05:09 -04:00
Georgij Cernysiov 951654cf18 include: dt-bindings: timer: stm32: move to correct dir
Moves dt-bindings constants file to correct location.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2022-04-19 11:49:42 +02:00
Georgij Cernysiov 7ce7f75ae9 include: dt-bindings: add stm32 fmc nor psram defines
Add defines to configure STM32
FMC NOR/PSRAM controller.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2022-04-19 11:47:06 +02:00
Flavio Ceolin 370ce60152 linker: Re-use device handle logic
Add a new file with the device handles logic that is included in both
ram and ROM

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-04-18 17:25:01 -07:00
Flavio Ceolin acca447948 pm: device: Use pm flags to mark a power domain
Add a new flag that is used to tell whether or not a device is a power
domain. In order to a device be identified as a power domain the node
has to be compatible with "power-domain".

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-04-18 17:25:01 -07:00
Flavio Ceolin 605d785428 pm: Add an underline in device pm slot
Add an underline character before "slot" to make the sufix easier to
read.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-04-18 17:25:01 -07:00
Flavio Ceolin 0b13b44a66 pm: device: Dynamically add a device to a power domain
Add API to add devices to a power domain in runtime. The number of
devices that can be added is defined in build time.

The script gen_handles.py will check the number defined in
`CONFIG_PM_DEVICE_POWER_DOMAIN_DYNAMIC` to resize the handles vector,
adding empty slots in the supported sector to be used later.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-04-18 17:25:01 -07:00
Henrik Brix Andersen d5f3f20edb drivers: can: allow calling can_set_bitrate() from userspace
Add syscall to allow calling can_set_bitrate() from userspace.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-04-18 17:23:28 -07:00
Vaishnav Achath e2ed8cf130 drivers: pinctrl: add CC13XX/CC26XX pinctrl driver
Add pinctrl driver for CC13XX/CC26XX family of SoCs
to facilitate transition from pinmux to pinctrl.

`IOCPortConfigureSet()` from TI hal driverlib used to
implement the generic pinctrl driver.

Signed-off-by: Vaishnav Achath <vaishnav@beagleboard.org>
2022-04-18 18:19:46 -04:00
Yuval Peress 8da60c3c7e cpp: Update structs to be compatible with C++
Both the `_cpu_arch` and `k_thread_runtime_stats` structs can have a
size of 0 in C, but will fail when building with C++. Add an extra
byte in those cases.

Signed-off-by: Yuval Peress <peress@google.com>
2022-04-18 13:21:52 -05:00
Anas Nashif 8d7a4f79fb kernel: fix cpu_mask api documentation
wrong kconfig is being used in the note, DEADLINE is not related to cpu
mask APIs.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-15 16:14:14 -07:00
Piotr Pryga 4a18d615a4 slist: Fix sys_slist_append_list with head and tail NULL break a list
If the sys_slist_t instance is not empty, its head and tail points to
some sys_snode_t instances. If sys_slist_append_list is executed with
tail being NULL the list object is corrupted. Tail of the sys_slist_t
instance is set to NULL. If one executes sys_slist_append on that node,
then nodes pointed by head are lost.

The commit fixes the issue and adds unit tests to verify correct
behavior.

Added change verifies if head and tail of appended list are not NULL.
In other case the list object is invalid and should not be appended
to a valid list instance.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-04-15 11:50:29 -07:00
Mariusz Skamra 4ac9eba3d5 Bluetooth: has: Add initial support for presets
This adds initial support for presets that includes API functions
to register/unregister presets and Read Preset Request control point
handler.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-04-15 10:32:54 -07:00
Pete Dietl 41e30f0234 drivers: i2c: Fix unused parameter warnings when compiling with -Wextra
Since the i2c header file is included directly by application code,
an application developer including this file and only applying
-Wextra to the application source files will see this warning.

Signed-off-by: Pete Dietl <petedietl@gmail.com>
2022-04-14 14:49:48 -05:00
Jaska Uimonen 783a96a71b drivers: add new audio dai driver interface
The DAI (digital audio interface) API is a high level audio driver
abstraction. It provides support for the standard I2S (SSP), DMIC, HDA
and SDW backends. The API has a config function with bespoke data
argument for device/vendor specific config. There are also optional
timestamping functions to get device specific audio clock time.

Signed-off-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
2022-04-14 11:42:08 -04:00
Krzysztof Chruscinski 8b0d429bfd logging: Add timestamp getter function part of internal API
Expose timestamp getter so it can be used, e.g. in the frontend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-04-13 13:45:36 -07:00
Krzysztof Chruscinski 24372f4e84 logging: Fix control macros for FRONTEND_ONLY case
When only frontend is used, core initialization and panic notification
should still be called. Before that change macros for that were empty
when CONFIG_LOG_FRONTEND_ONLY=y.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-04-13 13:45:36 -07:00
Nicolas Pitre 4f1988fbfd riscv: small arch_irq_* cleanup and optimization
- Allow immediate argument with the csrrc instruction
- Replace csrrs with csrs and avoid a needless register allocation
- Mask the MSTATUS_IEN only at the consumer
- Remove unappropriate comment

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-04-13 13:28:51 -07:00
Henrik Brix Andersen fba27b4bde drivers: can: change sample point for can_set_bitrate() at high bitrates
CAN in Automation (CiA) 301 v4.2.0 recommends a sample point location of
87.5% percent for all bitrates. However, some CAN controllers have
difficulties meeting this for higher bitrates.

Change can_set_bitrate() to use a sample point of 75.0% for bitrates
over 800 kbit/s, 80.0% for bitrates over 500 kbit/s, and 87.5% for all
other bitrates. This is in line with the sample point locations used by
the Linux kernel.

Regard a sample point error of more than +/- 5.0% as an error in setting
the bitrate. Previously, any sample rate error was accepted without
providing any feedback to the caller. This is in line with the CAN
sample point calculation criteria used by the Linux kernel.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-04-13 13:28:06 -07:00
Damian Krolik 5f5410a0cc sys: heap: support maximum allocated bytes statistic
Besides the current allocated/free bytes, keep track of
the maximum allocated bytes to help determine the heap
size requirements. Also, provide a function to reset
the statistic.

Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
2022-04-13 13:27:28 -07:00
Daniel Leung 3539db43ef lib: os: cbprintf: use TOOLCHAIN_HAS_C_GENERIC macro instead
Since toolchain.h supplies the macro TOOLCHAIN_HAS_C_GENERIC to
indicate if the compiler supports C Generic, there is no need to
do the long chain of macro arithmetic in cbprintf header file.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-04-13 08:29:23 -05:00
Christopher Friedt 7c583bbf8f lib: posix: support for pthread_attr_setstacksize
Support pthread_attr_setstacksize(3).

See https://pubs.opengroup.org/onlinepubs/7908799/xsh/pthread_attr_getstacksize.html

Fixes #44722

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2022-04-12 22:02:04 +09:00
Szymon Czapracki af2e781f5a Bluetooth: Immediate Alert Service
This commits adds IAS for zephyr bluetooth.

Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
2022-04-12 09:59:34 +02:00
Veijo Pesonen d1751cafd3 net: lwm2m: adds LwM2M specific shell command
First available subcommand is for doing a send operation. Send operation
is supported by the LwM2M version 1.1.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-04-12 09:57:20 +02:00
Henrik Brix Andersen f1f97a2bcc drivers: reset: add casts required by C++
Add casts required for C++ compilation. Use explicit NULL checks.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-04-12 09:55:27 +02:00
Henrik Brix Andersen f561013827 drivers: espi: emul: include needed header
Include drivers/espi.h in drivers/espi_emul.h to satisfy dependencies.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-04-12 09:55:27 +02:00
Henrik Brix Andersen 24dc527fc1 drivers: edac: add casts required by C++
Add casts required for C++ compilation.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-04-12 09:55:27 +02:00
Henrik Brix Andersen 4cdb6eebb4 drivers: dma: add casts required by C++
Add casts required for C++ compilation.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-04-12 09:55:27 +02:00
honglin leng 215efc02c2 include: fix the function pointer error
fix incorrect function pointer judgment in video_stream_stop

Signed-off-by: honglin leng <hlleng@listenai.com>
2022-04-11 11:14:13 -05:00
Lingao Meng 37e561f42e Bluetooth: Host: Add choice select whether BT RX
Change CONFIG_BT_RECV_IS_RX_THREAD into a
choice:CONFIG_BT_RECV_CONTEXT with the following options
(names can be discussed further of course):

    CONFIG_BT_RECV_BLOCKING
    CONFIG_BT_RECV_WORKQ_BT
    CONFIG_BT_RECV_WORKQ_SYS

This way users would be able to choose what to run most of
the BLE stack on, they wouldn't be forced to a single model.

We would default to CONFIG_BT_RECV_BLOCKING so that we wouldn't
need to change the system workqueue stack size by default, instead
asking users to do so if they select the CONFIG_BT_RECV_WORKQ_SYS option

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-04-11 10:58:09 +02:00
Mohan Kumar Kumar f105ea6ef5 net: add sndbuf socket option
Introduce set/get SO_SNDBUF option using the setsockopt
function. In addition, for TCP, check the sndbuf value
before queuing data.

Signed-off-by: Mohan Kumar Kumar <mohankm@fb.com>
2022-04-11 10:23:31 +02:00
Yuval Peress 53ef68d459 include: Prefix includes to use a scope
Move include paths and add new target_include_directories to support
backwards compatibility:
* /include -> /include/zephyr
  example: <irq.h> -> <zephyr/irq.h>

Issue #41543

Signed-off-by: Yuval Peress <peress@google.com>
2022-04-08 19:03:32 +02:00
Nazar Kazakov 9713f0d47c everywhere: fix typos
Fix a lot of typos

Signed-off-by: Nazar Kazakov <nazar.kazakov.work@gmail.com>
2022-03-14 20:22:24 -04:00
Kumar Gala 19e5a9c061 zephyr: Remove support for deprecated int types
Its been 2 releases since we deprecated the old zephyr integer types.
We can now remove support for the Kconfig option, code, and, test to
allow the old int types to be supported.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-03-05 04:56:13 -06:00
Martin Åberg e6f4140b30 zephyr: introduce z_max_align_t
Similar to the C11 type max_align_t.

Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
2020-11-17 11:44:16 +02:00
Kumar Gala 1737bd082d zephyr: Use deprecated instead of legacy for Kconfig int types
Rename the Kconfig symbol from LEGACY_ZEPHYR_INT_TYPES to
DEPRECATED_ZEPHYR_INT_TYPES.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-09 06:49:56 -05:00
Kumar Gala e353d123fd zephyr: Make Zephyr int types deprecated by default
As the int types defined in include/zephyr/types.h are typdef's we
utilize a Kconfig option (LEGACY_ZEPHYR_INT_TYPES) to enable/disable
the support for them.  By default to LEGACY_ZEPHYR_INT_TYPES not
being enabled and add an explicit test to ensure the types continue to
function until removed in the future.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Kumar Gala 1342dadc36 include: Remove compat include headers
Remove the compat headers as its been 2 releases since we introduced
them.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-12-10 08:39:37 -05:00
Nicolas Pitre 0440a815a9 riscv: make core code 64-bit compatible
There are two aspects to this: CPU registers are twice as big, and the
load and store instructions must use the 'd' suffix instead of the 'w'
one. To abstract register differences, we simply use a ulong_t instead
of u32_t given that RISC-V is either ILP32 or LP64. And the relevant
lw/sw instructions are replaced by LR/SR (load/store register) that get
defined as either lw/sw or ld/sd. Finally a few constants to deal with
register offsets are also provided.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2019-08-02 13:54:48 -07:00
Anas Nashif 4be2e9ebb6 cleanup: include/: move zephyr/jwt.h to data/jwt.h
move zephyr/jwt.h to data/jwt.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
David Brown f8b838d404 jwt: Add JSON web token library
This patch adds a JSON web token library that adds the capability
to sign JSON tokens.  This was located in subsys due to the dependency
on MBEDTLS, which resides in /ext.

Signed-off-by: David Brown <david.brown@linaro.org>
Signed-off-by: Andy Gross <andy.gross@linaro.org>
2019-02-08 15:32:58 -06: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
Kumar Gala 789081673f Introduce new sized integer typedefs
This is a start to move away from the C99 {u}int{8,16,32,64}_t types to
Zephyr defined u{8,16,32,64}_t and s{8,16,32,64}_t.  This allows Zephyr
to define the sized types in a consistent manor across all the
architectures we support and not conflict with what various compilers
and libc might do with regards to the C99 types.

We introduce <zephyr/types.h> as part of this and have it include
<stdint.h> for now until we transition all the code away from the C99
types.

We go with u{8,16,32,64}_t and s{8,16,32,64}_t as there are some
existing variables defined u8 & u16 as well as to be consistent with
Zephyr naming conventions.

Jira: ZEP-2051

Change-Id: I451fed0623b029d65866622e478225dfab2c0ca8
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-20 16:07:08 +00:00