Commit graph

1232 commits

Author SHA1 Message Date
Carlo Caione 385f06e6a1 arm64: cache: Rework cache API
And use the new API.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-12-01 13:40:56 -05:00
Carlo Caione 189cd1f4a2 cache: Rework cache API
The cache operations must be quick, optimized and possibly inlined. The
current API is clunky, functions are not inlined and passing parameters
around that are basically always known at compile time.

In this patch we rework the cache functions to allow us to get rid of
useless parameters and make inlining easier.

In particular this changeset is doing three things:

1. `CONFIG_HAS_ARCH_CACHE` is now `CONFIG_ARCH_CACHE` and
   `CONFIG_HAS_EXTERNAL_CACHE` is now `CONFIG_EXTERNAL_CACHE`

2. The cache API has been reworked.

3. Comments are added.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-12-01 13:40:56 -05:00
Gerard Marull-Paretas a29bdc262c drivers: regulator: drop async enable
Drop the async enable function. This feature is rarely/never used,
complicates driver design, and doesn't really follow the sync/async API
design/naming used in other areas. In the future we can introduce
regulator_enable_async if needed, with support from the driver class (no
onoff). Note that drivers like PCA9420 did not implement any
asynchronous behavior. regulator-fixed implemented in the past
asynchronous behavior using work queues, an overkill for most GPIO
driven regulators. Let's keep things simple for now and extend the API
when needed, based on specific usecases.

In the current implementation, reference counting is managed by the
driver class. \isr-ok attribute is dropped, since calls are potentially
blocking. Note that drivers like PCA9420 already violated such rule.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-30 15:49:30 +01:00
Théo Battrel a5ea4664c9 Bluetooth: Remove conditionnal declaration of bt_tbs_dbg_print_calls
Remove conditionnal declaration of `bt_tbs_dbg_print_calls` in
`subsys/bluetooth/audio/tbs.h` so the function still exist even if the
debug is not enabled.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2022-11-30 14:37:58 +01:00
Jay Vasanth 38ad230aec drivers: pinctrl: Microchip XEC PINCTRL add invert pin
Microchip XEC GPIO pins support inverting the output of
alternate pin functions. This feature may be useful for
those peripherals that do not implement output inversion
in the peripheral. GPIO control register pad input and
parallel input register values are not affected by the
function output invert feature. GPIO interrupt detection
of an output is inverted if the invert polarity is enabled.

Signed-off-by: Jay Vasanth <jay.vasanth@microchip.com>
2022-11-30 11:29:22 +01:00
Georgij Cernysiov a8ac1424d8 include: dt-bindings: clock: stm32h7 add PLL2 defines
Uncomments PPL2 defines as it is supported.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2022-11-29 11:54:52 +01:00
Georgij Cernysiov 2b0727d550 drivers: clock_control: stm32h7: add PLL2 support
Adds PLL2 support.

The driver configures and enables PPL2 when
it is enabled in the DTS.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2022-11-29 11:54:52 +01:00
Gerard Marull-Paretas a78bdbce89 dt-bindings: regulator: pca9420: reorganize headers/macros
pca9420_i2c.h has neem remamed to pca9420.h (device only has I2C, so
it's kind of redundant to have i2c in the header name).

pmic_i2c.h was again not generic but designed specifically for PCA9420.
All its macros have been renamed, s/PMIC/PCA9420, and moved to the
pca9420.h header.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-29 11:54:31 +01:00
Gerard Marull-Paretas 9219d3d2b5 drivers: regulator: pca9420: fix VIN current limit setting
The driver had a conceptual issue regarding current limitation. PCA9420
is able to limit the current flowing through VIN, ie input current. This
is a global setting, not individual to each regulator. This patch
creates a new DT property: nxp,vin-ilim-microamp to specify such limit.
It is applied when the device is initialized.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-29 11:54:31 +01:00
Gerard Marull-Paretas dcd63d288f drivers: regulator: pca9420: refactor voltage range handling
Voltage ranges were hardcoded in Devicetree, however, things can be
significantly simplified by using the recently introduce linear ranges
API. All values are now computed using information stored in the driver,
so there is no need to store any lookup table in ROM. Code should now
both be faster in average and consume less ROM.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-29 11:54:31 +01:00
Gerard Marull-Paretas 1caedf12dd drivers: regulator: pca9420: do not expose registers in DT
Regulator registers were set for each BUCK/LDO in DT, likely because of
the way the devices were instantiated. When using a generic iterator,
ie, DT_INST_FOREACH_CHILD, there's no way to differentiate the child
being _parsed_. Since instantiation happens now based on child node
names, we are able to know which registers each devices gets assigned at
the driver level. This greatly simplifies Devicetree, and it actually
removes information that is not strictly hardware description from it.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-29 11:54:31 +01:00
Gerard Marull-Paretas 85becbb5b3 drivers: regulator: pca9420: remove unused registers
The PCA9420 dt-bindings include file defines all device registers, but
many of them are not used (e.g. battery charger). It is also not the way
to use register definitions. Devicetree is about hardware description
after all. File will be cleaned up in subsequent commits.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-29 11:54:31 +01:00
Evgeniy Paltsev ae79de1930 ARC: MWDT add TLS support
Add thread local storage support for ARC MWDT toolchain.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2022-11-29 09:48:23 +01:00
Chris Friedt 43fb41fff2 include: sys: crc: add crc_by_type inline dispatch function
Rather than hard-coding calls to each individual CRC function, it
may be more convenient to specify the crc algorithm to use
parametrically.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2022-11-29 09:32:28 +01:00
Arsen Eloglian 3659c2db4b intel_common: clean up & rename cavs_* to adsp_*
ADSP common definitions has been fixed
and changed from CAVS_* to  ADSP_*

Signed-off-by: Arsen Eloglian <ArsenX.Eloglian@intel.com>
2022-11-28 17:45:20 -05:00
Hernan I. Gutierrez-Vazquez 28a815190f include: Add i2c helper methods for async implementation
Added 3 helper methods for async calls as they exist for
the blocking implementation

Signed-off-by: Hernan I. Gutierrez-Vazquez <quic_hernang@quicinc.com>
2022-11-28 19:00:20 +01:00
Evgeniy Paltsev 761be25c43 ARC: make ARC_MP_PRIMARY_CPU_ID definition public
Make ARC_MP_PRIMARY_CPU_ID definition public so it can be used in
other ARC code.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2022-11-28 17:44:54 +01:00
Emil Gydesen bbc85e0b2c Bluetooth: Audio: Use bt_vcp_vol_ctlr instead of bt_vcp
Use the `bt_vcp_vol_ctlr` opaque type instead of the more
generic `bt_vcp`.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-28 17:43:40 +01:00
Emil Gydesen ae11b5879b Bluetooth: Audio: Remove bt_vcp from vol rend API
Remove the struct bt_vcp pointer from the volume
renderer API, as there is only ever a single
Volume Renderer instance on a device.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-28 17:43:40 +01:00
Emil Gydesen c82af2885e Bluetooth: Audio: Split vol_ctlr and vol_rend callback structure
Split the `bt_vcp_cb` struct into separate structure for
the volume controller and the volume renderer.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-28 17:43:40 +01:00
Emil Gydesen 7f69b866f0 Bluetooth: Audio: Specify bt_vcp_vol_rend API
The VCP server, known as the volume renderer, has a
more explicity bt_vcp_vol_rend API naming scheme now.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-28 17:43:40 +01:00
Emil Gydesen 71bd487cc4 Bluetooth: Audio: Add separate API for VCP vol controller
Add a separate API for the VCP volume controller (client).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-28 17:43:40 +01:00
Emil Gydesen 966c9f80e7 Bluetooth: Audio: Remove the bt_vcp_vocs API
Remove the bt_vcp_vocs API as it did the same as the
bt_vocs API, and did not really any functionality.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-28 17:43:40 +01:00
Emil Gydesen bfbb704c8e Bluetooth: Audio: Remove the bt_vcp_aics API
The AICS functionality can be exercised using the
bt_aics API instead. These functions did very little
besides cluttering up the bt_vcp API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-28 17:43:40 +01:00
Emil Gydesen ce2b8f9fe1 Bluetooth: Audio: Rename VCS to VCP
Renames almost all occurences of VCS to VCP, as we want to
use the profile as the namespace for volume control.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-28 17:43:40 +01:00
Emil Gydesen aaac86dada Bluetooth: Audio: Rename vcs.h to vcp.h as well as the Kconfig file
Rename vcs.h to vcp.h to better detail what the
file contains, as it is more than just VCS. This also
renames the Kconfig file.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-28 17:43:40 +01:00
Mulin Chao 0893ca8c2f driver: gpio: npcx: correct the usage of npcx voltage flags
In npcx ec series, two detection levels, 3.3V (default) and 1.8V are
supported during gpio configuration. But the current implementation
always selects default detection level whether NPCX_GPIO_VOLTAGE_1P8 is
set. This PR is a fix for this issue.

Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
2022-11-28 09:56:33 +00:00
Théo Battrel e458f5aae6 Bluetooth: Use Zephyr standard log system instead of bluetooth/common/log
The `bluetooth/common/log.h` and `bluetooth/common/log.c` files have been
removed. Files that were using them have been updated to use
`zephyr/logging/log.h` instead.

Those replacement have been done consequently:
- `/BT_DBG/LOG_DBG/`
- `/BT_ERR/LOG_ERR/`
- `/BT_WARN/LOG_WRN/`
- `/BT_INFO/LOG_INF/`
- `/BT_HEXDUMP_DBG/LOG_HEXDUMP_DBG/`
- `/BT_DBG_OBJ_ID/LOG_DBG_OBJ_ID/`

Also, some files were relying on the `common/log.h` include to include
`zephyr/bluetooth/hci.h`, in those cases the include of `hci.h` has
been added.

For files that were including `common/log.h` but not using any logs,
the include has been removed and not replaced.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2022-11-25 17:08:36 +01:00
Emil Gydesen 292db21a18 Bluetooth: Audio: Use svc_inst instead of bt_csip for set_member
Use the service instance struct instead of the more generic
`bt_csip` for the CSIP set member API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-24 15:23:48 +01:00
Emil Gydesen 5ecaf5af1b Bluetooth: Audio: CSIP set coordinator API not using bt_csip
Modified the CSIP set coordinator slightly to not use the
bt_csip struct at all. For the use a void pointer works
equally well.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-24 15:23:48 +01:00
Emil Gydesen 87f86cebe2 Bluetooth: Audio: Rename bt_csip to bt_csip_set_member
Renamed remaining structs and functions that are not
for the set coordinator to use the set member CSIP
role name.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-24 15:23:48 +01:00
Emil Gydesen 93b3944a51 Bluetooth: Audio: Rename CSIS to CSIP
Renamed the coordinated set implementation to use the
profile (CSIP) name instead of the service (CSIS) name, as
the former is more general.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-24 15:23:48 +01:00
Johan Hedberg 96f9632ffe pcie: Deprecate pcie_probe() and pcie_bdf_lookup()
These functions are no longer needed with the centralized framework for
scanning for available PCIe devices and discovering their BDF value
through it.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2022-11-24 15:23:28 +01:00
Johan Hedberg 57c150af0c pcie: Add API for scanning for available endpoints
This adds a generic API to be used for scanning for available PCI
endpoints. It takes a more detailed approach than the "brute force"
based scanning that's so far been used in Zephyr, buy inspecting the
host controller node and bridge nodes, and only scanning for busses and
devices that are actually expected to exist.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2022-11-24 15:23:28 +01:00
Johan Hedberg a2c8fdca33 pcie: Add helper macro to identify valid identifiers
PCI(e) host controllers behave in different ways (some more buggy than
others) in what value they use to indicate that an endpoint is not
present. In most cases the VID/DID is all ones (PCIE_ID_NONE) but in
others it's all zeroes, and some may even have the VID all zeroes and
the DID all ones, or vice-versa.

Add a macro to easily test for all these possibilities. The "all ones"
and "all zeroes" cases have been verified to exist on actual HW
supported by Zephyr, however the test for the mixed cases is simply
based on what Linux considers valid values (drivers/pci/probe.c in the
Linux kernel tree).

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2022-11-24 15:23:28 +01:00
Morten Priess 3915754ac3 Bluetooth: controller: Add support for Read/Write Conn. Accept Timeout
Implement HCI commands HCI_Read_Connection_Accept_Timeout and
HCI_Write_Connection_Accept_Timeout, and enable the feature in
supported commands.
Remove hardcoded use of default accept timeout in new LLCP code, and
use configurable value instead.

This makes EBQ test /HCI/CIN/BV-03-C pass.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-11-24 11:17:28 +01:00
Emil Gydesen 40e3930ebd Bluetooth: Audio: Broadcast source subgroup and BIS codec support
Updates the broadcast source API to create subgroups and
to set BIS specific codec configuration

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-24 10:21:36 +01:00
Gerard Marull-Paretas 01eb102719 sys: linear_range: initial API
This patch adds a new API to map values in a linear range to a range
index. This API is useful in the context of regulators, where it is
common that devices map regulator voltages to a set of indices with a
linear relationship.

The original idea is borrowed from Linux.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-24 10:16:03 +01:00
Cyril Fougeray d8d714d57a pm: device_runtime: fix unused parameter warning
When using `-Wunused-parameter`, compiler complains about
unused parameter.

Signed-off-by: Cyril Fougeray <cyril.fougeray@worldcoin.org>
2022-11-24 09:36:12 +01:00
Johann Fischer ba966e7122 include: kernel: add comment about alignmend of allocated memory
Add comment that memory block allocated by k_malloc() and
k_heap_alloc(), are aligned to multiple of pointer sizes.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-11-24 09:35:13 +01:00
Adrian Warecki fc0c4552a2 dma: Extend api to allow get controller attributes
Added a new get_attribute function to the dma driver api.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
2022-11-23 15:36:31 -05:00
Adrian Warecki 5b8a66faa1 dma: dts: Add support for dma-copy-alignment and dma-buf-size-alignment
dma-buf-size-alignment: Buffer size alignment required by the DMA
controller.

dma-copy-alignment: Minimal chunk of data possible to be copied
by the controller.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
2022-11-23 15:36:31 -05:00
Adrian Warecki aac03280ec dma: dts: Rename of the dma_buf_alignment to dma-buf-addr-alignment
Renamed the dma-buf-alignment field to a more explicit
and descriptive name dma-buf-addr-alignment.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
2022-11-23 15:36:31 -05:00
Adrian Warecki 55fbea97d2 dma: Extend dma status api to get total copied data
Added a new field containing total copied data to the
dma_status structure.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
2022-11-23 15:36:31 -05:00
Chris Friedt f1ececc682 posix: key: abstract pthread_key_t as uint32_t
Consistent with the change of `pthread_t`, `pthread_mutex_t`,
and `pthread_cond_t` to `uint32_t`, we can now also abstract
`pthread_key_t` as `uint32_t` and separate the implementation
detail, hidden from POSIX API consumers.

This change introduces `CONFIG_MAX_PTHREAD_KEY_COUNT`.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2022-11-24 04:19:01 +09:00
Emil Gydesen 1b2f57270a Bluetooth: Host: Add addr to bt_le_ext_adv_get_info
Add the local advertising address to bt_le_ext_adv_get_info.

This may help with debugging, but is also needed to
properly support something like the BAP Broadcast Assistant.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-23 16:12:52 +00:00
Jamie McCrae 62dc229a08 doc: mgmt: mcumgr: Improve descriptions and add links
Makes the MCUmgr documentation on sphinx more readable and usable.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-23 12:19:45 +01:00
Henri Xavier b54ba9877f arm64: implement arch_system_halt
When PSCI is enabled, implement `arch_system_halt` using
PSCI_SHUTDOWN.

Signed-off-by: Henri Xavier <datacomos@huawei.com>
2022-11-23 11:37:08 +01:00
Radoslaw Koppel 0620cb1fe1 ipc: ipc_service: icmsg: Increase reliability of bonding
This commit changes the way bonding between endpoints is processed.
There is no blind attempt to read the buffer without mbox notification.
On second side the notification is repeated multiple times until valid
bonding is detected.

Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
2022-11-23 11:34:04 +01:00
Gerard Marull-Paretas eaadea5508 drivers: gpio: npm6001: initial driver
Add GPIO driver for the GPIO controller embedded in the nPM6001 PMIC.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-22 11:05:19 +01:00
Wojciech Slenska 188d2dfcca shell: shell_log_backend: take buffer size from config
Use LOG_MESSAGE_QUEUE_SIZE config instead of hardcoded value.
LOG_MESSAGE_QUEUE_SIZE default value has been changed to 512, so
it is now matching to the hardcoded value.

Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
2022-11-22 13:05:29 +09:00
Jamie McCrae 0922ec7d75 mgmt: mcumgr: Move zephyr basic group defines to standard files
Moves the zephyr group ID defines to the mgmt header file as it is
with other group IDs and moves the zephyr basic group command IDs
to the the same header-location style as other groups.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-22 12:42:48 +09:00
Jamie McCrae cbd0d2d55a mgmt: mcumgr: Add fs_mgmt prefix to hash/checksum functions/files
This aligns the naming of files in fs_mgmt so that files and
functions relating to hash/checksum are prefixed with fs_mgmt.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-22 12:41:49 +09:00
Jamie McCrae adbbb02525 mgmt: mcumgr: Fix include typo
Fixes a typo in an include statement which causes a build failure.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-21 17:34:02 +01:00
Carles Cufi 4796ffee7a drivers: mm: Move mm_drv_intel_adsp_mtl_tlb to zephyr/
This file was mistakenly placed in include/ instead of include/zephyr.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-11-21 20:43:50 +09:00
Guillaume Gautier fde9a657da include: zephyr: drivers: clock_control: LSI support for STM32WB
Add LSI1 and LSI2 (both present on STM32WB) to the list of possible
source for LSI clock
Solve a regression for RTC counter

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2022-11-21 10:14:41 +01:00
Guillaume Gautier b5f9ea073e include: zephyr: dt-bindings: clock: Add sysclk for STM32F1, F4 & L1
For STM32F1, F4 & L1 series, add the definition of SYSCLK to solve a
regression concerning the RTC counter

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2022-11-21 10:14:41 +01:00
Aaron Massey 5fa1abf1cb fuel_gauge: Add basic stub API doc.
Add a short stub doc as a placeholder for future documentation on the fuel
gauge API.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2022-11-19 17:56:05 -05:00
Aaron Massey ee6e85ca83 fuel_gauge: Initial fuel-gauge dedicated API
Add initial battery fuel-gauge driver API with the most basic of
native_posix driver tests.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2022-11-19 17:56:05 -05:00
Robert Lubos 387a66131e net: pkt: Introduce minimum length requirement to net_pkt_get_frag()
net_pkt_get_frag() and a few other functions did not specify the
allocated fragment length, incorrectly assuming that fixed-sized
buffers are always used.

In order to make the function work properly also with variable-sized
buffers, extend the function argument list with minimum expected
fragment length parameter. This allows to use net_buf_alloc_len()
allocator in variable buffer length configuration, as well as verify if
the fixed-sized buffer is large enough to satisfy the requirements
otherwise.

Update the existing codebase to provide the expected fragment length,
based on the context.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-11-19 07:39:32 -05:00
Chris Friedt 3a56d276e9 posix: cond: abstract pthread_cond_t as uint32_t
Consistent with the change of `pthread_t` from
`struct posix_thread` to `uint32_t`, we can now also abstract
`pthread_cond_t` as `uint32_t` and separate `struct posix_cond`
as an implementation detail, hidden from POSIX API consumers.

This change deprecates `PTHREAD_COND_DEFINE()` in favour of the
(standardized) `PTHREAD_COND_INITIALIZER`.

This change introduces `CONFIG_MAX_PTHREAD_COND_COUNT`.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2022-11-19 14:16:38 +09:00
Michał Barnaś 94458f88b9 ec_host_cmd: add eSPI peripheral for the host commands
This commit adds the support for host commands being transported
by the eSPI subsystem.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2022-11-18 10:11:40 +01:00
Michał Barnaś b91849c4bd ec_host_cmd: add missing fields and improve compatibility
Add missing fields in structure containing the arguments used by
the host commands handlers and change the order of parameters
in macro used for defining the handlers.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2022-11-18 10:11:40 +01:00
Michał Barnaś e184e45a52 ec_host_cmd: add missing status codes
Add missing status codes that can be used by host commands handlers

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2022-11-18 10:11:40 +01:00
Michał Barnaś 959d3b87fb ec_host_cmd: move the host_cmd_periph.h to subdirectory
Move the header file to corresponding directory which refers to
submodule name instead of root of drivers directory.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2022-11-18 10:11:40 +01:00
Michał Barnaś 1563cda9dd ec_host_cmd: remove syscalls for this subsystem
The functions for ec_host_cmd_periph are only used by statically defined
kernel thread and should never be used from other subsystem, especially
from userspace. This commit removes the syscalls prefixes from these
functions and leaves them as inline call to API implementations from
peripheral.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2022-11-18 10:11:40 +01:00
Pieter De Gendt 9e2dad91b4 devicetree: Move DT_INST_PARENT to devicetree-inst group
The DT_INST_PARENT macro belongs into the devicetree-inst
documentation group.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2022-11-17 10:18:11 -06:00
Pieter De Gendt 3064e58ac4 devicetree: Add DT_INST_GPARENT
Add the instance-based version of DT_GPARENT.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2022-11-17 10:18:11 -06:00
Dominik Ermel dbd212844f mgmt/mcumgr: Correct documentation in img_mgmt.h
Some documentation has not been properly formatted for generating
and some has been inaccurate.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-11-17 15:31:17 +01:00
Dominik Ermel 7048383362 doc: Move SMP transport documentation under doc/services
The commit moves MCUmgr SMP transport documentation from
subsys/mgmt/mcumgr/lib to doc/services/device_mgmt.
Documentation have been rewritten for that purpose.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-11-17 15:31:17 +01:00
Dominik Ermel 4328f165a8 mgmt/mcumgr: Reworking source code tree and API interface
The commit reworks mgmt/mcumgr subsystem source code to remove
lib subdirectory and make it a little bit more flat.
It also moves all API interface files, which are supposed to be
visible by applications using MCUMgr, to interface sub-directories,
and exposes them with full paths; for example to include general
MCUMgr support, group registration and so on, user would now include:
 <mgmt/mcumgr/mgmt/mgmt.h>
to additionally have control on File System group management
registration user would need:
 <mgmt/mcumgr/mgmt/grp/fs_mgmt.h>

All internal headers have been removed from interface.

CMAkeLists.txt get significant rework and various MCUMgr subsystems
have been divided into separate sub-libraries.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-11-17 15:31:17 +01:00
Dominik Ermel 7c2924f4bc mgmt/mcumgr: Move transport headers to transport subdir
The MCUmgr transport headers have been moved to
zephyr/mgmt/mcumgr/transport/

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-11-17 15:31:17 +01:00
Jamie McCrae 018b2ebebe doc: mgmt: mcumgr: Fix formatting
This add links to the MCUmgr documentation so that it will be
automatically linked in sphinx and fixes a link to the wrong
function.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-17 14:03:23 +01:00
Krzysztof Chruscinski 336c1ad7d2 drivers: tiemr: nrf_rtc_timer: Add test function for shifting time
RTC is 24 bit width and k_timer is 64 bit. It is hard to test corner
cases but RTC hardware feature can help here. There is a task which
moves counter to 0xfffff0 which is close to overflow. However, there
is an internal driver state that also needs to be aligned to shift
the time properly. Adding optional function which triggers overflow
and updates internal state. This can be used for testing corner cases.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-11-17 11:24:23 +01:00
Flavio Ceolin e3aac24821 xtensa: linker: Use zephyr's convention for rodata
Zephyr maps start/end of rodata section with variables
using __rodata_region namespace. The exception was Xtensa.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-11-17 15:44:48 +09:00
Nikolay Agishev 6e215ce6af boards: nsim_hs: Add separate config for XIP memory organization
Add XIP support with MWDT toolchain. To have it proper tested
add separate nsim platforms for XIP (flash + sram) and
non-XIP (sram) memory organization in addition to existing
nsim_hs platfor with CCMs (ICCM + DCCM) memory organization.

This PR also enables MPU for all nsim hs3x based platforms
(like we previously enabled it for qemu_arc_hs) to have proper
memory regions permissions.

Signed-off-by: Nikolay Agishev <agishev@synopsys.com>
2022-11-16 11:18:51 +01:00
Johan Hedberg 0eed096f99 pcie: Add support for centralized lookup of BDF values
The BDF values can differ on the same platform, based on e.g. BIOS
configuration, and in the case of qemu the command line parameters. It's
therefore more reliable to always look up the BDF value based on the
known Vendor and Device IDs.

This patch introduces such a framework, and allows the incremental
update of PCIe drivers to start taking advantage of it.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2022-11-16 11:18:43 +01:00
Emil Gydesen ecb7591d6b Bluetooth: Audio: Rename BASS and BASS client
Rename BASS to BAP Scan Delegator and BASS Client
to BAP Broadcast Assistant. This is the first step towards
integrating the BASS with the rest of BAP.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-16 11:17:52 +01:00
Henrik Brix Andersen 1885bee7c3 drivers: eeprom: add fake EEPROM driver
Add a FFF-based fake EEPROM driver which can be used either as a stub or a
mock for testing.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-11-15 09:43:42 -06:00
Jamie McCrae b7cc0cd056 mgmt: mcumgr: Fix smp_transport_clear_check_fn typo
Fixes a typo that should be smp_transport_query_valid_check_fn

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-15 16:00:42 +01:00
Henri Xavier 0f2d763099 pcie: Write MSI-X vectors using sys_write32
It was previously written as regular members of a struct, which
allows the C compiler to do things the way it wants. On ARM64, gcc
would typically write field by pairs (`STP`), which
would generate aborts.

By using `sys_write32`, we force it the right way.

Signed-off-by: Henri Xavier <datacomos@huawei.com>
2022-11-15 12:20:21 +00:00
Emil Gydesen 1d83e561e6 Bluetooth: Audio: Refactor use of cur_mcs_inst
Removes the global cur_mcs_inst and replace it
with lookup functionality.

This fixes an issue with bt_mcc_discover_mcs not being able
to be called more than once, as well
as streamline the implementation significantly.

This is also the first step towards not only supporting
multipe MCS instances for a single device, but also a
step towards handling multiple devices.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-15 12:18:50 +00:00
Ryan Erickson e01f977da1 modem: hl7800: Fix +CCID response to handle EID
For SIM cards that support eSIM, the +CCID response
will contain the ICCID and the EID.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2022-11-15 12:17:20 +00:00
Dominik Ermel 220c08967c mgmt/mcumgr: Correct serial frame size
Zephyr has been using 128 byte frame size instead of 127.
This change only affects buffer size as Base64 encodig,
together with preamble and terminating new line character,
has been only able to use 127 bytes of frame anyway,

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-11-15 13:06:02 +01:00
Rodrigo Peixoto b8ecbfaa57 zbus: Add message bus subsystem to Zephyr
Add zbus message bus as a Zephyr subsystem. No message bus
or communication abstraction other than the usual (message queues,
mailboxes, etc.) enabled developers to implement event-driven systems in
Zephyr quickly. Zbus would fill that gap by providing the community with
a lightweight and flexible message bus. The implementation tries to be
closest as possible to the existing ones. We use the claim/finish
approach, and the API for publishing and reading channels are similar
in message queues. Zbus is about channels, messages, and observers.

Signed-off-by: Rodrigo Peixoto <rodrigopex@gmail.com>
2022-11-14 17:25:29 -05:00
Chris Friedt b0b4c9c3f1 posix: mutex: abstract pthread_mutex_t as uint32_t
Consistent with the change of `pthread_t` from
`struct posix_thread` to `uint32_t`, we can now also abstract
`pthread_mutex_t` as `uint32_t` and separate `struct posix_mutex`
as an implementation detail, hidden from POSIX API consumers.

This change deprecates `PTHREAD_MUTEX_DEFINE()` in favour of the
(standardized) `PTHREAD_MUTEX_INITIALIZER`.

This change introduces `CONFIG_MAX_PTHREAD_MUTEX_COUNT`.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2022-11-15 05:56:31 +09:00
Gerard Marull-Paretas f7cb0933fc drivers: regulator: s/uV/uv and s/uA/ua
Zephyr coding style uses all-lowercase.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-14 16:59:05 +01:00
Gerard Marull-Paretas 6d744d3dd2 drivers: regulator: use int32_t for voltages/currents
Right now we had a mix of int (signed) and uint32_t (fixed-width
unsigned integer). Use int32_t for all cases, both values may be either
positive/negative, and we have a defined range when using fixed-width
integers.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-14 16:59:05 +01:00
Gerard Marull-Paretas 0a390b3ed6 drivers: regulator: improve Doxygen
The recently moved "consumer" API had multiple Doxygen issues. This
patch improves the Doxygen docs, e.g. use `@retval`, remove redundant
docs, improve parameter docs, etc.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-14 16:59:05 +01:00
Gerard Marull-Paretas ec3c566f8c drivers: regulator: convert all API calls to use ops
The previous "consumer" API was designed without API ops, meaning only a
single implementation (singleton) was possible. This was inconsistent
with all other APIs, and, a problem in systems where more than a single
PMIC IC is present.

Note that all "consumer" ops are optional, so this won't break any
existing drivers.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-14 16:59:05 +01:00
Gerard Marull-Paretas 74e40f88ae drivers: regulator: move consumer.h to regulator.h
In Zephyr all regulator APIs are consumer APIs. There's no point in
adding a separate header file. Our current implementation is also
inconsistent with Linux, where enable/disable are also part of the
consumer.h API.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-14 16:59:05 +01:00
Benjamin Lindqvist 85c6de4335 lorawan: enable run-time config of region/freq
This commit adds support for compiling in support for several different
regions/frequencies and dynamically choosing which to use in run-time.
This commit introduces no API breakages - if a prj.conf contains only a
single region Kconfig, the new function lorawan_set_region() does not
need to be called.

Signed-off-by: Benjamin Lindqvist <benjamin@eub.se>
2022-11-14 11:16:16 +00:00
Gerard Marull-Paretas 8d0eb6ce10 devicetree: remove deprecated DT_CHOSEN_*_LABEL macros
DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL and
DT_CHOSEN_ZEPHYR_ENTROPY_LABEL were deprecated a couple of releases ago,
so it is time to remove them. Note that the zephyr/devicetree/zephyr.h
is also removed, since both macros were its last content.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-11 11:00:26 +01:00
Gerard Marull-Paretas f7d24f78a2 fs: nvs: remove deprecated nvs_init
nvs_init was changed in favor of nvs_mount a couple of releases ago. It
is now time to remove it.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-11 11:00:26 +01:00
Gerard Marull-Paretas 8e04922f35 drivers: pwm: remove deprecated functions
Improved PWM API has shipped on the last 2 Zephyr releases (3.1, 3.2),
so it is time to remove deprecated functions.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-11 11:00:26 +01:00
Gerard Marull-Paretas 7dc047406c include: util_macro: remove deprecated UTIL_LISTIFY
Macro was deprecated 2 releases ago, it is now time to remove it.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-11 11:00:26 +01:00
Gerard Marull-Paretas b0dc5eee36 drivers: gpio: remove deprecated drive strength/voltage/debounce flags
Such generic flags were replaced for vendor-specific flags. Zephyr
releases 3.1 and 3.2 have shipped with the flags deprecated, it is now
time to remove them.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-11 11:00:26 +01:00
Gerard Marull-Paretas b1552001bf drivers: gpio: npcx: fix usage of deprecated voltage macros
The NPCX driver did use deprecated voltage macros. Define vendor
specific flags instead.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-11 11:00:26 +01:00
Gerard Marull-Paretas 4f4ca3905d linker: devicetree_regions: add missing includes
The devicetree_regions.h did not include any header, however, it uses
multiple APIs: DT, utils and toolchain macros.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-11 11:00:26 +01:00
Gerard Marull-Paretas 8aa0baed3d pm: policy: add missing include
zephyr/pm/policy.h is using ARG_UNUSED without including
zephyr/toolchain.h.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-11 11:00:26 +01:00
Gerard Marull-Paretas 21c4bbe385 driver: watchdog: multiple doxygen improvements
- Fix incorrect struct fields documentation (`@param` can't be used)
- Removed redundant `@file` entry, public APIs may be split into
  multiple headers.
- Grouped and anchored options and flags, so they can be referenced.
- Guarded some internal fields with INTERNAL_HIDDEN.
- Exposed conditional struct fields, using __DOXYGEN__.
- Use `@see` in cases where used was instructed to look at other
  function calls.
- Added `errno` `@retval` to all functions. In case of external
  watchdogs, communication errors may be propagated.
- Other minor/typo fixes

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-10 22:41:43 -05:00
Daniel Leung bbb2f8277a uart: ns16550: move command macro to public header
This moves the CMD_SET_DLF command macro to public header
so application can use it without weird include path to
include the "private" header file under drivers/serial.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-11-10 22:40:21 -05:00
Gerard Marull-Paretas 33e583b643 drivers: regulator: s/reg/dev
Use "dev" for device instance variable for consistency with other driver
classes.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-10 17:58:48 +01:00
Gerard Marull-Paretas e68ba0fd5b drivers: regulator: fix includes
File was including zephyr/types.h and zephyr/drivers/gpio.h for nothing,
and missed zephyr/device.h

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-10 17:58:48 +01:00
Gerard Marull-Paretas ee90deeafd drivers: regulator: improve Doxygen documentation
- Remove redundant `@file`
- Hide driver-specific code using `INTERNAL_HIDDEN`.
- Use standard `@funcprops`
- Use `@retval` for return codes, and clarify them as well. Added -errno
  case, since external regulators may propagate e.g. bus errors.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-10 17:58:48 +01:00
Jamie McCrae c2b872b901 mgmt: mcumgr: os_mgmt: Switch to new event callback system
Switches to the new event callback system for the os_mgmt
functionality and removes the old code.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-10 12:34:39 +01:00
Jamie McCrae 986ea39512 mgmt: mcumgr: img_mgmt: Switch to new event callback system
Switches to the new event callback system for the img_mgmt
functionality and removes the old code.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-10 12:34:39 +01:00
Jamie McCrae 4e8fde15a3 mgmt: mcumgr: fs_mgmt: Switch to new event callback system
Switches to the new event callback system for the fs_mgmt
functionality and removes the old code.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-10 12:34:39 +01:00
Jamie McCrae 6f75c99b8b mgmt: mcumgr: Rework event callback system
Reworks the event callback system to use a linked list to allow for
chained handlers and support passing a status back to the handler to
indicate if the request should be rejected or allowed. This also
removes the old base callback functionality.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-10 12:34:39 +01:00
Guillaume Gautier 00504fd585 include: zephyr: dt-bindings: clock: Add RTC clk src defines for STM32
For all STM32 series, add some defines to select the RTC clock source.
This change is necessary to be able to select the RTC clock source in
dts instead of Kconfig

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2022-11-10 11:27:49 +00:00
Guillaume Gautier a407c4e04e include: zephyr: drivers: clock_control: Add stm32 lse bypass
Add a define to get the value of the LSE bypass property from dts

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2022-11-10 11:27:49 +00:00
Jamie McCrae 2aca1242f7 mgmt: mcumgr: Fix Bluetooth transport issues
This fixes issues with the Bluetooth SMP transport whereby deadlocks
could arise from connection references being held in long-lasting
mcumgr command processing functions.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-10 11:08:52 +01:00
Emil Gydesen 79ca8f7f43 Bluetooth: Host: Add missing assigned numbers
Add missing assigned EIR/AD numbers.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-09 10:45:52 +01:00
René Beckmann 26758117d6 net: mqtt-sn: Add MQTT-SN library
This commit adds an implementation of MQTT-SN v1.2.
The specification is available on oasis-open.org:
https://www.oasis-open.org/committees/download.php/66091/MQTT-SN_spec_v1.2.pdf

The following things are missing in this implementation:
- Pre-defined topic IDs
- QoS -1 - it's most useful with predefined topics
- Gateway discovery using ADVERTISE, SEARCHGW and GWINFO messages.
- Setting the will topic and message after the initial connect
- Forwarder Encapsulation

Signed-off-by: René Beckmann <rene.beckmann@grandcentrix.net>
2022-11-09 10:43:00 +01:00
Hubert Miś 6f450fdf18 ipc: separate icmsg core from ipc_service backend
icmsg library was implemented as a ipc_service backend. It is a simple
library with minimal feature set. To preserve its simplicity while
adding more features it is useful to introduce separated ipc_service
backends with added features. To reuse most of the icmsg code for the
simplest backend and other including more features, the core of icmsg
is separated from the simplest ipc_service to an icmsg module which
can be used by multiple backends.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2022-11-09 10:41:43 +01:00
Seppo Takalo 83d79b5996 net: lwm2m: We should not use read callbacks to generate new data
When read callbacks are used, it bypasses LwM2M engine data
handling and therefore LwM2M observation cannot work properly.

Read callbacks should be used only on special cases.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2022-11-09 09:16:22 +00:00
Christoph Schnetzler c364721796 net: sockets: Prevent compiler error if warnings being treated as errors
If gcc compiler option -Werror is used the warning,

declared inside parameter list will not be visible outside of this
definition or declaration [-Werror]

is treated as error, for

sockets_internal.h:18:28: ‘struct net_context’
sockets_internal.h:19:32: ‘struct zsock_pollfd’
fdtable.h:108:17: ‘struct k_mutex’

Signed-off-by: Christoph Schnetzler <christoph.schnetzler@husqvarnagroup.com>
2022-11-09 09:15:32 +00:00
Sam Hurst df4c31ba98 usb-c: Correct the PDO enum type name
Table 6-7, in the USB PD3.1 spec, is labeled Power Data Object.
The enum that represents the table 6-7 values should be
labeled similarly.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2022-11-08 10:46:40 +01:00
Lingao Meng 93709a7359 Bluetooth: Mesh: Add specific number of keys & groups
Since Mesh Spec and Mesh model sayes, some model no need
groups and no need keys, such as Config Server, but the
current implementation, all model use same configuration,
which cause some ram ext comsume.

So that, change to specific way, but will consume more footprint size.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-11-08 10:45:15 +01:00
Tom Burdick e3d877f811 rtio: Userspace support
Add support for userspace with RTIO by making rtio and rtio_iodev
k_objects. As well as adding three syscalls for copying in submissions,
copying out completions, and starting tasks with submit.

For the small devices Zephyr typically runs on one of the most important
attributes tends to be low memory usage. To maintain the low footprint of
RTIO and its current executor implementations the rings are not shared with
userspace. Sharing the rings it turns out would require copying submissions
before working with them to avoid TOCTOU issues.

The API could still support shared rings in the future so that a
kernel thread could directly poll, copy, verify, and start the submitted
work. This would require a third executor implementation that maintains its
own copy of submissions similiar to how io_uring in Linux works.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-11-08 10:44:03 +01:00
Jose Alberto Meza b479c66e62 include: drivers: peci: Add missing subsystem macro
Add subsystem macro for peci driver API.

Signed-off-by: Jose Alberto Meza <jose.a.meza.arellano@intel.com>
2022-11-08 09:42:27 +00:00
Chris Friedt 4bae4f426f include: posix: move pthread impl detail to posix_internal.h
The `struct pthread` and `enum pthread_state` are actually
implementation details specific to Zephyr.

Let's limit the scope where that level of detail is visible.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2022-11-07 09:09:11 -05:00
Marc Herbert 44d9f2ce5c toolchain: more detailed #error messages on endianness mismatch
Recent commit ae123c9bd1 ("toolchain: Ensure that Kconfig endianness
matches the compiler's") added an endianness check which immediately
revealed a problem when compiling with -DSPARSE=y

Finding which values were wrong was a typical pre-processor
nightmare. Avoid this nightmare to anyone in a similar situation again
by adding more tests and #error messages.

- Before:
```
west build  -p -b intel_adsp_cavs25 samples/hello_world/ -- -DSPARSE=y

zephyr/toolchain.h: error: "Endiannes mismatch"
```

- Now:
```
zephyr/toolchain.h: error: "Kconfig/toolchain endianness mismatch:"
zephyr/toolchain.h: error: "CONFIG_LITTLE_ENDIAN but __ORDER_BIG_ENDIAN__"
```

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2022-11-07 09:49:11 +01:00
Jamie McCrae b6cd83bf7a net: ipv4: Add fragmented packet support
Adds support for incoming and outgoing IPv4 fragmented packet support,
allowing a single packet that is too large to be sent to be split up
and sent successfully.

Signed-off-by: Jamie McCrae <spam@helper3000.net>
2022-11-05 19:58:26 +01:00
Dat Nguyen Duy 607358b084 drivers: interrupt_controller: initial support for NXP S32Z27 EIRQ
Add initial support for the NXP S32Z27 SIUL2 External
Interrupt Controller. Each SIUL2 node has a child node
will act as an interrupt-controller that processes external
interrupt signals.

This driver is required to manage GPIO interrupts.

Signed-off-by: Dat Nguyen Duy <dat.nguyenduy@nxp.com>
2022-11-04 17:44:08 -04:00
Tom Burdick dbc366918d tests: Enable qemu_xtensa logging tests
Enables logging testing for qemu_xtensa along with the fixes needed to
correctly run the tests.

Several tests in log_api rely on being able to calculate the size of
the message in the mpsc_pbuf to know when an overflow occurs. The
size being calculated assumed a ROUND_UP size alignment to sizeof(long
long). On xtensa this is actually 16 bytes as defined by
CBPRINTF_PACKAGE_ALIGNMENT.

Changes the size calculation for SIMPLE_MSG_LEN to account for this.

The second issue was a misaligned package that would cause reading
from the incorrect memory when going to format the package with cbpprintf.

Fixes the padding used to align the package in cbprintf.h and adds a build
assert ensuring correct alignment when building against xtensa in both
cbprintf.h and log_msg.h.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-11-04 11:02:27 -04:00
Emil Obalski 2e9992f3c8 doc: Add IPC service documentation
Adding IPC service documentation for ICMSg backend.

Signed-off-by: Emil Obalski <Emil.Obalski@nordicsemi.no>
2022-11-04 11:51:54 +01:00
Evgeniy Paltsev 785f95a626 ARC: mwdt: add __fallthrough attribute support
As we set the minimal required version of ARC MWDT to 2022.06
we can add __fallthrough attribute

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2022-11-04 08:58:42 +00:00
Evgeniy Paltsev 82b14692ed ARC: mwdt: mark _Generic and __auto_type types supported
As we set the minimal required version of ARC MWDT to 2022.06
we can mark _Generic and __auto_type types supported

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2022-11-04 08:58:42 +00:00
Mariusz Skamra 3fa456905d Bluetooth: audio: Factor out bt_audio_iso pool
This adds common bt_audio_iso pool that will be used across all the
roles/profiles. The pool range is dependent on the CONFIG_BT_ISO_MAX_CHAN
which is the maximum number of ISO connections the host can maintain.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-11-04 08:55:12 +00:00
Kumar Gala 6bdd91e9b1 soc: Add ability for SOC to specify runtime CPU detection
Add Kconfig SOC_HAS_RUNTIME_NUM_CPUS symbol that an SoC can
set to specify that it supports determining the number of CPUs
at runtime.

On xtensa add support for SOC_HAS_RUNTIME_NUM_CPUS and expose
soc_num_cpus that the SoC code should set early in boot as the
means to expose the number of cpus.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-11-03 16:43:53 -04:00
Henri Xavier 55df3852bf arm64: Add comment that arch_curr_cpu and get_cpu must be synced
The is code duplication as one is in C, and the other is an assembly
macro. As there is no easy way to find out about this duplication,
adding a comment seems the best way to go.

Signed-off-by: Henri Xavier <datacomos@huawei.com>
2022-11-02 16:08:00 -05:00
Henrik Brix Andersen f30a5969d0 drivers: can: make the fake CAN driver generally available
Make the fake CAN controller driver available for use in tests outside of
the CAN shell test.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-11-02 08:19:33 -07:00
Evgeniy Paltsev 3d24a07c6b ARC: disallow build for secure configuration with firq
Such configuration isn't supported by HW.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2022-11-02 15:42:00 +09:00
Chris Friedt ce054404a2 posix: use uint32_t instead of void* for pthread_t
Several other widely-used pthread implementations
abstract `pthread_t` as `uint32_t`. The benefit
there is that we avoid passing around a pointer to
an internal structure (implementation detail).

Additionally, this removes the alias from `k_tid_t`
to `pthread_t` inside of `struct pthread_mutex`.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2022-11-02 15:39:44 +09:00
Henrik Brix Andersen 3c99a1e015 drivers: pcie: reintroduce support for I/O BARs
Reintroduce support for accessing I/O BARs which was removed in
43d84147d9.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2022-11-01 15:22:31 -04:00
Erdem Efe 0e05686d52 sensor: freefall added to lis2dw12 sensor driver.
lis2dw12 supports freefall detection and set related parameters

Signed-off-by: Erdem Efe <erdemefe1@gmail.com>
2022-11-01 08:25:24 -05:00
Sam Hurst 2d449b82a2 usb-c: Add missing errno.h include
Add missing errno.h include to usbc_tcpc.h which is
needed for the return of -ENOSYS.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2022-11-01 08:55:43 +00:00
Kumar Gala 4f458ba8de kernel: Convert away from CONFIG_MP_NUM_CPUS
Move runtime code to use arch_num_cpus() instead of CONFIG_MP_NUM_CPUS
and use CONFIG_MP_MAX_NUM_CPUS for ifdef and BUILD_ASSERT macros.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-31 17:09:14 +01:00
Chris Friedt bea16cae3a posix: correct struct label for pthread_attr_t
Normally, for typedef'ed structures, the struct label should not
end in `_t`.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2022-10-31 16:59:16 +01:00
Evgeniy Paltsev ead4d2bc02 ARC: cbprintf: enforce proper alignment
ARC ABI requires stack to be 32 / 64 bit aligned for 32bit and
64 bit architecture variant.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2022-10-31 11:22:12 +01:00
Maureen Helm eee3d8f566 drivers: sensor: Add sensor info iterable section
Adds an iterable section in ROM to hold constant information, such as
vendor and model name, for all enabled sensor driver instances. This
will be used by the future sensor subsystem to enumerate all available
sensors in the system.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2022-10-31 11:21:37 +01:00
Keith Packard cb5c440525 picolibc: Fix a couple of printfcb wrapper macros
Picolibc aliases the printfcb functions directly to printf
equivalents. There were a couple of these macros that were broken.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-10-31 17:17:42 +09:00
Jay Vasanth d0fe965b9f drivers: espi_saf: Add Microchip MEC172x eSPI SAF version 2 driver
Microchip MEC172x has a modified eSPI SAF hardware implementation.
Hardware changes include multiple clock dividers for each SPI
flash device and data transfer using QMSPI local DMA.
espi reset interrupt is made a higer priority in MEC172x devicetree
because espi reset event resets all espi hardware and we don't
to want to service any other espi interrupt blocks when espi reset
occurs.

Signed-off-by: Jay Vasanth <jay.vasanth@microchip.com>
2022-10-28 14:29:46 -05:00
Carles Cufi 8e4d499fa0 treewide: Use CONFIG_*_ENDIAN instead of __BYTE_ORDER__
In order to avoid using multiple sources of truth for the platfom's
endianness, convert the in-tree code to use the (BIG|LITTLE)_ENDIAN
Kconfig variables exclusively, instead of the compiler's
__BYTE_ORDER__.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-10-28 19:23:46 +09:00
Carles Cufi ae123c9bd1 toolchain: Ensure that Kconfig endianness matches the compiler's
In preparation for using CONFIG_(BIG|LITTLE)_ENDIAN exclusively for
endianness-based conditional compilation in the tree, ensure that the
Kconfig CONFIG_(BIG|LITTLE)_ENDIAN options match the compiler's
__BYTE_ORDER__ macro.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-10-28 19:23:46 +09:00
Balaji Kulkarni 7f1a5cce12 drivers: gpio: expose gpio_utils.h to external GPIO drivers
Expose "gpio_utils.h" header for external GPIO drivers.

Fixes #48609.

Signed-off-by: Balaji Kulkarni <balaji.kulkarni92@gmail.com>
2022-10-27 15:38:51 +02:00
Christoph Schnetzler a75f3e7871 net: if: fix type qualifiers ignored on function return type
if compiler option -Wextra and -Werror is enabled the compilation
fails due to ignored-qualifiers warning.

The 'const' qualifier on return type has no effect.

Signed-off-by: Christoph Schnetzler <christoph.schnetzler@husqvarnagroup.com>
2022-10-27 15:37:32 +02:00
Maureen Helm a9b223b26b drivers: sensor: Refactor drivers to use SENSOR_DEVICE_DT_INST_DEFINE
Refactors all sensor drivers to use SENSOR_DEVICE_DT_INST_DEFINE, which
is a sensor-specific variant of DEVICE_DT_INST_DEFINE that provides a
common place to instantiate additional data structures for the future
sensor subsystem and/or sensor driver stats.

This approach was inspired by I2C_DEVICE_DT_INST_DEFINE to streamline
adding I2C stats support across all I2C drivers.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2022-10-27 09:27:14 +00:00
Veijo Pesonen 59f53acd37 include: lwm2m: Brings API doc into line with the v1.1 spec
Section numbers do not match between v1.0 and v.1.1 so refer only to
those by their names which stay the same.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-10-27 11:05:05 +02:00
Rob Barnes 0b2b221b36 toolchain: Check if __STDC_VERSION__ is defined
Check if __STDC_VERSION__ is defined before referencing it. This will
prevent a compilation failure when __STDC_VERSION__ is not defined for
any reason.

Signed-off-by: Rob Barnes <robbarnes@google.com>
2022-10-27 11:03:49 +02:00
Dominik Ermel 12b1528df9 mgmt/mcumgr: Remove mgmt/mcumgr/buf.h
SMP buffer allocation functions have been moved to smp/smp.h,
and buf.h has been removed.
Definitions of cbor_nb_reader and cbor_nb_writer have also been moved.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-10-26 12:42:40 +02:00
Dominik Ermel 6fdf95fbce mgmt/mcumgr: Move and internalize cbor_nb_*_init functions
The commit moves functions used for initialization of CBOR encoding
and decoding to the only unit that is supposed to use them.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-10-26 12:42:40 +02:00
Florian Grandel 80e9f5f0a0 net: l2: ieee802154: doc: fix net mgmt doc group name
The API documentation currently lists two entries with the same name
"IEEE 802.15.4 Library". This change fixes this by separating the
network library from its net management library.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-10-26 12:01:00 +02:00
Mariusz Skamra 2627063ab2 Bluetooth: audio: pacs: Replace capabilities API with pacs
This changes the API to use proper naming convention, as the code has
been moved out of capabilities.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-26 08:49:00 +02:00
Henrik Brix Andersen f8a88cdb27 drivers: can: use flags fields for can_frame and can_filter structs
The can_frame and can_filter structs support a number of different flags
(standard/extended CAN ID type, Remote Transmission Request, CAN-FD format,
Bit Rate Switch, ...). Each of these flags is represented as a discrete bit
in the given structure.

This design pattern requires every user of these structs to initialize all
of these flags to either 0 or 1, which does not scale well for future flag
additions.

Some of these flags have associated enumerations to be used for assignment,
some do not. CAN drivers and protocols tend to rely on the logical value of
the flag instead of using the enumeration, leading to a very fragile
API. The enumerations are used inconsistently between the can_frame and
can_filter structures, which further complicates the API.

Instead, convert these flags to bitfields with separate flag definitions
for the can_frame and can_filter structures. This API allows for future
extensions without having to revisit existing users of the two
structures. Furthermore, this allows driver to easily check for unsupported
flags in the respective API calls.

As this change leads to the "id_mask" field of the can_filter to be the
only mask present in that structure, rename it to "mask" for simplicity.

Fixes: #50776

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-10-25 16:32:10 +02:00
Henrik Brix Andersen a9c7c58345 canbus: isotp: avoid reusing CAN controller driver API definitions
Avoid reusing the CAN_EXTENDED_IDENTIFIER and CAN_STANDARD_IDENTIFIER
definitions from the CAN controller driver API for ISO-TP structure members
as this is a fragile design.

The ISO-TP layer must be responsible for its own definitions where
needed. Replace the "id_type" ISO-TP struct member with a well-known
abbreviated "ide" bit (Identifier Extension Bit) struct member.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-10-25 16:32:10 +02:00
Kumar Gala a12b7734de interrupt_controller: gic: Rework usage of CONFIG_MP_NUM_CPUS
Replace usage of CONFIG_MP_NUM_CPUS with CONFIG_MP_MAX_NUM_CPUS for
init and declaration as we phase out CONFIG_MP_NUM_CPUS usage.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-25 10:52:17 +02:00
Emil Gydesen d5499e6b87 Bluetooth: Audio: Add CAP stream
Add a new stream object, bt_cap_stream, which is an extension
of the BAP bt_audio_stream. The purpose of this stream
is that we can extend the data stored in the BAP stream for
CAP usage, as well as making it more explicit what type
of stream should be used for CAP.

The callbacks will be extended for CAP in specific use cases,
e.g. when starting one or more unicast audio streams.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-24 10:39:11 +02:00
Emil Gydesen ce05cb5c2c Bluetooth: Audio: CAP initiator discover CSIS
The CAP initiator will now discover, or return a
known, CSIS instance included by CAS (if any).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-24 10:39:11 +02:00
Emil Gydesen ed11295cf6 Bluetooth: Audio: CSIS client register multiple callbacks
Change the CSIS client callback to a slist so that
multiple applications can register it. An example of
such a case is that both the application and CAP initiator
want to get the callbacks.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-24 10:39:11 +02:00
Emil Gydesen 2e42105df0 Bluetooth: Audio: CSIS: Refactor CSIS client discover API
The API will now take a simple bt_conn instead of a
set member struct. This is due to the set member struct
being moved to the stack. The reasoning for this is that
having the struct in the stack, rather than in the
application, the stack itself can initiate the CSIS
discovery which is useful if the remote device
has a service that includes a CSIS.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-24 10:39:11 +02:00
Emil Gydesen 7a49de12af Bluetooth: Audio: Implement CAP initiator discover
This is the primary discovery of the CAS on the remote device,
but does not include discovering the (optional) CSIS.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-24 10:39:11 +02:00
Emil Gydesen 760177b1be Bluetooth: Audio: Add CAP initiator skeleton
Add skeleton for the expected APIs and
implementation. May be subject to change as
implementation progresses.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-24 10:39:11 +02:00
Juha Heiskanen 4bcc880670 net: lwm2m: LwM2M engine time API update
Updated lwm2m_enigen_set/get_time API for support time_t.

Updated LwM2M engine set/get resource time to time resource support
time_t and uint32_t input.

LwM2M engine put and get time API update to use time_t.

Time series data cache entry have own type for time resource.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-10-24 10:39:03 +02:00
Emil Gydesen 31bf99cbd2 Bluetooth: ISO: Change ISO seq_num to 16-bit
The sequence number is by the core spec defined as 16-bit.
We had implemented a workaround for the wrapping of the
sequence number, which required the type to be larger
than 16-bit (32-bit).

However, since the definition of the sequence number,
and the use of, is poorly defined by the core spec, we
are reverting this workaround and reducing the sequence
number to 16-bit again. This way it is more in line
with the core spec, as well as more intuitive given the
other uses for the sequence number.

This change moves the responsibility of using the
right value to the upper layers, as the stack can
and will no longer provide any guarantees.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-24 10:38:49 +02:00
Sam Hurst e90f1b66d8 usb-c: Add USB-C Subsystem with Sink PD Support
This USB-C Subsystem enables an application to include
USB-C Power Delivery Sink functionality.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2022-10-22 18:38:35 -04:00
Sam Hurst a1e6e9dfbe dts: usb-c: Introduce usb-c-connector
A USB TypeC connector has many peripherals associated with
it and the DTS binding in this commit provides a way to group
peripherals and properties in a device tree.
This binding is used with the USB-C Subsytem.

This is based on Linux, documentation:
https://www.kernel.org/doc/Documentation/devicetree/bindings/connector/usb-connector.yaml

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2022-10-22 18:38:35 -04:00
Sam Hurst d9a200b6de usb-c: Add Type-C / Power Delivery macros
These macros are needed to implement a USB-C Sink device

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2022-10-22 18:38:35 -04:00
Sam Hurst 1a5e2c9c13 usb-c: Remove VBUS measurement and control
A USB-C VBUS driver will be used to measure VBUS
instead of accessing the measurement hardware
directly.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2022-10-22 18:38:35 -04:00
Sam Hurst 36c8e09095 usb-c: Add USB-C VBUS driver
USB-C VBUS can be measured and controlled by different devices.
For example, a TypeC Port Controller (TCPC) or an ADC and GPIO
can be used. This driver is used to abstracts the underlying
hardware used for USB VBUS measurement and control.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2022-10-22 18:38:35 -04:00
Sam Hurst 9659819365 usb-c: tcpc: Changes the @return tag to @retval
The "@return" command should be used for the arbitrary return
description, and "@retval <return value>" for the description
of named return value

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2022-10-22 18:38:35 -04:00
Sam Hurst 3dd07aebdd usb-c: Change dir name from usbc to usb_c
For improved readability, change dir name from
usbc to usb_c

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2022-10-22 18:38:35 -04:00
Peter Marheine d4549ed808 it8xxx2: generalize ILM support
Executing code out of RAM on IT8xxx2 requires that the relevant
addresses be mapped onto the CPU's instruction memory bus, referred to
by ITE documentation as Instruction Local Memory (ILM). ILM mappings
configure blocks of RAM to be used for accesses to chosen addresses when
performing instruction fetch, instead of the memory that would normally
be accessed at that address.

ILM must be used for some chip features (particularly Flash
self-programming, to execute from RAM while writing to Flash), and has
historically been configured in the Flash driver. The RAM for that was
hard-coded as a single 4k block in the linker script.  Configuring ILM
in the flash driver is confusing because it is used by other SoC code as
well, currently in code that cannot depend on the Flash being functional
or in hand-selected functions that seem performance-critical.

This change moves ILM configuration to a new driver and dynamically
allocates RAM to ILM in the linker script, allowing software use of the
entire 64k RAM depending on configuration.  This makes ILM configuration
more discoverable and makes it much easier to correctly support the
CODE_DATA_RELOCATION feature on this SoC.

Signed-off-by: Peter Marheine <pmarheine@chromium.org>
2022-10-21 20:31:47 +02:00
Nikolay Agishev 0422a04bfe boards: qemu_arc: fix of MPU regions setup for !XIP config
Add some changes to ARC linker script. They make correct alignment
for ROMable region. Now regions borders are aligned with respect
to MPU settings.

Signed-off-by: Nikolay Agishev <agishev@synopsys.com>
2022-10-21 20:31:31 +02:00
Kumar Gala 77dcf91f50 smp: define arch_num_cpus always
Move arch_num_cpus outside of CONFIG_SMP in sys/arch_interface.h and
add define arch_num_cpus on all platforms (added arch_inlines.h on
those platforms that didn't have it before).

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-21 13:14:58 +02:00
Robert Lubos 0ac6fe913e net: virtual: Align virtual L2 with iface status upgrade
Align virtual L2 with interface state handling update. Introduce
net_virtual_enable() function, which gets called whenever a network
interface is brought up (operational). This, combined with already
existing net_virtual_disable() function, can be used to update the
carrier state on the virtual interface, based on the underlying
interface status.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-20 10:00:31 +02:00
Robert Lubos efd03a86d7 net: if: Introduce carrier and dormant management on a network iface
Introduce a new interface state management scheme, according to
RFC 2863. This includes the following changes:

* Introduce a new interface flag: NET_IF_LOWER_UP, along with
  corresponding helper functions. The flag should be set/cleared on an
  interface by a network driver/L2 to signalize physical readiness of an
  interface to transmit data (for example cable plugged in).

* Introduce a new interface flag: NET_IF_DORMANT, along with
  corresponding helper functions. The flag should be set on an
  iterface when the interface is not ready to transmit application data,
  for example still not joined a Wi-Fi network.

* Introduce a new interface flag: NET_IF_RUNNING, indicating that
  interface is ready to transmit application data.

* Update the meaning of the NET_IF_UP flag - it now singnalizes whether
  an interface has been brought up/down by the application (admin
  up/down).

* Introduce operational state of an interface, derived from above. It
  reflects the internal interface state.

The meaning of net_if_is_up() function and NET_EVENT_IF_UP/DOWN events
remains unchanged to retain backward compability - they reflect the
interface readiness to transmit application data.

To verify the administrative up/down state, a new function
net_if_is_admin_up() has been introduced, along with
NET_EVENT_IF_ADMIN_UP/DOWN events.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-20 10:00:31 +02:00
Keith Packard 385ddecc54 arch/x86/ia32: Include TLS GDT entry in count
When generating zephyr_pre1.elf, the number of GDT entries must be known so
that the memory layout of the executable is correct. This count didn't
include an entry for the thread local storage GDT entry when necessary,
making all addresses in _pre1 off by 8 bytes compared with the final elf
file.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-10-20 09:59:33 +02:00
Robert Lubos 618fa8d665 net: sockets: Add options to control DSCP/ECN value
Add new socket options IP_TOS and IPV6_TCLASS which allows to set
DSCP/ECN values on a socket for an outgoing packet IPv4/IPv6 headers.

The options are compatible with Linux behaviour, where both DSCP and ECN
are set with a single socket option.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-19 19:03:48 +02:00
Robert Lubos c868018c3c net: context: Add DSCP/ECN support
Add a new net_context option, which allows to set DSCP/ECN values on a
net context. Those values are then encoded into outgoing packet
IPv4/IPv6 header.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-19 19:03:48 +02:00
Robert Lubos c5096f4ca1 net: pkt: Add IP DSCP/ECN information to a packet structure
Add new fields to the net_pkt structure, representing IP-specific
Differentiated services code point (DSCP) and Explicit Congestion
Notification (ECN) values. Those values are encoded in legacy
Type of Service (IPv4) and Trafic Class (IPv6) header fields.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-19 19:03:48 +02:00
Gerard Marull-Paretas cad9a7eb5b Revert "device: restore init_res bit field"
This reverts commit c109491f1a.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-19 16:27:06 +02:00
Gerard Marull-Paretas 8f03cae8ba device: align device state
Device state (struct device_state) was not aligned, required since all
states are gathered together in the z_devstate section. This was causing
boot failures on certain platforms depending on the layout of the struct
device_state.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-19 16:27:06 +02:00
Pavel Vasilyev cf701acb94 Bluetooth: Mesh: Convert model_ackd_send and model_send to a common API
Convert model_ackd_send and model_send from health_cli.c to a common API
to get rid of code duplication in other client models that implement
synchronous messages' sending.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-10-19 16:05:16 +02:00
Ayan Kumar Halder 888bc68727 AArch32: Use inline assembly for accessing IO
The reasons for using inline assembly is as follows:-
1. Prevent the compiler from doing funny optimizations. For eg
generating four ldrb instructions to read a 32 bit word. This may cause
an abort on certain MMIO registers.
2. Prevent the compiler from generating post indexing instructions. These
instructions are not supported on hypervisor when used to access emulated
MMIO regions.

Thus, we have used inline assembly similar to aarch64.
Also, see the linux commit id '195bbcac2e5c12f7fb99cdcc492c3000c5537f4a'
for reference.

Signed-off-by: Ayan Kumar Halder <ayankuma@amd.com>
2022-10-19 16:00:49 +02:00
Aleksander Wasaznik 6b36149738 Bluetooth: Add bt_addr_le_eq
The use of this function is more readable than `bt_addr_cmp`.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-10-19 15:40:18 +03:00
Mariusz Skamra 9973d2f1f7 Bluetooth: audio: Factor out PACS related API to internal header
This moves the PACS API to internal header, as it duplicates the
bt_capabilities API.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-18 14:14:19 +02:00
Tom Burdick 872e3553f9 kernel: Option to assert on spin lock time
Spin locks held for any lengthy duration prevent interrupts and
in a real time system where interrupts drive tasks this can be
problematic. Add an option to assert if a spin lock is held for
a duration longer than the configurable number of microseconds.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-10-18 14:14:12 +02:00
Daniel DeGrasse f10ec43808 drivers: regulator: add mode specific configuration functions for PMIC
Add mode specific PMIC configuration functions, to allow consumers to
configure target voltages of each regulator mode. This will allow users
to enable or disable, as well as set target voltages for regulator modes
without actually entering that mode.

This feature can be useful for power managment applications where the
consumer may want to switch the regulator to low power mode at a later
time.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-10-18 14:12:52 +02:00
Daniel DeGrasse 92c40db91f drivers: regulator: remove mode awareness from PMIC
Remove mode awareness from PMIC voltage setting, current setting, and
enable/disable functions. Concepts such as regulator consumers do not
work well with multiple modes, so support for changing voltages or
disabling regulators in each mode has been removed.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-10-18 14:12:52 +02:00
Dominik Ermel 7089f94be9 mgmt/mcumgr: Deprecate zephyr_ prefixed API
The zephyr_ prefixed functions have been marked __deprecated.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-10-18 12:05:42 +02:00
Dominik Ermel 79f105d778 mgmt/mcumgr: Drop zst_ prefix from smp_transport members
With dropping the zephyr_ prefix, the member prefix zst_ makes
no sense.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-10-18 12:05:42 +02:00
Dominik Ermel 71e498dbd2 mgmt/mcumgr: Rename zst pointers to smp_transport to smpt
Cosmetic change: the zst was short for zephyr_smp_transport,
now it is just smp_transport so smpt makes more sense.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-10-18 12:05:42 +02:00
Dominik Ermel a7e40b35f0 mgmt/mcumgr: Drop zephyr_ prefix from functions
The MCUMgr library is now part of Zephyr, so there is no point
to prefix SMP functions with Zephyr.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-10-18 12:05:42 +02:00
Florian Grandel b674ed6b8b net: pkt: decouple from ieee802154 internals
This change implements part two of the program laid out in the TSCH RFC,
see #50336#issuecomment-1250250154 :

> Consolidate IEEE 802.15.4 options in net_pkt

This change improves decoupling of generic net core code from
IEEE 802.15.4 internals. It also simplifies IEEE 802.15.4
attribute cloning and thereby makes it easier to maintain and less
error prone (and probably even faster as individual bits are no longer
copied over separately).

This enables us to extend and design IEEE 802.15.4 L2 attributes inside
the package in isolation from the net core code which will no longer
have to be changed when introducing changes or additions to the flags.

This flexibility will be built upon in later change sets to model the
IEEE 802.15.4 attributes closer to the spec.

The solution is inspired by Linux's sk_buff->cb attribute which addresses
the same concern as the attribute introduced in this change set:
https://elixir.bootlin.com/linux/v6.0.1/source/include/linux/skbuff.h#L871

As the inline comment says: The cb attribute can be made a union or even a
uint8[something] in the future, if further L2s need a control block, too.
Right now such full indirection would make the code overly abstract, so
I chose to compromise with maintainability in mind.

Care has been taken to ensure that this changes does not introduce
additional padding into the net package. To maintain zero-padding, future
changes to the net packet struct will have to ensure that the
IEEE 802.15.4 struct is 4-byte aligned (iff the IEEE 802.15.4 struct
continues with max uint32_t scalar members) which is no deviation from
the previous implementation.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-10-17 16:54:37 +02:00
Florian Grandel 75b55e0bf4 net: pkt: optimize net_pkt packing
This change removes unnecessary padding from the net_pkt struct in
preparation for restructuring it in a later commit. Depending on the
number of activated Kconfig options, this saves between 4 and 8 bytes
per packet.

The change also removes anonymous unions inside of bitfields:
 * The assumption, that anonymous unions inside bitfields save space is
   wrong. They rather enforce an additional byte aligment boundary with
   padding before or after on most compilers (try -Wpadded to prove it).
   Removing the unions therefore counter-intuitively removes padding.
 * Some of the fields inside the union may actually not be orthogonal if
   several extensions are enabled at the same time. They may overwrite
   each other when activated at the same time.

The change therefore not only improves packing of net_pkt but also makes
net_pkt easier to understand and maintain by removing potentially
non-orthogonal uses of bits within bitfields.

The union of RX/TX-only attributes has been maintained, though, as it DOES
save space and is easy to maintain. Maintainability has further been
improved by introducing additional inline comments and anonymous structs
that make the orthogonality of RX- and TX-attributes even more obvious.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-10-17 16:54:37 +02:00
Florian Grandel 5bc6b157f1 net: fix minor typos
This change just fixes some insignificant typos.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-10-17 16:54:37 +02:00
Gerard Marull-Paretas c109491f1a device: restore init_res bit field
After b5f3cf8006 some platforms
(qemu_riscv32_xip) are not able to boot. Re-introduce the bit field for
init_res, using `unsigned int` (valids are signed/unsigned int, and
bool).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-17 15:12:16 +02:00
Francois Ramu f37ebf48ec include: add missing kernel.h for lorawan subsys
Header lora.h and lorawan.c files make use of types defined
in kernel.h without including it.
The types.h is no more relevant with inclusion of kernel.h
Explicitely including <stdint.h>, even if the kernel.h includes
the stdint.h, this is an implementation detail. "If Kernel
decides one day to drop usage of stdint.h (unlikely),
lora.h users be in trouble."

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2022-10-17 18:10:10 +09:00
Krzysztof Chruscinski 6c785b5677 logging: Add remote link and backend
Added implementation of link and backend that are intended to
complement each other. Both requires transport function hooks
to be provided.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-10-17 10:16:53 +02:00
Krzysztof Chruscinski e322447109 logging: Initial multidomain support
Adding multidomain support by introducing log_link module which
acts as a receiver of log messages created by another domain.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-10-17 10:16:53 +02:00
Andy Ross bd063d1a9e net/ethernet/bridge: Fix k_mutex initialization
The bridge subsystem was written with a ETH_BRIDGE_INITIALIZER that
assumed it could initialize a k_mutex with a zero-filled initializer.
That never worked.  Unlike semaphores, mutexes have always required a
runtime call to k_mutex_init().  What happened instead is that
k_mutex_un/lock() returned error codes, which were ignored by the code
here.  So no locking was happening.

This was discovered while migrating to zync, where an attempt to
unlock an unlocked mutex is a panic condition (and where zero-filled
initializers are legal, but represent an unfair semaphore and not a
mutex, so deadlock correctly).

Signed-off-by: Andy Ross <andyross@google.com>
2022-10-17 10:13:56 +02:00
Gerard Marull-Paretas b5f3cf8006 device: use uint8_t for init_res
Init result is stored as an 8-bit unsigned integer, so let's use
uint8_t. Docs have been clarified as well.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-17 10:13:37 +02:00
Gerard Marull-Paretas 05dc794445 device: format file
Formatting in the file was inconsistent, results obtained using
clang-format (80 cols), with some minor tweaks.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-17 10:13:37 +02:00
Gerard Marull-Paretas c83ba64a56 device: some Doxygen fixes/improvements
- Align to 80cols
- Fix some incorrect `@p` usages
- Use `@ref foo` to let Doxygen generate references to structs instead
  of using <tt>...</tt>
- Use `@ref struct.field` to reference struct fields
- Use Markdown notation for literals
- use func_name()/MACRO_NAME() to let Doxygen generate references
  automatically without `@ref`
- Fix some minor typos/formatting issues

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-17 10:13:37 +02:00
Gerard Marull-Paretas ddb02717a3 pm: device: expose struct pm_device
struct pm_device was incorrectly hidden from docs, as well as
pm_device_action_cb_t and pm_device_action_failed_cb_t.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-17 10:13:37 +02:00
Gerard Marull-Paretas fce90c0fb9 device: expose device.pm field in the documentation
struct device.pm was not exposed in the docs, make it visible to Doxygen
and document it is conditional to CONFIG_PM_DEVICE=y.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-17 10:13:37 +02:00
Gerard Marull-Paretas 6dccedb172 device: s/name/dev_id in DEVICE_*_GET/DEVICE_DECLARE
The input parameter is a device identifier, not a name. Some macros are
used for all type of devices, DT and non-DT, so adjusted documentation
to be more precise where appropriated.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-17 10:13:37 +02:00
Gerard Marull-Paretas d39e2946dd device: remove device_model_api group
The device model API can be part of the device_model group.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-17 10:13:37 +02:00
Gerard Marull-Paretas e42888bf7c device: move independent groups to groups.dox
Some Doxygen groups do not belong to a specific header, they are used to
group multiple other sub-groups defined in other headers. For this
purpose we have the groups.dox file, there's no need to use device.h for
that.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-17 10:13:37 +02:00
Gerard Marull-Paretas 43b8ee7363 dt-bindings: clock: stm32: fix STM32_CLOCK macro docs location
Doxygen docs for a macro need to be placed together with the macro being
documented (unless using `@def`).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-17 14:40:31 +09:00
Gerard Marull-Paretas 440bbe0820 dt-bindings: pinctrl: stm32: fix STM32*_PINMUX docs location
Documentation for STM32*_PINMUX macros was incorrectly placed above the
macro, so it was in practice documenting the next macro (e.g.
STM32_MODE_SHIFT).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-17 14:40:31 +09:00
Gerard Marull-Paretas 8c695b5feb uart: fix enum references
Since Doxygen 1.9.5 @ref enum::FIELD references will not work. Use the
`#FIELD` notation instead. Since enums place all of its entries to the
global namespace, adding the enum only adds redundant information
Doxygen can figure out on its own.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-17 14:40:31 +09:00
Kumar Gala c778eb2a56 smp: Move arrays to use CONFIG_MP_MAX_NUM_CPUS
Move to use CONFIG_MP_MAX_NUM_CPUS for array size declarations instead
of CONFIG_MP_NUM_CPUS.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-17 14:40:12 +09:00
Emil Gydesen 7ab1cafbc2 Bluetooth: Audio: Add Broadcast source application AD
This refactors how the BAP broadcast source handles the
extended and periodic advertising.

First it removes the start and stop of the extended
advertising, and instead expects the application
(or upper layers) to do this.

Second it exposes API functions to get the
necessary advertising data from BAP (service data and
the BASE), which the upper layers will then also
be responsible for setting and updating.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-14 09:51:39 +02:00
Manuel Arguelles 337dc5d651 soc: arm: add pinctrl support for NXP S32Z/E SoC's
Introduce support for Pinctrl driver on NXP S32Z/E SoC's.
The NXP S32 pin controller is a singleton node responsible for
controlling the pin function selection and pin properties, based on the
pin node group approach. The pinmux configuration is encoded in a
32-bit value.

Each S32 SoC implementing Pinctrl must create a `pinctrl_soc.h` header
which define SoC-specific macros to initialize the pinctrl structure.

Signed-off-by: Manuel Arguelles <manuel.arguelles@nxp.com>
2022-10-14 09:51:14 +02:00
Kumar Gala 2530ba5750 arch: smp: Allow for number of cpus to be determined at runtime
Introduce a Kconfig (MP_MAX_NUM_CPUS) and an api arch_num_cpus() to
allow for systems that might determine the number of CPUs available to
Zephyr at runtime.

CONFIG_MP_MAX_NUM_CPUS is intented to be use for any array initialization
and such that need to occur at build time.  For most systems
arch_num_cpus() will just report the value of CONFIG_MP_MAX_NUM_CPUS.

The intent is to phase out CONFIG_NP_NUM_CPUS.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-13 16:02:19 +09:00
Martin Jäger 57e0ea6f98 toolchain: common: iterable sections: improve documentation
The macro STRUCT_SECTION_ITERABLE can only store items in ROM if a
const specifier is added to the struct declaration.

Also it does not create the iterable section itself, but adds an
element to the section.

This commit clarifies the documentation.

Signed-off-by: Martin Jäger <martin@libre.solar>
2022-10-12 18:42:28 +02:00
Mariusz Skamra 9c3f190721 Bluetooth: audio: capabilities: Hide bt_audio_capability_get function
This function exposes list pointer, so that it allows the user to modify
the internal list. This adds bt_audio_foreach_capability iterator finction
that can be used instead.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-12 18:41:22 +02:00
Florian Grandel 675757c601 net: l2: ieee802154: remove struct padding in context
This change re-orders attributes in struct ieee802154_context to
completely optimize struct padding away. This is done in a way that does
not impact readability.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-10-12 18:40:59 +02:00
Florian Grandel 14c608e9c4 net: l2: ieee802154: improved context thread safety
Several attributes in the ieee802154_context struct may potentially be
accessed from different threads and/or ISR context. Only some of these
attributes were properly guarded against race conditions.

This may not have been to problematic in the past but as other changes
in this PR introduce additional attributes and mutate several attributes
in a single atomic transaction, leaving such changes unprotected seems
dangerous.

This change therefore introduces systematic locking of the
ieee802154_context structure.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-10-12 18:40:59 +02:00
Florian Grandel 6a6b89516d net: l2: ieee802154: improve short address support
IEEE 802.15.4 short address support is incomplete in several places.
This change improves short address support without claiming to fix
it everywhere. Future iterations will have to continue where this change
leaves off.

The purpose of this change was to:
 * use the short address returned by association responses,
 * automatically bind IEEE 802.15.4 datagram sockets to the short
   address if available,
 * use the short address in outgoing packages where applicable,
 * improve validation of association/disassociation frames,
 * model association more closely to the spec by tying it to the
   existence of a short address in the MAC PIB thereby removing
   redundancy in the PIB (which makes race conditions less probable),
 * keep both, the short and extended addresses, of the coordinator.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-10-12 18:40:59 +02:00
Florian Grandel 1b658494d9 net: ip: test and clear net_if flag
This change introduces an additional function into the API that allows
to test and clear a net_if flag atomically. A similar function already
exists to test and set a flag. So this change actually improves symmetry
of the API.

The change is required in later commits of this PR.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-10-12 18:40:59 +02:00
Florian Grandel 34999a8b3e net: l2: ieee802154: document endianness
The IEEE 802.15.4 L2 code stores representation of attributes like
PAN id, short address and extended address in different encodings:

* big endian for extended address and CPU byte order for everything
  else whenever such attributes enter user space (except for IP/socket
  link layer addresses which are always big endian - even in case of
  short addresses - to maintain POSIX compatibility).

* little endian for everything that is close to the radio driver as
  IEEE 802.15.4 frames are little endian encoded.

Endianness was almost nowhere documented which led to several bugs and
inconsistencies where assignments of different byte order were not
converted (or sometimes converted, sometimes not).

This change documents endianness wherever possible within the realm of
the IEEE 802.15.4 L2 code. Conversion bugs and inconsistencies that were
revealed by the improved documentation will be fixed in a separate
commit.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-10-12 18:40:59 +02:00
Florian Grandel a05f0f3f7f net: ip: document endianness
To maintain POSIX compatibility, link-layer addresses are encoded in big
endian in the IP stack and socket API.

The intended endianness was however not documented everywhere which led
to bugs and inconsistencies. The IEEE 802.15.4 L2 stack, for example,
sometimes stores addresses in little endian in structures that intend
them to be stored in POSIX-compliant big endian byte order.

This change documents intended endianness within the realm of the
IP and sockets stack. Conversion bugs are fixed in a separate commit.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-10-12 18:40:59 +02:00
Florian Grandel 631f117ed1 drivers: ieee802154: document endianness
The IEEE 802.15.4 radio driver encodes attributes in:

* little endian for everything that is close to the protocol as
  IEEE 802.15.4 frames are little endian encoded.

* mixed big and little endian in its configuration where extended
  addresses are being represented. These inconsistencies are unfortunate
  but cannot be easily fixed in a backwards compatible way so will be
  left untouched in this change.

Endianness was almost nowhere documented which explains these
inconsistencies and led to several bugs where assignments of different
byte order are not converted (or sometimes converted, sometimes not).

This change documents intended endianness within the realm of the
IEEE 802.15.4 radio driver code. Conversion bugs are fixed in a separate
commit.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-10-12 18:40:59 +02:00
Daniel DeGrasse f37c8cc77e drivers: regulator: add support to PMIC regulator driver for modes
Add support for setting the target mode for a PMIC regulator. Some
regulators support multiple modes, each with distinctive voltage and
current configuration data. This function allows the consumer to switch
the PMIC into a new mode. The PMIC can then be configured to use a new
set of voltages.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-10-12 18:40:24 +02:00
Daniel DeGrasse 1d50265a2f include: dt-bindings: update regulator defintions for PCA9420 for modes
Update regulator binding definitions for PCA9420 to support mode setting
features. This will allow the 4 voltage modes present on the PCA9420 PMIC
to be utilized.

Note that bindings have also been updated to indicate the default
register value and target voltage for each regulator on the PCA9420.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-10-12 18:40:24 +02:00
Christopher Friedt dbe2c0d59e include: net: http: rename http_x.h http/x.h
Some minor housekeeping prior to adding an http server
implementation. There are already a number of http headers
and that number will likely increase with subsequent work.
Moving them into a common directory cleans up the
`include/net` directory a bit.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2022-10-12 09:02:21 -04:00
Christopher Friedt f6b73f413c include: net: http: define http response status codes
Provide a common header enumerating HTTP response status codes.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2022-10-12 09:02:21 -04:00
Christopher Friedt 4382df571f include: net: http: move http methods to separate header
Previously, HTTP method enumerations were only defined within
the `http_parser.h`, which may not be ideal for all use cases.

This commit moves the `enum http_method` definition to a
dedicated header in a dedicated `http` subdirectory.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2022-10-12 09:02:21 -04:00
Henrik Brix Andersen f393e2205c drivers: can: mark CAN-FD data phase timing API as optional
The can_set_timing_data() API function is optional and is not supported by
all CAN controller drivers.

On a board with only either classic CAN or CAN-FD capable controllers the
current behavior is fine, but on boards with a mix of classic CAN and
CAN-FD capable controllers/drivers, calling can_set_timing_data() on a
classic CAN controller will lead to a NULL pointer dereference.

To ensure a proper behavior when calling can_set_timing_data() on classic
CAN controller drivers, change the API wrapper function to return -ENOSYS
if the CAN driver does not implement CAN-FD support.

Note that the data phase timing calculation functions are fine as-is, as
the timing calculations will fail due to minimum/maximum data phase timing
parameters being all zeros for drivers only supporting classic CAN.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-10-12 18:49:33 +09:00
Henrik Brix Andersen dad8364d5f drivers: can: document which API functions are optional
Document that the can_get_max_filters() and can_get_max_bitrate() API
functions are optional.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-10-12 18:49:33 +09:00
Gerard Marull-Paretas 751f685043 init: format file
Format according our guidelines.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-12 18:49:12 +09:00
Gerard Marull-Paretas 476b3adc79 init: remove redundant Z_SYS_NAME
All init entries are already prepended with `__init_`, there's no point
in pre-pending 2 prefixes.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-12 18:49:12 +09:00
Gerard Marull-Paretas 1529d19ee7 init: s/entry_name/init_id
Use the `init_id`, in line with recent device changes, as the argument
is being used as a unique identifier.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-12 18:49:12 +09:00
Gerard Marull-Paretas 3f474b29a6 init: rename macro parameters
Remove unnecessary underscores where possible as there are no name
clashes.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-12 18:49:12 +09:00
Gerard Marull-Paretas bd364aecd4 init: improve Doxygen
- Create a sys_init entry, as init API is not strictly related to the
  device model (device model re-uses it)
- Hide internals (Z_*) from public API docs.
- Give overview within the group definition of allowed levels, meaning,
  etc.
- Properly document struct init_entry.
- Multiple style issues

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-12 18:49:12 +09:00
Gerard Marull-Paretas 495245a971 init: remove _SYS_INIT_LEVEL* definitions
The _SYS_INIT_LEVEL* definitions were used to indicate the index entry
into the levels array defined in init.c (z_sys_init_run_level). init.c
uses this information internally, so there is no point in exposing this
in a public header. It has been replaced with an enum inside init.c. The
device shell was re-using the same defines to index its own array. This
is a fragile design, the shell needs to be responsible of its own data
indexing. A similar situation happened with some unit tests.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-12 18:49:12 +09:00
Gerard Marull-Paretas 831239300f kernel: move z_sys_init_run_level to init.c
The function in charge of calling all init function was defined in
device.c, had a public prototype and was just used in init.c. Since this
is really an internal function tied to Kernel init code, move it to
init.c and make it static, there's no need to expose it publicly.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-12 18:49:12 +09:00
Gerard Marull-Paretas 9b7949b93d init: define Z_INIT_ENTRY_SECTION
Define Z_INIT_ENTRY_SECTION so that Z_INIT_ENTRY_DEFINE can be
de-cluttered.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-12 18:49:12 +09:00
Gerard Marull-Paretas e42f58ec94 init: s/ARCH/EARLY, call it just before arch kernel init
The `ARCH` init level was added to solve a specific problem, call init
code (SYS_INIT/devices) before `z_cstart` in the `intel_adsp` platform.
The documentation claims it runs before `z_cstart`, but this is only
true if the SoC/arch takes care of calling:

```c
z_sys_init_run_level(_SYS_INIT_LEVEL_ARCH);
```

Which is only true for `intel_adsp` nowadays. So in practice, we now
have a platform specific init level. This patch proposes to do things in
a slightly different way. First, level name is renamed to `EARLY`, to
emphasize it runs in the early stage of the boot process. Then, it is
handled by the Kernel (inside `z_cstart()` before calling
`arch_kernel_init()`). This means that any platform can now use this
level. For `intel_adsp`, there should be no changes, other than
`gcov_static_init()` will be called before (I assume this will allow to
obtain coverage for code called in EARLY?).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-12 17:16:27 +09:00
Anas Nashif 3d85ae37b6 arm: add missing includes
Add missing includes that were previously included indirectly.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-10-11 18:37:53 -04:00
Anas Nashif ede94516b0 drivers: intc_dw_ace: rename file
No need for the version in the file name, this will be used by multiple
versions of ACE.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-10-11 12:50:05 -04:00
Gerard Marull-Paretas 882162357c scripts: build: gen_handles: use Z_DECL_ALIGN
Instead of hardcoding alignment size for pass 2 device handles, use
Z_DECL_ALIGN. This makes sure gen_handles.py is always in sync with the
type defined in device.h. The build assert in device.h can be removed as
a result, since we do not hardcode handles size anywhere else.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-11 18:11:47 +02:00
Gerard Marull-Paretas a6a4400b86 init: only add necessary includes
The file does not use any of the API/types defined in kernel.h or
types.h. Added stdint.h include as we're using int32_t, and stddef.h for
NULL.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-11 18:05:17 +02:00
Gerard Marull-Paretas c7b1349392 arch: arm: aarch32: cmsis: include soc.h after other Zephyr headers
Some platforms, e.g. NXP LPC, pollute the namespace with definitions
like ARRAY_SIZE, MIN, MAX, etc. Since they don't re-define if already
defined, we're lucky enough to be able to "fix" this problem by
re-ordering includes. This likely deserves a proper fix, either by
patching offending code or Zephyr using a namespace. The "don't
re-define" technique makes implementation dependent on the include
order, i.e. poor/bad solution.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-11 18:05:17 +02:00
Gerard Marull-Paretas 343e900799 soc: arc: add missing aux_regs.h include
It is required for z_arc_v2_core_id()  or register read/write functions.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-11 18:05:17 +02:00
Gerard Marull-Paretas ac63bca423 include: add missing sys_clock.h include
Some headers made use of types defined in sys_clock.h (e.g. k_timeout_t)
without including it.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-11 18:05:17 +02:00