Commit graph

53 commits

Author SHA1 Message Date
Grzegorz Swiderski 7e95816baf dts: bindings: Move zephyr,memory-region property definition
Move it to a common file named `zephyr,memory-common.yaml`, which
replaces `zephyr,memory-attr.yaml` and takes its contents as well.

This is so that another binding, e.g., `vnd,memory-region`, can support
being combined with the `zephyr,memory-region` binding like so:

  node@deadbeef {
    compatible = "vnd,memory-region", "zephyr,memory-region";
    zephyr,memory-region = "NAME";
    ...
  };

To allow this, edtlib would require `vnd,memory-region` to include the
property definitions from this new common file.

The same can't be done by including `zephyr,memory-region.yaml` directly
because that file marks the property in question as always required, and
it shouldn't be required whenever the `vnd,memory-region` compatible is
used on its own.

Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
2024-05-16 15:18:46 +01:00
Gerard Marull-Paretas 2380e5fdaf dts: bindings: test: add vnd,mbox-consumer
Add a new binding that should help with samples or MBOX tests by getting
information from DT.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2024-03-07 14:32:57 +00:00
Yong Cong Sin 170c659292 tests: devicetree: api: test DT_IRQ_LEVEL and DT_INST_IRQ_LEVEL
Added new test for `DT_IRQ_LEVEL` and `DT_INST_IRQ_LEVEL`.

Introduced a new `vnd.cpu-intc` compatible so that we have a
root level interrupt controller that acts as level 1
aggregator, and modified `test_intc` to be level 2 aggregator,
updated test of `DT_IRQN(TEST_I2C_BUS)` accordingly.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-01-23 06:48:16 -05:00
Bjarki Arge Andreasen 4403d8f4c6 tests: lib: devicetree: api: Add tests for IRQ_INTC_* macros
Extend api test suite to cover the new devicetree macros. This
includes extending the devicetree overlay with two new bindings:

- GPIO device which is also an interrupt controller
- interrupt holder using interrupts-extended to point to both
  existing interrupt controller test_intc, and the newly added
  GPIO device

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-01-17 13:18:00 +01:00
Martí Bolívar b1532ce449 devicetree: remove label property accessors
These were first deprecated in v3.2. We have kept support for them
for as long as we can, but now their presence is causing CI failures
in some configurations. Specifically, using the deprecated 'label'
property is causing a warning which is promoted to an error in some
twister runs. This is blocking other forward progress in the
devicetree API.

I tried to rework the tests to avoid this, but it was too much effort
for the time I had to work on the task. Removing the APIs is therefore
unfortunately the best way forward to unblocking other work.

Re-work the test suite a bit to maintain coverage where we are using
the label property to test other macros.

Add a migration guide section to help with the transition.

Signed-off-by: Martí Bolívar <mbolivar@amperecomputing.com>
2023-12-01 13:09:56 -08:00
Aleksander Wasaznik 0e83c66cef dts: bindings: Remove reg from vnd,serial
`vnd,serial` is a virtual device which does not have an address.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-09-28 14:07:52 +03:00
Gerard Marull-Paretas ad08b3c300 dts: bindings: add missing pinctrl-device.yaml includes
These worked because edtlib allows 'pinctrl-.*' properties without
specifying them on the bindings. However, this has never been an
anounced pinctrl feature, the reference documents explicitly mention
that usage of pinctrl-device.yaml is mandatory.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-09-27 13:58:28 +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
Gerard Marull-Paretas a44f61c5f5 tests: lib: devicetree: api: test the 'reserved' status
The `reserved` status, even though supported, was not tested. Add
coverage for it.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-26 03:10:30 -04:00
Alexander Razinkov b158c52e24 devicetree: support of 64-bit addresses from devicetree
Usage of 64-bit address constants from devicetree without a
UINT64_C wrapping macro results in the following warning and the
cut-off of the address value:

"warning: integer constant is so large that it is unsigned"

This change extends devicetree API adding few wrappers over the
address constant getters which add ULL size suffix to an
address integer literal when the appearance of 64-bit address
values is possible

Signed-off-by: Alexander Razinkov <alexander.razinkov@syntacore.com>
2023-06-25 03:29:54 -04:00
Gerard Marull-Paretas 8605a8700c tests: lib: devicetree: test DT_ANY_INST_HAS_PROP_STATUS_OKAY
Add test coverage for the recently introduced
DT_ANY_INST_HAS_PROP_STATUS_OKAY.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-24 09:21:36 -05:00
Sung-Chi Li d455b6dee0 tests: drivers: gpio: Add test for GPIO_ENABLE_DISABLE_INTERRUPT
Add test for the experimental feature GPIO_ENABLE_DISABLE_INTERRUPT,
which covers APIs gpio_pin_interrupt_enable() and
gpio_pin_interrupt_disable().

Signed-off-by: Sung-Chi Li <lschyi@google.com>
2023-04-06 11:44:07 -04:00
Fabio Baltieri 12b863067c bindings: test: add a test input device binding
Add a vnd,input-device binding to be used for testing.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-03-24 13:48:28 +00:00
Radosław Koppel 14a1b2ffec dts: Add _STRING_UNQUOTED string and string-array
This commit adds access to the string values without a quotes.

Signed-off-by: Radosław Koppel <r.koppel@k-el.com>
Co-authored-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-02-20 09:49:00 +01:00
Keith Short 9664f863eb test: emul: Verify backend API operation
Verify backend API is functional with the emulator subsystem.

Signed-off-by: Keith Short <keithshort@google.com>
2023-01-27 01:01:06 +09:00
Fabio Baltieri eb0a524972 yamllint: indentation: fix dts/bindings/
Fix the YAML files indentation for files in dts/bindings/.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-01-04 14:23:53 +01:00
Gerard Marull-Paretas cfbff7896e dts: bindings: pinctrl: place pincfg-node props at root level
Since we can include other binding files at any level (child,
grand-child, etc.) it makes no sense to maintain two copies of pinctrl
props definitions (pincfg-node/pincfg-node-group). Instead,
pincfg-node.yaml defines props at root level, and it is included where
needed, either child-binding or grandchild-binding.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-24 09:36:20 +01:00
Chris Friedt 83bea9a796 dts: bindings: clean up redundant required false attributes
DTS property attributes are (by default) not required.

Explicitly specifying `required: false` is redundant.
Perhaps a warning to that effect would be useful.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2022-11-20 13:12:44 -05:00
Daniel Leung db9d83fbb8 tests: devicetree: add bits to test multi-bus nodes
This adds a few bits to the devicetree API tests for multi-bus
nodes where a bus can support multiple protocols. This uses
I3C as basis as I3C controller can support both I2C and I3C on
the same bus, while I2C controller cannot support both. So
this needs to make sure the correct bus macros are generated
if appropriate (and not generated if not needed).

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-09-09 17:42:33 -04:00
Jeremy Bettis da9448396c drivers/serial: Make serial_test a proper emul
Add emulator functionality to the serial_test driver, so that it can be
used to simulate a device on the other end of the uart.

If you don't set the buffer-size property in the dts node, there should
be effectively no change from the previous behavior.

Signed-off-by: Jeremy Bettis <jbettis@google.com>
2022-09-08 15:26:41 +00:00
Radosław Koppel 7614110a20 dts: Add _STRING_TOKEN and _STRING_UPPER_TOKEN to string-array
This commit adds string token versions of the values also
in items inside string-array.

Signed-off-by: Radosław Koppel <r.koppel@k-el.com>
Co-authored-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
Co-authored-by: Kumar Gala <galak@kernel.org>
2022-08-22 13:58:30 -05:00
Kumar Gala 9b5c653b3f dts: bindings: test: Add explicit label property
Don't import the label prop from base.yaml as it is marked deprecated.
This lets the various tests that still use DT_LABEL() to work properly.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-08-18 15:19:40 -07:00
Gerard Marull-Paretas 8f887b6f8a tests: subsys: openthread: refactor test
Use a test compatible so that test can create a DT-based device and
provide a valid choice when building the test.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-10 11:57:34 +02:00
Kumar Gala 7bc6bc8681 dts: bindings: test: device labels are now optional
All in tree device drivers use some form of DEVICE_DT_GET
so we no longer need to require label properties.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-19 12:31:53 +00:00
Thomas Stranger ae8543269a drivers: w1: add vnd,w1 driver for ci testing
This commit adds the vnd,w1 dummy host driver used for ci builds of
1-wire devices.

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2022-07-05 23:06:45 +02:00
Andrei-Edward Popa eeaf115291 dts: bindings: test: added bindings for devicetree test reset
added bindings for vnd,reset used for devicetree test reset
added adc temp sensor as supporting reset

Signed-off-by: Andrei-Edward Popa <andrei.popa105@yahoo.com>
2022-03-23 12:51:39 +01:00
Henrik Brix Andersen 5e8399f84b devicetree: add devicetree/can.h
This contains accessor macros for getting the maximum bitrate supported
by a CAN controller/transceiver combination.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-03-15 14:32:29 -05:00
Bernardo Perez Priego 9964414655 include/devicetree.h: Add DT_STRING_TOKEN_OR macro
This macro expands to DT_STRING_TOKEN if property exists, otherwise
falls back to default value.
Helpful when a non-required enum binding doesn't mention a default
value, but a default value makes sense to be set in the code.

Including DT_INST_STRING_TOKEN_OR and test code.

Signed-off-by: Bernardo Perez Priego <bernardo.perez.priego@intel.com>
2022-03-10 19:42:59 -08:00
Gerard Marull-Paretas 32bea9a7fb tests: lib: devicetree: use vnd,gpio-device
The vnd,gpio-device compatible is now used by the test GPIO driver
(CONFIG_GPIO_TEST) introduced in #41387. This means that we can't define
new devices with this compatible when CONFIG_GPIO=y.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2022-01-04 14:44:07 -05:00
Gerard Marull-Paretas c0fff657c5 pinctrl: use groupN instead of pinsN for groups
The pinsN group name can be a confusing in some circumstances, so change
it to groupN. Some platforms (e.g. nrf or gd32) are already using
groupN. Documentation and API tests have been updated.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-01-01 07:39:08 -05:00
Gerard Marull-Paretas 1832d68e01 tests: lib: devicetree: add tests for DT_INST_ENUM_IDX(_OR)
Add tests for the instance based enum macros DT_INST_ENUM_IDX and
DT_INST_ENUM_IDX_OR.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-11-18 19:12:07 -05:00
Neil Armstrong 2825481747 devicetree: add tests for devicetree ranges API macros
Test cases for new APIs.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2021-11-10 08:23:00 -05:00
Carlo Caione 1976f33e87 drivers: mbox: Introduce MBOX driver class
One limitation of the current IPM API is that it is assuming that the
hardware is only exporting one single channel through which the data can
be sent or signalling can happen.

If the hardware supports multiple channels, the IPM device must be
instantiated (possibly in the DT) several times, one for each channel to
be able to send data through multiple channels using the same hw
peripheral. Also in the current IPM API only one callback can be
registered, that means that only one driver is controlling all the
signalling happening on all the channels.

This patch is introducing a new MBOX API that is supporting
multi-channel signalling and data exachange leveraging and extending the
previous (and outdated) IPM API.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2021-10-27 18:27:21 +02:00
Gerard Marull-Paretas a578bb70b6 tests: drivers: pinctrl: add tests for API
Add a set of tests to check the API behavior. The API tests can only run
on a platform that does not have an actual pinctrl driver, e.g.
native_posix. The test itself implements a pinctrl mock driver and
provides the required "pinctrl_soc.h" header with required types/macros.
The implementation is used in the tests to verify the behavior of the
API or Devicetree macros.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-10-25 15:26:47 -05:00
Martí Bolívar f259790bf8 dts: bindings: fix file names
Make sure binding file names match their compatibles.

Done with a script.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-10-20 07:33:04 -04:00
Carlo Caione 42105ed882 dts: Add support for specifier-space property.
Currently all the *-names and *-cells properties are derived from the
name of the base <name>s property. This is a limitation because:

- It forces the base property name to be plural ending in -s
- It doesn't allow the english exception of plural words ending in -es

