aboutsummaryrefslogtreecommitdiffstats
path: root/arch/blackfin/include/asm/dma.h
diff options
context:
space:
mode:
authorMike Frysinger <vapier.adi@gmail.com>2009-01-07 10:14:39 -0500
committerBryan Wu <cooloney@kernel.org>2009-01-07 10:14:39 -0500
commit9c417a43299edc52931712a54c46cff4db19082c (patch)
tree5981a0f424543660335d600b70c82d99f9185fc8 /arch/blackfin/include/asm/dma.h
parent4c1ed6a57bc51ecd471989ae744da86a9101912f (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.h156
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 */ 132extern struct dma_channel dma_ch[MAX_DMA_CHANNELS];
133void set_dma_start_addr(unsigned int channel, unsigned long addr); 133extern struct dma_register *dma_io_base_addr[MAX_DMA_CHANNELS];
134void set_dma_next_desc_addr(unsigned int channel, unsigned long addr); 134extern int channel2irq(unsigned int channel);
135void set_dma_curr_desc_addr(unsigned int channel, unsigned long addr); 135
136void set_dma_x_count(unsigned int channel, unsigned short x_count); 136static inline void set_dma_start_addr(unsigned int channel, unsigned long addr)
137void set_dma_x_modify(unsigned int channel, short x_modify); 137{
138void set_dma_y_count(unsigned int channel, unsigned short y_count); 138 dma_ch[channel].regs->start_addr = addr;
139void set_dma_y_modify(unsigned int channel, short y_modify); 139}
140void set_dma_config(unsigned int channel, unsigned short config); 140static inline void set_dma_next_desc_addr(unsigned int channel, unsigned long addr)
141unsigned 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}
144void set_dma_curr_addr(unsigned int channel, unsigned long addr); 144static 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;
147unsigned short get_dma_curr_irqstat(unsigned int channel); 147}
148unsigned short get_dma_curr_xcount(unsigned int channel); 148static inline void set_dma_x_count(unsigned int channel, unsigned short x_count)
149unsigned short get_dma_curr_ycount(unsigned int channel); 149{
150unsigned long get_dma_next_desc_ptr(unsigned int channel); 150 dma_ch[channel].regs->x_count = x_count;
151unsigned long get_dma_curr_desc_ptr(unsigned int channel); 151}
152unsigned long get_dma_curr_addr(unsigned int channel); 152static 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;
155void set_dma_sg(unsigned int channel, struct dmasg *sg, int nr_sg); 155}
156 156static inline void set_dma_x_modify(unsigned int channel, short x_modify)
157/* check if current channel is in use */ 157{
158int 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 */ 160static inline void set_dma_y_modify(unsigned int channel, short y_modify)
161{
162 dma_ch[channel].regs->y_modify = y_modify;
163}
164static inline void set_dma_config(unsigned int channel, unsigned short config)
165{
166 dma_ch[channel].regs->cfg = config;
167}
168static inline void set_dma_curr_addr(unsigned int channel, unsigned long addr)
169{
170 dma_ch[channel].regs->curr_addr_ptr = addr;
171}
172
173static inline unsigned short
174set_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
181static inline unsigned short get_dma_curr_irqstat(unsigned int channel)
182{
183 return dma_ch[channel].regs->irq_status;
184}
185static inline unsigned short get_dma_curr_xcount(unsigned int channel)
186{
187 return dma_ch[channel].regs->curr_x_count;
188}
189static inline unsigned short get_dma_curr_ycount(unsigned int channel)
190{
191 return dma_ch[channel].regs->curr_y_count;
192}
193static inline unsigned long get_dma_next_desc_ptr(unsigned int channel)
194{
195 return dma_ch[channel].regs->next_desc_ptr;
196}
197static inline unsigned long get_dma_curr_desc_ptr(unsigned int channel)
198{
199 return dma_ch[channel].regs->curr_desc_ptr;
200}
201static inline unsigned long get_dma_curr_addr(unsigned int channel)
202{
203 return dma_ch[channel].regs->curr_addr_ptr;
204}
205
206static 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
212static 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
220static 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}
226static 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}
161void free_dma(unsigned int channel); 233void free_dma(unsigned int channel);
162int dma_channel_active(unsigned int channel); /* check if a channel is in use */
163void disable_dma(unsigned int channel);
164void enable_dma(unsigned int channel);
165int request_dma(unsigned int channel, const char *device_id); 234int request_dma(unsigned int channel, const char *device_id);
166int set_dma_callback(unsigned int channel, irq_handler_t callback, 235int set_dma_callback(unsigned int channel, irq_handler_t callback, void *data);
167 void *data); 236
168void dma_disable_irq(unsigned int channel); 237static inline void dma_disable_irq(unsigned int channel)
169void dma_enable_irq(unsigned int channel); 238{
170void clear_dma_irqstat(unsigned int channel); 239 disable_irq(dma_ch[channel].irq);
240}
241static inline void dma_enable_irq(unsigned int channel)
242{
243 enable_irq(dma_ch[channel].irq);
244}
245static inline void clear_dma_irqstat(unsigned int channel)
246{
247 dma_ch[channel].regs->irq_status = DMA_DONE | DMA_ERR;
248}
249
171void *dma_memcpy(void *dest, const void *src, size_t count); 250void *dma_memcpy(void *dest, const void *src, size_t count);
172void *safe_dma_memcpy(void *dest, const void *src, size_t count); 251void *safe_dma_memcpy(void *dest, const void *src, size_t count);
173void blackfin_dma_early_init(void); 252void blackfin_dma_early_init(void);
174 253
175extern int channel2irq(unsigned int channel);
176extern struct dma_register *dma_io_base_addr[MAX_DMA_CHANNELS];
177
178#endif 254#endif