-
Notifications
You must be signed in to change notification settings - Fork 7.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
include: devicetree: Generate defines for map property #87595
base: main
Are you sure you want to change the base?
Conversation
cea82a5
to
7bd4e36
Compare
Gets the specified number of elements from the beginning of the list. This is the symmetircal operation as `GET_ARGS_LESS_N`. Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Add `GET_ARGS_FIRST_N` tests. Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
32aac28
to
6f69749
Compare
They must be `array` type to match the existing `interrupt-map-mask` and `interrupt-map-pass-thru`. Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Add a base binding for interrupt and io-channel nexus nodes. This makes the implicit definitions explicit. Replace existing individual map definitions with this. This file does not define a specific `compatible` on its own, So you should include this file before using it practically. Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Making generalized the `_interrupt_cells` to be able to use for any `#...-cells` property. Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Add a method `to_compould()` to get a compound type value consisting of a number and a phandle, like `...-map`. Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
6f69749
to
812c000
Compare
Add Map dataclass to store `*-map` property. Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
This change introduces generating definitions corresponding to `*-map` property, which was currently discarded. The `*-map` data is like a two-dimensional array, so it is difficult to handle with the existing APIs, so we will also provide new APIs. Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
812c000
to
e5f0587
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, @soburi . The first 5/8 patches look good to me, with one minor comment.
I have some concerns about the last 3/8 patches. I think I understand the goal and exposing the map properties as first-class citizens makes sense to me. However, the approach using to_compound()
feels a little bit error-prone and I want to discuss the implementation.
Devicetree Specification v0.4 section 2.5, "Nexus Nodes and Specifier Mapping" is where the semantics are defined. There, it says:
A nexus node shall have a
#<specifier>-cells
property, where<specifier>
is some specifier space such as ‘gpio’, ‘clock’, ‘reset’, etc
The description of the <specifier>-map
property then says:
child specifier
The specifier of the child node being mapped. The number of 32-bit cells required to specify this component is described by the
#<specifier>-cells
property of this node—the nexus node containing the<specifier>-map
property
It also says:
parent specifier
The specifier in the parent domain. The number of 32-bit cells required to specify this component is described by the
#<specifier>-cells
property of the specifier parent node.
Combining these, I think that we should be able to decode each <specifier>-map
property without needing to_compound()
. We can make a loop like this:
- Read
#<specifier>-cells * 4
bytes from the current position in the<specifier>-map
property. This is the child specifier. We can convert it to<u32>
cells using existing dtlib features. - Read the next 4 bytes. This is the "specifier parent" phandle from section 2.5 of the specification. We can convert it to a "specifier parent node" using phandle2node.
- Read the
#<specifier>-cells
property from the specifier parent node. This is the number of<u32>
cells after the phandle which makes the "parent specifier" - Read the parent specifier bytes and convert them to cells.
What I mean is, by using the #<specifier>-cells
properties in the parent and child nodes, we can iterate through the <specifier>-map
property and convert it into a lookup table without to_compound()
.
I am concerned that to_compound()
is:
- not checking the proper
#<specifier>-cells
values we expect to find, and instead just uses the source encoding to guess where the table entry elements are in<specifier>-map
- adding a feature for strings that does not seem to be needed to handle
<speciifer>-map
properties -- this feels like it might be trying to do more than it needs to, and might have to be revisited over time as we add more heuristics
I'd be more comfortable with an approach that relied on the strict definitions in section 2.5 of the specification to decode the values of <specifier>-map
properties. We can be sure that this will not change and the code will stand the test of time.
"#io-channel-cells": | ||
type: int | ||
required: true | ||
description: Number of items to expect in a ADC specifier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, strictly speaking, that these are derived from the Linux iio bindings. The iio bindings are useful for ADCs but are not limited to ADCs. So perhaps this should be moved to dts/bindings/iio, and this "ADC specifier" portion should be changed to "channel specifier, e.g. ADC channel" or something similar?
This change introduces generating definitions corresponding to
*-map
property, which was currently discarded.The
*-map
data is like a two-dimensional array, so it is difficult tohandle with the existing APIs, so we will also provide new APIs.
Common utilities have been separated into a separate PR.
Please take a look at this first. #84190
I noticed this problem while developing https://github.com/zephyrproject-rtos/gsoc-2022-arduino-core.
Since map is used to associate with the physical layout, there is a need to know the "physical pin names".
Since the mapping process is performed during the generation of devicetree-generated.h, I don't think there are many cases where information about the mapping source is needed. However, there are such cases, however rare, and it is not desirable for the information written in the devicetree to be discarded, so I would like to introduce this.