-
Notifications
You must be signed in to change notification settings - Fork 7.6k
drivers: spi: atmel spi_sam0: Reset peripheral on init #90921
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
drivers: spi: atmel spi_sam0: Reset peripheral on init #90921
Conversation
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.
Overall LGTM, just small things and CI must be green : )
BTW, you need to follow the commit message guidelines.
I'm looking forward to accept you PR.
Sweet. Could you let me know what should be improved in the commit message? |
6aa7608
to
c95b27e
Compare
@nandojve I rebased, split the changes into two commits, added conditional compilation for the CTRLC register, and reworded the commit messages. Please let me know if you find this satisfactory or if you desire additional changes :) |
The sam0 SPI driver does not ensure that it clears the 32-bit extension option during init. The 32-bit extension option, which comprises of a field in the CTRLC register and the LENGTH register enables better bus utilization by allowing 32-bit writes to the SPI DATA register (as opposed to the usual 8-bit writes). The driver breaks down if this option is enabled by causing each intended byte of output to become four bytes. We fix this by explicitly disabling the 32-bit extension option in init. Signed-off-by: Pete Dietl <[email protected]>
Reset the SPI peripheral to its default state and register values on init by setting its SWRST bit. This is important since the driver assumes that certain registers are at their default values. Signed-off-by: Pete Dietl <[email protected]>
c95b27e
to
1720bcb
Compare
|
@pdgendt I think you need to resolve some requested changes. |
How so? All mine are resolved, also note that unresolved comments do not block PRs. |
@pdgendt ah ok. I just see this I guess we need someone with write access to approve? |
@pdgendt Thanks again for your time with this review! |
I ran into a problem where a vendor-provided bootloader also configured the same SPI peripheral before booting my Zephyr application. The bootloader configured the ENABLE32B option to make writes to the DATA register be 32 bits and not 8 bits -- this broke the Zephyr driver. Since the configuration of the SPI peripheral may be arbitrarily configured before the Zephyr driver attempts to initialize it and because the Zephyr SPI driver assumes that the peripheral is in its default state, it makes sense to use the SWRST bit to ensure that the peripheral is indeed in its default state.