-
Notifications
You must be signed in to change notification settings - Fork 8.2k
dts: silabs: use 'aliases' to remove dts_fixup defines #11707
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
|
@ekarlso, @diegosueiro, @mtuxpe I've prepared another PR as an RFC with a goal to remove reliance on dts_fixup.h file. The change was done for efr32fg1p series only. If this approach is accepted remaining SiLabs series would also need to be updated. Your comments are welcome. |
drivers/serial/uart_gecko.c
Outdated
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.
The USART string repetition in the generated #define seems unnecessary to me.
@galak, is there a way to avoid this?
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 pattern was established by #11180. The first part 'SILABS_GECKO_USART' is equal to the 'compatible' property of the node for which the define is generated. What follows is the extracted property itself.
One could argue that this is not the right choice for the define generated from an alias node since according to the device tree specification "The alias node shall be at the root of the devicetree". That means it belongs to the global namespace.
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 definitely agree on using aliases over dts_fixup. It is just strange for me (almost hurt my eyes) seeing this string repetitions.
Codecov Report
@@ Coverage Diff @@
## master #11707 +/- ##
=======================================
Coverage 48.2% 48.2%
=======================================
Files 280 280
Lines 43323 43323
Branches 10374 10374
=======================================
Hits 20886 20886
Misses 18289 18289
Partials 4148 4148Continue to review full report at Codecov.
|
dts/arm/silabs/efr32fg1p.dtsi
Outdated
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 have one question, maybe related to this. I plan to implement an spi driver that uses the usart peripheral.
In the device tree, this could use the same base node, e.g. usart@40010000, right?
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.
Yes, DTS describes underlying hardware and its structure. Since both drivers use the same hardware module they will use the same dts node.
One example that I know of where the same hardware module is used by several drivers is sercom peripheral on Atmel SAMD21 device. Best place to start looking into the code is here.
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.
Thank you
chrta
left a comment
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 prefer using aliases over dts_fixup.h
By adding 'aliases' node in SoC .dtsi file it is possible to generate DT_ defines which specify a logical name rather than relay on module location on APB bus. E.g. DT_SILABS_GECKO_USART_40010000_LABEL becomes DT_SILABS_GECKO_USART_USART_0_LABEL. Thus it is possible to remove dts_fixup.h defines. Signed-off-by: Piotr Mienkowski <[email protected]>
cd9c388 to
8b9c18b
Compare
|
I've pushed a new version that implements required changes for all SiLabs SoCs and boards. This PR is now suitable for merging. I confirmed that all SiLabs boards compile with no error. However, some more testing would definitely be welcomed. Especially verifying that i2c, usart, uart, leuart modules work in real life on the board. |
|
@galak, @MaureenHelm The discussion regarding the best method to remove dts_fixup files is still ongoing, however the aliases are already used by the Nordic SoCs. Even if we choose to handle generation of DTS defines differently it's easier to update defines within a few device drivers rather than maintain dts_fixup files. Could we review and merge this PR? |
Following PR is a request for comments. The change is implemented for efr32fg1p SoC only.
By adding 'aliases' node in SoC .dtsi file it is possible to generate DT_ defines which specify a logical name rather than relay on a module location on APB bus. E.g.
DT_SILABS_GECKO_USART_40010000_LABELbecomesDT_SILABS_GECKO_USART_USART_0_LABEL. Thus it is possible to remove dts_fixup.h defines. There is no limit on adding aliases for a given node and user is free to add a different one. Nordic family SoCs use the same approach.Another possibility to avoid adding dts_fixup entries is to modify the script which generates DT_ defines. A DTS node is defined as
e.g.
where usart0 is a node label. If a script used a node label rather than a unit address the resulting defines would relay on logical names and not on part number dependent, fixed addresses. However, since this approach was not implemented by maintainers of DTS scripts there may be a good reason to avoid it.