Commit graph

1232 commits

Author SHA1 Message Date
Krishna T fadb1fd168 net: wifi: Add support for regulatory domain configuration
Wi-Fi bands are regulated by a governing body depending on operating
country, add support for the user to provide a country of operation as a
hint to the Wi-Fi chipset.

Ideally if the chipset supports this is all handled internally, in that
case "get" is useful but for testing and other usecases add a "set" as
well, similar to "iw reg set" or "country_code=" configuration in
hostapd/wpa_supplicant in Linux world.

This add a new offload API operation "reg_domain" that can be used to
either get or set the regulatory information.

The validation is left to the underlying chipset, shell only does basic
validation, (XY/00).

This is just a regulatory hint to the chipset, there could be other
regulatory hints e.g., beacon that can override this configuration, so,
an additional option to force this setting despite other hints is also
given for testing purposes.

FYI, the standard database used is [1].

[1] - https://git.kernel.org/pub/scm/linux/kernel/git/sforshee/wireless-regdb.git/tree/db.txt

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-01-13 13:37:14 +00:00
Szymon Czapracki 35bd427927 Bluetooth: audio: Add configurable PACS supported contexts
Add the ability to change supported contexts in PACS.
Enhance the context command in the shell module to make it configurable.

Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
2023-01-13 13:47:19 +01:00
Pascal Brogle 136f032058 net: lwm2m: fix max path size
in various places the path can contain leading slash

Signed-off-by: Pascal Brogle <pascal.brogle@husqvarnagroup.com>
2023-01-13 12:02:07 +00:00
Pascal Brogle b6bc324a1d net: lwm2m: rename path size define
Rename max path constant to prevent string length vs data size confusion

Signed-off-by: Pascal Brogle <pascal.brogle@husqvarnagroup.com>
2023-01-13 12:02:07 +00:00
YuLong Yao e5d35910f4 drivers: pinctrl: gd32: add gd32a50x support
set port speed for `gd32a50x`

Signed-off-by: YuLong Yao <feilongphone@gmail.com>
2023-01-12 21:45:38 +01:00
YuLong Yao bfe085070b dt-bindings: gd32: reset: add support for gd32a50x
add support for gd32a50x

Signed-off-by: YuLong Yao <feilongphone@gmail.com>
2023-01-12 21:45:38 +01:00
YuLong Yao 4703d8efe5 dt-bindings: clock: gd32: add gd32a50x series support
add gd32a50x series support

Signed-off-by: YuLong Yao <feilongphone@gmail.com>
2023-01-12 21:45:38 +01:00
Lucas Tamborrino 17fbdc55b5 drivers: dma: esp32c3: add gdma driver
Add GDMA driver for esp32c3.

Signed-off-by: Lucas Tamborrino <lucas.tamborrino@espressif.com>
2023-01-12 19:09:01 +01:00
Guillaume Lager e67e6d5af6 mcuboot: Remove public dependency on bootutil
BOOT_MAGIC_SZ and BOOT_MAX_ALIGN were used in the header without
including bootutil/bootutil_public.h. This change remove the need of
the inclusion by making the dependency private.
Fixes #52095

Signed-off-by: Guillaume Lager <g.lager@innoseis.com>
2023-01-12 19:08:23 +01:00
Krishna T 7952197a89 net: shell: Add MAC address validation
Validate MAC address before setting, add new helper APIs to cover all
cases.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-01-12 19:07:44 +01:00
Gerard Marull-Paretas 8c73db666c drivers: regulator: npm1100: add initial support
While nPM1100 is to be operated in fixed configuration for some
applications, it has some degree of configuration via GPIOs. For
example, mode (auto/PWM) can be configured via MODE pin. VBUS current
can also be adjusted using ISET pin, even though there is no API yet to
limit the PMIC input current.

This patch adds a new regulator class driver for nPM1100 PMIC, so that
it can be used with the standard regulator API when needed.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-01-12 19:07:05 +01:00
Erwan Gouriou 6cbb3f5eec drivers: clock_control: stm32: Fixed domain clock configuration
In some case, we may need to describe a domain clock for a device
while there is no way to configure it (ex: USB clock set on PLL_Q output
on F405 devices > It is not selectable).
Then, configuring a device clock domain in the clock_control driver
will allow to retrieve its subsys rate.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2023-01-12 12:46:53 +01:00
Erwan Gouriou 7c147ef552 include: dt-bindings: stm32f4_clock.h: Add DCKCFGR registers
Add f4 binding files to provide DCKCFGR registers description
to enable clock selection for F410/F427/F446 variant lines

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2023-01-12 12:46:53 +01:00
Siddharth Chandrasekaran 73809472f8 mgmt/osdp: Add support for event delivery and notifications
The CP app sends PD a "command" and the PD responds to it. Some times,
the PD has something that it wants to tell the PD which it does so in
response to POLL command. Both CP and PD apps need a way to exchange
these info over the OSDP bus. To archive this we will introduce what are
called "events" that allow the PD app to enqueue and CP app to get
notified.

This is analogous to the incumbent "commands" abstraction where, the CP
app enqueues a command and the PD app gets notified of it.

Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2023-01-12 12:04:11 +01:00
Jordan Yates 2684c7ca78 arch: arm: aarch32: define arch specific fatal errors
Define aarch32 specific fatal errors.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-01-12 10:01:05 +01:00
Jordan Yates 8113d1c67d fatal_types: define start of arch specific faults
Define the index where arch specific faults start. This is a specific
number to avoid arch specific fault values changing each time a new
generic fault is added.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-01-12 10:01:05 +01:00
Jordan Yates 581e5375ff fatal: move enum definition to dedicated header
This allows enum values to be referenced in architecture `arch.h` files
without circular dependencies.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-01-12 10:01:05 +01:00
Jamie McCrae d363781c94 gpio: Fix GPIO_DT_SPEC_INST_GET_BY_IDX_OR macro
Fixes the macro for getting the instance of a device tree GPIO
with index or default value.

Signed-off-by: Jamie McCrae <spam@helper3000.net>
2023-01-12 10:00:24 +01:00
Johann Fischer 00adb2a539 drivers: udc: remove no more required pending state flag
Pending state flag was only used by the UDC nRF USBD driver.
With the introduction of busy state flag it is no longer needed
and can be removed.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-01-11 17:44:50 +01:00
Johann Fischer baef621bed drivers: udc: add helper functions to set/check endpoint busy state
Add helper functions to set and check endpoint busy state.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-01-11 17:44:50 +01:00
Henrik Brix Andersen 1147d73f9e drivers: can: fake: fix header guards
Change the fake CAN driver headers guards to match the updated file
location.

Fixes: f30a5969d0

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-01-11 09:40:43 +01:00
Carlo Caione b23c02f4e0 cache: Fix wrong defines
Fix wrong DCACHE/ICACHE defines.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-01-10 18:22:32 -05:00
Nick Ward 4ed49cf99b net: openthread: Depreciate openthread_set_state_changed_cb API
Will be replaced by APIs:
 - openthread_state_changed_cb_register
 - openthread_state_changed_cb_unregister

Signed-off-by: Nick Ward <nick.ward@ftpsolutions.com.au>
2023-01-10 13:29:15 +01:00
Nick Ward 583545b662 net: openthread: Add state change callback list
Add a new callback list structure for state change information.

These APIs are meant to eventually replace the single callback API
provided by openthread_set_state_changed_cb().

This will allow multiple users to gain information about
OpenThread stage changes.

Note CONFIG_OPENTHREAD_MAX_STATECHANGE_HANDLERS
with OpenThread's otSetStateChangedCallback() API can also be
used to enable registration of multiple callbacks of this type but this
cannot be modified if a certified OpenThread binary is used in the
build.

Signed-off-by: Nick Ward <nick.ward@ftpsolutions.com.au>
2023-01-10 13:29:15 +01:00
Pirun Lee 1e6f36cca7 Bluetooth: OTS - Add Calculate Checksum support
OTS add Calculate checksum feature support.
OTS client add object calculate checksum function.

Signed-off-by: Pirun Lee <pirun.lee@nordicsemi.no>
2023-01-10 09:59:36 +01:00
Krishna T d796f23e0e net: wifi_mgmt: Add support for power save configuration
Add support for configuring power-save in Wi-Fi chipsets, supports
Legacy, WMM and TWT.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-01-10 09:52:11 +01:00
TOKITA Hiroshi 8eff4b6036 include: sys: util_macro: add IS_BIT_MASK()/IS_SHIFTED_BIT_MASK()
Add IS_BIT_MASK() macro for determining whether a value is set bits
continuously from the LSB.
This macro is not dependent on bit-width and works in contrast to
BIT_MASK() and BIT64_MASK().
IS_SHIFTED_BIT_MASK() is a version of IS_BIT_MASK() that allows setting
the start bit of continuous bits.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-01-10 09:23:14 +01:00
Jamie McCrae 1bd05df1a9 doc: mgmt: mcumgr: callback: Improve documentation
Improves the documentation when OR'ing multiple events of the same
group together to describe that this is only supported for events
that are part of the same group, giving example of correct and
incorrect usage.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-01-09 17:36:04 -08:00
Chris Friedt 90c558f581 posix: sys/stat.h: declare missing types in sys/stat.h
After adopting the `<sys/stat.h>` header from picolibc, there is
a possibility that the following types are not defined.

```cpp
typedef int dev_t;
typedef int ino_t;
typedef unsigned short nlink_t;
typedef unsigned short uid_t;
typedef unsigned short gid_t;
typedef unsigned long blksize_t;
typedef unsigned long blkcnt_t;
```

Of the above missing types, the oonly ones that are used today
in Zephyr are `blksize_t` and `blkcnt_t`.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-10 09:02:21 +09:00
Chris Friedt ee03dc833f posix: sys/stat.h: format for coding style compliance
The original format of this file as imported from PicoLibC was not
compatible with Zephyr's coding stytle. This change fixes
compliance issues listed below:

- whitespace formatting
- block comment formatting
- named parameters

Introduction of new typedefs should be considered false-negatives
as these are existing standard POSIX types.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-10 09:02:21 +09:00
Chris Friedt 28726d6f0a posix: sys/stat.h: adopt the sys/stat.h header from picolibc
This may be getting ahead of the curve a bit, but here we adopt
the `<sys/stat.h>` header from picolibc. It is mostly the same
as that of newlib but the picolibc variant seemed to be slightly
more "inclusive".

Removed the `<_ansi.h>` include.

The commit immediately following this declares a few missing types
only if they are not already declared.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-10 09:02:21 +09:00
Chris Friedt addbec9591 libc: minimal: stdio.h: define SEEK_SET, SEEK_CUR, SEEK_END
The `SEEK_SET`, `SEEK_CUR`, and `SEEK_END` constants are defined
in `<stdio.h>`, not in `<sys/stat.h>`.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-10 09:02:21 +09:00
Chris Friedt a89d68db20 posix: sys/stat.h: move O_ACCMODE, RD WRONLY, RDWR to fcntl.h
Previously, `<sys/stat.h>` was declaring the following constants
which should be declared in `<fcntl.h>` according to POSIX.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-10 09:02:21 +09:00
Chris Friedt 194e610f9f posix: fcntl.h: define constants to agree with picolibc
PicoLibC defines `O_CREAT` (really `_FCREAT`) as 0x0040.

Otherwise, these constants are identical.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-10 09:02:21 +09:00
Chris Friedt 0697c7b3fe posix: headers: harmonize remaining types with newlib
The remaining types that needed to be harmonized between
Newlib and Zephyr's POSIX definitions are:

* `struct sched_param`
  - don't re-define if using minimal libc
* `pthread_attr_t`
  - convert to `struct pthread_attr`
  - define type if using minimal libc
  - assert acceptible object size
* `pthread_mutexattr_t`
  - convert to `struct pthread_mutexattr`
  - define type if using minimal libc
  - assert acceptible object size
* `pthred_condattr_t`
  - convert to `struct pthread_condattr`
  - define type if using minimal libc
  - assert acceptible object size
