Commit graph

68 commits

Author SHA1 Message Date
Yong Cong Sin bbe5e1e6eb build: namespace the generated headers with zephyr/
Namespaced the generated headers with `zephyr` to prevent
potential conflict with other headers.

Introduce a temporary Kconfig `LEGACY_GENERATED_INCLUDE_PATH`
that is enabled by default. This allows the developers to
continue the use of the old include paths for the time being
until it is deprecated and eventually removed. The Kconfig will
generate a build-time warning message, similar to the
`CONFIG_TIMER_RANDOM_GENERATOR`.

Updated the includes path of in-tree sources accordingly.

Most of the changes here are scripted, check the PR for more
info.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-28 22:03:55 +02:00
Declan Snyder 79f1b23cdb doc: Add missing ABNF macros for child num
Commit 5871ff010b
added support for generated DT macros to get the number
of child nodes of a node, but we forgot to update
the documentation of the augmented Backus–Naur form
of the DT macros to reflect this addition.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2024-05-22 13:46:04 -05:00
Jamie McCrae af467659de doc: build: Add details on SoC overlays
Adds details about Kconfig fragments and devicetree overlay files
that will be included in a build if they are found in the
``socs`` folder

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-04-29 15:08:35 +01:00
Benjamin Cabé 27f91456a4 doc: dts: fix link to reel board DTS file
fix broken link following hwmv2 migration

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2024-03-15 18:21:05 -04:00
Yong Cong Sin 450a66fa36 gen_defines: output the interrupt level of a node
Currently it is tedious to know the level of an interrupt for
a node in C. One would have to go through a very complex and
error prone macros to check if there's a parent interrupt
controller & if the controller has an interrupt number and thus
not a pseudo interrupt controller like the one found in
`rv32m1`. The level of a node is required to encode the
Zephyr's multi-level interrupt number

Since it is easier to do it in the `gen_defines` script, let's
do the heavy lifting there so that we can introduce new DT
macros to get the interrupt level very easily later.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-01-23 06:48:16 -05:00
Bjarki Arge Andreasen 08d6ff059e scripts: dts: gen_defines: Generate interrupt-controller macro
Extend the gen_defines.py write_interrupts(node) function to
generate macros to get the interrupt controller for an
interrupt specifier by idx and by name.

The information is already generated by edtlib.py and stored in
node.interrupts[].controller. This addition uses the node pointed
to by the controller member to generate the following example output

define DT_N_S_device1_IRQ_IDX_0_CONTROLLER \
       DT_N_S_gpio_800

define DT_N_S_device1_IRQ_NAME_test4_CONTROLLER \
       N_S_device1_IRQ_IDX_0_CONTROLLER

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-01-17 13:18:00 +01:00
Adam Bozanich 9e4328cdcd doc: build: dts: bindings-syntax: compatible typo
The discussion and bindings for this node
assume that it is compatible with `"bar,pwm"`.

Signed-off-by: Adam Bozanich <adam.boz@gmail.com>
2023-11-29 17:39:30 -08:00
Benjamin Cabé 155420522b doc: Fix occurrences of repeated words
Another round of repeated words cleanup. This commit tries to keep the
diff minimal and line wrapping was mostly left intact in the touched
files, as having them consistent across the documentation is probably
the topic of a future tree-wide cleanup (or not)

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-11-15 17:34:39 -05:00
Chris Friedt c0064f1de8 logging: uart: support multiple instances
Extends the log_backend_uart to support logging to multiple
UART instances.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-11-13 09:47:06 +01:00
Fabio Baltieri 8816852c2c doc: dts: api: update the inter-node dependencies documentation
Update the inter-node dependencies documentation to clarify the child
node dependency inheritance recently introduced in 403640b75e.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-11-08 10:06:57 +01:00
Benjamin Cabé 57c17da528 doc: devicetree: Fix highlighting of code blocks
Make sure devicetree code blocks all have proper pygments language set.
Fixed a few other "none" code blocks as well.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-10-18 13:22:45 +03:00
Carlo Caione e4a125b6a4 dt: Make zephyr,memory-attr a capabilities bitmask
This is the final step in making the `zephyr,memory-attr` property
actually useful.

