-
Notifications
You must be signed in to change notification settings - Fork 845
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
spi-axi-engine: Calculate buffer dimension for xfer
After the modification to the word length the buffer for rx and tx needed to be adapted to the new size. Before this update the size was fixed to 8 bits and that was stored inside memory. Example: 20 bit resolution -> entire 20 bit value stored inside 32 bit register. Value is separated into 3 parts of 8 bits and stored in the rx buffer. The same for tx part. Signed-off-by: Mircea Caprioru <[email protected]>
- Loading branch information
Showing
1 changed file
with
41 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30707b0
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 believe this commit breaks compatibility with the standard SPI API. The length of a transfer is always specified in bytes, not words. See https://elixir.bootlin.com/linux/v5.0/source/include/linux/spi/spi.h#L700
Commit 42d22f4 and 1ba9543 then seem to try and fix this, but drivers using the SPI controller that specify transfer length in bytes will still output the wrong value.
I'm still pretty green when it comes to the kernel, so please let me know if I've got that wrong!
30707b0
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.
Hi Iain,
You where right that the other commits are fixing some issues regarding the buffer writes but those are mostly related to how we interface to the SPI Engine IP core.
The SPI api has the option to specify a word length https://elixir.bootlin.com/linux/v5.0/source/include/linux/spi/spi.h#L703
The only thing to ensure is that the transfer length covers that word length. In a case with 20 bits word length you must have a transfer of 32 bits that means that tx length will be 4 bytes.
You also have this check here https://elixir.bootlin.com/linux/v5.0/source/drivers/spi/spi.c#L2979,
https://elixir.bootlin.com/linux/v5.0/source/drivers/spi/spi.c#L2798
It even drives the CS line on a per word basis.
Regards,
Mircea
30707b0
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.
Ah. My apologies. I think during my testing I accidentally grabbed this version rather than the one with the fix applied, and then correlated recalculations on xfer->len as the culprit for MSB byte copies. I should really have checked the code more thoroughly rather than presuming, and made sure I was running the correct version!
Thanks for taking the time to reply. Very much appreciated. Keep up the good work.
Cheers,
Iain
30707b0
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.
No worries Iain, glad to be of help.
Cheers,
Mircea