* `pthread_once_t`
  - adopt newlib definition
  - define type if using minimal libc
Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-10 09:02:21 +09:00
Chris Friedt 32ae2bf3cd include: posix: signal: fix header guard
`POSIX__SIGNAL_H` is not representative of the filename.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-10 09:02:21 +09:00
Chris Friedt 7921ed8bb9 include: posix: types: fix name on header guard
Just to match the filename remove the `SYS_` from
`POSIX_SYS_TYPES_H_`.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-10 09:02:21 +09:00
Chris Friedt 7be31813da posix: sched: use newlib-compatible SCHED_RR FIFO definitions
Zephyr's `SCHED_RR` and `SCHED_FIFO` definitions were slightly
different than Newlib's. Additionally, the test had hard-coded
magic numbers instead of using symbolic values.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-10 09:02:21 +09:00
Chris Friedt e71dd72b94 posix: pthread_attr_t: match size of newlib variant
Part of the POSIX Roadmap for LTSv3 is to adopt POSIX-related
headers from Newlib. The strategy to get there is to first make
the existing POSIX subsystem work in the presence of Newlib POSIX
types.

Part of the strategy involved adopting Newlib's `uint32_t`
abstraction for some Zephyr POSIX types.

However, some types are declared as structures. Luckily, the API
only passes those structures around in the form of pointers, and
the API only mutates those structures via global functions. With
that, we are able to alias Newlib POSIX types as Zephyr POSIX
structures.

One of the caveats to doing that without introducing stack
corruption is to ensure that the Zephyr POSIX types are <= their
respective Newlib counterparts.

There was only one Zephyr structure for which that requirement
did not hold: `pthread_attr_t`. We left `pthread_attr_t` as the
Newlib definition, and named the Zephyr variant
`struct pthread_attr`.

On 32-bit machines, both structures were 32-bytes.

```
sizeof(pthread_attr_t): 32 sizeof(struct pthread_attr): 32
```

However, on 64-bit machines, `pthread_attr_t` was 40 bytes, while
`struct pthread_attr` was 48 bytes.

```
sizeof(pthread_attr_t): 40 sizeof(struct pthread_attr): 48
```

That triggered the following assertion.

```
BUILD_ASSERT(sizeof(pthread_attr_t)
  >= sizeof(struct pthread_attr));
```

The `stacksize` field was subsequently changed from `size_t` to
`uint32_t`, and that reduced the latter to 40 bytes as well,
solving the last real problem.

```
sizeof(pthread_attr_t): 40 sizeof(struct pthread_attr): 40
```

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-10 09:02:21 +09:00
Chris Friedt ecb82784b7 posix: newlib compatible PTHREAD_CREATE_DETACHED and JOINABLE
Define `PTHREAD_CREATE_DETACHED` and
`PTHREAD_CREATE_JOINABLE` to be compatible with the Newlib
definitions.

This is a temporary workaround for #51211 until Newlib
headers are pulled in.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-10 09:02:21 +09:00
Chris Friedt 88e0f11e55 posix: fcntl: declare fcntl(2) in fcntl.h
The `fcntl.h` header should declare the `fcntl()` function,
according to the spec.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-10 09:02:21 +09:00
Chris Friedt 8659e2f69e libc: minimal: include: move fcntl.h to posix
The `fcntl.h` header has never been a part of ISO C so move it to
`include/zephyr/posix`.

To ensure a smooth migration, a header was left in
`lib/libc/minimal/include` that prints a deprecation warning.

Users should either include `<zephyr/posix/fcntl.h>` or switch to
`CONFIG_POSIX_API=y`.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-10 09:02:21 +09:00
Chris Friedt 6f4e96bc24 libc: minimal: include: move sys/stat.h to posix
The `sys/stat.h` header has never been a part of ISO C so move it
to `zephyr/include/posix/sys/`.

To ensure a smooth migration, leave a stub header in
`lib/libc/minimal/include/sys/` that prints a deprecation warning
suggesting developers either include `<zephyr/posix/sys/stat.h>`
or use `CONFIG_POSIX_API=y`.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-10 09:02:21 +09:00
Carlo Caione 43a61329cc riscv: Allow SOC to override arch_irq_{lock,unlock,unlocked}
RISC-V has a modular design. Some hardware with a custom interrupt
controller needs a bit more work to lock / unlock IRQs.

Account for this hardware by introducing a set of new
z_soc_irq_* functions that can override the default behaviour.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-01-09 19:21:39 +01:00
Gerard Marull-Paretas 7feb008c85 drivers: regulator: common: allow to specify on by default
Some regulators are enabled by default, however, such condition cannot
be captured now by the regulator driver API. Refactor
regulator_common_init_enable to regulator_common_init (enable removed,
as it also sets mode) and add a new argument to specify such condition.
With this change, regulator_disable() and regulator_is_enabled() work as
expected without a first call to regulator_enable().

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-01-09 16:19:09 +00:00
Erwan Gouriou 079470be02 drivers: clock_control: stm32: Fix HSI48 oversights
Take into account HSI48 when computing susbys rate.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2023-01-09 14:01:28 +00:00
Mark Watson 9de0a8bf55 bluetooth: added uuids for TMAS and PBA.
Added UUIDs for Telephony and Media Audio Service
(0x1855) and Public Broadcast Announcement (0x1856).

Fixes #53488

Signed-off-by: Mark Watson <markus.c.watson@gmail.com>
2023-01-09 12:19:45 +01:00
Carlo Caione c13d23a43e riscv: Add support for hardware stacking / unstacking
Some RISC-V SoCs implement a mechanism for hardware supported stacking /
unstacking of registers during ISR / exceptions. What happens is that on
ISR / exception entry part of the context is automatically saved by the
hardware on the stack without software intervention, and the same part
of the context is restored by the hardware usually on mret.

This is currently not yet supported by Zephyr, where the full context
must be saved by software in the full fledged ESF. This patcheset is
trying to address exactly this case.

At least three things are needed to support in a general fashion this
problem: (1) a way to store in software only the part of the ESF not
already stacked by hardware, (2) a way to restore in software only the
part of the context that is not going to be restored by hardware and (3)
a way to define a custom ESF.

Point (3) is important because the full ESF frame is now composed by a
custom part depending on the hardware (that can choose which register to
stack / unstack and the order they are saved onto the stack) and a part
defined in software for the remaining part of the context.

In this patch a new CONFIG_RISCV_SOC_HAS_ISR_STACKING is introduced that
enables the code path supporting the three points by the mean of three
macros that must be implemented by the user in a soc_stacking.h file:
SOC_ISR_SW_STACKING, SOC_ISR_SW_UNSTACKING and SOC_ISR_STACKING_ESF
(refer to the symbol help for more details).

This is an example of soc_isr_stacking.h for an hardware that doesn't do
any hardware stacking / unstacking but everything is managed in
software:

    #ifndef __SOC_ISR_STACKING
    #define __SOC_ISR_STACKING

    #if !defined(_ASMLANGUAGE)

    #define SOC_ISR_STACKING_ESF_DECLARE \
    	struct __esf { \
    		unsigned long ra; \
    		unsigned long t0; \
    		unsigned long t1; \
    		unsigned long t2; \
    		unsigned long t3; \
    		unsigned long t4; \
    		unsigned long t5; \
    		unsigned long t6; \
    		unsigned long a0; \
    		unsigned long a1; \
    		unsigned long a2; \
    		unsigned long a3; \
    		unsigned long a4; \
    		unsigned long a5; \
    		unsigned long a6; \
    		unsigned long a7; \
    		unsigned long mepc; \
    		unsigned long mstatus; \
    		unsigned long s0; \
    	} __aligned(16)
    #else

    #define SOC_ISR_SW_STACKING \
    	addi sp, sp, -__z_arch_esf_t_SIZEOF; \
    	DO_CALLER_SAVED(sr);

    #define SOC_ISR_SW_UNSTACKING \
    	DO_CALLER_SAVED(lr);

    #endif /* _ASMLANGUAGE */
    #endif /* __SOC_ISR_STACKING */

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-01-09 10:15:07 +01:00
Erwan Gouriou c83bc0539c include: dt-bindings: clocks: stm32wb_clock: Add RFWKP_SEL()
Add macros and defines related to the ability to select RFWK domain
clock.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2023-01-08 19:48:27 +01:00
Aaron Massey f5d269538b fuel_gauge: Add writable mfr access prop
Add fuel_gauge_set_property function to the fuel gauge API with starting
writable property of SBS specific manufactuer access.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2023-01-08 19:48:12 +01:00