0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef STE_DMA40_H
0010 #define STE_DMA40_H
0011
0012 #include <linux/dmaengine.h>
0013 #include <linux/scatterlist.h>
0014 #include <linux/workqueue.h>
0015 #include <linux/interrupt.h>
0016
0017
0018
0019
0020
0021
0022
0023 #define STEDMA40_MAX_SEG_SIZE 0xFFFF
0024
0025
0026 #define STEDMA40_DEV_DST_MEMORY (-1)
0027 #define STEDMA40_DEV_SRC_MEMORY (-1)
0028
0029 enum stedma40_mode {
0030 STEDMA40_MODE_LOGICAL = 0,
0031 STEDMA40_MODE_PHYSICAL,
0032 STEDMA40_MODE_OPERATION,
0033 };
0034
0035 enum stedma40_mode_opt {
0036 STEDMA40_PCHAN_BASIC_MODE = 0,
0037 STEDMA40_LCHAN_SRC_LOG_DST_LOG = 0,
0038 STEDMA40_PCHAN_MODULO_MODE,
0039 STEDMA40_PCHAN_DOUBLE_DST_MODE,
0040 STEDMA40_LCHAN_SRC_PHY_DST_LOG,
0041 STEDMA40_LCHAN_SRC_LOG_DST_PHY,
0042 };
0043
0044 #define STEDMA40_ESIZE_8_BIT 0x0
0045 #define STEDMA40_ESIZE_16_BIT 0x1
0046 #define STEDMA40_ESIZE_32_BIT 0x2
0047 #define STEDMA40_ESIZE_64_BIT 0x3
0048
0049
0050 #define STEDMA40_PSIZE_PHY_1 0x4
0051 #define STEDMA40_PSIZE_PHY_2 0x0
0052 #define STEDMA40_PSIZE_PHY_4 0x1
0053 #define STEDMA40_PSIZE_PHY_8 0x2
0054 #define STEDMA40_PSIZE_PHY_16 0x3
0055
0056
0057
0058
0059
0060 #define STEDMA40_PSIZE_LOG_1 STEDMA40_PSIZE_PHY_2
0061 #define STEDMA40_PSIZE_LOG_4 STEDMA40_PSIZE_PHY_4
0062 #define STEDMA40_PSIZE_LOG_8 STEDMA40_PSIZE_PHY_8
0063 #define STEDMA40_PSIZE_LOG_16 STEDMA40_PSIZE_PHY_16
0064
0065
0066 #define STEDMA40_MAX_PHYS 32
0067
0068 enum stedma40_flow_ctrl {
0069 STEDMA40_NO_FLOW_CTRL,
0070 STEDMA40_FLOW_CTRL,
0071 };
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081 struct stedma40_half_channel_info {
0082 bool big_endian;
0083 enum dma_slave_buswidth data_width;
0084 int psize;
0085 enum stedma40_flow_ctrl flow_ctrl;
0086 };
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107 struct stedma40_chan_cfg {
0108 enum dma_transfer_direction dir;
0109 bool high_priority;
0110 bool realtime;
0111 enum stedma40_mode mode;
0112 enum stedma40_mode_opt mode_opt;
0113 int dev_type;
0114 struct stedma40_half_channel_info src_info;
0115 struct stedma40_half_channel_info dst_info;
0116
0117 bool use_fixed_channel;
0118 int phy_channel;
0119 };
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140 struct stedma40_platform_data {
0141 int disabled_channels[STEDMA40_MAX_PHYS];
0142 int *soft_lli_chans;
0143 int num_of_soft_lli_chans;
0144 bool use_esram_lcla;
0145 int num_of_memcpy_chans;
0146 int num_of_phy_chans;
0147 };
0148
0149 #ifdef CONFIG_STE_DMA40
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164 bool stedma40_filter(struct dma_chan *chan, void *data);
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177 static inline struct
0178 dma_async_tx_descriptor *stedma40_slave_mem(struct dma_chan *chan,
0179 dma_addr_t addr,
0180 unsigned int size,
0181 enum dma_transfer_direction direction,
0182 unsigned long flags)
0183 {
0184 struct scatterlist sg;
0185 sg_init_table(&sg, 1);
0186 sg.dma_address = addr;
0187 sg.length = size;
0188
0189 return dmaengine_prep_slave_sg(chan, &sg, 1, direction, flags);
0190 }
0191
0192 #else
0193 static inline bool stedma40_filter(struct dma_chan *chan, void *data)
0194 {
0195 return false;
0196 }
0197
0198 static inline struct
0199 dma_async_tx_descriptor *stedma40_slave_mem(struct dma_chan *chan,
0200 dma_addr_t addr,
0201 unsigned int size,
0202 enum dma_transfer_direction direction,
0203 unsigned long flags)
0204 {
0205 return NULL;
0206 }
0207 #endif
0208
0209 #endif