diff options
Diffstat (limited to 'include/linux/spi/spi.h')
| -rw-r--r-- | include/linux/spi/spi.h | 57 |
1 files changed, 19 insertions, 38 deletions
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 9c4cd27f4685..97b60b37f445 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | #define __LINUX_SPI_H | 20 | #define __LINUX_SPI_H |
| 21 | 21 | ||
| 22 | #include <linux/device.h> | 22 | #include <linux/device.h> |
| 23 | #include <linux/mod_devicetable.h> | ||
| 23 | 24 | ||
| 24 | /* | 25 | /* |
| 25 | * INTERFACES between SPI master-side drivers and SPI infrastructure. | 26 | * INTERFACES between SPI master-side drivers and SPI infrastructure. |
| @@ -80,11 +81,13 @@ struct spi_device { | |||
| 80 | #define SPI_LSB_FIRST 0x08 /* per-word bits-on-wire */ | 81 | #define SPI_LSB_FIRST 0x08 /* per-word bits-on-wire */ |
| 81 | #define SPI_3WIRE 0x10 /* SI/SO signals shared */ | 82 | #define SPI_3WIRE 0x10 /* SI/SO signals shared */ |
| 82 | #define SPI_LOOP 0x20 /* loopback mode */ | 83 | #define SPI_LOOP 0x20 /* loopback mode */ |
| 84 | #define SPI_NO_CS 0x40 /* 1 dev/bus, no chipselect */ | ||
| 85 | #define SPI_READY 0x80 /* slave pulls low to pause */ | ||
| 83 | u8 bits_per_word; | 86 | u8 bits_per_word; |
| 84 | int irq; | 87 | int irq; |
| 85 | void *controller_state; | 88 | void *controller_state; |
| 86 | void *controller_data; | 89 | void *controller_data; |
| 87 | char modalias[32]; | 90 | char modalias[SPI_NAME_SIZE]; |
| 88 | 91 | ||
| 89 | /* | 92 | /* |
| 90 | * likely need more hooks for more protocol options affecting how | 93 | * likely need more hooks for more protocol options affecting how |
| @@ -143,6 +146,7 @@ struct spi_message; | |||
| 143 | 146 | ||
| 144 | /** | 147 | /** |
| 145 | * struct spi_driver - Host side "protocol" driver | 148 | * struct spi_driver - Host side "protocol" driver |
| 149 | * @id_table: List of SPI devices supported by this driver | ||
| 146 | * @probe: Binds this driver to the spi device. Drivers can verify | 150 | * @probe: Binds this driver to the spi device. Drivers can verify |
| 147 | * that the device is actually present, and may need to configure | 151 | * that the device is actually present, and may need to configure |
| 148 | * characteristics (such as bits_per_word) which weren't needed for | 152 | * characteristics (such as bits_per_word) which weren't needed for |
| @@ -168,6 +172,7 @@ struct spi_message; | |||
| 168 | * MMC, RTC, filesystem character device nodes, and hardware monitoring. | 172 | * MMC, RTC, filesystem character device nodes, and hardware monitoring. |
| 169 | */ | 173 | */ |
| 170 | struct spi_driver { | 174 | struct spi_driver { |
| 175 | const struct spi_device_id *id_table; | ||
| 171 | int (*probe)(struct spi_device *spi); | 176 | int (*probe)(struct spi_device *spi); |
| 172 | int (*remove)(struct spi_device *spi); | 177 | int (*remove)(struct spi_device *spi); |
| 173 | void (*shutdown)(struct spi_device *spi); | 178 | void (*shutdown)(struct spi_device *spi); |
| @@ -205,6 +210,8 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv) | |||
| 205 | * each slave has a chipselect signal, but it's common that not | 210 | * each slave has a chipselect signal, but it's common that not |
| 206 | * every chipselect is connected to a slave. | 211 | * every chipselect is connected to a slave. |
| 207 | * @dma_alignment: SPI controller constraint on DMA buffers alignment. | 212 | * @dma_alignment: SPI controller constraint on DMA buffers alignment. |
| 213 | * @mode_bits: flags understood by this controller driver | ||
| 214 | * @flags: other constraints relevant to this driver | ||
| 208 | * @setup: updates the device mode and clocking records used by a | 215 | * @setup: updates the device mode and clocking records used by a |
| 209 | * device's SPI controller; protocol code may call this. This | 216 | * device's SPI controller; protocol code may call this. This |
| 210 | * must fail if an unrecognized or unsupported mode is requested. | 217 | * must fail if an unrecognized or unsupported mode is requested. |
| @@ -248,6 +255,12 @@ struct spi_master { | |||
| 248 | /* spi_device.mode flags understood by this controller driver */ | 255 | /* spi_device.mode flags understood by this controller driver */ |
| 249 | u16 mode_bits; | 256 | u16 mode_bits; |
| 250 | 257 | ||
| 258 | /* other constraints relevant to this driver */ | ||
| 259 | u16 flags; | ||
| 260 | #define SPI_MASTER_HALF_DUPLEX BIT(0) /* can't do full duplex */ | ||
| 261 | #define SPI_MASTER_NO_RX BIT(1) /* can't do buffer read */ | ||
| 262 | #define SPI_MASTER_NO_TX BIT(2) /* can't do buffer write */ | ||
| 263 | |||
| 251 | /* Setup mode and clock, etc (spi driver may call many times). | 264 | /* Setup mode and clock, etc (spi driver may call many times). |
| 252 | * | 265 | * |
| 253 | * IMPORTANT: this may be called when transfers to another | 266 | * IMPORTANT: this may be called when transfers to another |
| @@ -527,42 +540,7 @@ static inline void spi_message_free(struct spi_message *m) | |||
| 527 | } | 540 | } |
| 528 | 541 | ||
| 529 | extern int spi_setup(struct spi_device *spi); | 542 | extern int spi_setup(struct spi_device *spi); |
| 530 | 543 | extern int spi_async(struct spi_device *spi, struct spi_message *message); | |
| 531 | /** | ||
| 532 | * spi_async - asynchronous SPI transfer | ||
| 533 | * @spi: device with which data will be exchanged | ||
| 534 | * @message: describes the data transfers, including completion callback | ||
| 535 | * Context: any (irqs may be blocked, etc) | ||
| 536 | * | ||
| 537 | * This call may be used in_irq and other contexts which can't sleep, | ||
| 538 | * as well as from task contexts which can sleep. | ||
| 539 | * | ||
| 540 | * The completion callback is invoked in a context which can't sleep. | ||
| 541 | * Before that invocation, the value of message->status is undefined. | ||
| 542 | * When the callback is issued, message->status holds either zero (to | ||
| 543 | * indicate complete success) or a negative error code. After that | ||
| 544 | * callback returns, the driver which issued the transfer request may | ||
| 545 | * deallocate the associated memory; it's no longer in use by any SPI | ||
| 546 | * core or controller driver code. | ||
| 547 | * | ||
| 548 | * Note that although all messages to a spi_device are handled in | ||
| 549 | * FIFO order, messages may go to different devices in other orders. | ||
| 550 | * Some device might be higher priority, or have various "hard" access | ||
| 551 | * time requirements, for example. | ||
| 552 | * | ||
| 553 | * On detection of any fault during the transfer, processing of | ||
| 554 | * the entire message is aborted, and the device is deselected. | ||
| 555 | * Until returning from the associated message completion callback, | ||
| 556 | * no other spi_message queued to that device will be processed. | ||
| 557 | * (This rule applies equally to all the synchronous transfer calls, | ||
| 558 | * which are wrappers around this core asynchronous primitive.) | ||
| 559 | */ | ||
| 560 | static inline int | ||
| 561 | spi_async(struct spi_device *spi, struct spi_message *message) | ||
| 562 | { | ||
| 563 | message->spi = spi; | ||
| 564 | return spi->master->transfer(spi, message); | ||
| 565 | } | ||
| 566 | 544 | ||
| 567 | /*---------------------------------------------------------------------------*/ | 545 | /*---------------------------------------------------------------------------*/ |
| 568 | 546 | ||
| @@ -726,7 +704,7 @@ struct spi_board_info { | |||
| 726 | * controller_data goes to spi_device.controller_data, | 704 | * controller_data goes to spi_device.controller_data, |
| 727 | * irq is copied too | 705 | * irq is copied too |
| 728 | */ | 706 | */ |
| 729 | char modalias[32]; | 707 | char modalias[SPI_NAME_SIZE]; |
| 730 | const void *platform_data; | 708 | const void *platform_data; |
| 731 | void *controller_data; | 709 | void *controller_data; |
| 732 | int irq; | 710 | int irq; |
| @@ -794,4 +772,7 @@ spi_unregister_device(struct spi_device *spi) | |||
| 794 | device_unregister(&spi->dev); | 772 | device_unregister(&spi->dev); |
| 795 | } | 773 | } |
| 796 | 774 | ||
| 775 | extern const struct spi_device_id * | ||
| 776 | spi_get_device_id(const struct spi_device *sdev); | ||
| 777 | |||
| 797 | #endif /* __LINUX_SPI_H */ | 778 | #endif /* __LINUX_SPI_H */ |
