SPI User Space Interface
Tom Jones
jones at sdf.org
Sun Apr 26 20:33:52 UTC 2015
This atteched patch adds user space access to spi drivers. Access is possible
via read, write and an ioctl call. I have tested this patch on a raspberry-pi B
against an avr running a simple program and a small monochrome oled screen
based on the ssd1306 display driver.
The ioctl requires the use of two new structs. The spi_rdwr_data struct takes a
number of spi_ioc_transfer structs, this is modeled on the iic driver. The
spi_ioc_transfer struct is compatible with the linux spidev implementation.
There is no support for ioctls to set spi device settings are there is in
linux, this is due to the limited driver interface in spibus. Only the buffer
and length options are used from the spi_ioc_transfer struct, this is from the
lack of driver interface on spibus.
struct spi_ioc_transfer {
void *tx_buf;
void *rx_buf;
uint32_t len;
uint32_t speed_hz;
uint16_t delay_usecs;
uint8_t bits_per_word;
uint8_t cs_change;
uint32_t pad;
};
struct spi_rdwr_data {
struct spi_ioc_transfer *msgs;
uint32_t nmsgs;
};
#define SPIRDWR _IOW('S', 1, struct spi_rdwr_data)
I have only managed to test this code on one platform and against a limited
number of spi devices. I think it needs more testing against real hardware, I
don't have any lying around.
--
Tom
@adventureloop
adventurist.me
:wq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: spidev.patch
Type: text/x-diff
Size: 9537 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-embedded/attachments/20150426/56dd3c9b/attachment.patch>
More information about the freebsd-embedded
mailing list