diff options
Diffstat (limited to 'include/linux/spi/spi.h')
-rw-r--r-- | include/linux/spi/spi.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 4203c66d8803..36c86ef51ff3 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h | |||
@@ -24,6 +24,9 @@ | |||
24 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |
25 | #include <linux/kthread.h> | 25 | #include <linux/kthread.h> |
26 | #include <linux/completion.h> | 26 | #include <linux/completion.h> |
27 | #include <linux/scatterlist.h> | ||
28 | |||
29 | struct dma_chan; | ||
27 | 30 | ||
28 | /* | 31 | /* |
29 | * INTERFACES between SPI master-side drivers and SPI infrastructure. | 32 | * INTERFACES between SPI master-side drivers and SPI infrastructure. |
@@ -266,6 +269,7 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv) | |||
266 | * @auto_runtime_pm: the core should ensure a runtime PM reference is held | 269 | * @auto_runtime_pm: the core should ensure a runtime PM reference is held |
267 | * while the hardware is prepared, using the parent | 270 | * while the hardware is prepared, using the parent |
268 | * device for the spidev | 271 | * device for the spidev |
272 | * @max_dma_len: Maximum length of a DMA transfer for the device. | ||
269 | * @prepare_transfer_hardware: a message will soon arrive from the queue | 273 | * @prepare_transfer_hardware: a message will soon arrive from the queue |
270 | * so the subsystem requests the driver to prepare the transfer hardware | 274 | * so the subsystem requests the driver to prepare the transfer hardware |
271 | * by issuing this call | 275 | * by issuing this call |
@@ -348,6 +352,8 @@ struct spi_master { | |||
348 | #define SPI_MASTER_HALF_DUPLEX BIT(0) /* can't do full duplex */ | 352 | #define SPI_MASTER_HALF_DUPLEX BIT(0) /* can't do full duplex */ |
349 | #define SPI_MASTER_NO_RX BIT(1) /* can't do buffer read */ | 353 | #define SPI_MASTER_NO_RX BIT(1) /* can't do buffer read */ |
350 | #define SPI_MASTER_NO_TX BIT(2) /* can't do buffer write */ | 354 | #define SPI_MASTER_NO_TX BIT(2) /* can't do buffer write */ |
355 | #define SPI_MASTER_MUST_RX BIT(3) /* requires rx */ | ||
356 | #define SPI_MASTER_MUST_TX BIT(4) /* requires tx */ | ||
351 | 357 | ||
352 | /* lock and mutex for SPI bus locking */ | 358 | /* lock and mutex for SPI bus locking */ |
353 | spinlock_t bus_lock_spinlock; | 359 | spinlock_t bus_lock_spinlock; |
@@ -390,6 +396,17 @@ struct spi_master { | |||
390 | void (*cleanup)(struct spi_device *spi); | 396 | void (*cleanup)(struct spi_device *spi); |
391 | 397 | ||
392 | /* | 398 | /* |
399 | * Used to enable core support for DMA handling, if can_dma() | ||
400 | * exists and returns true then the transfer will be mapped | ||
401 | * prior to transfer_one() being called. The driver should | ||
402 | * not modify or store xfer and dma_tx and dma_rx must be set | ||
403 | * while the device is prepared. | ||
404 | */ | ||
405 | bool (*can_dma)(struct spi_master *master, | ||
406 | struct spi_device *spi, | ||
407 | struct spi_transfer *xfer); | ||
408 | |||
409 | /* | ||
393 | * These hooks are for drivers that want to use the generic | 410 | * These hooks are for drivers that want to use the generic |
394 | * master transfer queueing mechanism. If these are used, the | 411 | * master transfer queueing mechanism. If these are used, the |
395 | * transfer() function above must NOT be specified by the driver. | 412 | * transfer() function above must NOT be specified by the driver. |
@@ -407,7 +424,9 @@ struct spi_master { | |||
407 | bool rt; | 424 | bool rt; |
408 | bool auto_runtime_pm; | 425 | bool auto_runtime_pm; |
409 | bool cur_msg_prepared; | 426 | bool cur_msg_prepared; |
427 | bool cur_msg_mapped; | ||
410 | struct completion xfer_completion; | 428 | struct completion xfer_completion; |
429 | size_t max_dma_len; | ||
411 | 430 | ||
412 | int (*prepare_transfer_hardware)(struct spi_master *master); | 431 | int (*prepare_transfer_hardware)(struct spi_master *master); |
413 | int (*transfer_one_message)(struct spi_master *master, | 432 | int (*transfer_one_message)(struct spi_master *master, |
@@ -428,6 +447,14 @@ struct spi_master { | |||
428 | 447 | ||
429 | /* gpio chip select */ | 448 | /* gpio chip select */ |
430 | int *cs_gpios; | 449 | int *cs_gpios; |
450 | |||
451 | /* DMA channels for use with core dmaengine helpers */ | ||
452 | struct dma_chan *dma_tx; | ||
453 | struct dma_chan *dma_rx; | ||
454 | |||
455 | /* dummy data for full duplex devices */ | ||
456 | void *dummy_rx; | ||
457 | void *dummy_tx; | ||
431 | }; | 458 | }; |
432 | 459 | ||
433 | static inline void *spi_master_get_devdata(struct spi_master *master) | 460 | static inline void *spi_master_get_devdata(struct spi_master *master) |
@@ -512,6 +539,8 @@ extern struct spi_master *spi_busnum_to_master(u16 busnum); | |||
512 | * (optionally) changing the chipselect status, then starting | 539 | * (optionally) changing the chipselect status, then starting |
513 | * the next transfer or completing this @spi_message. | 540 | * the next transfer or completing this @spi_message. |
514 | * @transfer_list: transfers are sequenced through @spi_message.transfers | 541 | * @transfer_list: transfers are sequenced through @spi_message.transfers |
542 | * @tx_sg: Scatterlist for transmit, currently not for client use | ||
543 | * @rx_sg: Scatterlist for receive, currently not for client use | ||
515 | * | 544 | * |
516 | * SPI transfers always write the same number of bytes as they read. | 545 | * SPI transfers always write the same number of bytes as they read. |
517 | * Protocol drivers should always provide @rx_buf and/or @tx_buf. | 546 | * Protocol drivers should always provide @rx_buf and/or @tx_buf. |
@@ -579,6 +608,8 @@ struct spi_transfer { | |||
579 | 608 | ||
580 | dma_addr_t tx_dma; | 609 | dma_addr_t tx_dma; |
581 | dma_addr_t rx_dma; | 610 | dma_addr_t rx_dma; |
611 | struct sg_table tx_sg; | ||
612 | struct sg_table rx_sg; | ||
582 | 613 | ||
583 | unsigned cs_change:1; | 614 | unsigned cs_change:1; |
584 | unsigned tx_nbits:3; | 615 | unsigned tx_nbits:3; |