table of contents
STRUCT SPI_MASTER(9) | Serial Peripheral Interface (S | STRUCT SPI_MASTER(9) |
NAME¶
struct_spi_master - interface to SPI master controller
SYNOPSIS¶
struct spi_master {
struct device dev;
struct list_head list;
s16 bus_num;
u16 num_chipselect;
u16 dma_alignment;
u16 mode_bits;
u32 bits_per_word_mask; #define SPI_BPW_MASK(bits) BIT((bits) - 1) #define SPI_BIT_MASK(bits) (((bits) == 32) ? ~0U : (BIT(bits) - 1)) #define SPI_BPW_RANGE_MASK(min# max) (SPI_BIT_MASK(max) - SPI_BIT_MASK(min - 1))
u32 min_speed_hz;
u32 max_speed_hz;
u16 flags; #define SPI_MASTER_HALF_DUPLEX BIT(0) #define SPI_MASTER_NO_RX BIT(1) #define SPI_MASTER_NO_TX BIT(2) #define SPI_MASTER_MUST_RX BIT(3) #define SPI_MASTER_MUST_TX BIT(4)
size_t (* max_transfer_size) (struct spi_device *spi);
struct mutex io_mutex;
spinlock_t bus_lock_spinlock;
struct mutex bus_lock_mutex;
bool bus_lock_flag;
int (* setup) (struct spi_device *spi);
int (* transfer) (struct spi_device *spi,struct spi_message *mesg);
void (* cleanup) (struct spi_device *spi);
bool (* can_dma) (struct spi_master *master,struct spi_device *spi,struct spi_transfer *xfer);
bool queued;
struct kthread_worker kworker;
struct task_struct * kworker_task;
struct kthread_work pump_messages;
spinlock_t queue_lock;
struct list_head queue;
struct spi_message * cur_msg;
bool idling;
bool busy;
bool running;
bool rt;
bool auto_runtime_pm;
bool cur_msg_prepared;
bool cur_msg_mapped;
struct completion xfer_completion;
size_t max_dma_len;
int (* prepare_transfer_hardware) (struct spi_master *master);
int (* transfer_one_message) (struct spi_master *master,struct spi_message *mesg);
int (* unprepare_transfer_hardware) (struct spi_master *master);
int (* prepare_message) (struct spi_master *master,struct spi_message *message);
int (* unprepare_message) (struct spi_master *master,struct spi_message *message);
int (* spi_flash_read) (struct spi_device *spi,struct spi_flash_read_message *msg);
bool (* flash_read_supported) (struct spi_device *spi);
void (* set_cs) (struct spi_device *spi, bool enable);
int (* transfer_one) (struct spi_master *master, struct spi_device *spi,struct spi_transfer *transfer);
void (* handle_err) (struct spi_master *master,struct spi_message *message);
int * cs_gpios;
struct spi_statistics statistics;
struct dma_chan * dma_tx;
struct dma_chan * dma_rx;
void * dummy_rx;
void * dummy_tx;
int (* fw_translate_cs) (struct spi_master *master, unsigned cs); };
MEMBERS¶
dev
list
bus_num
num_chipselect
dma_alignment
mode_bits
bits_per_word_mask
min_speed_hz
max_speed_hz
flags
max_transfer_size
io_mutex
bus_lock_spinlock
bus_lock_mutex
bus_lock_flag
setup
transfer
cleanup
can_dma
queued
kworker
kworker_task
pump_messages
queue_lock
queue
cur_msg
idling
busy
running
rt
auto_runtime_pm
cur_msg_prepared
cur_msg_mapped
xfer_completion
max_dma_len
prepare_transfer_hardware
transfer_one_message
unprepare_transfer_hardware
prepare_message
unprepare_message
spi_flash_read
flash_read_supported
set_cs
transfer_one
handle_err
cs_gpios
statistics
dma_tx
dma_rx
dummy_rx
dummy_tx
fw_translate_cs
DESCRIPTION¶
Each SPI master controller can communicate with one or more spi_device children. These make a small bus, sharing MOSI, MISO and SCK signals but not chip select signals. Each device may be configured to use a different clock rate, since those shared signals are ignored unless the chip is selected.
The driver for an SPI controller manages access to those devices through a queue of spi_message transactions, copying data between CPU memory and an SPI slave device. For each such message it queues, it calls the message's completion function when the transaction completes.
COPYRIGHT¶
January 2017 | Kernel Hackers Manual 4.8. |