-
Notifications
You must be signed in to change notification settings - Fork 8.3k
drivers: spi_ll_stm32: Get SPI configuration from DT #5582
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 #5582 +/- ##
======================================
Coverage 51.3% 51.3%
======================================
Files 440 440
Lines 42232 42232
Branches 8055 8055
======================================
Hits 21667 21667
Misses 20046 20046
Partials 519 519Continue to review full report at Codecov.
|
45e1f25 to
dd257a4
Compare
mbolivar
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.
Thanks for the patches.
I've got some comments/questions.
dts/bindings/spi/spi.yaml
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.
What does this mean? Why are SPI and I2C in a parent/child relationship 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.
I used i2c.yaml as a template and I didn't remove it. Fixed.
dts/bindings/spi/spi.yaml
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.
New to DT here, but I'm not sure from this description what should go into the clocks array.
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.
Also I don't see any clocks properties in any of the real device nodes defined later, even though this binding is category: required. What's wrong 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.
New to DT here, but I'm not sure from this description what should go into the clocks array.
We should add a property in the SPI node to enable the SPI peripheral clock. Like it is done in u(s)art nodes (e.g. clocks = <&rcc STM32_CLOCK_BUS_APB2 0x00000020>). I used the same description which is used in uart and i2c yaml files. I plan to create PRs to add the clock property in SPI and I2C nodes for STM32 SOCs.
Also I don't see any clocks properties in any of the real device nodes defined later, even though this binding is category: required. What's wrong here?
The python scripts which extracts the defines from the dts files does not check and force the required properties. Maybe, @erwango could share more info on 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.
Ack. #5460 was raised to track this issue.
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.
Yup, aware of the issue with not enforcing the check; my question is if it is really needed in this patch series since the clocks properties are not present in the SPI nodes. (And sorry if this is well understood from DT context).
From your example <&rcc STM32_CLOCK_BUS_APB2 0x00000020>, the contents are SoC specific (in this case, a phandle to the RCC node, parent clock bus ID, and bit mask).
Do we really need this property defined in the generic spi.yaml then, if the contents are always going to be opaque?
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.
Yup, aware of the issue with not enforcing the check; my question is if it is really needed in this patch series since the clocks properties are not present in the SPI nodes. (And sorry if this is well understood from DT context).
I removed the clocks property because it isn't needed in this patch series.
Do we really need this property defined in the generic spi.yaml then, if the contents are always going to be opaque?
I don't know how the SPI peripheral is implemented in each vendor's SOC. We may need to define clocks property in a vendor,spi.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.
Makes sense to me
dts/bindings/spi/st,stm32-spi.yaml
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.
There is at least one important difference in the SPI IP blocks found on the different families, namely whether or not a FIFO is available for I/O or if just a single register (the DR) can be used. Does that need to be reflected 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.
(I'm not saying it does, just asking)
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.
Thanks for the pointer. It should. I added a st,stm32-spi-fifo.yaml.
dts/bindings/spi/st,stm32-spi.yaml
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.
Isn't this redundant since this inherits spi.yaml?
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.
Removed.
dts/arm/st/stm32f1.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.
Where are SPI2 (40003800) and SPI3 (40003c00)? Other SPI peripherals present on some SoCs in other families appear missing as well.
It looks like you might be putting just the "least common denominator" in the stm32fX.dtsi DTSI files, and filling in additional peripherals in stm32fXYZ.dtsi for the SoC. If that's right, I guess there's more follow-up work to do to add the missing SPI nodes for other SoCs, 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, I added the "least common denominator" in the stm32fX.dtsi and filled the additional SPI nodes in stm32fXYZ.dtsi only to the SOCs where boards use the additional SPI. We could add the rest SPI nodes in stm32fXYZ.dtsi when we add SPI support to other boards.
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.
If this is the case (complete set of SPI instances to be provided in a later commit when required) please indicate the scope of current commit in the description.
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.
Done.
boards/arm/96b_carbon/96b_carbon.dts
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 think you can / should delete the interrupts properties from the board files. You've already defined them at SOC level, which is where they belong.
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.
Done.
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 commit log does not explain why these should be removed; can you explain why?
Presumably if an application sets a value specifically, it may be a necessary override of the default. Did you check to make sure you're just removing default settings?
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.
If we use DT to get the *_IRQ_PRI, we can't override it using Kconfig. We need to use a BOARD_NAME.overlay file.
Presumably if an application sets a value specifically, it may be a necessary override of the default. Did you check to make sure you're just removing default settings?
You are right. I didn't check if this value is just a default value or it is necessary for the application. I don't have the hardware to check it, so I will try to ask codeowner 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.
Presumably if an application sets a value specifically, it may be a necessary override of the default. Did you check to make sure you're just removing default settings?
You are right. I didn't check if this value is just a default value or it is necessary for the application. I don't have the hardware to check it, so I will try to ask codeowner for review.
And the samples codeowner is you. I apologize for not checking it with you first. If the value is necessary, I will update the PR with the needed overlay files.
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 went back and looked at the wire protocols for these drivers.
I think this lpd8806 sample is OK to use the SoC-provided IRQ PRI value (5), but I'm less sure what to do with the ws2812 sample.
(The ws2812 driver plays tricks with SPI to implement a one-wire real-time protocol, so the sample will probably work, but giving higher priority to the SPI IRQ and driver thread is important for applications with multiple tasks.)
This is a personal time driver for me so I will test tonight after work, but my guess is the default will be OK, but I'll need to add extra documentation for this driver about adjusting the IRQ priority using device tree overlays after your series goes in.
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.
@ydamigos I didn't make time to test, but I am OK with moving these to the default SoC provided values since these drivers don't have many users right now. I think I need to send those documentation patches about configuring the IRQ priority no matter what. If I run into problems, I'll add overlays to the samples myself. Thanks for the pointer on how to fix any issues.
erwango
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.
Some comments on IRQ prio
Otherwise, this is a good work, thanks!
dts/bindings/spi/spi.yaml
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.
Ack. #5460 was raised to track this issue.
dts/arm/st/stm32f0.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.
SPI IRQ prio is generally not 0.
Was 0 put here on purpose and meant to be modified in boards dts?
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, I set SPI IRQ prio to zero in SOC's dtsi file and meant to override it on application level. Should I change the default value in SOCs level to something else if the SPI IRQ prio is generally not 0? I would like to avoid setting the default SPI IRQ prio in boards level.
boards/arm/96b_carbon/96b_carbon.dts
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.
If you don't modify IRQ prio here, it will be 0 instead of 5 as set in Kconfig.defconfig
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 configured default SPI IRQ prio to 5 on SOC level.
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.
Same here, spi3 IRQ pri is defaultly set to 0 instead of 10
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 configured default SPI IRQ prio to 5 on SOC level.
dts/arm/st/stm32f1.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.
If this is the case (complete set of SPI instances to be provided in a later commit when required) please indicate the scope of current commit in the description.
5c3da68 to
5d28fee
Compare
dts/arm/st/stm32f0.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.
Add a space right before the = in all files changed:
label= "SPI_1";
to
label = "SPI_1";
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.
a674f66 to
725578a
Compare
|
I pushed an update to just fix some commits with empty bodies after the decision in yesterday's TSC meeting. |
725578a to
16c17d1
Compare
|
@erwango you good with this? |
|
Can we look at adding a spi device to any of these device trees? |
|
What's the difference between st,stm32-spi-fifo.yaml & st,stm32-spi? |
I used to yaml file to show the difference between SPI IP blocks found on the different families, which could have a FIFO available for I/O or just a single register (the DR).
I plan to add spi device support in a follow-up PR. |
Add yaml files to DT for initial support of STM32 SPI Origin: original Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
This commits adds the "least common denominator" in the stm32fX.dtsi files and fills the additional SPI nodes in stm32fXYZ.dtsi files, only for the SOCs where boards use the additional SPI peripheral. We could add the rest SPI nodes in the stm32fXYZ.dtsi files when we add SPI support to other boards. Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
Get SPI_*_BASE_ADDRESS, SPI_*_NAME, SPI_*_IRQ and SPI_*_IRQ_PRI from DT. Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
Configure SPI using DT for the following STM32 boards: 96b_carbon disco_l475_iot1 Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
Remove SPI_*_IRQ_PRI from tests and samples. Using DT to get the *_IRQ_PRI, we can't override it using Kconfig. If needed, use a BOARD_NAME.overlay file to override default values. Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
16c17d1 to
53c1014
Compare
|
I just added license header to the new spi yaml files. |
| string | ||
| prompt "SPI port 1 device name" | ||
| depends on SPI_1 | ||
| depends on SPI_1 && !HAS_DTS_SPI |
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.
@ydamigos
I know this PR is merged already, but I have a followup question:
why didn't SPI_0_NAME (same for SPI 4-6) get the same dependency?
I see you changed only the parts necessary for stm32 (SPI_1 to SPI_3), but wouldn't it be better to keep KConfig consistent in these parts?
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.
@dwagenk As you mentioned, the PR focused on adding DT support for the STM32 boards. We could add the dependencies to the rest SPI_x when they start to use DT in different PRs.
Get SPI_BASE_ADDRESS, SPINAME, SPIIRQ and SPI_IRQ_PRI from DT.