make oldconfig will rebuild these...
[linux-2.4.21-pre4.git] / include / asm-ppc / ppc4xx_dma.h
1 /*
2  *
3  *    Copyright 2000,2001,2002 MontaVista Software Inc.
4  *      PPC4xx modifications
5  *      MontaVista Software, Inc.
6  *      currently maintained by Armin Kuster akuster@mvista.com
7  *
8  *      original Author
9  *      MontaVista Software, Inc.
10  *      ppopov@mvista.com or source@mvista.com
11  *
12  *
13  *    Module name: ppc4xx_dma.h
14  *
15  *    Description:
16  *      Data structures specific to the IBM PPC4xx on-chip DMA controller
17  *      and API.
18  *
19  *    version 1.1: 02/02 - Armin
20  *    added stb03xxx suppor
21  *
22  *    version 1.2: 02/28/02 - armin
23  *    changed config_405gp to a more generic config
24  *
25  *    version 1.3: 07/18/02 - armin
26  *    moved scatter/gather inline code to ppc4xx_sgdma.c
27  *    added three new extern proto types for the STBxxxx API's
28  *
29  *    version 1.4: 08/26/02 - Armin
30  *    added in_use field for when a channel is claimed
31  *    added new return code *_NOTFREE
32  *
33  */
34
35 #ifdef __KERNEL__
36 #ifndef __ASMPPC_PPC4xx_DMA_H
37 #define __ASMPPC_PPC4xx_DMA_H
38
39 #include <linux/config.h>
40 #include <linux/types.h>
41 #include <asm/mmu.h>
42 #include <asm/ibm4xx.h>
43
44 #undef DEBUG_4xxDMA
45
46 #define MAX_PPC4xx_DMA_CHANNELS         4
47
48 /* 
49  * Function return status codes
50  * These values are used to indicate whether or not the function
51  * call was successful, or a bad/invalid parameter was passed.
52  */
53 #define DMA_STATUS_GOOD                 0
54 #define DMA_STATUS_BAD_CHANNEL          1
55 #define DMA_STATUS_BAD_HANDLE           2
56 #define DMA_STATUS_BAD_MODE             3
57 #define DMA_STATUS_NULL_POINTER         4
58 #define DMA_STATUS_OUT_OF_MEMORY        5
59 #define DMA_STATUS_SGL_LIST_EMPTY       6
60 #define DMA_STATUS_GENERAL_ERROR        7
61 #define DMA_STATUS_CHANNEL_NOTFREE      8
62
63 #define DMA_CHANNEL_BUSY                0x80000000
64
65 /*
66  * These indicate status as returned from the DMA Status Register.
67  */
68 #define DMA_STATUS_NO_ERROR     0
69 #define DMA_STATUS_CS           1       /* Count Status        */
70 #define DMA_STATUS_TS           2       /* Transfer Status     */
71 #define DMA_STATUS_DMA_ERROR    3       /* DMA Error Occurred  */
72 #define DMA_STATUS_DMA_BUSY     4       /* The channel is busy */
73
74
75 /*
76  * DMA Channel Control Registers
77  */
78
79 #ifdef CONFIG_440
80 #define DMA_CR_OFFSET           1
81 #else
82 #define DMA_CR_OFFSET           0
83 #endif
84
85 #define DMA_CE_ENABLE        (1<<31)    /* DMA Channel Enable */
86 #define SET_DMA_CE_ENABLE(x) (((x)&0x1)<<31)
87 #define GET_DMA_CE_ENABLE(x) (((x)&DMA_CE_ENABLE)>>31)
88
89 #define DMA_CIE_ENABLE        (1<<30)   /* DMA Channel Interrupt Enable */
90 #define SET_DMA_CIE_ENABLE(x) (((x)&0x1)<<30)
91 #define GET_DMA_CIE_ENABLE(x) (((x)&DMA_CIE_ENABLE)>>30)
92
93 #define DMA_TD                (1<<29)
94 #define SET_DMA_TD(x)         (((x)&0x1)<<29)
95 #define GET_DMA_TD(x)         (((x)&DMA_TD)>>29)
96
97 #define DMA_PL                (1<<28)   /* Peripheral Location */
98 #define SET_DMA_PL(x)         (((x)&0x1)<<28)
99 #define GET_DMA_PL(x)         (((x)&DMA_PL)>>28)
100
101 #define EXTERNAL_PERIPHERAL    0
102 #define INTERNAL_PERIPHERAL    1
103
104 #define SET_DMA_PW(x)     (((x)&0x3)<<(26-DMA_CR_OFFSET))       /* Peripheral Width */
105 #define DMA_PW_MASK       SET_DMA_PW(3)
106 #define   PW_8                 0
107 #define   PW_16                1
108 #define   PW_32                2
109 #define   PW_64                3
110 /* FIXME: Add PW_128 support for 440GP DMA block */
111 #define GET_DMA_PW(x)     (((x)&DMA_PW_MASK)>>(26-DMA_CR_OFFSET))
112
113 #define DMA_DAI           (1<<(25-DMA_CR_OFFSET))       /* Destination Address Increment */
114 #define SET_DMA_DAI(x)    (((x)&0x1)<<(25-DMA_CR_OFFSET))
115
116 #define DMA_SAI           (1<<(24-DMA_CR_OFFSET))       /* Source Address Increment */
117 #define SET_DMA_SAI(x)    (((x)&0x1)<<(24-DMA_CR_OFFSET))
118
119 #define DMA_BEN           (1<<(23-DMA_CR_OFFSET))       /* Buffer Enable */
120 #define SET_DMA_BEN(x)    (((x)&0x1)<<(23-DMA_CR_OFFSET))
121
122 #define SET_DMA_TM(x)     (((x)&0x3)<<(21-DMA_CR_OFFSET))       /* Transfer Mode */
123 #define DMA_TM_MASK       SET_DMA_TM(3)
124 #define   TM_PERIPHERAL        0        /* Peripheral */
125 #define   TM_RESERVED          1        /* Reserved */
126 #define   TM_S_MM              2        /* Memory to Memory */
127 #define   TM_D_MM              3        /* Device Paced Memory to Memory */
128 #define GET_DMA_TM(x)     (((x)&DMA_TM_MASK)>>(21-DMA_CR_OFFSET))
129
130 #define SET_DMA_PSC(x)    (((x)&0x3)<<(19-DMA_CR_OFFSET))       /* Peripheral Setup Cycles */
131 #define DMA_PSC_MASK      SET_DMA_PSC(3)
132 #define GET_DMA_PSC(x)    (((x)&DMA_PSC_MASK)>>(19-DMA_CR_OFFSET))
133
134 #define SET_DMA_PWC(x)    (((x)&0x3F)<<(13-DMA_CR_OFFSET))      /* Peripheral Wait Cycles */
135 #define DMA_PWC_MASK      SET_DMA_PWC(0x3F)
136 #define GET_DMA_PWC(x)    (((x)&DMA_PWC_MASK)>>(13-DMA_CR_OFFSET))
137
138 #define SET_DMA_PHC(x)    (((x)&0x7)<<(10-DMA_CR_OFFSET))       /* Peripheral Hold Cycles */
139 #define DMA_PHC_MASK      SET_DMA_PHC(0x7)
140 #define GET_DMA_PHC(x)    (((x)&DMA_PHC_MASK)>>(10-DMA_CR_OFFSET))
141
142 #define DMA_ETD_OUTPUT     (1<<(9-DMA_CR_OFFSET))       /* EOT pin is a TC output */
143 #define SET_DMA_ETD(x)     (((x)&0x1)<<(9-DMA_CR_OFFSET))
144
145 #define DMA_TCE_ENABLE     (1<<(8-DMA_CR_OFFSET))
146 #define SET_DMA_TCE(x)     (((x)&0x1)<<(8-DMA_CR_OFFSET))
147
148 #define DMA_DEC            (1<<(2)      /* Address Decrement */
149 #define SET_DMA_DEC(x)     (((x)&0x1)<<2)
150 #define GET_DMA_DEC(x)     (((x)&DMA_DEC)>>2)
151
152 /*
153  * Transfer Modes
154  * These modes are defined in a way that makes it possible to
155  * simply "or" in the value in the control register.
156  */
157
158 #define DMA_MODE_MM             (SET_DMA_TM(TM_S_MM))   /* memory to memory */
159
160                                 /* Device-paced memory to memory, */
161                                 /* device is at source address    */
162 #define DMA_MODE_MM_DEVATSRC    (DMA_TD | SET_DMA_TM(TM_D_MM))
163
164                                 /* Device-paced memory to memory,      */
165                                 /* device is at destination address    */
166 #define DMA_MODE_MM_DEVATDST    (SET_DMA_TM(TM_D_MM))
167
168 /* 405gp/440gp */
169 #define SET_DMA_PREFETCH(x)   (((x)&0x3)<<(4-DMA_CR_OFFSET))    /* Memory Read Prefetch */
170 #define DMA_PREFETCH_MASK      SET_DMA_PREFETCH(3)
171 #define   PREFETCH_1           0        /* Prefetch 1 Double Word */
172 #define   PREFETCH_2           1
173 #define   PREFETCH_4           2
174 #define GET_DMA_PREFETCH(x) (((x)&DMA_PREFETCH_MASK)>>(4-DMA_CR_OFFSET))
175
176 #define DMA_PCE            (1<<(3-DMA_CR_OFFSET))       /* Parity Check Enable */
177 #define SET_DMA_PCE(x)     (((x)&0x1)<<(3-DMA_CR_OFFSET))
178 #define GET_DMA_PCE(x)     (((x)&DMA_PCE)>>(3-DMA_CR_OFFSET))
179
180 /* stb3x */
181
182 #define DMA_ECE_ENABLE (1<<5)
183 #define SET_DMA_ECE(x) (((x)&0x1)<<5)
184 #define GET_DMA_ECE(x) (((x)&DMA_ECE_ENABLE)>>5)
185
186 #define DMA_TCD_DISABLE (1<<4)
187 #define SET_DMA_TCD(x) (((x)&0x1)<<4)
188 #define GET_DMA_TCD(x) (((x)&DMA_TCD_DISABLE)>>4)
189
190 typedef uint32_t sgl_handle_t;
191
192 #ifdef CONFIG_PPC4xx_EDMA
193
194 #define SGL_LIST_SIZE 4096
195 #define DMA_PPC4xx_SIZE SGL_LIST_SIZE
196
197 #define SET_DMA_PRIORITY(x)   (((x)&0x3)<<(6-DMA_CR_OFFSET))    /* DMA Channel Priority */
198 #define DMA_PRIORITY_MASK SET_DMA_PRIORITY(3)
199 #define PRIORITY_LOW           0
200 #define PRIORITY_MID_LOW       1
201 #define PRIORITY_MID_HIGH      2
202 #define PRIORITY_HIGH          3
203 #define GET_DMA_PRIORITY(x) (((x)&DMA_PRIORITY_MASK)>>(6-DMA_CR_OFFSET))
204
205 /* 
206  * DMA Polarity Configuration Register
207  */
208
209 #define DMAReq0_ActiveLow (1<<31)
210 #define DMAAck0_ActiveLow (1<<30)
211 #define EOT0_ActiveLow    (1<<29)       /* End of Transfer      */
212
213 #define DMAReq1_ActiveLow (1<<28)
214 #define DMAAck1_ActiveLow (1<<27)
215 #define EOT1_ActiveLow    (1<<26)
216
217 #define DMAReq2_ActiveLow (1<<25)
218 #define DMAAck2_ActiveLow (1<<24)
219 #define EOT2_ActiveLow    (1<<23)
220
221 #define DMAReq3_ActiveLow (1<<22)
222 #define DMAAck3_ActiveLow (1<<21)
223 #define EOT3_ActiveLow    (1<<20)
224
225 /*
226  * DMA Sleep Mode Register
227  */
228 #define SLEEP_MODE_ENABLE (1<<21)
229
230 /*
231  * DMA Status Register
232  */
233 #define DMA_CS0           (1<<31)       /* Terminal Count has been reached */
234 #define DMA_CS1           (1<<30)
235 #define DMA_CS2           (1<<29)
236 #define DMA_CS3           (1<<28)
237
238 #define DMA_TS0           (1<<27)       /* End of Transfer has been requested */
239 #define DMA_TS1           (1<<26)
240 #define DMA_TS2           (1<<25)
241 #define DMA_TS3           (1<<24)
242
243 #define DMA_CH0_ERR       (1<<23)       /* DMA Chanel 0 Error */
244 #define DMA_CH1_ERR       (1<<22)
245 #define DMA_CH2_ERR       (1<<21)
246 #define DMA_CH3_ERR       (1<<20)
247
248 #define DMA_IN_DMA_REQ0   (1<<19)       /* Internal DMA Request is pending */
249 #define DMA_IN_DMA_REQ1   (1<<18)
250 #define DMA_IN_DMA_REQ2   (1<<17)
251 #define DMA_IN_DMA_REQ3   (1<<16)
252
253 #define DMA_EXT_DMA_REQ0  (1<<15)       /* External DMA Request is pending */
254 #define DMA_EXT_DMA_REQ1  (1<<14)
255 #define DMA_EXT_DMA_REQ2  (1<<13)
256 #define DMA_EXT_DMA_REQ3  (1<<12)
257
258 #define DMA_CH0_BUSY      (1<<11)       /* DMA Channel 0 Busy */
259 #define DMA_CH1_BUSY      (1<<10)
260 #define DMA_CH2_BUSY       (1<<9)
261 #define DMA_CH3_BUSY       (1<<8)
262
263 #define DMA_SG0            (1<<7)       /* DMA Channel 0 Scatter/Gather in progress */
264 #define DMA_SG1            (1<<6)
265 #define DMA_SG2            (1<<5)
266 #define DMA_SG3            (1<<4)
267
268 /*
269  * DMA SG Command Register
270  */
271 #define SSG0_ENABLE        (1<<31)      /* Start Scatter Gather */
272 #define SSG1_ENABLE        (1<<30)
273 #define SSG2_ENABLE        (1<<29)
274 #define SSG3_ENABLE        (1<<28)
275 #define SSG0_MASK_ENABLE   (1<<15)      /* Enable writing to SSG0 bit */
276 #define SSG1_MASK_ENABLE   (1<<14)
277 #define SSG2_MASK_ENABLE   (1<<13)
278 #define SSG3_MASK_ENABLE   (1<<12)
279
280 /*
281  * DMA Scatter/Gather Descriptor Bit fields 
282  */
283 #define SG_LINK            (1<<31)      /* Link */
284 #define SG_TCI_ENABLE      (1<<29)      /* Enable Terminal Count Interrupt */
285 #define SG_ETI_ENABLE      (1<<28)      /* Enable End of Transfer Interrupt */
286 #define SG_ERI_ENABLE      (1<<27)      /* Enable Error Interrupt */
287 #define SG_COUNT_MASK       0xFFFF      /* Count Field */
288
289 #define SET_DMA_CONTROL \
290                 (SET_DMA_CIE_ENABLE(p_init->int_enable) | /* interrupt enable         */ \
291                 SET_DMA_BEN(p_init->buffer_enable)     | /* buffer enable            */\
292                 SET_DMA_ETD(p_init->etd_output)        | /* end of transfer pin      */ \
293                 SET_DMA_TCE(p_init->tce_enable)        | /* terminal count enable    */ \
294                 SET_DMA_PL(p_init->pl)                 | /* peripheral location      */ \
295                 SET_DMA_DAI(p_init->dai)               | /* dest addr increment      */ \
296                 SET_DMA_SAI(p_init->sai)               | /* src addr increment       */ \
297                 SET_DMA_PRIORITY(p_init->cp)           |  /* channel priority        */ \
298                 SET_DMA_PW(p_init->pwidth)             |  /* peripheral/bus width    */ \
299                 SET_DMA_PSC(p_init->psc)               |  /* peripheral setup cycles */ \
300                 SET_DMA_PWC(p_init->pwc)               |  /* peripheral wait cycles  */ \
301                 SET_DMA_PHC(p_init->phc)               |  /* peripheral hold cycles  */ \
302                 SET_DMA_PREFETCH(p_init->pf)              /* read prefetch           */)
303
304 #define GET_DMA_POLARITY(chan) (DMAReq##chan##_ActiveLow | DMAAck##chan##_ActiveLow | EOT##chan##_ActiveLow)
305
306 #elif defined(CONFIG_STBXXX_DMA)                /* stb03xxx */
307
308 #define DMA_PPC4xx_SIZE 4096
309
310 /*
311  * DMA Status Register
312  */
313
314 #define SET_DMA_PRIORITY(x)   (((x)&0x00800001))        /* DMA Channel Priority */
315 #define DMA_PRIORITY_MASK       0x00800001
316 #define   PRIORITY_LOW          0x00000000
317 #define   PRIORITY_MID_LOW      0x00000001
318 #define   PRIORITY_MID_HIGH     0x00800000
319 #define   PRIORITY_HIGH         0x00800001
320 #define GET_DMA_PRIORITY(x) (((((x)&DMA_PRIORITY_MASK) &0x00800000) >> 22 ) | (((x)&DMA_PRIORITY_MASK) &0x00000001))
321
322 #define DMA_CS0           (1<<31)       /* Terminal Count has been reached */
323 #define DMA_CS1           (1<<30)
324 #define DMA_CS2           (1<<29)
325 #define DMA_CS3           (1<<28)
326
327 #define DMA_TS0           (1<<27)       /* End of Transfer has been requested */
328 #define DMA_TS1           (1<<26)
329 #define DMA_TS2           (1<<25)
330 #define DMA_TS3           (1<<24)
331
332 #define DMA_CH0_ERR       (1<<23)       /* DMA Chanel 0 Error */
333 #define DMA_CH1_ERR       (1<<22)
334 #define DMA_CH2_ERR       (1<<21)
335 #define DMA_CH3_ERR       (1<<20)
336
337 #define DMA_CT0           (1<<19)       /* Chained transfere */
338
339 #define DMA_IN_DMA_REQ0   (1<<18)       /* Internal DMA Request is pending */
340 #define DMA_IN_DMA_REQ1   (1<<17)
341 #define DMA_IN_DMA_REQ2   (1<<16)
342 #define DMA_IN_DMA_REQ3   (1<<15)
343
344 #define DMA_EXT_DMA_REQ0  (1<<14)       /* External DMA Request is pending */
345 #define DMA_EXT_DMA_REQ1  (1<<13)
346 #define DMA_EXT_DMA_REQ2  (1<<12)
347 #define DMA_EXT_DMA_REQ3  (1<<11)
348
349 #define DMA_CH0_BUSY      (1<<10)       /* DMA Channel 0 Busy */
350 #define DMA_CH1_BUSY      (1<<9)
351 #define DMA_CH2_BUSY       (1<<8)
352 #define DMA_CH3_BUSY       (1<<7)
353
354 #define DMA_CT1            (1<<6)       /* Chained transfere */
355 #define DMA_CT2            (1<<5)
356 #define DMA_CT3            (1<<4)
357
358 #define DMA_CH_ENABLE (1<<7)
359 #define SET_DMA_CH(x) (((x)&0x1)<<7)
360 #define GET_DMA_CH(x) (((x)&DMA_CH_ENABLE)>>7)
361
362 /* STBx25xxx dma unique */
363 /* enable device port on a dma channel 
364  * example ext 0 on dma 1
365  */
366
367 #define SSP0_RECV       15
368 #define SSP0_XMIT       14
369 #define EXT_DMA_0       12
370 #define SC1_XMIT        11
371 #define SC1_RECV        10
372 #define EXT_DMA_2       9 
373 #define EXT_DMA_3       8 
374 #define SERIAL2_XMIT    7
375 #define SERIAL2_RECV    6
376 #define SC0_XMIT        5
377 #define SC0_RECV        4
378 #define SERIAL1_XMIT    3 
379 #define SERIAL1_RECV    2
380 #define SERIAL0_XMIT    1
381 #define SERIAL0_RECV    0
382
383 #define DMA_CHAN_0      1
384 #define DMA_CHAN_1      2
385 #define DMA_CHAN_2      3
386 #define DMA_CHAN_3      4
387
388 /* end STBx25xx */
389
390 /*
391  * Bit 30 must be one for Redwoods, otherwise transfers may receive errors.
392  */
393
394 #define DMA_CR_MBO 0x2
395
396 #define SET_DMA_CONTROL \
397                 (SET_DMA_CIE_ENABLE(p_init->int_enable) |  /* interrupt enable         */ \
398                 SET_DMA_ETD(p_init->etd_output)        |  /* end of transfer pin      */ \
399                 SET_DMA_TCE(p_init->tce_enable)        |  /* terminal count enable    */ \
400                 SET_DMA_PL(p_init->pl)                 |  /* peripheral location      */ \
401                 SET_DMA_DAI(p_init->dai)               |  /* dest addr increment      */ \
402                 SET_DMA_SAI(p_init->sai)               |  /* src addr increment       */ \
403                 SET_DMA_PRIORITY(p_init->cp)           |  /* channel priority        */  \
404                 SET_DMA_PW(p_init->pwidth)             |  /* peripheral/bus width    */ \
405                 SET_DMA_PSC(p_init->psc)               |  /* peripheral setup cycles */ \
406                 SET_DMA_PWC(p_init->pwc)               |  /* peripheral wait cycles  */ \
407                 SET_DMA_PHC(p_init->phc)               |  /* peripheral hold cycles  */ \
408                 SET_DMA_TCD(p_init->tcd_disable)          |  /* TC chain mode disable   */ \
409                 SET_DMA_ECE(p_init->ece_enable)   |  /* ECE chanin mode enable  */ \
410                 SET_DMA_CH(p_init->ch_enable)   |    /* Chain enable            */ \
411                 DMA_CR_MBO                /* must be one */)
412
413 #define GET_DMA_POLARITY(chan) chan
414
415 #endif
416
417 typedef struct {
418         unsigned short in_use;  /* set when channel is being used, clr when 
419                                  * avaliable.
420                                  */
421         /* 
422          * Valid polarity settings:
423          *   DMAReq0_ActiveLow
424          *   DMAAck0_ActiveLow
425          *   EOT0_ActiveLow
426          *
427          *   DMAReq1_ActiveLow
428          *   DMAAck1_ActiveLow
429          *   EOT1_ActiveLow
430          * 
431          *   DMAReq2_ActiveLow
432          *   DMAAck2_ActiveLow
433          *   EOT2_ActiveLow
434          *
435          *   DMAReq3_ActiveLow 
436          *   DMAAck3_ActiveLow
437          *   EOT3_ActiveLow
438          */
439         unsigned int polarity;
440
441         char buffer_enable;     /* Boolean: buffer enable            */
442         char tce_enable;        /* Boolean: terminal count enable    */
443         char etd_output;        /* Boolean: eot pin is a tc output   */
444         char pce;               /* Boolean: parity check enable      */
445
446         /*
447          * Peripheral location:
448          * INTERNAL_PERIPHERAL (UART0 on the 405GP)
449          * EXTERNAL_PERIPHERAL
450          */
451         char pl;                /* internal/external peripheral      */
452
453         /*
454          * Valid pwidth settings:
455          *   PW_8
456          *   PW_16
457          *   PW_32
458          *   PW_64
459          */
460         unsigned int pwidth;
461
462         char dai;               /* Boolean: dst address increment   */
463         char sai;               /* Boolean: src address increment   */
464
465         /*
466          * Valid psc settings: 0-3
467          */
468         unsigned int psc;       /* Peripheral Setup Cycles         */
469
470         /*
471          * Valid pwc settings:
472          * 0-63
473          */
474         unsigned int pwc;       /* Peripheral Wait Cycles          */
475
476         /*
477          * Valid phc settings:
478          * 0-7
479          */
480         unsigned int phc;       /* Peripheral Hold Cycles          */
481
482         /*
483          * Valid cp (channel priority) settings:
484          *   PRIORITY_LOW
485          *   PRIORITY_MID_LOW
486          *   PRIORITY_MID_HIGH
487          *   PRIORITY_HIGH
488          */
489         unsigned int cp;        /* channel priority                */
490
491         /*
492          * Valid pf (memory read prefetch) settings:
493          *
494          *   PREFETCH_1
495          *   PREFETCH_2
496          *   PREFETCH_4
497          */
498         unsigned int pf;        /* memory read prefetch            */
499
500         /*
501          * Boolean: channel interrupt enable
502          * NOTE: for sgl transfers, only the last descriptor will be setup to
503          * interrupt.
504          */
505         char int_enable;
506
507         char shift;             /* easy access to byte_count shift, based on */
508         /* the width of the channel                  */
509
510         uint32_t control;       /* channel control word                      */
511
512         /* These variabled are used ONLY in single dma transfers              */
513         unsigned int mode;      /* transfer mode                     */
514         phys_addr_t addr;
515         char ce;                /* channel enable */
516 #ifdef CONFIG_STB03xxx
517         char ch_enable;
518         char tcd_disable;
519         char ece_enable;
520         char td;                /* transfer direction */
521 #endif
522
523 } ppc_dma_ch_t;
524
525 typedef struct {
526         uint32_t control;
527         phys_addr_t src_addr;
528         phys_addr_t dst_addr;
529         uint32_t control_count;
530         uint32_t next;
531 } ppc_sgl_t;
532
533 typedef struct {
534         unsigned int dmanr;
535         uint32_t control;       /* channel ctrl word; loaded from each descrptr */
536         uint32_t sgl_control;   /* LK, TCI, ETI, and ERI bits in sgl descriptor */
537         dma_addr_t dma_addr;    /* dma (physical) address of this list          */
538         ppc_sgl_t *phead;
539         ppc_sgl_t *ptail;
540
541 } sgl_list_info_t;
542
543 typedef struct {
544         phys_addr_t *src_addr;
545         phys_addr_t *dst_addr;
546         phys_addr_t dma_src_addr;
547         phys_addr_t dma_dst_addr;
548 } pci_alloc_desc_t;
549
550 extern ppc_dma_ch_t dma_channels[];
551
552 /*
553  * The DMA API are in ppc4xx_dma.c and ppc4xx_sgdma.c
554  */
555 extern int hw_init_dma_channel(unsigned int, ppc_dma_ch_t *);
556 extern int get_channel_config(unsigned int, ppc_dma_ch_t *);
557 extern int set_channel_priority(unsigned int, unsigned int);
558 extern unsigned int get_peripheral_width(unsigned int);
559 extern int alloc_dma_handle(sgl_handle_t *, unsigned int, unsigned int);
560 extern void free_dma_handle(sgl_handle_t);
561 extern int get_dma_status(void);
562 extern void set_src_addr(int dmanr, phys_addr_t src_addr);
563 extern void set_dst_addr(int dmanr, phys_addr_t dst_addr);
564 extern int enable_dma(unsigned int dmanr);
565 extern void disable_dma(unsigned int dmanr);
566 extern int set_dma_mode(unsigned int dmanr, unsigned int mode);
567 extern void set_dma_count(unsigned int dmanr, unsigned int count);
568 extern int get_dma_residue(unsigned int dmanr);
569 extern void set_dma_addr(unsigned int dmanr, phys_addr_t addr);
570 extern void set_dma_addr2(unsigned int dmanr, phys_addr_t src_dma_addr,
571                         phys_addr_t dst_dma_addr);
572 extern int enable_dma_interrupt(unsigned int dmanr);
573 extern int disable_dma_interrupt(unsigned int dmanr);
574 extern int clr_dma_status(unsigned int dmanr);
575 extern int map_dma_port(unsigned int dmanr, unsigned int ocp_dma,short dma_chan);
576 extern int disable_dma_port(unsigned int dmanr, unsigned int ocp_dma,short dma_chan);
577
578 #endif
579 #endif                          /* __KERNEL__ */