With this patch we add one additional property 'specifier-space' that
can be used to explicitly specify the base property name.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
Suggested-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-10-13 09:56:46 -05:00
Martí Bolívar aa8fc3d7ff devicetree: add tests for devicetree/pinctrl.h macros
Test cases for new APIs.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-25 18:09:00 -04:00
Martí Bolívar d85118fde9 dts: test: fix vnd,adc-temp-sensor binding path
This isn't following the <compatible>.yaml naming convention; fix it.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-25 18:09:00 -04:00
Krzysztof Chruscinski ffc4a6c928 testsuite: Add busy simulator module
Busy simulator is using counter device and entropy device to
generate random cpu load. Counter device cofiguration can be
used to set cpu load interrupt priority and optional pin that
can be set during the load.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-07-29 10:59:00 -04:00
Martí Bolívar b2cc526061 tests: dts: test child bindings with compatibles
Make sure that child bindings with their own compatibles are treated
as first-class bindings. Do this by making sure that nodes whose
bindings are defined via 'child-binding:' are picked up as bus nodes,
instead of a parent bus node of the same type.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-03-25 09:37:42 -05:00
Peter Bigot feb0179d81 dts: bindings: test: complete bindings for gpio expander
These need to be gpio controllers and have the necessary specifier
properties for use in gpio specifiers.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-01-21 14:49:04 -06:00
Flavio Ceolin 3ec2cb5cb1 tests: devicetree: Add DT_PROP_BY_PHANDLE_IDX_OR test
Test macro DT_PROP_BY_PHANDLE_IDX_OR. There are two tests, one when
the property exists and other when the property is not set.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-12-09 16:39:33 -05:00
Kumar Gala e5eeb9d2f8 dts: bindings: test: Update vnd,serial to not require interrupts
We aren't using vnd,serial for anything currently.  Remove requiring
interrurpts property as that requirement isn't needed.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-10-23 08:53:38 -05:00
Erwan Gouriou c3eef7744a include/devicetree.h: Add DT_ENUM_IDX_OR macro
In case a "required: False" enum binding doesn't mention a
default value, but a default value makes sense to be set in the code,
DT_ENUM_IDX_OR could be used to provide the default idx to be used.

New macro comes with appropriate tests.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-10-05 10:15:32 -05:00
Henrik Brix Andersen 0e7a76e462 dts: bindings: move io-channels and io-channel-names to base.yaml
Generalize io-channels and io-channel-names devicetree node properties
and move their definitions to base.yaml. Keep binding specific
description where relevant.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-10-02 11:50:30 +02:00
Henrik Brix Andersen 8b5b7fcf8d test: lib: devicetree: add tests for DT_ macros for retrieving PWM period
Add tests for DT_ macros for retrieving the 'period' cell value.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-05-29 14:48:12 +02:00
Martí Bolívar e4a761cffe devicetree: add migration guide documentation and tests
Add test cases that verify various bits and pieces of the legacy
devicetree macros match the new APIs.

Writing these test cases without giving rise to deprecated macro
warnings which might break people's CI if they build with -Werror
requires turning off the __WARN() generation in
devicetree_legacy_unfixed.h. The entire file is deprecated at this
point and must be explicitly enabled with an opt-in Kconfig option, so
there isn't any harm in doing this.

Nevertheless, take a minimally invasive approach to avoiding __WARN()
generation in gen_legacy_defines.py, to avoid the possibility of
breakage. This code is basically frozen anyway, so hacks like this
won't cause maintainability problems since it isn't being actively
maintained.

Use the new tests as fodder for a migration guide from the old API in
the documentation.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-28 22:12:38 +02:00
Martí Bolívar 930c5807d5 tests: devicetree: test great-grandchild bindings
At some point, "child-binding:" apparently only worked up to 2 levels
deep. That's not the case anymore, but add a regression test to make
sure that doesn't break. 3 levels deep ought to be enough for anyone.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-28 22:12:38 +02:00
Gerard Marull-Paretas b35152ed4b devicetree: add DT_INST_FOREACH_CHILD macro
The macro iterates through the list of child nodes in a DT_DRV_COMPAT
instance and invokes provided macro for each node.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2020-05-13 21:22:06 +02:00
Kumar Gala 689f93bc33 devicetree.h: pwms: Add DT_PWMS_ macros
Add DT_PWMS macros to be used in pwm clients drivers.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-29 13:11:22 -05:00