1 /* 2 * Definitions shared between dma-sa1100.c and dma-sa1111.c 3 * (C) 2000 Nicolas Pitre <nico@cam.org> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License version 2 as 7 * published by the Free Software Foundation. 8 */ 9 10 #include <linux/config.h> 11 12 /* 13 * DMA buffer structure 14 */ 15 16 typedef struct dma_buf_s { 17 int size; /* buffer size */ 18 dma_addr_t dma_start; /* starting DMA address */ 19 dma_addr_t dma_ptr; /* next DMA pointer to use */ 20 int ref; /* number of DMA references */ 21 void *id; /* to identify buffer from outside */ 22 struct dma_buf_s *next; /* next buffer to process */ 23 } dma_buf_t; 24 25 26 /* 27 * DMA channel structure. 28 */ 29 30 typedef struct { 31 unsigned int in_use; /* Device is allocated */ 32 const char *device_id; /* Device name */ 33 dma_device_t device; /* ... to which this channel is attached */ 34 dma_buf_t *head; /* where to insert buffers */ 35 dma_buf_t *tail; /* where to remove buffers */ 36 dma_buf_t *curr; /* buffer currently DMA'ed */ 37 int stopped; /* 1 if DMA is stalled */ 38 dma_regs_t *regs; /* points to appropriate DMA registers */ 39 int irq; /* IRQ used by the channel */ 40 dma_callback_t callback; /* ... to call when buffers are done */ 41 int spin_size; /* > 0 when DMA should spin when no more buffer */ 42 dma_addr_t spin_addr; /* DMA address to spin onto */ 43 int spin_ref; /* number of spinning references */ 44 #ifdef CONFIG_SA1111 45 int dma_a, dma_b, last_dma; /* SA-1111 specific */ 46 #endif 47 } sa1100_dma_t; 48 49 extern sa1100_dma_t dma_chan[MAX_SA1100_DMA_CHANNELS]; 50 51 52 int start_sa1111_sac_dma(sa1100_dma_t *dma, dma_addr_t dma_ptr, size_t size); 53 int sa1111_dma_get_current(dmach_t channel, void **buf_id, dma_addr_t *addr); 54 int sa1111_dma_stop(dmach_t channel); 55 int sa1111_dma_resume(dmach_t channel); 56 void sa1111_reset_sac_dma(dmach_t channel); 57 void sa1111_cleanup_sac_dma(dmach_t channel); 58 59 void sa1100_dma_done (sa1100_dma_t *dma); 60 61 62 #ifdef CONFIG_SA1111 63 #define channel_is_sa1111_sac(ch) \ 64 ((ch) >= SA1111_SAC_DMA_BASE && \ 65 (ch) < SA1111_SAC_DMA_BASE + SA1111_SAC_DMA_CHANNELS) 66 #else 67 #define channel_is_sa1111_sac(ch) (0) 68 #endif 69 70