You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a device that the kernel reliably fails to initialize when using the driver.
After debugging, it looks like it has to do with the driver taking a lock via master->bus_lock_flag during initialization, which somehow changes the bus traffic, I suspect it has to do with CS but haven't pinned it down.
To check, I implemented a simplified version of set_cs/transfer_one so that I could test the default kernel impl of transfer_one_message. The problem immediately went way.
To make sure I correctly identified the problem, I modified transfer_one_message
from the project so it does not release CS if the bus is locked - again, the problem went away.
Please have a look at this. Here's my modified version, if it helps:
Some spi devices take the release of their chip select line as some sort of reset. That may be what's happening. However since no other spi driver is even checking the bus_lock_flag, I think this is not the right fix.
It's possible that the ch341 driver doesn't handle the cs mode properly.
The comments in include/linux/spi/spi.h about cs_change are starting to make more sense.
To keep CS high, the protocol driver needs to set cs_change=0 for the last transfer in a message and take a lock on the bus so no other device gets talked to in the meantime (which would de-assert the CS left active)
So you're right, the SPI controller driver doesn't need to know about the lock.
I did add the cs_change logic to ch341_transfer_one_message and at the time I thought it didn't solve the issue. But now I seem to recall it did change the error I was getting, and that was due to an unrelated issue.
I have a device that the kernel reliably fails to initialize when using the driver.
After debugging, it looks like it has to do with the driver taking a lock via
master->bus_lock_flag
during initialization, which somehow changes the bus traffic, I suspect it has to do with CS but haven't pinned it down.To check, I implemented a simplified version of
set_cs
/transfer_one
so that I could test the default kernel impl oftransfer_one_message
. The problem immediately went way.To make sure I correctly identified the problem, I modified
transfer_one_message
from the project so it does not release CS if the bus is locked - again, the problem went away.
Please have a look at this. Here's my modified version, if it helps:
The text was updated successfully, but these errors were encountered: