@@ -370,6 +370,33 @@ struct dma_slave_config {
370370 unsigned int slave_id ;
371371};
372372
373+ /* struct dma_slave_caps - expose capabilities of a slave channel only
374+ *
375+ * @src_addr_widths: bit mask of src addr widths the channel supports
376+ * @dstn_addr_widths: bit mask of dstn addr widths the channel supports
377+ * @directions: bit mask of slave direction the channel supported
378+ * since the enum dma_transfer_direction is not defined as bits for each
379+ * type of direction, the dma controller should fill (1 << <TYPE>) and same
380+ * should be checked by controller as well
381+ * @cmd_pause: true, if pause and thereby resume is supported
382+ * @cmd_terminate: true, if terminate cmd is supported
383+ *
384+ * @max_sg_nr: maximum number of SG segments supported
385+ * 0 for no maximum
386+ * @max_sg_len: maximum length of a SG segment supported
387+ * 0 for no maximum
388+ */
389+ struct dma_slave_caps {
390+ u32 src_addr_widths ;
391+ u32 dstn_addr_widths ;
392+ u32 directions ;
393+ bool cmd_pause ;
394+ bool cmd_terminate ;
395+
396+ u32 max_sg_nr ;
397+ u32 max_sg_len ;
398+ };
399+
373400static inline const char * dma_chan_name (struct dma_chan * chan )
374401{
375402 return dev_name (& chan -> dev -> device );
@@ -532,6 +559,7 @@ struct dma_tx_state {
532559 * struct with auxiliary transfer status information, otherwise the call
533560 * will just return a simple status code
534561 * @device_issue_pending: push pending transactions to hardware
562+ * @device_slave_caps: return the slave channel capabilities
535563 */
536564struct dma_device {
537565
@@ -597,6 +625,7 @@ struct dma_device {
597625 dma_cookie_t cookie ,
598626 struct dma_tx_state * txstate );
599627 void (* device_issue_pending )(struct dma_chan * chan );
628+ int (* device_slave_caps )(struct dma_chan * chan , struct dma_slave_caps * caps );
600629};
601630
602631static inline int dmaengine_device_control (struct dma_chan * chan ,
@@ -670,6 +699,21 @@ static inline struct dma_async_tx_descriptor *dmaengine_prep_interleaved_dma(
670699 return chan -> device -> device_prep_interleaved_dma (chan , xt , flags );
671700}
672701
702+ static inline int dma_get_slave_caps (struct dma_chan * chan , struct dma_slave_caps * caps )
703+ {
704+ if (!chan || !caps )
705+ return - EINVAL ;
706+
707+ /* check if the channel supports slave transactions */
708+ if (!test_bit (DMA_SLAVE , chan -> device -> cap_mask .bits ))
709+ return - ENXIO ;
710+
711+ if (chan -> device -> device_slave_caps )
712+ return chan -> device -> device_slave_caps (chan , caps );
713+
714+ return - ENXIO ;
715+ }
716+
673717static inline int dmaengine_terminate_all (struct dma_chan * chan )
674718{
675719 return dmaengine_device_control (chan , DMA_TERMINATE_ALL , 0 );
0 commit comments