Commit graph

2441 commits

Author SHA1 Message Date
Christopher Friedt 52cc49e1ad fdtable: add ioctl numbers for FIONBIO, FIONREAD
Rather than defining these constants in the POSIX layer,
define them in the Zephyr layer, and make the POSIX layer a
simple wrapper.

This will allow the POSIX layer and networking to have a
common dependency rather than a cyclic one.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-08-22 09:59:44 +02:00
Benjamin Cabé d22e08c067 pm: Fix unused-parameter warnings
Added a few missing ARG_UNUSED

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-08-21 17:15:56 +02:00
Morten Priess 856e555b51 Bluetooth: controller: Fix HCI ISO header RFU bit masking
Mask out RFU bits in HCI ISO header to prevent set RFU bits leaking into
length values.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-08-21 15:11:48 +02:00
Jaxson Han 0f7bbff050 arch: arm64: Refine v8R AArch64 MPU regions switch
The current mechanism of the MPU region switching configures and
reprograms the regions (including inserting, splitting the dynamic
region, and flushing the regions to the registers) every time during the
context switch. This, not only causes a large usage of the kernel stack
but also a lower performance.

To improve it, move the configuration operations ahead to make sure the
context swtich only flushes the current thread regions to the registers
and does not configure the regions anymore. To achieve this, configure
the regions during any operations related to partitions (partition
add/remove, and domain add/remove thread), flush the sys_dyn_regions if
the current thread is the privileged thread, and flush the thread's own
regions if it's a user thread.

Signed-off-by: Jaxson Han <jaxson.han@arm.com>
2023-08-21 13:27:07 +02:00
Jaxson Han c039e05724 arch: arm64: mpu: Use BR mode to flush the MPU regions
Using BR(background region) during the flushing regions instead of
enabling/disabling the MPU which is a heavy operation.

Signed-off-by: Jaxson Han <jaxson.han@arm.com>
2023-08-21 13:27:07 +02:00
Jamie McCrae 5c88d45544 treewide: mgmt: mcumgr: Change "ret" to "err" for SMP version 2
This is a stable API treewide change changing the newly introduced
"ret" response to "err" as it was overlooked that the shell_mgmt
group already used "ret" to return the exit code of the command
and this created a collision. Since SMP version 2 was only recently
introduced, there should not be any public implementations of it
as of yet, but the original function has been kept and marked as
deprecated.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-08-21 10:18:50 +02:00
Jamie McCrae 0001d01bfe mgmt: mcumgr: Allow additional cbor states for encoding
Allows selecting more than the default number of encoding states.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-08-21 10:12:06 +02:00
Manuel Argüelles 26d398548f arm: cortex_r: support recoverable data abort
Add support for processing the Fault Status Registers and recoverable
data abort for Armv8-R AArch32.

Based on Arm Architecture Reference Manual Supplement Armv8, for the
Armv8-R AArch32 architecture profile (ARM DDI 0568).

Signed-off-by: Manuel Argüelles <manuel.arguelles@nxp.com>
2023-08-21 10:07:29 +02:00
Andy Sinclair 7a71ebe372 drivers: mfd: npm1300: Added event interrupt handling
Added support for npm1300 interrupt events

Signed-off-by: Andy Sinclair <andy.sinclair@nordicsemi.no>
2023-08-21 10:04:03 +02:00
Leifu Zhao 45a4177704 x86: linker: add linker script for ish aon section
link aon code into special aon memory region by put aon object files
into aon section.

Signed-off-by: Leifu Zhao <leifu.zhao@intel.com>
2023-08-18 12:24:31 +01:00
Maureen Helm 202a8ae5ca arch: x86: Enable devicetree linker memory regions
A devicetree compatible "zephyr,memory-region" was introduced in commit
18ffcdcf74 to generate linker script
memory regions from devicetree. It was enabled on arm and riscv
architectures only; extend that support to x86.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-08-18 12:24:31 +01:00
Anas Nashif c8a9e445bb Bluetooth: BT_OTS_OACP_CHECKSUM_SUPPORT implies CRC support
BT_OTS_OACP_CHECKSUM_SUPPORT requires CRC to be enabled.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-08-18 08:52:16 +03:00
Fabio Baltieri 8409599114 Revert "arch: aarch32: fix z_mapped_start location for non-XIP operation"
This reverts commit 9e9e60b67f.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-17 20:56:32 +01:00
Fabio Baltieri a08d359820 Revert "arch: aarch32: place .bss, .noinit sections at the end of the binary"
This reverts commit 36997de796, as that's
breaking few tests in CI, see:

https://github.com/zephyrproject-rtos/zephyr/issues/61572

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-17 20:56:32 +01:00
Mykola Kvach 867ba172b4 arch: arm64: cache: delete arm64_dcache_all
Delete arm64_dcache_all function, because it is unused and in order to
avoid future usage of set/way cache maintenance instructions. It isn't
safe to use them.

Set/way operations are not guaranteed to affect all caches prior to the
PoC, and may require other IMPLEMENTATION DEFINED maintenance.

Exposing set/way cache maintenance to virtual machines is unsafe, not
least because the instructions are not permission-checked, but also
because they are not broadcast between CPUs.

Signed-off-by: Mykola Kvach <mykola_kvach@epam.com>
2023-08-17 15:15:15 +02:00
Aziz Idomar c3ac598c7f drivers: introduce hardware spinlock framework
The intention of hardware spinlock is to allow two processors,
that have no alternative mechanism for accomplish synchronization
and mutual exclusion operations, to share resources (such as
memory and/or any other element).

Here, we add the hwspinlock framework, that makes possible to use
those hwspinlock devices and stay platform-independent. Each
platform wishing to support hardware spinlock must describe a
driver using this framework.

Signed-off-by: Aziz Idomar <aidomar@sequans.com>
2023-08-16 20:46:55 +02:00
Andriy Gelman d481ec286d driver: pintcrl: xmc4xxx: Revert recent changes from i2c driver
In commit 541482ff20 the pinctrl alternate
function mask was increased to also include open-drain setting.

Revert this change because open-drain can already be set via property
drive-open-drain.

The commit also added separate pinctrl nodes for the i2c controller and
target modes. However, the alternate function settings
is the same in both modes, so keep only one and remove the mode
label.

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2023-08-16 20:43:50 +02:00
Thomas Stranger 2d988879ec dt-bindings: use dt-bindings/dt-util.h instead of sys/util_macro.h
Replaces some usages of <zephyr/sys/util_macro.h> with
<zephyr/dt-bindings/dt-util.h> such that this is done in a uniform way.

The latter being a wrapper around the former, which was introduced in
PR #28779 with the intention to be able to retain the pattern of only
including <zephyr/dt-bindings/foo.h> files in in-tree dts files.

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2023-08-16 20:31:07 +02:00
Lukas Woodtli 1018ffe885 net: coap: Update documentation for adding options
CoAP options do not need to be added in the order of
their code number. The function documentation is updated
accordingly.

Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
2023-08-16 17:06:41 +02:00
Lukas Woodtli 3b4e54e39e net: coap: Add function to check for block option in message
The added function allows to check if a descriptive block
option was already added to a message.

Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
2023-08-16 17:06:41 +02:00
Lukas Woodtli e13e90914a net: coap: Add function for removing block transfer option
In some cases the options of a CoAP message are reused for
block transfer. Then the block header needs to be updated.
The current approach is to remove the old block option and
add an updated one.

Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
2023-08-16 17:06:41 +02:00
Lukas Woodtli 6277a3904a net: coap: Add function for removing CoAP options
The provided function allows to remove a CoAP option in a
message. This is useful for reusing parts of a message.

Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
2023-08-16 17:06:41 +02:00
Florian Grandel 137a7edd6e drivers: ieee802154: nRF5: TX timestamp now refers to start of PHR
Based on the standard based definitions given in previous commits, the
TX timestamp used for timed TX now refers to the start of PHR. As OT
continues to calculate timestamps based on a "start of SHR" definition,
the duration of the PHY specific SHR is added in the OT adaptation layer
to make up for this OT quirk.

Fixes: #59245

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-08-16 17:06:16 +02:00
Moritz Fischer 9e8a8b4e85 soc: arm: common: cortex_m: Move arm_mpu_mem_cfg.h
Move arm_mpu_mem_cfg header to common include directory.

The benefits are two-fold:
- Allow for out of tree SoC definitions to use them to
  define mpu_regions.
- Remove odd relative include path

Signed-off-by: Moritz Fischer <moritzf@google.com>
2023-08-16 14:56:06 +02:00
Daniel DeGrasse d8bdddd52f arch: arm: aarch32: introduce CONFIG_BUILD_ALIGN_LMA
Introduce CONFIG_BUILD_ALIGN_LMA. When enabled, this symbol will add a
padding section after the final read only data section in the image.
This padding section will ensure that the LMA of the data sections
follows the same alignment restrictions as the VMA does. This LMA alignment
is needed for objcopy to adjust the LMA address of the output ELF file.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2023-08-16 14:53:58 +02:00
Andrzej Głąbek ff0f389d0b dts: bindings: adc-controller: Add zephyr,differential property
Add a property that allows explicit selection of the differential
input mode for ADC channels in DTS. This is useful for controllers
that do not have configurable inputs, so the zephyr,negative-input
property that implicitly selects the differential mode is not
specified for them.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2023-08-16 14:51:03 +02:00
Lukas Woodtli 2f6c0d7ca3 net: coap: Improve the handling of CoAP response code 'continue'
When using block-wise transfer, call the reply callback only when
the last block arrived.

Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
2023-08-16 13:04:11 +02:00
Henrik Eriksen 5a18f0dda7 bluetooth: audio: micp: Wrong error response for invalid Mute Value.
Qualification test MICS/SR/SPE/BI-01-C [Invalid Mute Value]

Specification: Microphone Control Service Revision v1.0 Section 3.1.1

If the client writes a value of Disabled or RFU to the Mute
characteristic, the server shall return an ATT Error Response with the
ATT error code Value Not Allowed (0x13) as defined in Assigned Numbers.

Signed-off-by: Henrik Eriksen <heri@demant.com>
2023-08-16 10:24:53 +02:00
Rubin Gerritsen b939633f73 Bluetooth: ISO: Remove bt_iso_chan_get_type() API declaration
The API was never implemented.
The channel type can also be obtained using bt_iso_chan_get_info().
If we would have to implement this API, it would share a lot of the
implementation with bt_iso_chan_get_info().

Removing the API makes the ISO APIs more similar to the ACL APIs
where we don't have a special API to fetch the role.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2023-08-16 10:21:54 +02:00
Emil Gydesen 53502cb417 Bluetooth: Audio: Make codec_cap const
There is no reason why the capabilities
should be modified by the stack after registration,
nor any reason why a the unicast client application
needs to modify the reported remote capabilities, so
all have been marked as const.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-08-15 11:14:29 +00:00
Emil Gydesen aa990ae6dc Bluetooth: Audio: Refactor bt_audio_codec_cap to flat arrays
Refactor the bt_audio_codec_cap to use flat arrays to store
metadata and codec specific capabilities.

The purpose of this is to make it easier to copy the data
between layers, but also to support non-LTV data for non-LC3
codec capabilities.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-08-15 11:14:29 +00:00
Joshua Lilly 00e9461489 irq.h: build assert removal from irq.h
This diff removes a build assert that no longer makes
sense due to the fact the MAX_IRQ_PER_AGGREGATOR number
does not need to fit into only the first level interrupt
bits. Before the extension of the interrupt bit masks if
the MAX_IRQ_PER_AGGREGATOR bits was larger than the first
level of interrupts then the first level bits could overflow
into the second level. This is no longer necessary to check
since the user can set the correct number of bits needed per
level.

Signed-off-by: Joshua Lilly <jgl@meta.com>
2023-08-14 14:42:21 -04:00
Benjamin Cabé ff09cc74d0 doc: net: lwm2m: doxygen cleanup
Various fixes to LwM2M doxygen documentation
- document all macros
- mount path helpers in lwm2m_api doxygen group
- hide internal macros
- created proper header definitions for macros that belong together
(ex. result codes)
- fixed capitalization for Objlnk

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-08-14 18:12:12 +00:00
Benjamin Cabé 1d65548e74 net: lwm2m: add Fuel Cell power source type
LwM2M 1.1 added Fuel Cell as a new type of power source.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-08-14 18:12:12 +00:00
Emil Gydesen db2624def4 Bluetooth: BAP: Remove scan and PA sync from broadcast sink
This removes the scanning and PA sync capabilities from the
broadcast sink implementation, moving the responsibility of this
to the application layer.

The reason for this is to add more flexibility and choice to the
upper layers, while simplifying the Broadcast Sink implementation.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-08-14 13:34:26 +00:00
Emil Gydesen 4f966de74b Bluetooth: CAP: Add cap stream send and tx sync
Add bt_cap_stream_send and bt_cap_stream_get_tx_sync for
CAP streams

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-08-14 13:33:57 +00:00
Emil Gydesen da874178ff Bluetooth: BAP: Fix note in bt_bap_stream_send
The @note in bt_bap_stream_send did not make any sense, and has
been replaced with a new note.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-08-14 13:33:57 +00:00
Emil Gydesen 8600356f98 Bluetooth: BAP: Add bt_bap_stream_get_tx_sync
Add bt_bap_stream_get_tx_sync to get the ISO tx info from a BAP
stream.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-08-14 13:33:57 +00:00
Emil Gydesen e882847cf3 Bluetooth: BAP: Add can_send field to bt_bap_ep_info
This makes it easier to check if a stream, or ep, can send.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-08-14 13:33:57 +00:00
Uma Praseeda d11c0a1664 doc: Doxygen fixes in conn.h
Fixes the issue of some doxygen comments not being visible in the
documentation.

Signed-off-by: Uma Praseeda <uma.praseeda@nordicsemi.no>
2023-08-12 12:16:59 +02:00
Benjamin Cabé 38775fa6db doc: net: conn_mgr: Doxygen cleanup
Added some missing doxygen comments (missing javadoc style syntax)
Fixed some brief descriptions
Added named heading in conn_mgr_conn_binding

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-08-11 12:01:41 +00:00
Benjamin Cabé b6a501b2e9 doc: time_units: Add to Time Utility docs
Add time units helpers to the Time Utility APIs category.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-08-11 11:59:55 +00:00
Mykola Kvach d9fe261f8e drivers: regulator-fixed: extend api of driver (list/count voltages)
Allow properties 'regulator-min-microvolt' and 'regulator-max-microvolt'
for fixed regulators: Note: they should be equal.

Add simple functions for getting list of allowed and count of voltages.

Signed-off-by: Mykola Kvach <mykola_kvach@epam.com>
2023-08-10 18:11:35 +00:00
Mykola Kvach ed9ca0f6d3 drivers: regulator-fixed: add possibility to work without enable pins
Possible situation is that in some driver, devices can be controlled in
different ways: in some, we can only turn the power on or off, in others,
we can only control the voltage, and in some, we can control power supply
or voltage level. There may also be devices where there is no control
over power supply at all. A clear example of this can be eMMC devices
where the voltage is usually fixed and they are always powered on.
However, we would like to have a common code for controlling all the
mentioned types of devices, at least the driver shouldn't worry about the
implementation details of voltage regulators. Therefore, there may exist
empty regulators - regulators that only contain information about the
supported voltage, and we cannot change anything in them. The device tree
node description for such a regulator is only necessary for compatibility
with other regulators. Hence, we need to add the possibility of the
existence of such a dummy fixed-regulator.

In this commit, support for a fixed dummy regulator without the ability
for any control has been added. Note that such support also exists in the
Linux kernel. In other words, the logic of the fixed regulator has been
aligned with the logic of the fixed regulator inside the Linux kernel.

Signed-off-by: Mykola Kvach <mykola_kvach@epam.com>
2023-08-10 18:11:35 +00:00
Joshua Lilly cce530cae4 scripts: build: gen_isr_tables: make bit masks configurable
Some architectures such as RISC-v support more than 255 interrupts
per aggrigator. This diff adds the ability to forgo the aggrigator
pattern and use a configurable number of bits for multilevel
interruts.

Signed-off-by: Joshua Lilly <jgl@meta.com>
2023-08-10 10:55:41 -04:00
Fabio Baltieri a534169ed4 input: rename callback define macro to INPUT_CALLBACK_DEFINE
Looking back at the current INPUT_LISTENER_CB_DEFINE api naming, it
feels like it's a bit overloaded. Rename it to a simpler
INPUT_CALLBACK_DEFINE.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-10 08:15:10 +00:00
Daniel Leung b22db9892e sys: rename local variables in WAIT_FOR()
This renames the local variables in WAIT_FOR() to make them
more unique to avoid them being shadow variables.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-10 08:14:12 +00:00
Daniel Leung a952055ba3 lib: cbprintf: renames shadow variables
Renames shadow variables found by -Wshadow.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-10 08:14:12 +00:00
Daniel Leung 9c0ff33e04 kernel: rename shadow variables
Renames	shadow variables found by -Wshadow.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-10 08:14:12 +00:00
Daniel Leung 6b740b20de riscv: renames shadow variables
In print_pmp_entries(), start and end are function arguments
and yet another start and end are declared inside the for
loop. So rename the function arguments to fix shadow variables
warning.

The changes in csr_*() macros are needed to avoid shadowing
__v when nesting those functions together, for example,
csr_write(..., csr_read(...)).

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-10 08:14:12 +00:00
Daniel Leung 88c43566fa arm64: renames shadow variables
Renames	shadow variables found by -Wshadow.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-10 08:14:12 +00:00
Daniel Leung 6f6f7d6cd7 toolchain: gcc: rename argument for UNALIGNED_GET()
Rename the argument for UNALIGNED_GET() from p to g.
This fixes shadow variable warning of __p if UNALIGNED_GET()
is nested with UNALIGNED_PUT().

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-10 08:14:12 +00:00
Daniel Leung 7c4e641f84 debug: rename shadow variables
This renames the shadow variables found by -Wshadow.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-10 08:14:12 +00:00
Daniel Leung 179c46be03 syscall: Z_SYSCALL_VERIFY_MSG to ignore -Wshadow
Z_SYSCALL_VERIFY_MSG() does LOG_MODULE_DECLARE() internally to
log errors during verification. However, this is definitely
going to conflict with any LOG_MODULE_DECLARE() in the source
file using Z_SYSCALL_VERIFY_MSG(). So we need to selectively
disable -Wshadow for Z_SYSCALL_VERIFY_MSG() to avoid compiler
warnings as this is an intentional behavior.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-10 08:14:12 +00:00
Daniel Leung 8dc9d89d29 toolchain: introduce macros to ignore -Wshadow
This introduces two macros TOOLCHAIN_IGNORE_WSHADOW_BEGIN and
TOOLCHAIN_IGNORE_WSHADOW_END which can be used inside another
macro to ignore -Wshadow for certain block of code. This is
useful for common macros that may nest upon themselves
(for example, logging).

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-10 08:14:12 +00:00
Benjamin Cabé 3f1868e0f9 doc: drivers: i2s: doxygen cleanup
Added missing doxygen comments + fixed improperly documented structure.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-08-09 18:33:44 +00:00
Jani Hirsimäki 83ea1e26a2 net: l2: ppp: ppp uart usage fixed
This fixes 3 issues that came within PR #59124 for ppp uart usage.

Earlier start/stop of ppp was done at enable() but that
was removed in PR #59124. Now putting enable/disable() back and
putting start/stop there.
Additionally, there was a double ppp carrier ON when NET_EVENT_IF_DOWN.
For that net_if_carrier_on/off is set in uart ppp.c driver.
Also, maybe worth to be mentioned that after PR #59124 there is no
ppp carrier off when lcp is disconnected, for workaround that change,
application should use ppp dead/running events.

Signed-off-by: Jani Hirsimäki <jani.hirsimaki@nordicsemi.no>
2023-08-09 16:07:46 +00:00
Immo Birnbaum 9e9e60b67f arch: aarch32: fix z_mapped_start location for non-XIP operation
Move the z_mapped_start marker for non-XIP builds to the base RAM address.
This has already been the marker's location when building for XIP.

Prior to this change, z_mapped_start was located at the start of the
text section for non-XIP builds. However, at least for the Cortex-A
family of CPUs, the first section located at the RAM base address
isn't the text section, but the single 4k page containing the exception
vectors which are copied to either address 0 or the HIVECS address upon
early boot.

This resulted in this first 4k page at the bottom of RAM to be considered
available for memory mappings via the MMU at run-time, followed by all
the permanently mapped stuff, with available mappable memory only
continuing behind z_mapped_end. A call at run-time requesting memory to
be mapped via the MMU therefore always assigned the single 4k page
containing the vectors data first, before continuing mapping physical
memory behind z_mapped_end. For any map call requesting more than 4k,
this resulted in a contiguous virtual memory address range mapped to
non-contiguous physical memory. This behaviour has already been
documented in #51024.

This behaviour would also cause further problems in case of support
for the Cortex-A's VBAR register, which has been proposed before, but
eventually wasn't merged. Letting VBAR point to the RAM base where
the 4k vectors page is located within the Zephyr image instead of
copying the vectors to either 0 or the HIVECS address means that this
page may under no circumstance be re-assigned for use as regular RAM
mapped via the MMU.

Signed-off-by: Immo Birnbaum <mail@birnbaum.immo>
2023-08-09 16:05:24 +00:00
Immo Birnbaum 36997de796 arch: aarch32: place .bss, .noinit sections at the end of the binary
This is a follow up to #53262, which still lacked the adjustment of the
.noinit section's position within the binary by the time the PR went
stale.

