-
Notifications
You must be signed in to change notification settings - Fork 7k
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
new devicetree.h API #23245
new devicetree.h API #23245
Conversation
All checks are passing now. checkpatch (informational only, not a failure)
Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages. |
66a327f
to
e3c55ba
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.
Random comments from skimming.
Thanks @ulfalizer; comments addressed. I've done a couple of test conversions of nRF drivers as well. |
@ulfalizer do you know if we can whitelist "vnd," for examples here? |
When we use the new macros such as I propose to convert the Then we should make a judgment, trying to asses if the error message produced by the compiler is something this user is able to deal with. I run some tests locally, but it looks like we are missing macros to access properties with type phandle-array, i.e. extract pin value from gpios property.
so I'm not really sure what the end result would be. Zephyr's logging subsystem is also using macros extensively and the error messages produced are bulky and complex, difficult to interpret. |
OK, that's something to discuss then, because a phandle+specifier is a very useful thing to be able to treat as a single unit, for GPIO, IO channels, probably everything. |
@pabigot - Do we have an issue open for this? |
No, because there's a working solution for the old API. The new API doesn't have a replacement. |
I agree, but I think the correct solution is for the initializer generated for a phandle+specifier to replace the phandle with a pointer to the struct device, which we can't do yet. Edit: I think that is the next step, just to be explicit. |
In the final configuration, yes. For now, I need something to replace the existing uses of initializer-lists that include the name of the device along with the specifier. I will deal with that on a case-by-case basis. |
This is useful for devicetree documentation, examples, and tests, where we need to put something for the vendor but we can't use an actual piece of hardware for some reason. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This returns the entire logical {name: Node} dictionary which is currently being accessed element by element via chosen_node(name). It will be used in a new gen_defines.py for moving the handling of chosen nodes into C from Python. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This rename is mostly to easy git managment and review so any changes or the addition of the new gen_defines.py doesn't look like a diff against the old code if you look at just that commit. We keep changes to a minimum to just keep things building with the renamed gen_legacy_defines.py. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
If the #address-cells property for a register is 0 than we set the addr value of the reg to None. Similar, if #size-cells is 0 than we set the size value to None for the reg. Fixup kconfigfunctions.py to handle reg.size and reg.addr being None. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This is joint work with Kumar Gala (see signed-off-by). This supports a new devicetree macro syntax coming. It's not really worth mixing up the old and the new generation scripts into one file, because: - we aim to remove support for the old macros at some point, so it will be cleaner to start fresh with a new script based on the old one that only generates the new syntax - it will avoid regressions to leave the existing code alone while we're moving users to the new names Keep the existing script by moving it to gen_legacy_defines.py and changing a few comments and strings around. It's responsible for generating: - devicetree.conf: only needed by deprecated kconfigfunctions - devicetree_legacy_unfixed.h: "old" devicetree_unfixed.h macros Put a new gen_defines.py in its place. It generates: - zephyr.dts - devicetree_unfixed.h in the new syntax Include devicetree_legacy_unfixed.h from devicetree.h so no DT users are affected by this change. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no> Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This is joint work with Kumar Gala (see signed-off-by). Add helper macros which abstract the "true names" of each of the four types of node identifier we intend to support (e.g. DT_ALIAS(), DT_INST()). These can be passed to a new DT_PROP() macro which can be used to read the value of a devicetree property given a node identifier from one of these four other macros, and the as-a-c-token name of the property. Add other accessor macros and tests as well. Add some convenience APIs for writing device drivers based on instance numbers as well. Drivers can "#define DT_DRV_COMPAT driver_compatible" at the top of the file, then utilize these DT_INST_* macros to access various property defines. For example, the uart_sifive driver can do: #define DT_DRV_COMPAT sifive_uart0 Then use DT_INST macros like: .port = DT_INST_REG_ADDR(0), .sys_clk_freq = DT_INST_PROP(0, clock_frequency), For convenience working with specific hardware, also add: <devicetree/gpio.h> <devicetree/adc.h> <devicetree/spi.h> Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no> Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This is joint work with Kumar Gala (see signed-off-by). Document the changes to the generated node macros in macros.bnf, moving the old file to legacy-macros.bnf and putting it in its own section. The actual generated macros are now a low-level detail, so rewrite the foregoing sections as examples in terms of the new <devicetree.h> APIs. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no> Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This doesn't sacrifice any readability when compiled for boards that don't support this alias. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Use the new devicetree.h API instead of the legacy macros. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This allows us to start using DT_NODELABEL() to access SPIMs that way, instead of via an alias. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Use the new devicetree.h API instead of the legacy macros. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Use the new devicetree.h API instead of the legacy macros. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Mention the new devicetree.h API and link to relevant resources. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Update maintainers for code and docs. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
How do you feel about a macro per subsystem/class? Or do you see the need for this for phandle/phandle-array out of tree? |
Can we just do this as needed for now since it's temporary? Any other cases besides GPIO? I really want to be able to turn a phandle into a struct device* sooner rather than later, so I am hoping we don't have to spend too much review / discussion bandwidth solving an interim problem... |
There are other cases, yes, ADC in particular. But external workarounds are fine for now. #23691 can be resolved in the context of generating a device handle instead of the name; that's preferable anyway. |
Add a new devicetree.h API. This makes the current macros deprecated but keeps them around. The new API uses macros which are not generated, hiding the details of the generated macros from the user.
This is inspired by #22964 (comment) but "reverses" the capitalization: the names from devicetree remain lowercase. See the documentation changes for what I mean.
Fixes: #22964
Fixes: #22555
Fixes: #22554
Per @galak and @pabigot:
Fixes: #21369
Fixes: #19285
TODO list:
Out of scope for this PR, to be addressed later: