Commit graph

15409 commits

Author SHA1 Message Date
Gerard Marull-Paretas
a659548a30 net: fix pm argument documentation
The `pm` field is used to provide a reference to pre-allocated PM
resources. Its usage as a callback was removed a while ago, and these
headers missed the migration.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-04 10:13:34 +02:00
Gerard Marull-Paretas
129a093785 device: only use dev_id in Z_DEVICE_HANDLES_NAME
The dev_id is already unique for DT devices (dts_ord_XX), there's no
need to rely on the full node identifier.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-04 10:13:34 +02:00
Gerard Marull-Paretas
80e0b1e2a3 device: format Z_DEVICE_HANDLES_DEFINE
Format according to our guidelines.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-04 10:13:34 +02:00
Gerard Marull-Paretas
6fc42a0e4e device: s/Z_DEVICE_HANDLE_NAME/Z_DEVICE_HANDLES_NAME
Use Z_DEVICE_HANDLES_NAME to be consistent with the definition macro.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-04 10:13:34 +02:00
Gerard Marull-Paretas
84d1982703 device: introduce Z_DEVICE_HANDLES_SECTION
Allows de-cluttering Z_DEVICE_HANDLES_DEFINE.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-04 10:13:34 +02:00
Gerard Marull-Paretas
184a5467cb device: use __weak in Z_DEVICE_HANDLES_DEFINE
Use the pre-defined __weak attribute.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-04 10:13:34 +02:00
Gerard Marull-Paretas
b2d1514e32 device: use Z_DECL_ALIGN in Z_DEVICE_HANDLES_DEFINE
Z_DECL_ALIGN is equivalent to the manually specified
__aligned(sizeof(type)).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-04 10:13:34 +02:00
Gerard Marull-Paretas
cfd3560e1b device: s/Z_DEVICE_DT_DEV_NAME/Z_DEVICE_DT_DEV_ID
Rename Z_DEVICE_DT_DEV_NAME to Z_DEVICE_DT_DEV_ID to make it more clear,
as the macro is generating a token that identifies the created struct
device.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-04 10:13:34 +02:00
Gerard Marull-Paretas
75373881a3 device: move handle size assert close to type definition
This improves code readability.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-04 10:13:34 +02:00
Gerard Marull-Paretas
3426050f5f device: Z_DEVICE_STATE_DEFINE doesn't need node_id
The macro is not using node_id, so remove it from the arg list. Do the
same for I2C/CAN "sub-macros".

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-04 10:13:34 +02:00
Gerard Marull-Paretas
92ad3940c0 device: introduce Z_DEVICE_INIT_ENTRY_DEFINE
Add a new helper macro to define a device init entry. This helps
de-cluttering Z_DEVICE_DEFINE.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-04 10:13:34 +02:00
Gerard Marull-Paretas
f25f55290a device: define Z_DEVICE_BASE_DEFINE
This adds a new helper to define the base struct device, without any
other required objects. This helps de-cluttering Z_DEVICE_DEFINE.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-04 10:13:34 +02:00
Gerard Marull-Paretas
92c9db2e82 device: rename some *DEVICE*DEFINE* arguments
drv_name -> name
pm_device -> pm
data_ptr -> data
cfg_ptr -> config
api_ptr -> api
state_ptr -> state

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-04 10:13:34 +02:00
Gerard Marull-Paretas
33161222d7 device: s/dev_name/dev_id
The usage of dev_name is misleading, since it does not represent the
device name (struct device name field) but the name given to the defined
struct device. In practice, it is used as a kind of unique device
identtifier, so let's rename it to dev_id.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-04 10:13:34 +02:00
Gerard Marull-Paretas
8ddd4299d9 device: add documentation for some internal helpers
Add or extend documentation for some internal device helpers.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-04 10:13:34 +02:00
Gerard Marull-Paretas
ba81ec2bdb device: hide some internal device macros from public docs
This allows us to use regular Doxygen docstrings to document internal
helpers while keeping them out of public API docs.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-04 10:13:34 +02:00
Gerard Marull-Paretas
fd0f71554d device: move Z_DEVICE_MAX_NAME_LEN close to Z_DEVICE_NAME_CHECK
Improves code readability.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-04 10:13:34 +02:00
Gerard Marull-Paretas
a39a1cad96 device: group Z_DEVICE_STATE_NAME/Z_DEVICE_STATE_DEFINE
Bring both defines together to improve code readability.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-04 10:13:34 +02:00
Gerard Marull-Paretas
cf3f42e7fd device: reorganize Z_DEVICE_DEFINE
- checks/build asserts (device name)
- definitions required by struct device (state, handles)
- device definition
- device init entry

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-04 10:13:34 +02:00
Gerard Marull-Paretas
d7cf60728a device: define Z_DEVICE_NAME_CHECK
Define Z_DEVICE_NAME_CHECK to perform a build time assertion on device
name length. This allows de-cluttering Z_DEVICE_DEFINE.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-04 10:13:34 +02:00
Gerard Marull-Paretas
92ef9f47f4 device: s/Z_DEVICE_DEFINE_HANDLES/Z_DEVICE_HANDLES_DEFINE
Use the same naming scheme as in other macros/areas.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-04 10:13:34 +02:00
Gerard Marull-Paretas
eb10f7e9e8 device: remove ; from Z_DEVICE_DEFINE_HANDLES
Remove trailing ; in Z_DEVICE_DEFINE_HANDLES as it results in a more
idiomatic usage of the macro.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-04 10:13:34 +02:00
Gerard Marull-Paretas
4c5e0aaab3 device: remove ; from Z_DEVICE_STATE_DEFINE
This results in more idiomatic usage of the macro.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-04 10:13:34 +02:00
Gerard Marull-Paretas
47065593e2 device: remove Z_DEVICE_DEFINE_PRE
Z_DEVICE_DEFINE_PRE existed when PM was tightly coupled to the device
API, but now it is just a shim for Z_DEVICE_DEFINE_HANDLES, so it adds
no value.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-04 10:13:34 +02:00
Gerard Marull-Paretas
01c56f063a device: define Z_DEVICE_INIT
Define an initializer for `struct device`. This allows de-cluttering
Z_DEVICE_DEFINE and allows for re-usability if needed somewhere else.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-04 10:13:34 +02:00
Gerard Marull-Paretas
6dc4b2fcb2 device: format Z_DEVICE_DEFINE
Format the macro (using 80 cols for \). This improves readability and
further rework.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-04 10:13:34 +02:00
Gerard Marull-Paretas
b51c8ba33c device: define Z_DEVICE_SECTION
Define device section helper to de-clutter Z_DEVICE_DEFINE.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-04 10:13:34 +02:00
Torsten Rasmussen
c107827bb7 linker: correct linker script _flash_used calculation
Linker scripts contains a `.last_section` section that is placed in rom
region as NOLOAD for the purpose of retrieve the actual number of bytes
contained in the image. See d85efe0b10