Adjust the linker command file so that the .bss and .noinit sections
are placed at the end of the resulting binary. Until now, those sections
have been located somewhere in the middle of the binary, so that the
inclusion of structures like statically defined heaps or large zero-
initialized arrays reflected 1:1 in the resulting binary's size. Even
for a stripped binary, such data was included in full as the linker
couldn't omit it due to subsequent sections within the binary.

This fix has been tested with a 32 MB statically allocated heap and
a 32 MB uint8 zero-initialized array. Both structures are clearly
identifyable in the memory consumption statistics, however, the final
binary's size is unaffected by their inclusion.

Signed-off-by: Immo Birnbaum <mail@birnbaum.immo>
2023-08-09 16:05:24 +00:00
Diego Elio Pettenò 65f7f741f3 usb_tcpc: fix typo.
"verion" should obviously have been "version".

Signed-off-by: Diego Elio Pettenò <flameeyes@meta.com>
2023-08-09 13:47:22 +00:00
Benjamin Cabé 12e484cd41 drivers: dac: doc: Cleanup Doxygen documentation
Fixed Doxygen doc for dac_channel_cfg struct.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-08-09 07:47:45 -04:00
Benjamin Cabé e439ed2da1 doc: sys: onoff: cleanup doxygen documentation
Cleaned up some inconsistencies or mistakes in the way onoff.h
was documented.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-08-09 07:41:22 -04:00
Flavio Ceolin d16c5b9048 kernel: canaries: Allow using TLS to store it
Add new option to use thread local storage for stack
canaries. This makes harder to find the canaries location
and value. This is made optional because there is
a performance and size penalty when using it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-08-08 19:08:04 -04:00
Benjamin Cabé 68b1930309 include: rb: doc: Move code to make Doxygen happy
Moved alloca.h trick further down the file to workaround Doxygen
getting confused with #ifdef/#ifndef.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-08-08 13:02:47 -04:00
Benjamin Cabé 9dbb1ecc53 include: rb: doc: RB-tree doc wording
Small tweaks to balanced RB-tree's doc wording

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-08-08 13:02:47 -04:00
Benjamin Cabé 72f5923981 include: doc: Add missing docs for data structures
Data structures in Modules > Utilities > Data Structures were missing
some documentation.
Also properly hid the structures' internals (note that for some of the
files touched by this commit, some internals were already de-facto
hidden by Doxygen as they begin with an _ character).

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-08-08 13:02:47 -04:00
Benjamin Cabé e00e2108c9 include: doc: Properly document data structures
Move brief and description under group instead of file so that they show
up nicely in the documentation.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-08-08 13:02:47 -04:00
Benjamin Cabé 1a85866935 drivers: peci: doc: Doxygen cleanup
Put command format defines in proper sections and fix improperly
documented struct.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-08-08 13:01:28 -04:00
Robert Lubos 32bd3aa781 net: iface: Allow NULL pointer to be handled in net_if_is_ip_offloaded
In case native interface is used with NET_OFFLOAD enabled, the
net_if_is_ip_offloaded() could lead to a crash, if called on unbound
net_context (i.e. with no iface assigned to net_context yet).

As since commit 40d2240226 the net_context
allocated on offloaded interface is always assigned with the iface
pointer during its creation, it can be safely assumed that in case of
NULL pointer is provided we deal with a native interface. Therefore
instead of asserting on the iface pointer, indicate that the interface
is native when NULL pointer is provided.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-08-08 08:15:53 +00:00
Grzegorz Swiderski e28cbb3633 devicetree: Add DT_FIXED_PARTITION_ADDR macro
This convenience API returns the absolute address of a fixed partition,
i.e., relative offset + base address. It's distinct from `DT_REG_ADDR()`
and `FIXED_PARTITION_OFFSET()`, both of which return just the offset.

The base address is taken from the parent memory node as given by the
newly added `DT_MEM_FROM_FIXED_PARTITION()`. This is expected to ensure
that the returned address is directly addressable by the CPU. This is
also meant to prevent `DT_FIXED_PARTITION_ADDR()` from working with
external memory partitions.

Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
2023-08-07 15:45:23 +02:00
Grzegorz Swiderski 99599b5d3b devicetree: Add DT_MEM_FROM_FIXED_PARTITION macro
This is a new fixed-partitions API, which serves as a companion to the
existing `DT_MTD_FROM_FIXED_PARTITION()`. In the following example:

  flash-controller@0 {
          compatible = "flash-controller";
          flash@1000000 {
                  compatible = "soc-nv-flash";
                  partitions {
                          compatible = "fixed-partitions";
                          partition@3a000 {};
                  };
          };
  };

`DT_MTD_FROM_FIXED_PARTITION()` would let us map `partition@3a000` to
`flash-controller@0`. Now, the new `DT_MEM_FROM_FIXED_PARTITION()` can
let us retrieve the memory node (`flash@1000000`) as well, in a manner
consistent with the existing API.

Caution: if a fixed partition is not said to belong to a memory node,
like in this alternative example:

  flash@0 {
          compatible = "spi-nor";
          partitions {
                  compatible = "fixed-partitions";
                  partition@0 {};
          };
  };

then `DT_MEM_FROM_FIXED_PARTITION()` will map `partition@0` to an
invalid node identifier. This partition belongs to `flash@0`, which
could be an MTD on a SPI bus.

For consistency, the existing `DT_MTD_FROM_FIXED_PARTITION()` is now re-
expressed in terms of the new `DT_MEM_FROM_FIXED_PARTITION()`.

Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
2023-08-07 15:45:23 +02:00
Fabio Baltieri b8e27297fa input: input-event-codes: add few extra definitions
Add few extra definitions used by board DTSs and some that seems to make
sense for potential applications. These match the code and name of the
Linux event codes.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-07 11:26:26 +02:00
Konrad Derda 409b15c7ce net: event: provide complete information about the prefix in events
At the moment, NET_EVENT_IPV6_PREFIX_ADD and NET_EVENT_IPV6_PREFIX_DEL
events provide provide information about an address without its length
and lifetime.

Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
2023-08-07 11:25:40 +02:00
Tom Burdick 108b38b357 rtio: Fix signed compare warning
atomic_t is a machine word signed integer but cq_count is meant to be an
unsigned positive only count of total completions. Cast when needed to
ensure the correct math and comparisons are being done.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-08-05 09:34:07 +00:00
Tom Burdick 0aaedf7205 docs: rtio: Show RTIO API Docs again
The RTIO API docs weren't being shown. I made a poor assumption thinking
I could simply include the top level doxygen group in index.rst which isn't
the case. Fix the groups, and remove a note about a poll function
that doesn't exist yet.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-08-04 12:30:05 -04:00
Gerard Marull-Paretas 28c139f653 drivers: pm_cpu_ops: psci: provide sys_poweroff hook
Instead of implementing a custom power off API (pm_system_off),
implement the sys_poweroff hook, and indicate power off is supported by
selecting HAS_POWEROFF. Note that according to the PSCI specification
(DEN0022E), the SYSTEM_OFF operation does not return, however, an error
is printed and system is halted in case this occurs.

