Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Fields
spi_transfer Struct Reference

#include <spi.h>

Data Fields

const voidtx_buf
 
voidrx_buf
 
unsigned len
 
dma_addr_t tx_dma
 
dma_addr_t rx_dma
 
unsigned cs_change:1
 
u8 bits_per_word
 
u16 delay_usecs
 
u32 speed_hz
 
struct list_head transfer_list
 

Detailed Description

struct spi_transfer - a read/write buffer pair : data to be written (dma-safe memory), or NULL : data to be read (dma-safe memory), or NULL : DMA address of tx_buf, if .is_dma_mapped : DMA address of rx_buf, if .is_dma_mapped : size of rx and tx buffers (in bytes) : Select a speed other than the device default for this transfer. If 0 the default (from ) is used. : select a bits_per_word other than the device default for this transfer. If 0 the default (from ) is used. : affects chipselect after this transfer completes : microseconds to delay after this transfer before (optionally) changing the chipselect status, then starting the next transfer or completing this . : transfers are sequenced through .transfers

SPI transfers always write the same number of bytes as they read. Protocol drivers should always provide and/or . In some cases, they may also want to provide DMA addresses for the data being transferred; that may reduce overhead, when the underlying driver uses dma.

If the transmit buffer is null, zeroes will be shifted out while filling . If the receive buffer is null, the data shifted in will be discarded. Only "len" bytes shift out (or in). It's an error to try to shift out a partial word. (For example, by shifting out three bytes with word size of sixteen or twenty bits; the former uses two bytes per word, the latter uses four bytes.)

In-memory data values are always in native CPU byte order, translated from the wire byte order (big-endian except with SPI_LSB_FIRST). So for example when bits_per_word is sixteen, buffers are 2N bytes long ( = 2N) and hold N sixteen bit words in CPU byte order.

When the word size of the SPI transfer is not a power-of-two multiple of eight bits, those in-memory words include extra bits. In-memory words are always seen by protocol drivers as right-justified, so the undefined (rx) or unused (tx) bits are always the most significant bits.

All SPI transfers start with the relevant chipselect active. Normally it stays selected until after the last transfer in a message. Drivers can affect the chipselect signal using cs_change.

(i) If the transfer isn't the last one in the message, this flag is used to make the chipselect briefly go inactive in the middle of the message. Toggling chipselect in this way may be needed to terminate a chip command, letting a single spi_message perform all of group of chip transactions together.

(ii) When the transfer is the last one in the message, the chip may stay selected until the next transfer. On multi-device SPI busses with nothing blocking messages going to other devices, this is just a performance hint; starting a message to another device deselects this one. But in other cases, this can be used to ensure correctness. Some devices need protocol transactions to be built from a series of spi_message submissions, where the content of one message is determined by the results of previous messages and where the whole transaction ends when the chipselect goes intactive.

The code that submits an spi_message (and its spi_transfers) to the lower layers is responsible for managing its memory. Zero-initialize every field you don't set up explicitly, to insulate against future API updates. After you submit a message and its transfers, ignore them until its completion callback.

Definition at line 492 of file spi.h.

Field Documentation

u8 bits_per_word

Definition at line 506 of file spi.h.

unsigned cs_change

Definition at line 505 of file spi.h.

u16 delay_usecs

Definition at line 507 of file spi.h.

unsigned len

Definition at line 500 of file spi.h.

void* rx_buf

Definition at line 499 of file spi.h.

Definition at line 503 of file spi.h.

u32 speed_hz

Definition at line 508 of file spi.h.

struct list_head transfer_list

Definition at line 510 of file spi.h.

Definition at line 498 of file spi.h.

Definition at line 502 of file spi.h.


The documentation for this struct was generated from the following file: