-
Notifications
You must be signed in to change notification settings - Fork 7.3k
spi: sam0: use Device Tree for configuration. #5865
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
Codecov Report
@@ Coverage Diff @@
## master #5865 +/- ##
=======================================
Coverage 53.08% 53.08%
=======================================
Files 430 430
Lines 41040 41040
Branches 7908 7908
=======================================
Hits 21785 21785
Misses 16032 16032
Partials 3223 3223 Continue to review full report at Codecov.
|
You could merge this with #5731 |
4b79288
to
8805696
Compare
@galak @tbursztyka this is now ready for review. |
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.
We need to rework how we deal w/SPI & UART since they are all just modes of SERCOM.
I think we should have a node per SERCOM, have multiple compatibles in the node. One for “atmel,sercom”, and one for “atmel,sercom-spi”, “atmel,sercom-i2c” or “atmel,sercom-uart”. Not sure if we should expand the compats to match the all the modes (CTRLA.MODE) can be set to.
@nzmichaelh any updates here? |
Hey @galak I'm happy to rework this but I'll need some pointers on Device Tree :) The peripheral reset and clock configuration code is basically the same for all SERCOMs. The peripheral is pretty simple so the actual serial, SPI, etc drivers are dominated by how different the Zephyr API is. |
@galak let me know what the changes would look like and I'll start working on them |
I've also rebased onto master. |
0c0d645
to
b79b64c
Compare
Hi @galak I've rebased this and updated it for the Trinket M0. re: the many modes of SERCOM, I had a look around the code and couldn't find an example of how to do support multiple modes of one peripheral. Could you tell me how, else could we land this patch and merge the SERCOM modes in a follow up? |
I need to play around with this, the straight forward method is to modify the compatible in the board .dts file to set it to uart or spi. I need to chat with a few people to see if there are examples of how this should be handled. |
Ok, after a little discussion I think the compatible solution is the way to go. So I think we should have sercom nodes in dts/arm/atmel/samd21.dtsi - w/o any compatible. In the board.dts we than add the compatible in addition to status = "ok"; So something like: &sercom0 { &sercom4 { Make sense? |
@galak done. It turned out pretty clean - the Device Tree generator uses the compatible string as part of the #define, so I didn't need to make any other changes. |
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.
DT node inheritance is not clear to me. For example, the interrupt property exists in atmel,sam0-uart.yaml but I cannot find it in atmel,sam0-spi.yaml. Does SAM0 spi driver support interrupt?
sercom0: uart@42000800 { | ||
compatible = "atmel,sam0-uart"; | ||
sercom0: sercom@42000800 { | ||
compatible = "atmel,sam0-sercom"; |
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 couldn't find this constrain in any yaml file.
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.
Fixed.
re: sercom, uart, and spi: the SPI driver doesn't use interrupts as the SAM0 has no FIFO so it's faster and cheaper to use polling. re: inheritance, it seems the Device Tree generator doesn't support multiple inheritance so, for example, the sam0-uart binding can't inherit from both uart.yaml and atmel,sam0-sercom.yaml. |
I propose to remove atmel,sam0-sercom.yaml,
In board's dtsi we add uart as:
and SPI as you already did. In board level, you could use aliases and override label property (e.g. SPI_1, UART_1) to make things more clear. WDYT? If SPI HW uses interrupts we could leave interrupts property in sercomX nodes in samd21.dtsi file. The SPI driver won't use them. |
The SPI HW does support interrupts so leaving them in samd21.dtsi SGTM. They're just not used as the driver is master only. |
@ydamigos SGTM. Looking forward to seeing this land in the tree. |
The SPI loopback config for the Arduino Zero |
Define a Device Tree binding for the SAM0 SPI and use it instead of
Kconfig for enabling / disabling instances
Signed-off-by: Michael Hope [email protected]