Note that the pm_system_off has also been deleted, from now on, systems
supporting PSCI should enable CONFIG_POWEROFF and call the standard
sys_poweroff() API.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-08-04 16:59:36 +02:00
Gerard Marull-Paretas 90b247b90b lib: os: add support for system power off
Add a new API to perform an immediate system power off:
`sys_poweroff()`.

Until now, this functionality has been implemented via the system power
management module, but in a clunky fashion. The way system PM works is
by defining some idle states in devicetree, that, given some properties
(e.g. minimal residency, exit latency, etc.) are automatically selected
when system goes to idle based on the expected next wake-up. However,
system off is a power state that one typically wants to control manually
from the application because it implies state loss, and in most cases,
configuring some sort of wake-up source. So in general, it is not
desired to let the system enter this state automatically. This led to
the following stuff in-tree:

from `boards/arm/mimxrt595_evk/mimxrt595_evk_cm33.dts`:

```c
/*
 * Deep power-down mode is supported in this SoC through
 *  'PM_STATE_SOFT_OFF' state. There is no entry for this in device tree,
 *  user can call pm_state_force to enter this state.
 */
```

That is, state not being defined in devicetree so that PM subsystem
doesn't pick it automatically, but still implemented in in the PM hooks:

from `soc/arm/nxp_imx/rt5xx/power.c`, `pm_state_set()`:
```c
case PM_STATE_SOFT_OFF:
	set_deepsleep_pin_config();
	POWER_EnterDeepPowerDown(EXCLUDE_FROM_DEEP_POWERDOWN);
	break;
```

And to actually make use of this state, users had to do this kind of
abominations:

```c
pm_state_force(0u, &(struct pm_state_info){ PM_STATE_SOFT_OFF, 0, 0 });

/* Now we need to go sleep. This will let the idle thread runs and
 * the pm subsystem will use the forced state. To confirm that the
 * forced state is used, lets set the same timeout used previously.
 */
k_sleep(K_SECONDS(SLEEP_S));

printk("ERROR: System off failed\n");
while (true) {
	/* spin to avoid fall-off behavior */
}
```

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-08-04 16:59:36 +02:00
Mathieu Anquetin 26f4fab391 drivers: led: lp503x: extend driver to all lp50xx devices
Add support for LP5009, LP5012, LP5018 and LP5024 devices which only
differ by the number of LEDs they can control.

Also, update application sample to run on all these new supported
devices.

Based on initial work from:
  - Marek Janus <marek.janus@grinn-global.com>
  - Rico Ganahl <rico.ganahl@bytesatwork.ch>

Signed-off-by: Mathieu Anquetin <mathieu.anquetin@groupe-cahors.com>
2023-08-04 13:18:01 +02:00
Jamie McCrae 4b9dddcd3a mgmt: mcumgr: grp: os_mgmt: Add force parameter to reset command
Adds the force parameter to the reset command which is now
provided to the callback hook (if enabled).

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-08-04 12:17:07 +02:00
Maciej Sobkowski 8a670d0713 drivers: pinctrl: Add pinctrl driver for Apollo4
This commit addst pinctrl support for Apollo4 SoCs.

Co-authored-by: Mateusz Sierszulski <msierszulski@antmicro.com>
Signed-off-by: Maciej Sobkowski <msobkowski@antmicro.com>
2023-08-04 10:48:58 +02:00
Seppo Takalo 4aeb80b374 kernel/timeout: Introduce comparison for timepoint values
Introduce new API to compare two timepoint values to
find the one that is going to expire sooner, or is already
expired.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-08-04 10:41:15 +02:00
Franciszek Zdobylak 64da407ea5 fs: ext2: create dir and file operations
Introduced functions:
  - open
  - close
  - mkdir

Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
2023-08-03 12:22:01 -04:00
Franciszek Zdobylak 1eccf55102 fs: ext2: Implementation of basic operations
Included operations:
  - mount
  - unmount
  - mkfs
  - statvfs

Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
2023-08-03 12:22:01 -04:00
Nicolas Pitre 90eac6e4bc timepoints: minimal compatibility with CONFIG_SYS_CLOCK_EXISTS=n
When timers are configured out, timepoint-based timeouts are reduced to
"no wait" or "wait forever" only.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2023-08-03 10:29:46 +02:00
Benjamin Cabé 169d35decb drivers: dai: doc: Cleanup Doxygen documentation
Fixed some improperly documented structs and uniformized DAI spelling.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-08-02 10:00:29 +00:00
Keith Packard d47025bd84 libc/picolibc: Remove unused read_stdin/write_stdout hooks
Picolibc doesn't need these two syscall implementations as it uses
zephyr_fputc instead. Make sure that zephyr_putc is declared correctly.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-08-02 10:35:18 +02:00
Andriy Gelman 68ee177a01 linker: devicetree_regions: Infer VMA when defining section
Explicitly setting the start of VMA can intefere if the memory
region was used in another section, for example indirectly via
zephyr_code_relocate().

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2023-08-01 18:09:22 +02:00
Seppo Takalo 838ab80bca net: coap: Use 64bit timestamps
Use 64bit timestamps from k_uptime_get() so they don't
roll over during the expected device lifetime.

Fixes #60826

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-08-01 15:40:04 +02:00
Seppo Takalo 2da8844d19 net: lwm2m: Add support for non-periodic services
Engine now allows registering service callbacks that are
called only once on a given timestamp.
This allows tickless services to be developed.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-08-01 12:07:12 +02:00
Peter Mitsis 2143502f54 include: util: Add Z_DETECT_POINTER_OVERFLOW()
The Z_DETECT_POINTER_OVERFLOW() macro is intended detect whether
or not a buffer spans a region of memory that goes beyond the
highest possible address (thereby overflowing the pointer).

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2023-08-01 09:51:33 +02:00
Emil Gydesen 0081ecd626 Bluetooth: ISO: Add advanced broadcast ISO parameters
Add support for setting advanced broadcast ISO parameters
using the ISO test commands. This allows the host to set
ISO parameters that the controller normally would handle.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-31 09:04:52 +00:00
Emil Gydesen 63aca8d868 Bluetooth: ISO: Add advanced unicast ISO parameters
Add support for setting advanced unicast ISO parameters
using the ISO test commands. This allows the host to
set ISO parameters that the controller normally would
handle.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-31 09:04:52 +00:00
Jamie McCrae 588f6acbd5 mgmt: mcumgr: grp: img_mgmt: Fix not checking write bounds
Fixes an issue whereby the data packets were not checked to ensure
that the client has not attempted to write more data than the size
that was provided in the original upload packet.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-07-31 10:43:54 +02:00
Jamie McCrae 9422fc6e20 mgmt: mcumgr: grp: img_mgmt: Fix not checking image upload size
Fixes an issue whereby upload image size would not be checked in
the first packet of an upload, which would allow an image to be
uploaded until it reached the point of it being too large to
fit anymore.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-07-31 10:43:54 +02:00
Henrik Brix Andersen 71a7afacbd drivers: can: mcan: add CAN_MCAN_DT_MRBA() and CAN_MCAN_DT_INST_MRBA()
Add CAN_MCAN_DT_MRBA() and CAN_MCAN_DT_INST_MRBA() macros for retrieving
the Bosch M_CAN Message RAM Base Address (MRBA) and clarify that the
existing CAN_MCAN_DT_MRAM_ADDR() and CAN_MCAN_DT_INST_MRAM_ADDR() macros do
not retrieve the base address, but rather the base address + the offset, if
any.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2023-07-31 10:09:47 +02:00
Benjamin Cabé d8bc8c0f1d drivers: w1: doc: Doxygen doc for 1-Wire commands
Added Doxygen comments for 1-Wire commands

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-07-31 10:07:59 +02:00
Tristan Honscheid 171c1fc9d9 emul: Introduce emulator backend API and generic sensor test
This PR introduces a backend API to be implemented by sensor emulators
that creates a standardized mechanism for setting expected sensor
readings in tests. This unlocks the ability to create a generic sensor
test that can automatically set expected values in supported sensor
emulators and verify them through the existing sensor API. An
implementation of this API is provided for the AKM09918C magnetometer.

