SPI User Space Interface

Adrian Chadd adrian at freebsd.org
Mon Apr 27 03:06:04 UTC 2015


Hey, this is cool!

What can we do to spibus to make it better?



-adrian


On 26 April 2015 at 13:33, Tom Jones <jones at sdf.org> wrote:
> 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
>
> _______________________________________________
> freebsd-embedded at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-embedded
> To unsubscribe, send any mail to "freebsd-embedded-unsubscribe at freebsd.org"


More information about the freebsd-embedded mailing list