Lines Matching full:spi

27  * INTERFACES between SPI master-side drivers and SPI infrastructure.
28 * (There's no SPI slave support for Linux yet...)
33 * struct spi_device - Master side proxy for an SPI slave device
35 * @master: SPI controller used with the device.
40 * @mode: The spi mode defines how data is clocked out and in.
60 * A @spi_device is used to interchange data between an SPI slave
110 static inline struct spi_device *spi_dev_get(struct spi_device *spi) in spi_dev_get() argument
112 return (spi && get_device(&spi->dev)) ? spi : NULL; in spi_dev_get()
115 static inline void spi_dev_put(struct spi_device *spi) in spi_dev_put() argument
117 if (spi) in spi_dev_put()
118 put_device(&spi->dev); in spi_dev_put()
122 static inline void *spi_get_ctldata(struct spi_device *spi) in spi_get_ctldata() argument
124 return spi->controller_state; in spi_get_ctldata()
127 static inline void spi_set_ctldata(struct spi_device *spi, void *state) in spi_set_ctldata() argument
129 spi->controller_state = state; in spi_set_ctldata()
134 static inline void spi_set_drvdata(struct spi_device *spi, void *data) in spi_set_drvdata() argument
136 dev_set_drvdata(&spi->dev, data); in spi_set_drvdata()
139 static inline void *spi_get_drvdata(struct spi_device *spi) in spi_get_drvdata() argument
141 return dev_get_drvdata(&spi->dev); in spi_get_drvdata()
150 * @id_table: List of SPI devices supported by this driver
151 * @probe: Binds this driver to the spi device. Drivers can verify
155 * @remove: Unbinds this driver from the spi device
160 * @driver: SPI device drivers should initialize the name and owner
163 * This represents the kind of device driver that uses SPI messages to
164 * interact with the hardware at the other end of a SPI link. It's called
166 * directly to SPI hardware (which is what the underlying SPI controller
177 int (*probe)(struct spi_device *spi);
178 int (*remove)(struct spi_device *spi);
179 void (*shutdown)(struct spi_device *spi);
180 int (*suspend)(struct spi_device *spi, pm_message_t mesg);
181 int (*resume)(struct spi_device *spi);
204 * module_spi_driver() - Helper macro for registering a SPI driver
207 * Helper macro for SPI drivers which do not do anything special in module
216 * struct spi_master - interface to SPI master controller
220 * given SPI controller.
222 * SPI slaves, and are numbered from zero to num_chipselects.
225 * @dma_alignment: SPI controller constraint on DMA buffers alignment.
228 * @bus_lock_spinlock: spinlock for SPI bus locking
229 * @bus_lock_mutex: mutex for SPI bus locking
230 * @bus_lock_flag: indicates that the SPI bus is locked for exclusive use
232 * device's SPI controller; protocol code may call this. This
239 * Each SPI master controller can communicate with one or more @spi_device
245 * The driver for an SPI controller manages access to those devices through
247 * an SPI slave device. For each such message it queues, it calls the
257 * example: one SOC has three SPI controllers, numbered 0..2,
258 * and one board's schematics might show it using SPI-2. software
268 /* some SPI controllers pose alignment requirements on DMAable
282 /* lock and mutex for SPI bus locking */
286 /* flag indicating that the SPI bus is locked for exclusive use */
289 /* Setup mode and clock, etc (spi driver may call many times).
295 int (*setup)(struct spi_device *spi);
313 * + The message transfers use clock and SPI mode parameters
316 int (*transfer)(struct spi_device *spi,
320 void (*cleanup)(struct spi_device *spi);
347 /* the spi driver core manages memory for the spi_master classdev */
359 * I/O INTERFACE between SPI controller and protocol drivers
367 * pointer. (This is unlike most types of I/O API, because SPI hardware
392 * SPI transfers always write the same number of bytes as they read.
410 * When the word size of the SPI transfer is not a power-of-two multiple
415 * All SPI transfers start with the relevant chipselect active. Normally
426 * stay selected until the next transfer. On multi-device SPI busses
463 * struct spi_message - one multi-segment SPI transaction
465 * @spi: SPI device to which the transaction is queued
478 * in the sense that no other spi_message may use that SPI bus until that
493 struct spi_device *spi; member
567 extern int spi_setup(struct spi_device *spi);
568 extern int spi_async(struct spi_device *spi, struct spi_message *message);
569 extern int spi_async_locked(struct spi_device *spi,
574 /* All these synchronous SPI transfer routines are utilities layered
579 extern int spi_sync(struct spi_device *spi, struct spi_message *message);
580 extern int spi_sync_locked(struct spi_device *spi, struct spi_message *message);
585 * spi_write - SPI synchronous write
586 * @spi: device to which data will be written
595 spi_write(struct spi_device *spi, const void *buf, size_t len) in spi_write() argument
605 return spi_sync(spi, &m); in spi_write()
609 * spi_read - SPI synchronous read
610 * @spi: device from which data will be read
619 spi_read(struct spi_device *spi, void *buf, size_t len) in spi_read() argument
629 return spi_sync(spi, &m); in spi_read()
633 extern int spi_write_then_read(struct spi_device *spi,
638 * spi_w8r8 - SPI synchronous 8 bit write followed by 8 bit read
639 * @spi: device with which data will be exchanged
647 static inline ssize_t spi_w8r8(struct spi_device *spi, u8 cmd) in spi_w8r8() argument
652 status = spi_write_then_read(spi, &cmd, 1, &result, 1); in spi_w8r8()
659 * spi_w8r16 - SPI synchronous 8 bit write followed by 16 bit read
660 * @spi: device with which data will be exchanged
671 static inline ssize_t spi_w8r16(struct spi_device *spi, u8 cmd) in spi_w8r16() argument
676 status = spi_write_then_read(spi, &cmd, 1, (u8 *) &result, 2); in spi_w8r16()
685 * INTERFACE between board init code and SPI infrastructure.
687 * No SPI driver ever sees these SPI device table segments, but
688 * it's how the SPI core (or adapters that get hotplugged) grows
691 * As a rule, SPI devices can't be probed. Instead, board init code
695 * parport adapters, or microcontrollers acting as USB-to-SPI bridges.
699 * struct spi_board_info - board-specific template for a SPI device
716 * When adding new SPI devices to the device tree, these structures serve
771 /* board init code may ignore whether SPI is configured or not */
793 spi_add_device(struct spi_device *spi);
799 spi_unregister_device(struct spi_device *spi) in spi_unregister_device() argument
801 if (spi) in spi_unregister_device()
802 device_unregister(&spi->dev); in spi_unregister_device()