A generic sensor test is also created to exercise this implementation.
Observe that this test knows nothing about the AKM09918C; info about
supported channels and sample ranges is discovered through the backend
API. The test iterates over all devices attached to the virtual I2C and
SPI buses in the test binary's device tree, which (theoretically) covers
all sensors. Sensors whose emulator does not exist yet or does not
support the backend API are skipped.

Signed-off-by: Tristan Honscheid <honscheid@google.com>
2023-07-28 17:48:31 +02:00
Daniel Leung 56a8123eed toolchain: xcc/xt-clang: include llvm.h for xt-clang...
...and removed the copied macros. This allows xt-clang to
inherit macros from llvm.h to align with any LLVM related
additions.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-07-28 08:08:13 -04:00
Florian Grandel a4cd5cee40 drivers: ieee802154: consistent high res timestamps
The IEEE 802.15.4 API and networking subsystem were using several
inconsistent timestamp resolutions and types. This change defines all
timestamps with nanosecond resolution and reduces the number of
available types to represent timestamps to two:
* `struct net_ptp_time` for PTP timestamps
* `net_time_t` for all other high resolution timestamps

All timestamps (including PTP timestamps) are now referred to a
"virtual" local network subsystem clock source based on the well-defined
types above. It is the responsibility of network subsystem L2/driver
implementations (notably Ethernet and IEEE 802.15.4 L2 stacks) to ensure
consistency of all timestamps and radio timer values exposed by the
driver API to such a network subsystem uptime reference clock
independent of internal implementation details.

The "virtual" network clock source may be implemented based on arbitrary
hardware peripherals (e.g. a coarse low power RTC counter during sleep
time plus a high resolution/high precision radio timer while receiving
or sending). Such implementation details must be hidden from API
clients, as if the driver used a single high resolution clock source
instead.

For IEEE 802.15.4, whenever timestamps refer to packet send or receive
times, they are measured when the end of the IEEE 802.15.4 SFD (message
timestamp point) is present at the local antenna (reference plane).

Due to its limited range of ~290 years, net_time_t timestamps (and
therefore net_pkt timestamps and times) must not be used to represent
absolute points in time referred to an external epoch independent of
system uptime (e.g.  UTC, TAI, PTP, NTP, ...).

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-28 09:06:35 +00:00
Florian Grandel 69212bb169 doc: drivers: ieee802154: radio API
Improves the documentation of the IEEE 802.15.4 radio API.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-28 09:06:35 +00:00
Florian Grandel 7378b91294 doc: net: ptp: PTP structs
Improves documentation of PTP structs and explains basic underlying
concepts to increase the probability that these structs will be used
correctly and consistently.

Also introduces references to the underlying specifications.

Note: We currently (ab)use the PTP structs for timestamps in the IEEE
802.15.4 context for which they are undefined. It is also not ideal that
the generic `struct net_pkt` depends directly on PTP. Future changes
will therefore have to remove the reference to PTP structs in net_pkt
and replace them by net_time_t. Clients will then have to convert these
to PTP structures if required.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-28 09:06:35 +00:00
Florian Grandel bd34c946fc net: introduce scalar nanosecond time representation
Introduces a well-defined intermediate concept of syntonized scalar
nanosecond resolution time with overflow protection above low-level
counters/cycles/ticks and below higher level time abstractions
(timescales, calenders, etc.).

The rationale of this type has been extensively documented and
contrasted to already existing time representations to ensure that it
fills a well defined gap without overlap.

This change prepares for later changes in this change set that will
unify the usage of time across the network subsystem (RX/TX timestamps,
timed TX, CSL, scheduled reception windows, (g)PTP integration, etc.).

The type is EXPERIMENTAL and named net_time_t while it is not used in a
larger clock subsystems, the details of which are still being discussed
(see #60400 for details).

See
https://github.com/zephyrproject-rtos/zephyr/issues/19030#issuecomment-1597226731
for its embedding in a larger clock subsystem architecture relevant to
the network stack, IEEE 802.15.4 and the POSIX roadmap.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-28 09:06:35 +00:00
Marcin Niestroj e47175becd dts: bindings: extend st-morpho-header to support Nucleo-144
Nucleo-144 boards have up to 72 pins (there are boards with only 70) on
each ST Morpho header. Extend pin identifiers to support that number.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2023-07-28 08:39:39 +00:00
Marcin Niestroj cbb83d64ab dts: bindings: rename st-morpho-header pin identifiers
So far pin identifiers were named after CN7 and CN10 connector names on
Nucleo-64 boards. In case of Nucleo-144 there are ST Morpho connectors on
both sides, but bigger (up to 72 instead of 38 pins on each side). First 38
pins out of 72 on each side usually map to the same pins (e.g. PA5 being
13th pin on right ST Morpho connector). This means that single ST Morpho
connector definition will suffice.

Leaving CN7 and CN10 (name of pin headers on Nucleo-64 boards) is confusing
in context of Nucleo-144 boards, since corresponding pin headers are named
CN11 and CN12.

Rename:

 * s/ST_MORPHO_CN7_/ST_MORPHO_L_/
 * s/ST_MORPHO_CN10_/ST_MORPHO_R_/

so that pin identifiers make more sense in context of Nucleo-144 boards.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2023-07-28 08:39:39 +00:00
Johann Fischer aecb1ca2e7 usb: device: move the content of usb_msc.h to implementation file
The usb_msc.h header does not provide any API. The content is only
used by the MSC implementation for the current USB device stack and
is not required for any use of MSC by the application.
The content has no proper namespace and must not be reused for
anything else in (new) USB support.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-07-28 07:09:48 +02:00
Juha Heiskanen d77a657526 mgmt: smp: MCUmgr Client support
MCUmgr client basic implementation for support Image and OS grpup
commands.

Image Group:
* Image state read/write
* Image Upload secondary slot
* Image Erase secondary slot

OS group:
* Reset
* Echo service, disabled by default

Opeartion's are blocked call and cant't call inside worker queue.
IMG and OS need to be SMP client object for transport.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2023-07-27 14:35:43 +02:00
Juha Heiskanen 5797e4241e mgmt: smp: SMP Client enabler
SMP client support for generate request and handling
response message.

Updated SMP transport for send request.

Added API for register SMP transport.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2023-07-27 14:35:43 +02:00
Aaron Massey 43601095b5 emul: sbs_gauge: Return err or unsupported feature
The fuel gauge emulators will attempt to access a 0 pointer when running a
backend emulator function that hasn't been implemented.

Add an explicit runtime check to return -ENOTSUP to signify the emulator
feature is not supported. We do not ASSERT here so we can write tests that
are generic and can run with various emulators that support a variety of
features.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2023-07-27 10:17:37 +02:00
Gerard Marull-Paretas a05371d353 pm: state: allow disabling certain power states
In some platforms it may be desirable to disable certain CPU power
states, for example, because they have extra requirements not available
on all boards/applications. Because `cpu-power-states` are defined at
SoC dts file levels, the only way to achieve that now was by re-defining
`cpu-power-states` property in e.g. a board file. With this patch, one
can now selectively set `status = "disabled";` to any power state and it
will be skipped by the PM subsystem.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-07-26 16:49:00 +02:00
Gerard Marull-Paretas 68452bd4cc pm: device_runtime: allow calling pm_device_runtime_get from ISRs
pm_device_runtime_get() uses a semaphore to protect resources.
pm_device_runtime_get() blocked forever until obtaining the lock, making
it unusable from contexts where blocking is not allowed, e.g. ISRs. With
this patch, we give the chance to use the function from an ISR by not
waiting on the lock and returning -EWOULDBLOCK instead. If device is
suspending (from a previous put_async() operation) the same value is
returned as we can't wait either.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-07-26 16:48:51 +02:00
Wojciech Sipak bff69f5384 drivers: pinctrl: add driver for EOS S3
This adds a new pinctrl driver for Quicklogic EOS S3 SoC

Signed-off-by: Wojciech Sipak <wsipak@antmicro.com>
2023-07-26 14:59:59 +02:00
Johann Fischer 740f2697bc include: usb: revise BOS support header
Hide parts that are not relevant to the application and are
only used internally by the stack. Add minimal documentation.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-07-26 14:37:34 +02:00
Wojciech Sipak 40fa96506b drivers: pinctrl: Add pinctrl driver for Gecko Series 1
This adds a new pinctrl driver for EFM32.

Co-authored-by: Todd Dust <Todd.Dust@silabs.com>
Signed-off-by: Wojciech Sipak <wsipak@antmicro.com>
2023-07-26 14:33:03 +02:00
Florian Grandel d34709121f drivers: cc13xx_cc26xx: pinctrl: support edge detection
Introduces support for SoC-specific input-edge-detect configuration to
the CC13/26xx pinctrl driver.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-26 14:32:53 +02:00
Jamie McCrae 7ca7f5a39c mgmt: mcumgr: Use MCUboot bootutil file instead of outdated copy
Uses the MCUboot bootutil image.h file directly instead of an
outdated copy which resides in the zephyr tree.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-07-26 14:32:20 +02:00
Carlo Caione b7e252c2db shared_multi_heap: Use proper enum instead of int
We have an enum for the memory attr, use that instead of a generic
unsigned int.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-07-26 07:56:39 -04:00
Johann Fischer e6bfc7f868 usb: fix common misspellings in USB support
Fix common misspellings in USB device next and host.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-07-26 10:46:01 +02:00
Johann Fischer 41e9547ead drivers: usb: fix common misspellings in USB drivers
Fix common misspellings in USB drivers.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-07-26 10:46:01 +02:00
Jordan Yates 5be8664e8d pm: device: add driver init helper
Adds a helper function for initializing devices into the expected power
state, through the devices `pm_device_action_cb_t`. This eliminates code
duplication between the init functions and the PM callback.

The expected device states in order of priority are:
 * No power applied to device, `OFF`
 * `zephyr,pm-device-runtime-auto` enabled, `SUSPEND`
 * Otherwise, `ACTIVE`

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-07-26 08:16:44 +00:00
Yong Cong Sin 84b86d9b0c soc: riscv: Add ability to use custom sys_io functions
Add Kconfig RISCV_SOC_HAS_CUSTOM_SYS_IO symbol so that a riscv
SoC can set to specify that it has a custom implementation for
sys_io functions.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-07-26 09:43:59 +02:00
Bartosz Bilas 9ce202e50c lib: json: add helper macro for named array of array
Variant of JSON_OBJ_DESCR_ARRAY_ARRAY that can be used when the
 structure and JSON field names differ.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2023-07-26 09:11:16 +02:00
Pavlo Havrylyuk f4a1d40924 drivers: counter: Add Infineon CAT1 counter driver
Add initial version of Infineon CAT1 counter driver
Add initial version of binding file for Infineon
Add counters to psco6 dtsi
Add external trigger pin that runs counter

Signed-off-by: Pavlo Havrylyuk <pavlo.havrylyuk@infineon.com>
2023-07-26 09:10:31 +02:00
Yong Cong Sin 74f73cd535 arch/common: add 64bit register access functions for 64bit arch
Some 64bit arch SoC happens to have 64bit registers.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-07-25 19:08:48 -04:00
Girisha Dengi 62dbe72cb7 drivers: pm_cpu_ops: Add support for multiple PSCI versions
Each PSCI interface versions have different DT compatible strings
like arm,psci-0.2, arm,psci-1.1 and so on. However, the same driver
can be used for all the versions by adding #define DT_COMPAT for
required version and #undef DT_COMPAT for default version.

Add support for PSCI cold reset, warm reset and cpu-on function IDs.

Signed-off-by: Girisha Dengi <girisha.dengi@intel.com>
Signed-off-by: Navinkumar Balabakthan <navinkumar.balabakthan@intel.com>
2023-07-25 16:58:01 +00:00
Girisha Dengi 6639756fae drivers: reset: Add reset controller for Intel Agilex5 platform
This is Intel's proprietary IP which controls individual module
reset signals. During each system driver initialization, these
reset signals will be used to bring module out of reset state.

Signed-off-by: Navinkumar Balabakthan <navinkumar.balabakthan@intel.com>
Signed-off-by: Girisha Dengi <girisha.dengi@intel.com>
2023-07-25 16:58:01 +00:00
Girisha Dengi 2ca6ffcd79 drivers: clock_control: clock driver for Intel Agilex5 platform
This is Intel's proprietary IP which supply the clock for all the
system peripherals. Clock manager is initialized only one time
during boot up by FSBL (ATF BL2) based on external user settings.

Signed-off-by: Girisha Dengi <girisha.dengi@intel.com>
2023-07-25 16:58:01 +00:00
Marek Matej 5e1b18526c include: dt-bingings: Fix typo
Fix minor typo in esp32s3-gpio-sigmap

Signed-off-by: Marek Matej <marek.matej@espressif.com>
2023-07-25 18:12:33 +02:00
Jordan Yates 2790547cbd init: add sub-priority to internal ordering
Add a sub-priority field to `Z_INIT_ENTRY_SECTION`, which is used to
ensure that multiple drivers running at the same init priority still
run in an order that respects their devicetree dependencies.

This is primarily useful when multiple instances of the same device are
instantiated that can depend on each other, for example power domains
and i2c muxes.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-07-25 15:58:06 +00:00
Jordan Yates b6e03417c7 dts: gen_defines: generate _ORD_STR_SORTABLE
Generate a zero padded variant of `_ORD` that is suitable for use in
linker scripts with the `SORT` property, so that `6` is correctly placed
before `24`, and so on.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-07-25 15:58:06 +00:00
Robert Lubos b2314c8362 net: if: Add functions to loop over IPv4/IPv6 addresses
Add new net_if API functions which allow to loop over all valid
IPv4/IPv6 addresses assigned to the interface and execute a callback
function on them.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-07-25 14:18:54 +02:00
Jordan Yates f0958c62e4 Revert "dts: gen_defines: generate _ORD_STR_SORTABLE"
This reverts commit 9b77681473.
2023-07-25 14:17:11 +02:00
Jordan Yates 109fc87737 Revert "init: add sub-priority to internal ordering"
This reverts commit bb590b5b6e.
2023-07-25 14:17:11 +02:00
Jordan Yates 6edab1f050 Revert "pm: device: add driver init helper"
This reverts commit 84016c1cd3.
2023-07-25 14:17:11 +02:00
Robert Lubos 30382daf88 net: wifi_shell: Add user input validation for SSID and PSK
When parsing user input for "wifi connect" and "wifi ap enable"
commands, the SSID and PSK lengths were not verified. It's better to
detect invalid connect/AP enable parameters early, so that help text can
be printed, instead of letting wifi_mgmt command to fail.

For WIFI_SECURITY_TYPE_SAE, follow the Linux convention of limiting the
size to 128 bytes.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-07-25 14:16:17 +02:00
Carlo Caione 15e84cbfac dts: Move to 'zephyr,memory-attr'
Move to 'zephyr,memory-attr' and use the newly introduced helpers.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-07-25 11:22:10 +02:00
Carlo Caione 7483e43f0c devicetree: Add 'zephyr,memory-attr' and DT helpers
The 'zephyr,memory-region-mpu' property was addede gqas a
convenient way to create and configure MPU regions using information
coming from DT. It has been used a lot since it was introduced so I
guess we can consider it a Zephyr success story ™ .

Unfortunately it has been proved to be a bit limited and with some
important limitations:

1. It was introduced as a property of the compatible
   zephyr,memory-region that is used to create linker regions and
   sections from DT data. This means that we can actually create MPU
   regions only for DT-defined regions and sections.
2. The naming is unfortunate because it is implying that it is used only
   for MPU.
3. It is misplaced being in include/zephyr/linker/devicetree_regions.h
   and still it has nothing to do with the linker at all.
4. It is exporting a function called LINKER_DT_REGION_MPU that again has
   nothing to do with the linker.

Point (1) is also particularly limiting because it is preventing us to
characterize memory regions that are not generated using the
'zephyr,memory-region' compatible, like generic mmio-sram regions.

While we fix all the issues, we also want to extend a bit the range of
usefulness of this property. We are renaming it 'zephyr,memory-attr' and
it is now carrying information about the type of memory the property is
attached to (cacheable, non-cacheable, IO, eXecutable, etc...). The user
can use this property and the DT API coming with it to act on the memory
node it is accompanied by.

We are still providing the DT_MEMORY_ATTR_APPLY() macro that can be used
to create the MPU regions as before, but we are adding also a
DT_MEMORY_ATTR_FOREACH_NODE() macro that can be used to cycle through
the memory nodes and act on those.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-07-25 11:22:10 +02:00
Jonathan Rico 0a8bbbda4a Bluetooth: adv: add USE_NRPA advertising option
Allows the application to force the use of an NRPA.

This is applied regardless of any other roles running (ie scanner) or
advertising type.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Co-authored-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-07-25 10:47:37 +02:00
Benjamin Cabé d379542490 bluetooth: iso: doc: Doxygen cleanup
Added several missing brief descriptions and documented some of the
fields guarded by Kconfig options.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-07-25 10:45:36 +02:00
Benjamin Cabé e5d07588ae drivers: sdhc: doc: Document sdhc_host_caps
Add Doxygen comments for SD Host controller capability flags.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-07-25 10:45:20 +02:00
Benjamin Cabé b88d52e98f bluetooth: doc: Improve sdp.h Doxygen doc
Grouped some defines together, documented service classes and
attributes, and fixed some missing javadoc-style comments.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-07-25 10:45:05 +02:00
Paul Fagerburg 6199ecba69 cbprintf: use type instead of name in sizeof
Using `arg + 0` in sizeof causes problems with `void *`, so use the
type name instead, but make sure it's at least `sizeof(int)` because
the variadic expects a minimum of `int` size. This allows deleting
the specialization for `void *`, which the linker wasn't choosing
reliably anyway.

Signed-off-by: Paul Fagerburg <pfagerburg@google.com>
2023-07-25 09:16:59 +02:00
Gerard Marull-Paretas e4c43e4cc9 pm: power-states node needs to be a child of cpus
This again aligns with Linux.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-07-25 09:16:14 +02:00
Andrzej Kuros d6567fc9e2 net: openthread: multiple cca as ieee802154 extensions interface
This commit adds extenstion interface that extends ieee802154_radio.h
New OT-specific capability, transmit mode and configuration parameter
is added.

Signed-off-by: Andrzej Kuroś <andrzej.kuros@nordicsemi.no>
2023-07-25 09:13:41 +02:00
Andrzej Kuros a04a059ccc net: ieee802154_radio: add attribute getter API
The `attr_get` method is added to the ieee802154_radio to allow
reading of driver specific attributes of given device.

The enum `ieee802154_attr` provides common extension pattern
allowing to extend the attribute set.

Accessor function `ieee802154_radio_attr_get` is provided.

Signed-off-by: Andrzej Kuroś <andrzej.kuros@nordicsemi.no>
2023-07-25 09:13:41 +02:00
Andrzej Kuros 83ad3fdafa net: ieee802154_radio: add extension values
The ieee802154_tx_mode and ieee802154_config_type types are given
values allowing to extend these types elsewhere.

Signed-off-by: Andrzej Kuroś <andrzej.kuros@nordicsemi.no>
2023-07-25 09:13:41 +02:00
Jordan Yates 84016c1cd3 pm: device: add driver init helper
Adds a helper function for initializing devices into the expected power
state, through the devices `pm_device_action_cb_t`. This eliminates code
duplication between the init functions and the PM callback.

The expected device states in order of priority are:
 * No power applied to device, `OFF`
 * `zephyr,pm-device-runtime-auto` enabled, `SUSPEND`
 * Otherwise, `ACTIVE`

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-07-25 09:13:16 +02:00
Jordan Yates bb590b5b6e init: add sub-priority to internal ordering
Add a sub-priority field to `Z_INIT_ENTRY_SECTION`, which is used to
ensure that multiple drivers running at the same init priority still
run in an order that respects their devicetree dependencies.

This is primarily useful when multiple instances of the same device are
instantiated that can depend on each other, for example power domains
and i2c muxes.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-07-25 09:13:16 +02:00
Jordan Yates 9b77681473 dts: gen_defines: generate _ORD_STR_SORTABLE
Generate a zero padded variant of `_ORD` that is suitable for use in
linker scripts with the `SORT` property, so that `6` is correctly placed
before `24`, and so on.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-07-25 09:13:16 +02:00
Nicolas Pitre a7b3584745 subsys/zbus: move to timepoint API
Remove sys_clock_timeout_end_calc() usage as well as custom
_zbus_timeout_remainder().

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2023-07-25 09:12:26 +02:00
Nicolas Pitre 531aa5786d drivers: move to timepoint API
Remove sys_clock_timeout_end_calc() usage.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2023-07-25 09:12:26 +02:00