The problem with the current implementation is that `zephyr,memory-attr`
is an enum type, this is making very difficult to use that to actually
describe the memory capabilities. The solution proposed in this PR is to
use the `zephyr,memory-attr` property as an OR-ed bitmask of memory
attributes.

With the change proposed in this PR it is possible in the DeviceTree to
mark the memory regions with a bitmask of attributes by using the
`zephyr,memory-attr` property. This property and the related memory
region can then be retrieved at run-time by leveraging a provided helper
library or the usual DT helpers.

The set of general attributes that can be specified in the property are
defined and explained in
`include/zephyr/dt-bindings/memory-attr/memory-attr.h` (the list can be
extended when needed).

For example, to mark a memory region in the DeviceTree as volatile,
non-cacheable, out-of-order:

   mem: memory@10000000 {
       compatible = "mmio-sram";
       reg = <0x10000000 0x1000>;
       zephyr,memory-attr = <( DT_MEM_VOLATILE |
			       DT_MEM_NON_CACHEABLE |
			       DT_MEM_OOO )>;
   };

The `zephyr,memory-attr` property can also be used to set
architecture-specific custom attributes that can be interpreted at run
time. This is leveraged, among other things, to create MPU regions out
of DeviceTree defined memory regions on ARM, for example:

   mem: memory@10000000 {
       compatible = "mmio-sram";
       reg = <0x10000000 0x1000>;
       zephyr,memory-region = "NOCACHE_REGION";
       zephyr,memory-attr = <( DT_ARM_MPU(ATTR_MPU_RAM_NOCACHE) )>;
   };

See `include/zephyr/dt-bindings/memory-attr/memory-attr-mpu.h` to see
how an architecture can define its own special memory attributes (in
this case ARM MPU).

The property can also be used to set custom software-specific
attributes. For example we can think of marking a memory region as
available to be used for memory allocation (not yet implemented):

   mem: memory@10000000 {
       compatible = "mmio-sram";
       reg = <0x10000000 0x1000>;
       zephyr,memory-attr = <( DT_MEM_NON_CACHEABLE |
			       DT_MEM_SW_ALLOCATABLE )>;
   };

Or maybe we can leverage the property to specify some alignment
requirements for the region:

   mem: memory@10000000 {
       compatible = "mmio-sram";
       reg = <0x10000000 0x1000>;
       zephyr,memory-attr = <( DT_MEM_CACHEABLE |
			       DT_MEM_SW_ALIGN(32) )>;
   };

The conventional and recommended way to deal and manage with memory
regions marked with attributes is by using the provided `mem-attr`
helper library by enabling `CONFIG_MEM_ATTR` (or by using the usual DT
helpers).

When this option is enabled the list of memory regions and their
attributes are compiled in a user-accessible array and a set of
functions is made available that can be used to query, probe and act on
regions and attributes, see `include/zephyr/mem_mgmt/mem_attr.h`

Note that the `zephyr,memory-attr` property is only a descriptive
property of the capabilities of the associated memory  region, but it
does not result in any actual setting for the memory to be set. The
user, code or subsystem willing to use this information to do some work
(for example creating an MPU region out of the property) must use either
the provided `mem-attr` library or the usual DeviceTree helpers to
perform the required work / setting.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-09-15 12:46:54 +02:00
Benjamin Cabé 59e4c5aed0 samples: fully migrate basic samples to the new Sphinx extension
- Updated basic samples READMEs to use the new zephyr:code-sample::
  directive. Dropped "-sample" suffix that's not required anymore now
  that samples have their own namespace.
- Updated all references to the samples to use the :zephyr:code-sample:
  role. Checked and updated the wording of said references to account
  for the fact that samples should not have "... sample" in their name
  anymore.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-09-13 09:15:34 +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
Torsten Rasmussen 754eca92a2 doc: introduce EXTRA_CONF_FILE and EXTRA_DTC_OVERLAY_FILE
Introduce EXTRA_CONF_FILE and EXTRA_DTC_OVERLAY_FILE and remove old
references to OVERLAY_CONFIG.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-05-23 16:40:21 +02:00
Martí Bolívar b6425b913a doc: dts: adjust CONFIG_COMPILER_TRACK_MACRO_EXPANSION text
Rework to address some grammar issues and typos in the original.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-05-05 12:19:36 -07:00
Gerard Marull-Paretas d45946c65d doc: build: dts: add CONFIG_COMPILER_TRACK_MACRO_EXPANSION
When debugging devicetree related issues, it may be useful to turn macro
expansion tracking off. Let's document this in the troubleshooting
section.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-05 12:08:48 +02:00
Martí Bolívar c625a0e7a8 doc: dts: add help for undefined reference to __device_dts_ord_N
This is an FAQ and we don't have a satisfactory page that describes
the current state of the world for how to troubleshoot. This leads
to frustrated users and duplicated support efforts. Try to improve
this by at least writing down what people have to do today.

If we ever improve the situation by adding a machine-readable map
between drivers, Kconfig options, and DT compatibles, we can hopefully
do better than this, but at least it's a start.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-04-26 12:53:48 +02:00
Fabio Baltieri 08d1b33d07 doc: troubleshooting: update the save-temps instructions
Update the save-temps instruction to mention the new kconfig option
instead of setting EXTRA_CFLAGS directly.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-04-02 22:07:22 -04:00
Adrien Leravat 534b7ec78d doc: build: dts: fix small doc typo
`using west build` was repeated, and supposed to be `west build`.

Signed-off-by: Adrien Leravat <adrien.leravat@gmail.com>
2023-03-06 16:44:16 +01:00
Martí Bolívar 04386be57e doc: dt: fix links to script files
These have been moved into a subpackage.

Fixes: #55198
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-02-28 11:51:24 -08:00
Henrik Brix Andersen 28819152cb scripts: dts: add special tooling for handling GPIO hog nodes
GPIO hog nodes contain a "gpios" property, but unlike other "*-gpios"
properties, these are not phandle-arrays as they only carry the data part
(e.g. pin, flags) but lack the phandles to the (parent) GPIO controller.

Add special devicetree tooling to handle the "gpios" property of GPIO hog
nodes and generate special devicetree helper macros as if they were phandle
arrays.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-01-27 14:38:52 -08:00
Marti Bolivar c4b10874eb doc: dts: add missing entry to dts/bindings search path
Since SHIELD_DIRS gets added to DTS_ROOT in dts.cmake, any shield
directories are also places where we look for bindings by default.
This feature is not used in upstream Zephyr, but it is supported,
so document it.

Suggested-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-01-23 07:16:04 -08:00
Marti Bolivar 196df5c9b4 doc: dts: clarify reg format
These are in hex.

Suggested-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-01-23 07:16:04 -08:00
Marti Bolivar 7812bedb09 doc: dts: touch up api
Just a few minor things from a periodic review.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-01-23 07:16:04 -08:00
Marti Bolivar c35d83f95d doc: dts: touch up api-usage
Just a few minor things from a periodic review.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-01-23 07:16:04 -08:00
Marti Bolivar 1ab3a6f53d doc: dts: document zephyr, prefix for props/compats
We have established a convention that the zephyr, prefix in property
names indicates some sort of zephyr-specific extension to a common
binding, or a zephyr-specific driver configuration knob. We also have
established a convention that compatibles which begin with "zephyr,"
are specific to our operating system. Document these facts.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-01-23 07:16:04 -08:00
Marti Bolivar 0d827a8f50 doc: dts: improve bindings-upstream
Splitting up the 'general rules' section into subsections makes it
possible to link directly to a particular rule. This is useful when
pointing out an issue during code review, sharing with another
colleague, etc. Adding a local table of contents makes the page
skimmable (it's buried too deeply in the toctree to have sections
listed in the HTML sidebar).

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-01-23 07:16:04 -08:00
Marti Bolivar cd3008a9ac doc: dts: improve zephyr-user-node.rst
Now that this information is in a separate page instead of buried at
the bottom of the DT bindings documentation, it's more convenient to
split it up into subsections for readability.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-01-23 07:16:04 -08:00
Marti Bolivar 67b0cd382e doc: dts: clarify a design requirement
There's been some confusion about what we mean by hardware
description. We're really talking about the user-facing inputs that
need to be configured per SoC, application, etc. It's fine to do
things like use ifdeffery on a CMSIS header in an aarch32 support file
to decide if the current target has some feature, for instance -- that
sort of thing doesn't *have* to come from DT.

At the same time, we don't want to encourage vendor-specific hardware
configuration languages from creeping into upstream zephyr, so keep
the language strong in an effort to avoid that misinterpretation.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-01-23 07:16:04 -08:00
Marti Bolivar b141c72a2a doc: dts: add guide to phandles
Phandles, specifier spaces, and cell names are simultaneously
extremely common and woefully underdocumented. Address that by:

- reworking our existing documentation on these subjects in
  bindings-syntax.rst, fixing missing information in the
  property syntax template as well

- adding a standalone guide which describes how all the pieces
  fit together, providing a bridge for the gap between
  DTS/bindings and C APIs

My goal is not to eventually make this a comprehensive place
where *all* specifier spaces are documented. It would be better (more
scalable, more discoverable) to improve the individual API pages to
cover the devicetree-related conventions that apply in each case.
That's a problem for someone else and another day, but we do need a
few concrete references in the DTS guides to keep the motivation
clear.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-01-23 07:16:04 -08:00
Marti Bolivar 6780ed4a82 doc: dts: split up intro
The devicetree introduction page is too big. Split it up to improve
readability and restore maintainability. Add more section headers and
do some other rearranging now that it's more convenient to do so.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-01-23 07:16:04 -08:00
Marti Bolivar aeabe31c60 doc: dts: bindings-syntax improvements
Generic improvements:

- clean up some language that needs adjusting
- rename some section headers and reorder some content to
  improve readability
- add a table of contents to ease search

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-01-23 07:16:04 -08:00
Marti Bolivar eb21bd36eb doc: dts: split up bindings docs
The bindings.rst page has gotten too big. Split it up into
sub-documents to improve readability and restore maintainability.

As part of this effort, move the /zephyr,user node documentation into
its own page in the guide. This page has proven extremely difficult
for users to spot in my experience, and it's meant as a convenience,
so let's make the documentation more convenient as well.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-01-23 07:16:04 -08:00
Torsten Rasmussen 7ea6031430 doc: clarify where relative devicetree files are found
Add description of how relative devicetree overlay files are picked up
from the application configuration directory.

Also add a link to detailed description of application configuration
directory.

This aligns the devicetree overlays with the description found for
Kconfig configuration files.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-11-24 15:22:21 +01:00
Chris Friedt bf0612cae3 doc: build: dts: bindings: discourage use of redundant: false
Aside from base properties (maybe for documentation purposes),
`required: false` should not be encouraged.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2022-11-20 13:12:44 -05:00
Gerard Marull-Paretas a76c1cf41b doc: build: dts: mention it is allowed to include at any level
This feature was not mentioned, even though it is supported.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-17 06:57:46 -06:00
Gerard Marull-Paretas 8d0eb6ce10 devicetree: remove deprecated DT_CHOSEN_*_LABEL macros
DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL and
DT_CHOSEN_ZEPHYR_ENTROPY_LABEL were deprecated a couple of releases ago,
so it is time to remove them. Note that the zephyr/devicetree/zephyr.h
is also removed, since both macros were its last content.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-11 11:00:26 +01:00
Gregory Shue cfcf630184 build: Overlay build vars expand ${ZEPHYR_<module>_MODULE_DIR}
Support referencing module directories by name in CONF_FILE,
OVERLAY_CONFIG, and DTC_OVERLAY_FILE so that projects can reference
overlay files in arbitrary modules.

Verified by passing all the following tests:
  ./scripts/twister -T tests/cmake/overlays/

Fixes #41830

