diff options
Diffstat (limited to 'include/linux/spi/spi.h')
-rw-r--r-- | include/linux/spi/spi.h | 51 |
1 files changed, 13 insertions, 38 deletions
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index c47c4b4da97..97b60b37f44 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. |
@@ -86,7 +87,7 @@ struct spi_device { | |||
86 | int irq; | 87 | int irq; |
87 | void *controller_state; | 88 | void *controller_state; |
88 | void *controller_data; | 89 | void *controller_data; |
89 | char modalias[32]; | 90 | char modalias[SPI_NAME_SIZE]; |
90 | 91 | ||
91 | /* | 92 | /* |
92 | * likely need more hooks for more protocol options affecting how | 93 | * likely need more hooks for more protocol options affecting how |
@@ -145,6 +146,7 @@ struct spi_message; | |||
145 | 146 | ||
146 | /** | 147 | /** |
147 | * 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 | ||
148 | * @probe: Binds this driver to the spi device. Drivers can verify | 150 | * @probe: Binds this driver to the spi device. Drivers can verify |
149 | * that the device is actually present, and may need to configure | 151 | * that the device is actually present, and may need to configure |
150 | * characteristics (such as bits_per_word) which weren't needed for | 152 | * characteristics (such as bits_per_word) which weren't needed for |
@@ -170,6 +172,7 @@ struct spi_message; | |||
170 | * MMC, RTC, filesystem character device nodes, and hardware monitoring. | 172 | * MMC, RTC, filesystem character device nodes, and hardware monitoring. |
171 | */ | 173 | */ |
172 | struct spi_driver { | 174 | struct spi_driver { |
175 | const struct spi_device_id *id_table; | ||
173 | int (*probe)(struct spi_device *spi); | 176 | int (*probe)(struct spi_device *spi); |
174 | int (*remove)(struct spi_device *spi); | 177 | int (*remove)(struct spi_device *spi); |
175 | void (*shutdown)(struct spi_device *spi); | 178 | void (*shutdown)(struct spi_device *spi); |
@@ -207,6 +210,8 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv) | |||
207 | * 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 |
208 | * every chipselect is connected to a slave. | 211 | * every chipselect is connected to a slave. |
209 | * @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 | ||
210 | * @setup: updates the device mode and clocking records used by a | 215 | * @setup: updates the device mode and clocking records used by a |
211 | * device's SPI controller; protocol code may call this. This | 216 | * device's SPI controller; protocol code may call this. This |
212 | * must fail if an unrecognized or unsupported mode is requested. | 217 | * must fail if an unrecognized or unsupported mode is requested. |
@@ -253,6 +258,8 @@ struct spi_master { | |||
253 | /* other constraints relevant to this driver */ | 258 | /* other constraints relevant to this driver */ |
254 | u16 flags; | 259 | u16 flags; |
255 | #define SPI_MASTER_HALF_DUPLEX BIT(0) /* can't do full duplex */ | 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 */ | ||
256 | 263 | ||
257 | /* Setup mode and clock, etc (spi driver may call many times). | 264 | /* Setup mode and clock, etc (spi driver may call many times). |
258 | * | 265 | * |
@@ -533,42 +540,7 @@ static inline void spi_message_free(struct spi_message *m) | |||
533 | } | 540 | } |
534 | 541 | ||
535 | extern int spi_setup(struct spi_device *spi); | 542 | extern int spi_setup(struct spi_device *spi); |
536 | 543 | extern int spi_async(struct spi_device *spi, struct spi_message *message); | |
537 | /** | ||
538 | * spi_async - asynchronous SPI transfer | ||
539 | * @spi: device with which data will be exchanged | ||
540 | * @message: describes the data transfers, including completion callback | ||
541 | * Context: any (irqs may be blocked, etc) | ||
542 | * | ||
543 | * This call may be used in_irq and other contexts which can't sleep, | ||
544 | * as well as from task contexts which can sleep. | ||
545 | * | ||
546 | * The completion callback is invoked in a context which can't sleep. | ||
547 | * Before that invocation, the value of message->status is undefined. | ||
548 | * When the callback is issued, message->status holds either zero (to | ||
549 | * indicate complete success) or a negative error code. After that | ||
550 | * callback returns, the driver which issued the transfer request may | ||
551 | * deallocate the associated memory; it's no longer in use by any SPI | ||
552 | * core or controller driver code. | ||
553 | * | ||
554 | * Note that although all messages to a spi_device are handled in | ||
555 | * FIFO order, messages may go to different devices in other orders. | ||
556 | * Some device might be higher priority, or have various "hard" access | ||
557 | * time requirements, for example. | ||
558 | * | ||
559 | * On detection of any fault during the transfer, processing of | ||
560 | * the entire message is aborted, and the device is deselected. | ||
561 | * Until returning from the associated message completion callback, | ||
562 | * no other spi_message queued to that device will be processed. | ||
563 | * (This rule applies equally to all the synchronous transfer calls, | ||
564 | * which are wrappers around this core asynchronous primitive.) | ||
565 | */ | ||
566 | static inline int | ||
567 | spi_async(struct spi_device *spi, struct spi_message *message) | ||
568 | { | ||
569 | message->spi = spi; | ||
570 | return spi->master->transfer(spi, message); | ||
571 | } | ||
572 | 544 | ||
573 | /*---------------------------------------------------------------------------*/ | 545 | /*---------------------------------------------------------------------------*/ |
574 | 546 | ||
@@ -732,7 +704,7 @@ struct spi_board_info { | |||
732 | * controller_data goes to spi_device.controller_data, | 704 | * controller_data goes to spi_device.controller_data, |
733 | * irq is copied too | 705 | * irq is copied too |
734 | */ | 706 | */ |
735 | char modalias[32]; | 707 | char modalias[SPI_NAME_SIZE]; |
736 | const void *platform_data; | 708 | const void *platform_data; |
737 | void *controller_data; | 709 | void *controller_data; |
738 | int irq; | 710 | int irq; |
@@ -800,4 +772,7 @@ spi_unregister_device(struct spi_device *spi) | |||
800 | device_unregister(&spi->dev); | 772 | device_unregister(&spi->dev); |
801 | } | 773 | } |
802 | 774 | ||
775 | extern const struct spi_device_id * | ||
776 | spi_get_device_id(const struct spi_device *sdev); | ||
777 | |||
803 | #endif /* __LINUX_SPI_H */ | 778 | #endif /* __LINUX_SPI_H */ |