-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Add spi-gpio module and dtoverlay #2318
Conversation
This commit adds bitbanging SPI support for GPIOs via the spi-gpio module
There are a few implementation issues with this PR:
...and an existential issue: |
Setting is automatically selected with SPI_GPIO
|
Compiling overlays via the kernel makefiles is quick and easy (once you've downloaded the kernel source tree...) - just use Your new overlay is fine, but your answer to 3 means that most of it is unnecessary. The hardware SPI driver can make use of any GPIO as a software-controlled chip select line - just add them to the |
I think it would still be useful as an possibility to add an additional SPI bus, especially for slow sensor devices. Using the existing CS in the example lines was not very lucky for general use, I think. |
But your patch effectively disables the SPI0 hardware interface, which is less useful. To be accepted, the spi-gpio interface would have to appear as spidev3.x so as not to clash with any of the hardware interfaces. |
Software bit banging can still be useful even with unlimited chip selects, but I agree that I wouldn't want bit banging to override the hardware SPI in any way. Example use case: I had a project where I needed to drive a TFT screen with fbtft and a string of 20 APA102 LEDs both via SPI. While I was able connect them both to the hardware SPI interface and write to both of them, the massive amount of data being sent to the screen caused visible jitter in animations sent to the LEDs. My solution was to let the SPI display have the hardware SPI all to itself and bit bang the LEDs. |
A bit off-topic maybe, but currently SPI interaction seems to automatically do CS, so that if I try two transfers within my explicit CS low/high section, the second transfer returns an invalid buffer. I suspect the kernel does the CS automatically even if I pass SPI_NO_CS. Would this PR fix that? |
Do you have a small test program (C, Python etc.) that demonstrates the problem? Please start another issue - it makes it easier to track progress etc. |
If the author is still working on this, another probable use case is for those HAT manufacturers that create HATs with SPI peripherals but connected to non-hardware SPI pins. Sure, you could always bitbang the SPI bus, but when you mix that with Thing is, I don't think a fixed overlay should be included, anyway. The huge amount of flexibility associated with the bitbanged SPI bus (single / multiple / no chip select / tx only mode / rx only mode / etc) really can't be expressed with that. Could the modules simply be enabled? - That would resolve the issue around the implementation of the overlay. Those using this module would probably need to write their own overlay, anyway, to deal with their own specific issues. |
That works for me, and it doesn't preclude somebody coming back later with a better overlay. |
See: #2318 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
CONFIG_SPI_GPIO=m is now defined in rpi-4.14.y, so the module will be in future builds. |
May I close the issue now? I´m happy. |
Allow me. |
kernel: net: lan78xx: Disable TCP Segmentation Offload (TSO) See: raspberrypi/linux#2449 See: raspberrypi/linux#2482 kernel: config: Add CONFIG_NET_IPVTI=m See: raspberrypi/linux#2581 kernel: config: Add CONFIG_SPI_GPIO See: raspberrypi/linux#2318 kernel: sc16is7xx: Fix for Unexpected interrupt: 8 See: raspberrypi/linux#2529
kernel: net: lan78xx: Disable TCP Segmentation Offload (TSO) See: raspberrypi/linux#2449 See: raspberrypi/linux#2482 kernel: config: Add CONFIG_NET_IPVTI=m See: raspberrypi/linux#2581 kernel: config: Add CONFIG_SPI_GPIO See: raspberrypi/linux#2318 kernel: sc16is7xx: Fix for Unexpected interrupt: 8 See: raspberrypi/linux#2529
See: #2318 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #2318 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #2318 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #2318 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #2318 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #2318 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #2318 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #2318 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #2318 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #2318 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #2318 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #2318 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #2318 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #2318 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #2318 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #2318 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #2318 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #2318 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #2318 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #2318 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #2318 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #2318 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #2318 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #2318 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #2318 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #2318 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #2318 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #2318 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: raspberrypi/linux#2318 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #2318 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: raspberrypi/linux#2318 Signed-off-by: Phil Elwell <phil@raspberrypi.org> (cherry picked from commit e840c2f08e8101485e61d46553d2efc83d1250a8) Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
Adds support for bit banging SPI over GPIO via the spi-gpio module
Closes #2169