-
Notifications
You must be signed in to change notification settings - Fork 8.1k
include: devicetree: Generate defines for map property #87595
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
base: main
Are you sure you want to change the base?
Conversation
32aac28
to
6f69749
Compare
6f69749
to
812c000
Compare
21c854e
to
b4a6f6a
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.
@soburi thank you for your update. I think there is enough in here for me to give this a good review, which I will do as soon as I can. (I am traveling this week on a work trip so my availability will be a bit less than it was last week, but I want to prioritize your PR among other DT review requests I have.)
As an overall design question, I'm not sure that I think that ControllerAndData is an appropriate class to be using to represent the maps.
The zephyr phandle-array type is used when we have a list of (phandle, specifier) pairs. But in the case of generic maps, we don't have pairs, we have triples: (child_specifier, specifier_parent_phandle, parent_specifier). And in the case of interrupt maps, we have 5-tuples: (child_unit_address, child_interrupt_specifier, interrupt_parent, parent_unit_address, parent_interrupt_specifier).
I think that neither of these types of information is really a ControllerAndData due to the additional "child -> parent" information.
I am currently thinking it would make more sense to introduce two new types:
NexusMapEntry
: for the table entries contained in a<specifier>-map
as documented in DTSpec section 2.5.1. This would contain attributes namedchild_specifier
,parent
,parent_specifier
.InterruptMapEntry
: similar, except for theinterrupt-map
property table entries in DTSpec 2.4.3.
This would match the same pattern we have done with the Range
type used to represent elements of the standard ranges
property. Experience has shown from that case that picking type names and designing APIs to match the specification leads to future-proof work.
What do you think about this idea?
cc @dottspina for his perspective as a consumer of this API |
This was possible with the current structure, so I did so, but There may be some room for debate as to whether to use I'll move forward with it, but I might not have enough time this week. |
I agree there's room for debate. We could also use class inheritance to capture the specialization, perhaps. Thanks and looking forward to your next update. |
b4a6f6a
to
028b898
Compare
e6ff1b4
to
96619b5
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 <[email protected]>
Add `GET_ARGS_FIRST_N` tests. Signed-off-by: TOKITA Hiroshi <[email protected]>
They must be `array` type to match the existing `interrupt-map-mask` and `interrupt-map-pass-thru`. And also, updating descriptions. Signed-off-by: TOKITA Hiroshi <[email protected]>
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 <[email protected]>
96619b5
to
8318abc
Compare
Update done.
I decided to use
As a result, I updated macro generation rules and the APIs. It is mainly just a cleanup, but the structure makes it simple and reduces the code. |
5a3869a
to
6dd283e
Compare
6dd283e
to
163e905
Compare
163e905
to
d973109
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.
I noticed that in this file, some macros that require entry_idx
include xxx_BY_IDX
in their names, while others don't. They take the same parameters, but the suffixes used are not consistent, I think it would be better to make this consistent, e.g.:
#define DT_MAP_ENTRY_CHILD_ADDRESS_LEN(node_id, prop, entry_idx) \
DT_CAT6(node_id, _P_, prop, _MAP_ENTRY_, entry_idx, _CHILD_ADDRESS_LEN)
#define DT_MAP_HAS_ENTRY_BY_IDX(node_id, prop, entry_idx) \
IS_ENABLED(DT_CAT6(node_id, _P_, prop, _MAP_ENTRY_, entry_idx, _EXISTS))
And, it seems that when using these macros, you have to specify entry_idx
even when it's 0
. Therefore, I suggest adding wrapper macros similar to the existing ones, e.g.:
#define DT_REG_SIZE(node_id) DT_REG_SIZE_BY_IDX(node_id, 0)
#define DT_IRQ_HAS_CELL(node_id, cell) DT_IRQ_HAS_CELL_AT_IDX(node_id, 0, cell)
WDYT?
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.
This is done to prevent BY_IDX for map entries and
BY_IDX for lists of child/parent specifiers to appear simultaneously.
IMO, since "two-dimensional arrays" have not existed in devicetree until now,
applying the rules as is would make the code more difficult to read.
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.
And, it seems that when using these macros, you have to specify entry_idx even when it's 0. Therefore, I suggest adding wrapper macros similar to the existing ones, e.g.:
This has also been addressed.
Looks good, let's be patient, we are almost done :) |
This change introduces generating definitions corresponding to `*-map` property, which was currently discarded. For `*-map` properties are made able to be treated as a variation of phandle-array, assign sequential cell names for each group of specifiers (child_specifier_0, child_specifier_1, ..., parent_specifier_0, ...). 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 <[email protected]>
Add a map property test for `test_edtlib.py`. Signed-off-by: TOKITA Hiroshi <[email protected]>
Add tests for map property related macros. Add `native_sim/native/64` to allowed platforms. Signed-off-by: TOKITA Hiroshi <[email protected]>
d973109
to
6974b3c
Compare
|
Update done. |
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.