-
Notifications
You must be signed in to change notification settings - Fork 5.2k
CM4 SPI speed issue Bookworm v6.6 #6225
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
Comments
What was the last-known-good version? Rather than have us start an open-ended investigation into SPI speed handling on CM4, please post some example code/DTS that demonstrates the issue. If there is a problem in the SPI driver/framework then you should be able to reproduce it using spidev, removing the need to use your driver. |
Hi @pelwell, like I mentioned before it is working with 5.15.74. (5.15.74 -> 6.6.31) Here is my DT,
And this is trimmed driver test code:
And this is what I get with kernel 5.15.74. This is correct speed and data! The following image is taken kernel 6.6.31. Probably the data is true (logic analyzer can't handle) but the problem is speed! Simple math 717 us / 5.9 us =~121 So, it looks like the SPI speed is around 125 MHZ instead of 1MHZ I can't reproduce the same issue with spidev driver. I spent 2 days but I can't figure out what is wrong, I am not able to set speed with current kernel 6.6.31. Thanks for your help. |
Thanks for your time @pelwell, today I tried all combinations that I have; CM4 lite 1Gb ( 2 different) 6.6.20-1+rpt1 (2024-03-07) aarch64 (fresh installed) All ended with the same result. I can't control SPI speed! The only working kernel is 5.15.74. I am going crazy, I am probably missing something. Could you let me know your device and setup? And how did you load the test driver? Thank you. |
I'm testing on a CM4+CM4IO, loading your driver using your overlay. I chose to load it at runtime ( |
Thanks for your reply. Are you able to share your config.txt? |
This is what I have in config.txt (comments and blank lines removed):
Ah - it might be interesting for you to add |
Under other circumstance I would now be running the same test without |
@pelwell, Finally I figured out the issue. All this happens due to "short-enums" flag. I have a few int8_t enum definitions in the original driver. I made a mistake and used the same make file while compiling it. And that "short-enums" flag cause the problem. I still don't know what has changed since 5.15.74, this flag has an issue, but now I am able to control SPI speed with the current kernel. I appreciate your support and time. |
Describe the bug
I have a custom SPI driver which drives 2 LCD via SPI0, CS0 and CS1. It was working perfectly until the 6.6.31 update. I figured out that the issue related to SPI speed.
I am not able control SPI speed with DT or manually. It won't response to ;
spi-max-frequency = or spi->max_speed_hz = xxxx;
If I set speed via Device Tree; spi->max_speed_hz returns abnormal values like 1077680128, 1090041856
If I set it manually with spi->max_speed_hz = xxxx than I can read the correct value but it won't change the speed.
The device can handle 125mhz without an issue with kernel 5.15.74.
Did I miss something or is there an issue on SPI bus?
Steps to reproduce the behaviour
Probably the best approach will be to check speed via oscilloscope or a logic analyzer. My equipment does not allow me to check speeds over 100mhz. It looks between 150 - 200 Mhz based on my frame calculation!
Device (s)
Raspberry Pi CM4 Lite
System
Raspberry Pi reference 2024-03-15
Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, f19ee211ddafcae300827f953d143de92a5c6624, stage2
May 24 2024 15:30:04
Copyright (c) 2012 Broadcom
version 4942b7633c0ff1af1ee95a51a33b56a9dae47529 (clean) (release) (start)
Linux doly 6.6.31+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.31-1+rpt1 (2024-05-29) aarch64 GNU/Linux
Logs
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: