spigen(4) SPI Generic IO interface -- need comments
Brian Fundakowski Feldman
brianfundakowskifeldman at gmail.com
Mon Aug 17 14:00:30 UTC 2015
I'm woefully out-of-practice with my kernel hackery (but still pretty
proficient in jiggery-pokery) so I would like to get comments on a little
driver I just made for interfacing arbitrarily in userland with SPI
components. The only thing I'm exposing is a /dev/spigenN node with a
single transfer ioctl and I put together a test circuit and program with an
MCP3008 10-bit ADC IC to validate that it basically works, other than the
limitation that the transfers must be octet-multiply-sized, but I haven't
looked at the SoC's (I'm using a Raspberry Pi 2) data sheet to tell whether
that's just a limit on the spibus(4) interface or the Broadcom SPI driver
or the Broadcom SoC itself.
I hit one snag in development where I simply called the ioctl wrong and
found copyin(9) to page fault HARD if given a bogus user address to copy
from, and panic the kernel. I can post up the test program if anyone wants
but it's very trivial: I just align the start bit and the command data into
the least significant bits of the first octet, shift it up two positions so
the NULs get clocked out as part of the command field, and provide two
octets for the data field to retrieve back the 10-bit digital value.
Good to be back in the FreeBSD hacking!
Cheers,
Brian Fundakowski Feldman
-------------- next part --------------
A non-text attachment was scrubbed...
Name: spigen.patch
Type: application/octet-stream
Size: 8387 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20150817/25a44aca/attachment.obj>
More information about the freebsd-hackers
mailing list