I started with the MMC driver documented at 2.2. Adding an MMC/SD Card, hacked out the MMC/SD parts and replaced the block driver code with character driver code. The new driver creates a /dev/spi/0
I want to put the code into the Wiki, but before I do that, I want to get all the copyright notices and attributions correct. In particular, most of the code in the SPI driver, came from the MMC driver by "Madsuk/Rohde". What is the appropriate way to write the MODULE_AUTHOR line? I don't want to claim that I wrote their code, nor do I want them to suffer from bugs in my code.
My version of the code is at http://hamjudo.com/spi_driver in the files spi.c and Makefile. There is also a program spitest.c that does a trivial test of the spi driver. I added symlinks ending in .txt for the 3 files, since I didn't want to delay everything while I looked up how to get the files to transfer as type text for your browsers.
Right now there is no logic for multiple SPI ports, it needs more comments, general cleanup, and probably bug fixes. After I get the copyright notices and attributions correct, then I'll add support for /dev/spi/1. With /dev/spi/0 and /dev/spi/1, it'll be obvious to other coders how to add more SPI devices in the source, as long as there are GPIO lines available.
The code as written doesn't support full duplex communication over the SPI port. It writes all ones when it reads. If I can get an example full duplex device, I can add an ioctl or other interface to switch to a real full duplex mode. I'm old, I only know ioctl, but I can learn the new better way to do this sort of thing.
If it isn't already obvious, the goal is to talk to spi devices other than MMC cards. I just haven't started on that part of the hardware.
As I was researching this, I came across links to an LCD driver at http://www.duff.dk/wrt54gs, which is another driver that contains an SPI driver. My goal is to make something a bit more generic for connecting PIC's, AVR's and random chips from DigiKey. So I want to keep as much as the chip specific stuff in user space.