-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
devicetree: fixed non-alias reference to specific nodes #19285
Comments
In #20115 I discovered that the IMX GPIO driver enumerates ports from 1 to 7, corresponding to the datasheet names. I also discovered that I'm making this high because we need a solution for this that does not involve massive soc/series-specific |
About DT_INST_ macros, there are 2 main concerns on my side:
[1] Similarly to following observation:
On STM32 SoCs, this case is frequent as well. For instance:
[2] Also in some particular cases, we need instance specific code in drivers, due to specialties of one instance (cf zephyr/drivers/can/can_stm32.c Line 432 in 4f16268
|
Side note on the 'non-alias' nature of the solution: I think aliases are highly valuable in case of providing a hook between hardware abstracted application and a particular target. For instance the use of led0 or sw0, that provides a handy application<>hardware matching. We can even find more value in these, such as the ability to know of specific if a board support such or such feature in a cross-vendor scheme. |
I agree with @erwango about the value of aliases for cross-target naming of common capability like LEDs and buttons. But for that to be robust we might need to control the namespace, so people know that I also find the two-part definition for alias to be inconvenient: because At this time I'm leaning toward adding In the case of IMX GPIO for example the fifth GPIO node is defined by:
and currently tooling generates:
I propose removing the alias from the devicetree source, since it's not useful for cross-target resource identification, and generating:
which is unambiguous within SOC-specific code like a peripheral driver, assuming the SOC devicetree includes are consistent. I'd also be interested in considering:
to solve the "how do I find things by path" problem. |
Could it be: compatible + label (prop) ?
+1 |
That's probably it and makes more sense than alias (though still not particularly useful). Thanks, updated comment. |
As part of this work, I think we should settle on current usage of aliases.
A (non exhaustive) list of occurrences could be given by following link: Following #22555 implementation, next step would be removal of pleonastic |
@pabigot as discussed internally at Nordic, @anangl has identified at least one place where this is an invalid assumption:
In particular, the Nordic HAL exposes some ISR routines for SPI peripherals through names that correspond to their SoC IDs, namely nrfx_spim_X_irq_handler: https://github.com/zephyrproject-rtos/zephyr/blob/master/drivers/spi/spi_nrfx_spim.c#L396 I.e. the driver does care which one is which in some cases, even when drivers have identical compats, so drivers should be able to use NODELABEL in time of need. It also seems to me there's no disagreement to #22555 (generate NODELABEL node identifiers) in principle, there's just desire to settle on a more robust naming convention ( #22964) for DT macros before adding more names. I will follow up with another comment summarizing the discussion and making a proposal for how we can close this. |
That likely could be finessed through indexing cast initializer lists, but I have no objections to using NODELABEL for cases where something special is needed. I think it's @galak that particularly wants things to be instance-based. |
@pabigot @erwango @galak @ulfalizer @carlescufi @mnkp @anangl @jfischer-phytec-iot : Edit: this comment is now a working consensus, following discussion at 27 February 2020 dev-review metting. I propose these answers to the questions raised by this issue:
|
This seems quite fine to me. Though, I'm not clear on the difference you make between in-tree and built-in. Can you clarify this ? Finally, about legit aliases, should we work on defining naming rules, or keep as is for now and clarify when need arises? |
No difference was intended. Sorry to be confusing. I've updated the comment to use in-tree consistently.
I don't know myself, but I think that might be a separate issue. It seems like this issue is mainly about what types of node identifiers should be used, and when, rather than how to name each alias identifier. |
Perfect thanks.
Ok, thanks. |
…ccess Aliases should be used to refer to generic hardware components from application code. This way board and hardware can be changed completly and only overlay with aliases will be needed to connect application components with relevant hardware drivers. Reference: zephyrproject-rtos/zephyr#19285 (comment)
This issue steps back from a solution-oriented #18986 and poses more generally the question of how to get access to devicetree node data from application and driver sources, given that code does not have the ability to follow a node path.
For background, three cases have been identified:
foo = &label
, which produces node properties with the prefixDT_ALIAS_FOO_
. This closely models standard devicetree use and is fine, but it requires that nodes be given a (node) label (notlabel
property) that's referenced in thealias
section.DT_INST_#_COMPATIBLE_
where#
is a zero-based ordinal. The association between a given ordinal and a specific instance is not fixed, because new instances may be added through devicetree overlays. Here the solution is fine because user code will access specific devices through the instance identifier (label
property value) and the driver doesn't care which one is which.DT_INST_#_
does not work) and use of an alias (DT_ALIAS_
) is annoying. Examples are accessing node properties using the name provided in the hardware description, such as vendor SOC documentation or board schematics.This issue addresses the last. The most recent motivating use case was in #18937 where many aliases were added solely to have a fixed name for specific instances. An earlier proposal was #12546 which was closed at a time where the previous spelling of
DT_ALIAS_
was judged adequate.Current proposed solutions circle around a string property that provides the name.
soc-label
has been proposed, as haszephyr,id
. Let's pick a property name, decide once and for all that aliases are the right approach, or pick from other unknown solution approaches.The text was updated successfully, but these errors were encountered: