SPIGEN(4) | Device Drivers Manual | SPIGEN(4) |
spigen
— SPI
generic I/O device driver
To compile this driver into the kernel, place the following lines in your kernel configuration file:
device spi
device spibus
device spigen
Alternatively, to load the driver as a module at boot time, place the following line in loader.conf(5):
spigen_load="YES"
The spigen
driver provides direct access
to a slave device on the SPI bus. Each instance of a
spigen
device is associated with a single
chip-select line on the bus, and all I/O performed through that instance is
done with that chip-select line asserted.
SPI data transfers are inherently bi-directional; there are not separate read and write operations. When commands and data are sent to a device, data also comes back from the device, although in some cases the data may not be useful (or even documented or predictable for some devices). Likewise on a read operation, whatever data is in the buffer at the start of the operation is sent to (and typically ignored by) the device, with each outgoing byte then replaced in the buffer by the corresponding incoming byte. Thus, all buffers passed to the transfer functions are both input and output buffers.
The spigen
driver provides access to the
SPI slave device with the following ioctl(2) calls,
defined in
<sys/spigenio.h>
:
SPIGENIOC_TRANSFER
(struct spigen_transfer)struct spigen_transfer { struct iovec st_command; struct iovec st_data; };
SPIGENIOC_TRANSFER_MMAPPED
(spigen_transfer_mmapped)struct spigen_transfer_mmapped { size_t stm_command_length; size_t stm_data_length; };
SPIGENIOC_GET_CLOCK_SPEED
(uint32_t)SPIGENIOC_SET_CLOCK_SPEED
(uint32_t)SPIGENIOC_GET_SPI_MODE
(uint32_t)SPIGENIOC_SET_SPI_MODE
(uint32_t)On a device.hints(5) based system, such as
MIPS
, these values are configurable for
spigen
:
spigen
instance is attached
to.On an fdt(4) based system, the spigen device is
defined as a slave device subnode of the SPI bus controller node. All
properties documented in the spibus.txt bindings
document can be used with the spigen
device. The
most commonly-used ones are documented below.
The following properties are required in the
spigen
device subnode:
The following properties are optional for the
spigen
device subnode:
The spigen
driver appeared in
FreeBSD 11.0. FDT support appeared in
FreeBSD 11.2.
April 7, 2018 | Debian |