diff options
author | Mike Frysinger <vapier.adi@gmail.com> | 2009-01-07 10:14:39 -0500 |
---|---|---|
committer | Bryan Wu <cooloney@kernel.org> | 2009-01-07 10:14:39 -0500 |
commit | 9c417a43299edc52931712a54c46cff4db19082c (patch) | |
tree | 5981a0f424543660335d600b70c82d99f9185fc8 /arch/blackfin/include/asm/dma.h | |
parent | 4c1ed6a57bc51ecd471989ae744da86a9101912f (diff) |
Blackfin arch: move most dma functions into static inlines
move most dma functions into static inlines since they are vastly 1
liners that get/set a value in a structure
Signed-off-by: Mike Frysinger <vapier.adi@gmail.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
Diffstat (limited to 'arch/blackfin/include/asm/dma.h')
-rw-r--r-- | arch/blackfin/include/asm/dma.h | 156 |
1 files changed, 116 insertions, 40 deletions
diff --git a/arch/blackfin/include/asm/dma.h b/arch/blackfin/include/asm/dma.h index 4928e7aa4801..690c25f5f992 100644 --- a/arch/blackfin/include/asm/dma.h +++ b/arch/blackfin/include/asm/dma.h | |||
@@ -129,50 +129,126 @@ void blackfin_dma_resume(void); | |||
129 | /******************************************************************************* | 129 | /******************************************************************************* |
130 | * DMA API's | 130 | * DMA API's |
131 | *******************************************************************************/ | 131 | *******************************************************************************/ |
132 | /* functions to set register mode */ | 132 | extern struct dma_channel dma_ch[MAX_DMA_CHANNELS]; |
133 | void set_dma_start_addr(unsigned int channel, unsigned long addr); | 133 | extern struct dma_register *dma_io_base_addr[MAX_DMA_CHANNELS]; |
134 | void set_dma_next_desc_addr(unsigned int channel, unsigned long addr); | 134 | extern int channel2irq(unsigned int channel); |
135 | void set_dma_curr_desc_addr(unsigned int channel, unsigned long addr); | 135 | |
136 | void set_dma_x_count(unsigned int channel, unsigned short x_count); | 136 | static inline void set_dma_start_addr(unsigned int channel, unsigned long addr) |
137 | void set_dma_x_modify(unsigned int channel, short x_modify); | 137 | { |
138 | void set_dma_y_count(unsigned int channel, unsigned short y_count); | 138 | dma_ch[channel].regs->start_addr = addr; |
139 | void set_dma_y_modify(unsigned int channel, short y_modify); | 139 | } |
140 | void set_dma_config(unsigned int channel, unsigned short config); | 140 | static inline void set_dma_next_desc_addr(unsigned int channel, unsigned long addr) |
141 | unsigned short set_bfin_dma_config(char direction, char flow_mode, | 141 | { |
142 | char intr_mode, char dma_mode, char width, | 142 | dma_ch[channel].regs->next_desc_ptr = addr; |
143 | char syncmode); | 143 | } |
144 | void set_dma_curr_addr(unsigned int channel, unsigned long addr); | 144 | static inline void set_dma_curr_desc_addr(unsigned int channel, unsigned long addr) |
145 | 145 | { | |
146 | /* get curr status for polling */ | 146 | dma_ch[channel].regs->curr_desc_ptr = addr; |
147 | unsigned short get_dma_curr_irqstat(unsigned int channel); | 147 | } |
148 | unsigned short get_dma_curr_xcount(unsigned int channel); | 148 | static inline void set_dma_x_count(unsigned int channel, unsigned short x_count) |
149 | unsigned short get_dma_curr_ycount(unsigned int channel); | 149 | { |
150 | unsigned long get_dma_next_desc_ptr(unsigned int channel); | 150 | dma_ch[channel].regs->x_count = x_count; |
151 | unsigned long get_dma_curr_desc_ptr(unsigned int channel); | 151 | } |
152 | unsigned long get_dma_curr_addr(unsigned int channel); | 152 | static inline void set_dma_y_count(unsigned int channel, unsigned short y_count) |
153 | 153 | { | |
154 | /* set large DMA mode descriptor */ | 154 | dma_ch[channel].regs->y_count = y_count; |
155 | void set_dma_sg(unsigned int channel, struct dmasg *sg, int nr_sg); | 155 | } |
156 | 156 | static inline void set_dma_x_modify(unsigned int channel, short x_modify) | |
157 | /* check if current channel is in use */ | 157 | { |
158 | int dma_channel_active(unsigned int channel); | 158 | dma_ch[channel].regs->x_modify = x_modify; |
159 | 159 | } | |
160 | /* common functions must be called in any mode */ | 160 | static inline void set_dma_y_modify(unsigned int channel, short y_modify) |
161 | { | ||
162 | dma_ch[channel].regs->y_modify = y_modify; | ||
163 | } | ||
164 | static inline void set_dma_config(unsigned int channel, unsigned short config) | ||
165 | { | ||
166 | dma_ch[channel].regs->cfg = config; | ||
167 | } | ||
168 | static inline void set_dma_curr_addr(unsigned int channel, unsigned long addr) | ||
169 | { | ||
170 | dma_ch[channel].regs->curr_addr_ptr = addr; | ||
171 | } | ||
172 | |||
173 | static inline unsigned short | ||
174 | set_bfin_dma_config(char direction, char flow_mode, | ||
175 | char intr_mode, char dma_mode, char width, char syncmode) | ||
176 | { | ||
177 | return (direction << 1) | (width << 2) | (dma_mode << 4) | | ||
178 | (intr_mode << 6) | (flow_mode << 12) | (syncmode << 5); | ||
179 | } | ||
180 | |||
181 | static inline unsigned short get_dma_curr_irqstat(unsigned int channel) | ||
182 | { | ||
183 | return dma_ch[channel].regs->irq_status; | ||
184 | } | ||
185 | static inline unsigned short get_dma_curr_xcount(unsigned int channel) | ||
186 | { | ||
187 | return dma_ch[channel].regs->curr_x_count; | ||
188 | } | ||
189 | static inline unsigned short get_dma_curr_ycount(unsigned int channel) | ||
190 | { | ||
191 | return dma_ch[channel].regs->curr_y_count; | ||
192 | } | ||
193 | static inline unsigned long get_dma_next_desc_ptr(unsigned int channel) | ||
194 | { | ||
195 | return dma_ch[channel].regs->next_desc_ptr; | ||
196 | } | ||
197 | static inline unsigned long get_dma_curr_desc_ptr(unsigned int channel) | ||
198 | { | ||
199 | return dma_ch[channel].regs->curr_desc_ptr; | ||
200 | } | ||
201 | static inline unsigned long get_dma_curr_addr(unsigned int channel) | ||
202 | { | ||
203 | return dma_ch[channel].regs->curr_addr_ptr; | ||
204 | } | ||
205 | |||
206 | static inline void set_dma_sg(unsigned int channel, struct dmasg *sg, int ndsize) | ||
207 | { | ||
208 | dma_ch[channel].regs->cfg |= ((ndsize & 0x0F) << 8); | ||
209 | dma_ch[channel].regs->next_desc_ptr = (unsigned long)sg; | ||
210 | } | ||
211 | |||
212 | static inline int dma_channel_active(unsigned int channel) | ||
213 | { | ||
214 | if (dma_ch[channel].chan_status == DMA_CHANNEL_FREE) | ||
215 | return 0; | ||
216 | else | ||
217 | return 1; | ||
218 | } | ||
219 | |||
220 | static inline void disable_dma(unsigned int channel) | ||
221 | { | ||
222 | dma_ch[channel].regs->cfg &= ~DMAEN; | ||
223 | SSYNC(); | ||
224 | dma_ch[channel].chan_status = DMA_CHANNEL_REQUESTED; | ||
225 | } | ||
226 | static inline void enable_dma(unsigned int channel) | ||
227 | { | ||
228 | dma_ch[channel].regs->curr_x_count = 0; | ||
229 | dma_ch[channel].regs->curr_y_count = 0; | ||
230 | dma_ch[channel].regs->cfg |= DMAEN; | ||
231 | dma_ch[channel].chan_status = DMA_CHANNEL_ENABLED; | ||
232 | } | ||
161 | void free_dma(unsigned int channel); | 233 | void free_dma(unsigned int channel); |
162 | int dma_channel_active(unsigned int channel); /* check if a channel is in use */ | ||
163 | void disable_dma(unsigned int channel); | ||
164 | void enable_dma(unsigned int channel); | ||
165 | int request_dma(unsigned int channel, const char *device_id); | 234 | int request_dma(unsigned int channel, const char *device_id); |
166 | int set_dma_callback(unsigned int channel, irq_handler_t callback, | 235 | int set_dma_callback(unsigned int channel, irq_handler_t callback, void *data); |
167 | void *data); | 236 | |
168 | void dma_disable_irq(unsigned int channel); | 237 | static inline void dma_disable_irq(unsigned int channel) |
169 | void dma_enable_irq(unsigned int channel); | 238 | { |
170 | void clear_dma_irqstat(unsigned int channel); | 239 | disable_irq(dma_ch[channel].irq); |
240 | } | ||
241 | static inline void dma_enable_irq(unsigned int channel) | ||
242 | { | ||
243 | enable_irq(dma_ch[channel].irq); | ||
244 | } | ||
245 | static inline void clear_dma_irqstat(unsigned int channel) | ||
246 | { | ||
247 | dma_ch[channel].regs->irq_status = DMA_DONE | DMA_ERR; | ||
248 | } | ||
249 | |||
171 | void *dma_memcpy(void *dest, const void *src, size_t count); | 250 | void *dma_memcpy(void *dest, const void *src, size_t count); |
172 | void *safe_dma_memcpy(void *dest, const void *src, size_t count); | 251 | void *safe_dma_memcpy(void *dest, const void *src, size_t count); |
173 | void blackfin_dma_early_init(void); | 252 | void blackfin_dma_early_init(void); |
174 | 253 | ||
175 | extern int channel2irq(unsigned int channel); | ||
176 | extern struct dma_register *dma_io_base_addr[MAX_DMA_CHANNELS]; | ||
177 | |||
178 | #endif | 254 | #endif |