However, a previous section may cause the location counter to be
incremented for alignment purposes. This can result in the size of the
image to be 0x10FA but location counter to be 0x1100 because it has been
aligned for next section placement.

Therefore, two new Kconfig settings are introduced.
Those settings request the linker to will write a pattern in
`.last_section`. Together with removing NOLOAD and writing a patten to
the section then we ensure that data is written after alignment of
location counter, and thereby forces the image size to be in sync with
the location counter.

The default pattern used will be 0xE015 (end of last section).

Some systems may fill up the flash completely, or simply write data at
the end of the flash, which in both cases can result in overflow.
Therefore, the new settings can be disabled.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-10-03 13:13:46 +00:00
Juha Heiskanen
8279489aee net: lwm2m: RD Client update registration timeout
Renamed LWM2M_RD_CLIENT_EVENT_REG_UPDATE_FAILURE to
LWM2M_RD_CLIENT_EVENT_REG_TIMEOUT.

Changed reported event type for registration timeout to
LWM2M_RD_CLIENT_EVENT_REG_TIMEOUT from
LWM2M_RD_CLIENT_EVENT_REGISTRATION_FAILURE.
LWM2M_RD_CLIENT_EVENT_REGISTRATION_FAILURE should be only
reported case when server reject by response registration.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-10-03 10:20:13 +02:00
Mariusz Skamra
9ecbee2587 Bluetooth: audio: capabilities: Remove callbacks
This removes the callbacks from capabilities. The callbacks are used for
unicast server role only, while the capabilities are used for the
broadcast sink role as well. Thus the callbacks can be removed as there
is another bt_audio_unicast_server_cb API that is specific for unicast
server role.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-10-03 10:17:21 +02:00
Gerard Marull-Paretas
fdea3c9a44 devicetree: add DT(_INST)_FOREACH_PROP_ELEM_SEP(_VARGS)
Add a new set of helpers for expanding property entries with a
separator. These macros complement DT(_INST)FOREACH_PROP_ELEM(_VARGS) by
adding the capability to expand with a custom separator between property
entries. This allows, in some cases, to re-use existing macros (e.g.
DT_PROP_BY_IDX) without creating an auxiliary macro that just appends a
separator. Example:

```dts
n: node {
	...
	my-gpios = <&gpioa 0 GPIO_ACTIVE_HIGH>,
		   <&gpiob 1 GPIO_ACTIVE_HIGH>;
};
```

Before:

```c
 #define GPIO_DT_SPEC_BY_IDX_AND_COMMA(node_id, prop, idx) \
	GPIO_DT_SPEC_BY_IDX(node_id, prop, idx),

struct gpio_dt_spec specs[] = {
	DT_FOREACH_PROP_ELEM(DT_NODELABEL(n), my_gpios,
			     GPIO_DT_SPEC_BY_IDX_AND_COMMA)
};
```

After:

```c
struct gpio_dt_spec specs[] = {
	DT_FOREACH_PROP_ELEM_SEP(DT_NODELABEL(n), my_gpios,
				 GPIO_DT_SPEC_BY_IDX, (,))
};
```

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-03 10:11:18 +02:00
Krzysztof Chruscinski
e6bbc6941a logging: Use STRUCT_SECTION macros for log backend
Clean up logging code to utilize macros for handling sections.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-10-03 10:11:03 +02:00
Valerio Setti
cda7d05ca6 dts: sensor: adding nodes for STM32 quadrature encoder
Nodes for quadrature encoders are added to the STM32F4 devices

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2022-10-03 10:10:31 +02:00
Peter Marheine
42a25255d2 nios2: rename default RAM region from 'SRAM' to 'RAM'
It's useful for the default RAM region to have a uniform name across
architectures so higher-level build processes do not need to have their
own awareness of the names. Since NIOS2 uniformly uses 'SRAM', change it
to 'RAM' to match most other architectures.

Signed-off-by: Peter Marheine <pmarheine@chromium.org>
2022-10-03 10:09:53 +02:00
Peter Marheine
ec5b9ad348 arm64: rename default RAM region from 'SRAM' to 'RAM'
As with 32-bit ARM, it is useful to make the RAMABLE_REGION name uniform
across architectures so the build system does not need to be aware of
the differences when CODE_DATA_RELOCATION is supported. Generalize the
name to just 'RAM' for uniformity.

Signed-off-by: Peter Marheine <pmarheine@chromium.org>
2022-10-03 10:09:53 +02:00
Peter Marheine
5eb75b81f7 arm: rename default RAM region from 'SRAM' to 'RAM'
It's useful for RAMABLE_REGION to have a uniform name when
CODE_DATA_RELOCATION is supported, because otherwise the build system
needs to be aware of how the region name differs between architectures.
Since architectures tend to prefer one of 'SRAM' or 'RAM' for that
region, prefer to use 'RAM' as the more general term.

Signed-off-by: Peter Marheine <pmarheine@chromium.org>
2022-10-03 10:09:53 +02:00
Jackson Cooper-Driver
23c9f7b215 ipc_service: Add ipc_service_close_instance function
This function allows the application to close an ipc_service instance.
It is intended for use when the remote agent it is communicating with
has gone down and allows for cleanup.
It first checks that the endpoints have been separately deregistered
with the instance using the deregister_endpoint function before
calling into previously added functions in ipc_static_vrings.c
and ipc_rpmsg.c to close those instances.

Signed-off-by: Jackson Cooper-Driver <jackson.cooper---driver@amd.com>
2022-10-03 10:08:44 +02:00
Jackson Cooper-Driver
e69d131bc5 ipc_service: Adding ipc_static_vrings_deinit function
This function deinitialises the static vrings used by the ipc_service
instance. It acheieves this by tearing down the initialised
virtqueues before closing the various aspects of libmetal which
are in use.

Signed-off-by: Jackson Cooper-Driver <jackson.cooper---driver@amd.com>
2022-10-03 10:08:44 +02:00
Jackson Cooper-Driver
f16a19c33f ipc_service: Add ipc_rpmsg_deinit function
This function does the opposite of the ipc_rpmsg_init function and
allows the rpmsg instance to be torndown in the case that the application
wishes to do so. It is intended to be used by the ipc_service subsystem.

Signed-off-by: Jackson Cooper-Driver <jackson.cooper---driver@amd.com>
2022-10-03 10:08:44 +02:00
Ederson de Souza
edd524b4e3 drivers/mm: Add API to query memory regions
Some systems may need to query the available memory regions in runtime.
For those, this patch adds a simple API that memory management drivers
can implement to provide such discovery.

A small test also added to exercise the default, empty implementation.

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2022-10-01 14:52:29 -04:00
Dominik Ermel
54db76b4cd storage/flash_map: Deprecate FLASH_AREA_ macros
FLASH_AREA_ macros and usage of label property to identify
fixed-partitions, for purpose of usage with flash map API,
has been deprecated and now FIXED_PARTITION_ macros
should be used with DTS node labels.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-09-30 07:44:49 -05:00
Gerard Marull-Paretas
550f918b01 device: remove duplicate Z_DEVICE_STATE_DEFINE macro definition
The macro is defined twice in the same header file.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-09-28 13:54:10 -05:00
Gerard Marull-Paretas
4bd68112c3 device: use IF_ENABLED to initialize PM field
IF_ENABLED(CONFIG_FOO, (x)) is equivalent to COND_CODE_1(CONFIG_FOO,
(x), ()).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-09-28 17:39:36 +00:00
Stephanos Ioannidis
c5a4bb9daf kernel: Remove stale references to memory pool API
This commit removes all stale references in the kernel header to the
memory pool API, which was removed in the v2.5.0 release.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2022-09-28 14:24:34 +00:00
Stephanos Ioannidis
ed13880f1d linker: Remove k_mem_pool section
This commit removes the `k_mem_pool` section for the memory pool API,
which was removed in the v2.5.0 release.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2022-09-28 14:24:34 +00:00
Emil Gydesen
874c45241e Bluetooth: Audio: Remove caching ASE on release
Remove the support for caching ASEs on release.

This is mainly due to the 2-stage design in Zephyr: We
have the bt_audio_stream and the bt_audio_ep, where the
the latter represents an ASE in most cases.

However, once the endpoint goes into the codec configured
state, then a stream must be bound to it. This would be fine
(although a stream is technically not established at this point),
except that a stream is also, for unicast, specified for a
specific ACL. Once the ACL disconnects, the stream technically
becomes invalid, and if the stream is invalid, so is the endpoint.

Based on that, there's no reason (or even option) to keep the
endpoint in a codec configured state, as it would not
have a valid stream associated with it.

If we want to support an ASE going into the codec
configured state on ASE release (or ACL disconnect),
the relationsship between ASEs and streams needs to
be redefined.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-09-27 09:16:21 +00:00
Peter Tönz
387d84e452 includes: prevent warnings (Z_CBPRINTF_ARG_SIZE shadows variables)
We compile with the gcc compiler flags -Werror and -Wshadow. So
the mentioned macro rasies a warning (and with the flags the
warning becoms to an error). It uses the same variable names
as on of its caller. Add an addidional underscore to the
affected variables to prevent this warning.

Signed-off-by: Peter Tönz <peter.tonz@husqvarnagroup.com>
2022-09-26 09:43:28 -05:00
Jonathan Rico
77e1a9dcad Bluetooth: host: l2cap: add alloc_seg callback
This callback allows use-cases where the SDU is much larger than the l2cap
MPS. The stack will then try to allocate using this callback if specified,
and fall-back on using the buffer's pool (previous behavior).

This way one can define two buffer pools, one with a very large buffer
size, and one with a buffer size >= MPS, and the stack will allocate from
that instead.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-09-26 11:05:04 +02:00
Henrik Brix Andersen
9ca4b34035 drivers: can: calling can_stop() shall abort any pending transmissions
Update the documentation for can_stop() to mention that it shall abort any
pending CAN frame transmissions.

Fixes: #50545

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-09-23 17:25:01 +00:00
Henrik Brix Andersen
d6fc3f6596 drivers: can: provide default callback to can_send() if NULL
Provide a default, internal callback to CAN controller drivers
implementation of can_send() if no callback was provided by the caller.

This allows for simplifying the CAN driver implementations of can_send() as
these no longer need special handling for callback/no callback operation.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-09-23 17:25:01 +00:00