-
Notifications
You must be signed in to change notification settings - Fork 7.4k
dts: Add device type handing support #17976
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
Conversation
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 this adds complexity for no value. We already have the compatible
property, and this just adds another property that works the same way.
Having cpu
nodes without device_type
is common in the Linux kernel, if you're worried about existing practice. See this, this, this, and this for example.
The schema you found in #17860 doesn't say that device_type
is required for cpu
nodes. It says that cpu
nodes should have at least one of device_type
, reg
, or compatible
(note the anyOf
).
device_type
is deprecated in the devicetree specification:
The device_type property was used in IEEE 1275 to describe the device's
FCode programming model. Because DTSpec does not have FCode, new use of the
property is deprecated, and it should be included only on `cpu` and
`memory` nodes for compatibility with IEEE 1275–derived devicetrees.
(IEEE 1275 is a standard from 1994.)
The wording is a bit ambiguous, but I think it's just making concessions for old IEEE 1275-derived devicetrees, by saying that it's okay to have device_type
on cpu
and memory
nodes (but not on any other nodes). It's not saying that you must have device_type
on those.
That leaves device_type = "memory"
, which seems to be put in pretty consistently in the Linux .dts
files, and is required by at least one random schema file. I think we should just remove it along with device_type = "cpu"
still, since we don't use it. The compatible
mechanism is all we need. If we absolutely must have it, we could require it in the binding though, along with a comment that says it's unused.
I understand your intent in the comments, but my goal is to eventually pull edtlib.py out of Zephyr and have it as a standalone project that can be used by others. As such support for Additionally, we've had a long term goal of sharing device tree's across projects (there are already STM32 dts files in Linux for example). So I understand the desire not to clutter things for various semantics we might not like in Zephyr, but I don't think we can fully take that stance. |
365f823
to
4916910
Compare
This is a meta-comment: I have no opinion about the technical aspects of this particular PR. I'm swayed by the argument of standard conformance to support reusability, applying both here and #17829. So, no default support as currently proposed in #17928. However: this cuts both ways. If we say we want devicetree source to be compatible with non-Zephyr systems, we should not be using our own schemas but instead have a plan to move to the dt-schema hierarchy for both And we need to be more careful about using standard properties appropriately. I have not changed my position on Zephyr's (mis)use of But that assumes the schema is extensible so that the presence of environment-specific properties can be validated. (Which also kills the "diagnose unrecognized properties" feature. Annoying!) I don't plan to look into this so I'm blue-skying here, but if the standard supports it, I think #17928 can be salvaged by naming the YAML entry Similarly, things like setting driver init group and priority--which is a critical gap (#17830) for multi-instance devices--are specific to the way Zephyr uses devicetree content. I want to see something like this in the YAML for GPIO [*]:
Then, in the devicetree, I can enforce the conditions that an SX1509B driver hanging off an I2C bus has an init priority that places it after the parent bus is initialized. Right now that's done with a Kconfig setting, which is, simply, wrong. [**] In short: we need be consistent in what we're aiming for, and make sure everybody understands and accepts it, so we stop wasting time working on features that aren't acceptable, and so we end up with a system that meets clearly-defined goals. A good way to start would be to write it down and reference it when assessing whether a proposed solution is appropriate. (It may be written down, but most of the rejections I've seen are independently justified rather than based on reference to a documented plan.) [*] In fact I really need this, and can't get it without modifying the scripting, so I'm again giving up on a generic regulator to support ultra-low-power sensor applications (see #17830). [**] IMO the correct way to deal with device initialization is to create a dependency graph based on devicetree node relations, then use a strongly-connected-components algorithm to sort them into an initialization order that is correct, rather than relying on magic numbers sprinkled throughout the infrastructure. You'd still need |
I don't think we should put any effort into supporting deprecated Linux hacks that we don't need in Zephyr, especially not at this point. The C tools do not special-case
Fixing them up is trivial, and having clean and easy-to-understand devicetree files is much more important than allowing people to blindly copy-paste stuff in. |
I agree and have stated thats a goal to convert the bindings to use dt-schema in the future. |
I agree with this as well, the first step was the cleanup the base scripts and introduce edtlib.py that we could utilize for code generation. Now that we've got a cleaner base I think it will be easier to move to a model in which we don't need the strings at all and could remove the |
I imagine this is need for power management as well. |
The deprecation in Linux and the DT spec is with regards to new device classes and not propagating the use of
Which C tool are you referring too?
The devicetree model in other projects isn't as fluid as it has been in Zephyr, so one has to take some of the baggage along with it. For example since in Linux or other projects a binary DTB get used there contents are far more static and thus you can't just say we can change the dts files. |
It's that way for legacy reasons in Linux, not because it's a good way to do things. The Supporting copy-paste of files with poorly-designed legacy stuff in them isn't worth the effort I think. Fixing it takes second. A much bigger problem that we have is that our devicetree stuff is unnecessarily complex, and this adds to it.
Do we need that? If you want to follow the spec., it disallows it.
I don't get it. If someone puts
I'm not against moving to something like One minor iffy thing is that we currently do an ugly regex thing to find bindings, inherited from the old code (see Line 1029 in 209a910
dt-schema seems to do something fancier that might not allow that hack.
Don't know if it'd be a problem though. Wonder if we could just match on filename instead. Another thing is that |
I'm not against removing |
Let me ask more clearly: Is there a written down roadmap of where Zephyr is heading with devicetree? Including the overall goals and constraints, which people reviewing PRs can use as reference in assessing them for architectural consistency? Rather like #17706 that was provided to meet that demand before POSIX changes were acceptable? Except maybe even more detailed, since it's such a large scale and long term activity with multiple intermediate steps. Because there needs to be such a plan, possibly even a github project to manage it. We can't be expected to know everything that's been said in a comment or slack discussion somewhere. Proposing, preparing, and submitting PRs for workarounds that you're going to reject is a waste of time. And we can't give quality feedback on PRs without an understanding of what they're intended to do and how they advance Zephyr to a desired end state. This one doesn't even have a description. |
For legacy reasons, not because it's a good way to do things. Linux has reasons to preserve that legacy, because The writing on the wall in the spec. and devicetree-org/devicetree-specification#29 is that no one would be sad to see For pure RAM nodes, why not change If you look at the pattern in my PRs (lots of documentation, commenting, and code cleanups), a lot of it is about making things simpler to understand and cleaner. I'd be happy to put in a custom message that tells people what to do instead if they put in a We could even put in support for One thing that irks me about even adding support in edtlib though is that it's a step towards the unreadable mess in the old scripts.
The stuff that's getting rejected seems to be exactly the kind of stuff I was planning to work on too, so it's pretty frustrating for me. Our devicetree stuff is too complex and quirky and poorly documented, even with the rewrite, so I want to change it to be simpler. I won't do anything that I think would make people more confused, because that would make me feel bad. (Family of teachers, so maybe I'm damaged from that. :P) |
Agree with @galak here. If we want edtlib to be used outside zephyr, then we need to adapt it to (rather common) dts practices, because we won't be able to impose new usages in dts because of edtlib. As said device tree guys (devicetree-org/devicetree-specification#29 (comment))
And then, about (in same comment):
Ok, but if we want to be able to enjoy multiplatform build with zephyr using edtslib, then, we don't fall in that category. |
Yes. In the same vein, I remain concerned that we seem to be developing parsing/validation code and making policies about what's an error/warning/ignored when dt-schema clearly has the ability to process schema, and to validate both schema and devicetree data. We should be trying to use or integrate with as much of that infrastructure as possible. I understand this may be a goal that can't be reached now because of past Zephyr-specific decisions, but if there's no plan then the new effort is just going to create more incompatibilities that will have to be worked around in the future. |
c4ec776
to
1a7d15a
Compare
Rename the helper function _binding_compat to _binding_constraint as its not limited to matching a constraint on the compatible property but can also easily work for a constraint on any property. Signed-off-by: Kumar Gala <[email protected]>
Rename matching_compat to matching_constraint to be more generic since we could have the constraint be on something other than a compatible property. Signed-off-by: Kumar Gala <[email protected]>
Treat device_type similar to compatiable, use it to match a binding if there isn't a compatiable. Signed-off-by: Kumar Gala <[email protected]>
Add support for handling generation of defines if the binding match is based on device_type and not compatiable. This is primarily for handling memory nodes which don't typically have a compatiable property. Signed-off-by: Kumar Gala <[email protected]>
b9093e2
to
43813b6
Compare
@galak, should we keep this one ? |
No description provided.