spibus access serialization

Luiz Otavio O Souza loos.br at gmail.com
Sun Sep 2 12:37:36 UTC 2012


Hi,

I've some embedded systems with spi devices that share the same spibus and because of that i'm working to get some kind of access serialization on spibus and also protection to devices which need a series of spi transfers to achieve some goal.

The SPI usage (with all the patches applied) goes like this:

/* Wait until the spibus is free. When free, acquire the bus and select the device */
SPIBUS_ACQUIRE_BUS(spibus, device);

/* Program the CPLD to read data from NAND */
SPIBUS_TRANSFER(spibus, device, &cmd);

/* Read 'n' bytes from CPLD */
SPIBUS_TRANSFER(spibus, device, &cmd);

/* Release the spibus and deselect the device */
SPIBUS_RELEASE_BUS(spibus, device);

While today everything is done inside SPIBUS_TRANSFER().

The patch spibus-01.diff adds the bus methods and the default methods.

The spibus-02-devices.diff adds the needed glue to all spi devices (dev/flash/at45d.c, dev/flash/mx25l.c, arm/lpc/ssd1289.c, mips/atheros/pcf2123_rtc.c). As the default methods are just nops, there are no functional changes.

On spibus-03-controllers.diff we finally add the serialization methods to spi controllers (mips/atheros/ar71xx_spi.c and arm/lpc/lpc_spi.c) and change the device CS to happen on bus acquire and release and not on start and end of each transfer.

The spi controller on arm/at91/at91_spi.c wasn't changed because looks like it will be need to move the device CS control from the controller and use it as a GPIO pin. I need to read more of at91 code before i can suggest some change there. Until there it will work just as now (no serialization and selecting/deselecting the device within each transfer).

Comments ?

Thanks,
Luiz



-------------- next part --------------
A non-text attachment was scrubbed...
Name: spibus-01.diff
Type: application/octet-stream
Size: 1630 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-arch/attachments/20120902/bca8a42d/spibus-01.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: spibus-02-devices.diff
Type: application/octet-stream
Size: 5787 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-arch/attachments/20120902/bca8a42d/spibus-02-devices.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: spibus-03-controllers.diff
Type: application/octet-stream
Size: 6659 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-arch/attachments/20120902/bca8a42d/spibus-03-controllers.obj


More information about the freebsd-arch mailing list