I am looking for how to use the SPI bitbang driver provided in Linux kernel, commonly known as spi-gpio.c
.
I have compiled it to a valid *.ko file, first inserted the spi-bitbang
driver and now I have inserted the spidriv.c
driver that I made and compiled from spi-gpio.c
. All goes without a hitch, no errors in dmesg | tail
however I cannot find any record of the SPI device I just added existing aside from an entry of my SPI driver in /sys/modules
.
Frankly, this is ridiculous because every article I read says to use this and that it is "easy" however with the amount of time I have so far invested I could have written my own driver for an SPI device.
To elaborate how do I use this driver to get an entry in /dev
aside from the obvious and simple instructions given in the kernel driver itself because they apparently do not register any kind of device.
What I've tried: Using spi-bitbang driver
My custom SPI driver:
// led sck sda rst a0 cs w h
// 332, 329, 330, 335, 336, 338, 128, 160
#define DRIVER_NAME "spidriv"
#define SPI_MISO_GPIO 334
#define SPI_MOSI_GPIO 330
#define SPI_SCK_GPIO 329
#define SPI_N_CHIPSEL 338
#include "spi-gpio.c"
My install process:
$ sudo rmmod spi_bitbang
$ sudo modprobe spi_bitbang
$ sudo insmod spidriv.ko
# No (recent) errors in dmesg
$ lsmod | grep spi
spidriv 16384 0 # My driver
spi_bitbang 16384 1 spidriv
spi_pxa2xx_platform 28672 0
Nothing is in /sys/class/spi* or /dev* after install the kernel module.
I have heard rumors of having to create a device tree entry, if I need to do this please help me step-by-step as I have never interfaced with the device tree system in Linux (despite being a long time Linux user and even writing my own basic kernel modules) and documentation seems non-existent or so overly complicated that it is incomprehensible!
This project has took me weeks (literally just connecting a ST7735 display to my homemade WiFi router) and this is driving me nuts, I wrote my own bit-banged SPI C library but it is simply not fast enough and I need a kernel level SPI interface to really get the bandwidth up.