Signed-off-by: Gregory Shue <gregory.shue@legrand.us>
2022-10-13 12:04:38 +02:00
Maureen Helm e73c363346 scripts: edtlib: gen_defines: Add model name macros based on compat
Follow up to 5b5aa6ebba adding model name
and existence macros for all compatibles of a node that match an entry
in vendor prefixes.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2022-10-07 11:48:02 -07: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
Gerard Marull-Paretas 1f98c24fc2 doc: dts: macros.bnf: add missing DT_FOREACH_PROP_ELEM entries
Entries for DT_FOREACH_PROP_ELEM_(VARGS) internal helpers were missing.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-03 10:11:18 +02:00
Stephanos Ioannidis 45a8ace1f3 doc: Use inline literals
Use inline literals where applicable -- especially for the words that
contain `@`; otherwise, Sphinx will think it is an email address.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2022-09-29 12:20:14 +02:00
Martí Bolívar 88ef844bd8 doc: dts: fix reference table of contents generation
Commit 6e9a43be79 ("doc: move DTS under Build/Configuration systems
section") made it so that the internal organization of the API
reference page is no longer visible to users. This means users have to
scroll around looking for macros they need, instead of being able to
look for a section that looks relevant and reading just that.

Fix it by restoring the independent toctree for DT reference material
with an appropriate maxdepth, and adding a local table of contents in
the reference page.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-09-19 18:15:43 +02:00
Daniel Leung 418c915f1b dts: add primitive support for multi-bus in bindings
For a single bus that supports multiple protocols, e.g. I3C and I2C,
the single value "bus:" setting is no longer sufficient, as a I3C bus
cannot be matched to a device having "on-bus: I2C". This commit
extends the "bus:" setting so that it can accept a list of values.
This change allows corresponding devicetree macros to be generated
so that DT_ON_BUS() can work properly in this scenario.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-09-09 17:42:33 -04:00
Maureen Helm 5b5aa6ebba scripts: gen_defines: Add vendor name macros based on vendor prefixes
Adds vendor name and existence macros for all compatibles of a node that
match an entry in the vendor prefixes file.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2022-09-01 14:53:55 -07:00
Gerard Marull-Paretas fff9ecbc7f devicetree: add DT_(INST_)FOREACH_CHILD(_STATUS_OKAY)_SEP(_VARGS)
It is frequent to see in Devicetree code constructs like:

```c
 #define NAME_AND_COMMA(node_id) DT_NODE_FULL_NAME(node_id),

const char *child_names[] = {
	DT_FOREACH_CHILD(DT_NODELABEL(n), NAME_AND_COMMA)
};
```

That is, an auxiliary macro to append a separator character in
DT_FOREACH* macros. Non-DT API, e.g. FOR_EACH(), takes a separator
argument to avoid such intermediate macros.

This patch adds DT_FOREACH_CHILD_SEP (and instance/status okay/vargs
versions of it). They all take an extra argument: a separator. With this
change, the example above can be simplified to:

```c
const char *child_labels[] = {
	DT_FOREACH_CHILD(DT_NODELABEL(n), DT_NODE_FULL_NAME, (,))
};
```

Notes:
- Other DT_FOREACH* macros could/should be extended as well

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-30 16:19:57 +02:00
Kumar Gala f1660f4d51 edtlib: allow const arrays
Allow for having array types (array, uint8-array, string-array) be const.
This would allow for something like:

properties:
    reg-names:
        const: ["foo", "bar"]

To be supported.

Renamed function _check_prop_type_and_default to _check_prop_by_type
as part of this change and Moved the check for 'const' types into
_check_prop_by_type as its similar to the prop_type check and it was
easier to implement in _check_prop_by_type as we already extract
prop_type from the option in that function.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-08-25 18:11:27 -07:00
Gerard Marull-Paretas a202341958 devices: constify device pointers initialized at compile time
Many device pointers are initialized at compile and never changed. This
means that the device pointer can be constified (immutable).

Automated using:

```
perl -i -pe 's/const struct device \*(?!const)(.*)= DEVICE/const struct
device *const $1= DEVICE/g' **/*.c
```

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-22 17:08:26 +02:00
Kevin Townsend 0e560bf8e9 doc: build: dts: Remove refs to label property
Removes references to the label property in devicetree, replacing
them with node label where appropriate.

Signed-off-by: Kevin Townsend <kevin.townsend@linaro.org>
2022-08-18 19:50:39 -05:00