Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef __ASM_ARCH_DMA_H
0003 #define __ASM_ARCH_DMA_H
0004 
0005 #include <linux/types.h>
0006 #include <linux/dmaengine.h>
0007 #include <linux/dma-mapping.h>
0008 
0009 /*
0010  * M2P channels.
0011  *
0012  * Note that these values are also directly used for setting the PPALLOC
0013  * register.
0014  */
0015 #define EP93XX_DMA_I2S1     0
0016 #define EP93XX_DMA_I2S2     1
0017 #define EP93XX_DMA_AAC1     2
0018 #define EP93XX_DMA_AAC2     3
0019 #define EP93XX_DMA_AAC3     4
0020 #define EP93XX_DMA_I2S3     5
0021 #define EP93XX_DMA_UART1    6
0022 #define EP93XX_DMA_UART2    7
0023 #define EP93XX_DMA_UART3    8
0024 #define EP93XX_DMA_IRDA     9
0025 /* M2M channels */
0026 #define EP93XX_DMA_SSP      10
0027 #define EP93XX_DMA_IDE      11
0028 
0029 /**
0030  * struct ep93xx_dma_data - configuration data for the EP93xx dmaengine
0031  * @port: peripheral which is requesting the channel
0032  * @direction: TX/RX channel
0033  * @name: optional name for the channel, this is displayed in /proc/interrupts
0034  *
0035  * This information is passed as private channel parameter in a filter
0036  * function. Note that this is only needed for slave/cyclic channels.  For
0037  * memcpy channels %NULL data should be passed.
0038  */
0039 struct ep93xx_dma_data {
0040     int             port;
0041     enum dma_transfer_direction direction;
0042     const char          *name;
0043 };
0044 
0045 /**
0046  * struct ep93xx_dma_chan_data - platform specific data for a DMA channel
0047  * @name: name of the channel, used for getting the right clock for the channel
0048  * @base: mapped registers
0049  * @irq: interrupt number used by this channel
0050  */
0051 struct ep93xx_dma_chan_data {
0052     const char          *name;
0053     void __iomem            *base;
0054     int             irq;
0055 };
0056 
0057 /**
0058  * struct ep93xx_dma_platform_data - platform data for the dmaengine driver
0059  * @channels: array of channels which are passed to the driver
0060  * @num_channels: number of channels in the array
0061  *
0062  * This structure is passed to the DMA engine driver via platform data. For
0063  * M2P channels, contract is that even channels are for TX and odd for RX.
0064  * There is no requirement for the M2M channels.
0065  */
0066 struct ep93xx_dma_platform_data {
0067     struct ep93xx_dma_chan_data *channels;
0068     size_t              num_channels;
0069 };
0070 
0071 static inline bool ep93xx_dma_chan_is_m2p(struct dma_chan *chan)
0072 {
0073     return !strcmp(dev_name(chan->device->dev), "ep93xx-dma-m2p");
0074 }
0075 
0076 /**
0077  * ep93xx_dma_chan_direction - returns direction the channel can be used
0078  * @chan: channel
0079  *
0080  * This function can be used in filter functions to find out whether the
0081  * channel supports given DMA direction. Only M2P channels have such
0082  * limitation, for M2M channels the direction is configurable.
0083  */
0084 static inline enum dma_transfer_direction
0085 ep93xx_dma_chan_direction(struct dma_chan *chan)
0086 {
0087     if (!ep93xx_dma_chan_is_m2p(chan))
0088         return DMA_TRANS_NONE;
0089 
0090     /* even channels are for TX, odd for RX */
0091     return (chan->chan_id % 2 == 0) ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM;
0092 }
0093 
0094 #endif /* __ASM_ARCH_DMA_H */