Commit graph

15409 commits

Author SHA1 Message Date
Dawid Niedzwiecki
0a17aa8605 mgmt: ec_host_cmd: add autoinit config
Add a separate config to enable autoinitialization of the host command
subsystem, called by the chosen backend.

It allows setting the chosen backend without autoinit.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-05-18 09:46:37 +02:00
Dawid Niedzwiecki
3d8a5c7e5c mgmt: ec_host_cmd: make host command structure available
The application code may need inside information about the host command
e.g. the thread id. Add a function that returns the main host command
structure which contains such data.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-05-18 09:46:37 +02:00
Riccardo Paolo Bestetti
5db08ca3d8 doc: flash: fix direction for flash_area_write src parameter
Change the `src` parameter direction from 'out' to 'in' for the
flash_area_write function, since the src data buffer is the data source
for the flash write and thus an input parameter

Fixes #57996

Signed-off-by: Riccardo Paolo Bestetti <pbl@bestov.io>
2023-05-17 19:54:51 +02:00
Benjamin Cabé
d793764cfa doc: fix NUMICRO_PINMUX bit field documentation
Fix Doxygen documentation by moving @brief just before NUMICRO_PINMUX
definition.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-05-17 09:49:24 +02:00
Benjamin Cabé
dfd0eedf39 doc: fix Doxygen doc for LOG2(x)
Param x was documented twice.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-05-17 09:49:24 +02:00
Benjamin Cabé
984745950a doc: add missing param in DT_INST_PIO_PIN_BY_NAME
Add missing '@param name' for DT_INST_PIO_PIN_BY_NAME macro.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-05-17 09:49:24 +02:00
Benjamin Cabé
c28b5d3fca doc: fix STM32_CLOCK bit field documentation
Fix Doxygen documentation by moving @brief just before STM32_CLOCK
definition.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-05-17 09:49:24 +02:00
Krzysztof Chruscinski
9bf333aa8d logging: Fix user space crash when runtime filtering is on
Logging module data (including filters) are not accessible by
the user space. Macro for creating logs where creating local
variable with filters before checking is we are in the user
context. It was not used in that case but creating variable
was violating access writes that resulted in failure.

Removing variable creation and using filters directly in the
if clause but after checking condition that it is not the
user context. With this approach data is accessed only in
the kernel mode.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2023-05-16 20:15:06 -04:00
Manimaran A
f8c8ee65be drivers: pinctrl: Microchip XEC PINCTRL glitch fix
Glitches were observed if a GPIO pin was configured by
ROM to a non-default state and then Zephyr PINCTRL
reconfigured the pin. The fix involves using the correct
PINCTRL YAML output enable and state flags. Reading the
current spin state and reflecting into new pin configuration
if the pin is output and the drive low/high properties are
not present. We also take advantage of GPIO hardware reflecing
the alternate output value in the parallel output bit before
enabling parallel output mode. Interpret boolean flags with
both enable and disable as do not touch if neither flag is
present. We give precedence to enable over disable if both
flags mistakenly appear. Note, PINCTRL always clears the
GPIO control input pad disable bit.

Signed-off-by: Manimaran A <manimaran.a@microchip.com>
2023-05-16 18:52:44 -04:00
Martí Bolívar
0c29e07e30 devicetree: better DT_PROP_BY_IDX()/DT_FOREACH_PROP_ELEM() support
Support use of these macros with properties of type phandle and
string by allowing iterating over:

- a phandle as if it were a phandles of length 1, for convenience and
  consistency with our ability to take its length (and getting 1)

- the non-null characters in a string: we exclude the null for
  consistency with the return value of DT_PROP_LEN() on string
  properties, which, like strlen(), does not include the null

With this and a previous patch expanding the usage of DT_PROP_LEN(),
there is now a relationship between being able to take a property's
logical length with DT_PROP_LEN() and being able to iterate over its
logical elements with DT_FOREACH_PROP_ELEM(). Explain this in the
documentation.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-05-16 18:14:26 +02:00
Martí Bolívar
8aa83f6ae8 devicetree: support DT_PROP_LEN() on phandle and string
It will be convenient to treat these respectively as degenerate cases
of 'phandles' and 'string-array'. Add support for this and regression
tests. (There's nothing to do in the case of 'phandle' beyond
documenting the guarantee.)

For the record, the other DT_PROP_LEN() tests for each type are in:

  type            test case              property
  ------------    --------------------   ------------
  array           test_arrays            a
  string-array    test_path_props        compatible
  uint8-array     test_arrays            b
  phandles        test_phandles          phs
  phandle-array   test_phandles          pha-gpios
  phandle         test_phandles          ph

Update docstrings and fix some issues in them.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-05-16 18:14:26 +02:00
Benjamin Cabé
0b47a714b0 usb-c: Remove duplicate typedefs
Remove duplicate declaration for policy_cb_get_src_rp_t and
policy_cb_src_en_t typedefs.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-05-16 11:42:24 -04:00
Krishna T
10f3ca2e1d net: wifi: Add an event for disconnect complete
This is needed for applications that rely on WPA supplicant being
in disconnected state before issue subsequent commands (e.g., issue scan
immediately after disconnect fails, until disconnect is completed).

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-05-16 13:21:10 +02:00
Wojciech Slenska
9c3047e097 net: net_pkt: Fix cpp compatibility
Assignment uint8_t to enum without casting, makes error in
cpp compiler.

Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
2023-05-16 13:21:02 +02:00
Madhurima Paruchuri
f8d9cd67c8 drivers: sbs_gauge: Reformat the changes
Reformat the files touched by code changes using clang

Signed-off-by: Madhurima Paruchuri <mparuchuri@google.com>
2023-05-16 12:07:14 +02:00
Madhurima Paruchuri
2432c94186 drivers: sbs_gauge: Add support for Alarm properties
RemainingCapacityAlarm(r/w) and RemainingTimeAlarm(r/w)

Signed-off-by: Madhurima Paruchuri <mparuchuri@google.com>
2023-05-16 12:07:14 +02:00
Jordan Yates
b6fb701f89 devicetree: add DT_ENUM_HAS_VALUE
Add a macro for checking if an enumeration matches a given value.
This enables code to directly check whether a string enumeration is a
specific value, without needing to construct an intermediate variable,
and without checking against a index value which may change.

```
/* Enables this */
if (DT_INST_ENUM_HAS_VALUE(0, power_amplifier_output, rfo_hp)) {}
/* Instead of this */
if (DT_INST_ENUM_IDX(0, power_amplifier_output) == 0) {}
```

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-05-15 09:03:37 -07:00
Yuval Peress
7153157f88 rtio: Add support for multishot reads
- Introduce multishot reads which remain on the SQ until canceled

Signed-off-by: Yuval Peress <peress@google.com>
2023-05-15 10:10:12 -04:00
Yuval Peress
2c30920b40 rtio: add cancel support
- Add a new API `rtio_sqe_cancel` to attempt canceling a queued SQE
- Add a new syscall `rtio_sqe_copy_in_get_handles` which allows getting
  back the SQE handles generated by the copy_in operation so that they
  can be canceled.

Signed-off-by: Yuval Peress <peress@google.com>
2023-05-15 10:10:12 -04:00
Yuval Peress
66328f41a7 rtio: Clear sqe data before prep
Add a memset to clear out the sqe prior to running any of the
rtio_sqe_prep_* functions.

Signed-off-by: Yuval Peress <peress@google.com>
2023-05-15 10:10:12 -04:00
Gerard Marull-Paretas
5dd1e8d145 toolchain: add STRUCT_SECTION_ITERABLE_ARRAY
Add a new utility macro to define an array of structs that should be
part of an iterable section.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-15 18:52:07 +09:00
Jamie McCrae
f59b857f6a mgmt: mcumgr: smp: Convert functions to function pointer array
Converts the list of functions for registering an MCUmgr SMP
transport from function arguments to a single list which contains
the function pointers.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-15 10:23:35 +02:00
Jamie McCrae
6f5b974949 mgmt: mcumgr: Add command result codes (ret)
Adds a new map to responses that command handlers can use to
return result codes of functions themselves, unrelated to SMP
error codes. This is achieved by adding an optional "ret" map
which contains a 16-bit "group" and 16-bit "rc" error code,
this map will not be included if the "ret rc" is 0 (which
implies success).

In order to allow this, a new version of the protocol has been
which can be indicated for use by setting a bit in the header.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-15 09:27:16 +02:00
Lukas Woodtli
12de4018ef net: coap: Add function for getting BLOCK1 option
The function gets the the BLOCK1 option from a received message
and extracts the block number, block size and has-more flag from
it.

Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
2023-05-15 09:18:09 +02:00
Lukas Woodtli
db480169a0 net: coap: Add function for inserting block option for sending
The function adds a block option to a CoAP message. If the message
is a request the BLOCK1 option is added. Otherwise (response) the
BLOCK2 option is added.

Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
2023-05-15 09:18:09 +02:00
Armin Brauns
d2abe2b661 include: net: net_if: add NULL checks
This makes sure NULL iface pointers are caught before they're dereferenced
to garbage.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2023-05-15 09:17:11 +02:00
Grant Ramsay
58d41373cd arch: arm64: cache: Add ARG_UNUSED to unused arguments
The unused arguments were causing warnings

Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
2023-05-14 18:17:33 -04:00
Grant Ramsay
244f4f2034 drivers: pcie: Enable filtering PCIe devices by class-rev
This allows finding the correct PCIe device when multiple devices
have the same vendor-id/device-id but differ in the class-rev register

Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
2023-05-14 18:17:33 -04:00
Grant Ramsay
4ed404a27f drivers: virtualization: Add interface for ivshmem-v2
ivshmem-v2 is primarily used for IPC in the Jailhouse hypervisor

Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
2023-05-14 18:17:33 -04:00
Armin Brauns
0bc342fbbd kernel: fix buffer overflow from incorrect K_MSGQ_DEFINE definition
Without these parentheses, specifying a q_max_msgs of e.g.
`MY_DEFAULT_QUEUESIZE+1` would result in a buffer of size
(1 element + MY_DEFAULT_QUEUESIZE bytes).

This would then lead to an unbounded buffer overflow because the queue
never reaches the exact (offset by MY_DEFAULT_QUEUESIZE bytes)
`buffer_end` and just keeps writing.

Additionally, add asserts to make sure this can't happen again.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2023-05-12 13:39:10 -04:00
Emil Gydesen
ec1b2a1844 Bluetooth: Audio: PAC discover by UUID added
Instead of using the read by UUID, we do a "proper"
discover by UUID. The reason for this is that read by
UUID is not mandatory in the BAP specs, and that we need
to do a long read on the PAC records anyhow, and that
cannot be done with the read by type/UUID.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-12 15:29:17 +02:00
Ajay Parida
e70bb70651 net: wifi_mgmt: Support to provide raw scan data
Support to provide raw beacon and probe response data
to registered application.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-05-12 10:50:21 +00:00
Flavio Ceolin
87bac4481b arch: xtensa: Fix cpluplus guard
Move the cpluplus guard to the end of the header.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-05-12 06:01:46 -04:00
Flavio Ceolin
3e2f3828a0 arch: xtensa: Lock vecbase register helper
Lock vecbase register after the HW initialization. After this
VECBASE address can change only after reset.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-05-12 06:01:46 -04:00
Gerard Marull-Paretas
d0e58ad0a6 device: use iterable sections
Use iterable sections to handle devices list. This simplifies devices
implementation by using standard APIs.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-12 12:01:10 +02:00
Gerard Marull-Paretas
ab7621340f init: add INIT_LEVEL_ORD
This patch introduces a new helper: INIT_LEVEL_ORD, which given a level
token, e.g. EARLY, PRE_KERNEL_1, etc. returns its ordinal. This can be
useful for sorting purposes, as level tokens do not result in the right
initialization order if sorted, e.g. POST_KERNEL < APPLICATION, but P >
A.

The implementation uses a bit of macrobatics to achieve this. First, we
define some helpers Z_INIT_XX_XX that evaluate to 1, and where XX
correspond to init levels. With them, we can perform equality checks
like this:

COND_CODE_1(Z_INIT_XX_##level, (VAL_IF_EXISTS), (VAL_IF_NOT_EXISTS))

It's a bit obscure, but it seems to work.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-12 12:01:10 +02:00
Gerard Marull-Paretas
b8efac92e0 linker: add ITERABLE_SECTION_RA|OM_NUMERIC
In some cases, like devices, it is necessary to sort numerically, that
is, sort 10 before 2. Add a new helper function to do that, up to 2
numeric digits.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-12 12:01:10 +02:00
Gerard Marull-Paretas
f0db892d7b toolchain: add trailing _ to iterable section name
Add a trailing _ to the section iterable name. This is useful, for
example, to implement numeric sorting like this:

SORT(.z_device_LEVEL_?_)
SORT(.z_device_LEVEL_??_)

Without the trailing _ it would not be possible to use the ?? wildcard
without triggering into trigraphs issues, because linker-defs.h header
is included in C files as well.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-12 12:01:10 +02:00
Gerard Marull-Paretas
aae0fe8dab toolchain: add STRUCT_SECTION_ITERABLE_NAMED
Add a new API that allows to customize the name of an iterable section.
This allows to influence how section elements are sorted.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-12 12:01:10 +02:00
Gerard Marull-Paretas
7525a551cf toolchain: add STRUCT_SECTION_START|END helpers
Even though they are just wrappers around TYPE_SECTION_START|END, it
allows using the STRUCT_SECTION* API namespace everywhere when working
with struct-based iterable sections.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-12 12:01:10 +02:00
Dominik Ermel
2244974dd6 mgmt/mcumgr: Add img_mgmt_active_slot() and img_mgmt_active_image()
The commit adds img_mgmt_active_slot() which allows to get
active (running) slot for given application image.
Added img_mgmt_active_image() allows to get number of image running
on current MCU core.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-05-12 10:00:23 +02:00
Evgeniy Paltsev
4e81b0e081 linker: restore CREATE_OBJ_LEVEL wildcard pattern
The 2c98a001a4 (#57597) cause
regression with ARC MWDT toolchain.

Restore CREATE_OBJ_LEVEL wildcard pattern to be suitable for
both GNU and MWDT toolchains. We return asterisk symbol which
was dropped in 2c98a001a4
(but keep rest of the changes to wildcard pattern).

Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
2023-05-11 19:44:37 +02:00
Benedikt Schmidt
ecac441171 drivers: gpio: implement GPIOs in ADS114S08
Implement GPIO exander within the ADC ADS114S08.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-05-11 12:04:15 -04:00
Ajay Parida
f519b4d6f2 net: shell: Fix CI warning implicit declaration
Fixes "implicit declaration of function ARRAY_SIZE"
observed during CI.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-05-11 13:29:38 +02:00
Georges Oates_Larsen
62168b659e net: conn_mgr: connect/disconnect adjustments
Rather than raise error on connect if iface is down, just take the iface
up.

Rather than raise error on disconnect if iface is down, just ignore the
disconnection request.

Adjust tests and documentation accordingly.

This should make the API easier to use for applications and is more in
line with the original L2 agnostic connectivity RFC.

Also replace some instances of net_if_flag_is_set with
net_if_is_admin_up, which is cleaner and identical in function.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-05-11 12:15:44 +02:00
Georges Oates_Larsen
b6897c211a net: conn_mgr: Ignore ifaces and L2s
Adds a flag to allow ifaces and L2s to be ignored.

This is so that applictions have better control over what ifaces they
want connectivity management for.

Enabling the flag forces conn_mgr to consider the iface
unready.

Also increase NET_CONNECTION_MANAGER_PRIORITY default value from 0 to 1
so that applications can register SYS_INIT callbacks that fire just
before conn_mgr initializes. This allows ignored ifaces to be configured
before conn_mgr starts, if needed.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-05-11 12:15:44 +02:00
Georges Oates_Larsen
716c19f7ef net: conn_mgr: Reorganize files
Since conn_mgr is a subsystem rather than a library, relocate it
directly into subsys/net rather than subsys/net/lib/

Rename header files to better match their function.

Remove net_ prefix from conn_mgr types, API, and files, since it is
unnecessary.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-05-11 12:15:44 +02:00
Daniel DeGrasse
7c228c9042 drivers: display: stm32_ltdc: Update LTDC driver to use LCDIF binding
Update LTDC driver to use LCDIF bindings, to simplify bindings
between LCD interface controller IP blocks.

Boards supporting the LTDC are also updated to use the properties as
declared by the new lcd controller binding

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2023-05-11 10:04:24 +02:00
Daniel DeGrasse
eed6e893cd dts: bindings: add common LCD interface binding
Add common LCD interface binding. This binding captures the
following properties, which are shared between multiple LCD interface
IP blocks:
- VSYNC/HSYNC pulse width
- Vertical/Horizontal front and back porch
- HSYNC,VSYNC,data enable, and pixel clock polarity flags
- pixel clock frequency

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2023-05-11 10:04:24 +02:00
Robert Lubos
ff0fd2d7a7 net: iface: Improve thread safety of net_if_ipv*_maddr_* functions
Provide an extra struct net_if * iface parameter to
net_if_ipv*_maddr_join/leave functions, so that the corresponding
interface context, the mcast address belong to, can be locked for the
operation.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-05-10 11:06:15 +02:00