/* limits on transfer speed */ u32 min_speed_hz; u32 max_speed_hz;
/* other constraints relevant to this driver */ u16 flags; ...
/* flag indicating this is an SPI slave controller */ bool slave;
/* * on some hardware transfer / message size may be constrained * the limit may depend on device transfer settings */ size_t (*max_transfer_size)(struct spi_device *spi); size_t (*max_message_size)(struct spi_device *spi);
/* I/O mutex */ struct mutex io_mutex;
/* lock and mutex for SPI bus locking */ ...
/* flag indicating that the SPI bus is locked for exclusive use */ bool bus_lock_flag;
/* called on release() to free memory provided by spi_controller */ void (*cleanup)(struct spi_device *spi);
... /* * These hooks are for drivers that want to use the generic * controller transfer queueing mechanism. If these are used, the * transfer() function above must NOT be specified by the driver. * Over time we expect SPI drivers to be phased over to this API. */ ... /* * These hooks are for drivers that use a generic implementation * of transfer_one_message() provied by the core. */ ... /* Optimized handlers for SPI memory-like operations. */ const struct spi_controller_mem_ops *mem_ops;
/* DMA channels for use with core dmaengine helpers */ struct dma_chan *dma_tx; struct dma_chan *dma_rx;
/* dummy data for full duplex devices */ void *dummy_rx; void *dummy_tx;
int (*fw_translate_cs)(struct spi_controller *ctlr, unsigned cs);
/* * Driver sets this field to indicate it is able to snapshot SPI * transfers (needed e.g. for reading the time of POSIX clocks) */ bool ptp_sts_supported;
/* Interrupt enable state during PTP system timestamping */ unsigned long irq_flags; };
struct spi_controller *spi_alloc_master(struct device *host, unsigned int size); int spi_register_controller(struct spi_controller *ctlr); int devm_spi_register_controller(struct device *dev, struct spi_controller *ctlr); void spi_unregister_controller(struct spi_controller *ctlr);
struct spi_transfer { /* it's ok if tx_buf == rx_buf (right?) * for MicroWire, one buffer must be null * buffers must work with dma_*map_single() calls, unless * spi_message.is_dma_mapped reports a pre-existing mapping */ const void *tx_buf; void *rx_buf; unsigned len;
/* REVISIT: we might want a flag affecting the behavior of the * last transfer ... allowing things like "read 16 bit length L" * immediately followed by "read L bytes". Basically imposing * a specific message scheduling algorithm. * * Some controller drivers (message-at-a-time queue processing) * could provide that as their default scheduling algorithm. But * others (with multi-message pipelines) could need a flag to * tell them about such special cases. */
/* completion is reported through a callback */ void (*complete)(void *context); void *context; unsigned frame_length; unsigned actual_length; int status;
/* for optional use by whatever driver currently owns the * spi_message ... between calls to spi_async and then later * complete(), that's the spi_controller controller driver. */ struct list_head queue; void *state;
/* list of spi_res reources when the spi message is processed */ struct list_head resources; };
struct spi_board_info { /* the device name and module name are coupled, like platform_bus; * "modalias" is normally the driver name. * * platform_data goes to spi_device.dev.platform_data, * controller_data goes to spi_device.controller_data, * device properties are copied and attached to spi_device, * irq is copied too */ char modalias[SPI_NAME_SIZE]; const void *platform_data; const struct property_entry *properties; void *controller_data; int irq;
/* slower signaling on noisy or low voltage boards */ u32 max_speed_hz;
/* bus_num is board specific and matches the bus_num of some * spi_controller that will probably be registered later. * * chip_select reflects how this chip is wired to that master; * it's less than num_chipselect. */ u16 bus_num; u16 chip_select;
/* mode becomes spi_device.mode, and is essential for chips * where the default of SPI_CS_HIGH = 0 is wrong. */ u32 mode;
/* ... may need additional spi_device chip config data here. * avoid stuff protocol drivers can set; but include stuff * needed to behave without being bound to a driver: * - quirks like clock rate mattering when not selected */ };