10 #include <linux/kernel.h>
12 #include <linux/module.h>
13 #include <linux/errno.h>
21 #include <asm/uaccess.h>
24 #include <asm/pgtable.h>
29 #define CONF_DEBUG_VDMA 0
38 #define vdma_debug ((CONF_DEBUG_VDMA) ? debuglvl : 0)
40 static int debuglvl = 3;
48 static inline void vdma_pgtbl_init(
void)
50 unsigned long paddr = 0;
63 static int __init vdma_init(
void)
99 if (paddr > 0x1fffffff) {
101 printk(
"vdma_alloc: Invalid physical address: %08lx\n",
105 if (size > 0x400000 || size == 0) {
107 printk(
"vdma_alloc: Invalid size: %08lx\n", size);
121 spin_unlock_irqrestore(&vdma_lock, flags);
127 && last - first < pages)
130 if (last - first == pages)
141 for (i = first; i < last; i++) {
153 printk(
"vdma_alloc: Allocated %d pages starting from %08lx\n",
158 for (i = first; i < last; i++)
161 for (i = first; i < last; i++)
162 printk(
"%08x ", pgtbl[i].frame);
164 for (i = first; i < last; i++)
169 spin_unlock_irqrestore(&vdma_lock, flags);
187 if (pgtbl[i].
owner != laddr) {
189 (
"vdma_free: trying to free other's dma pages, laddr=%8lx\n",
200 printk(
"vdma_free: freed %ld pages starting from %08lx\n",
201 i - (laddr >> 12), laddr);
216 if (laddr > 0xffffff) {
219 (
"vdma_map: Invalid logical address: %08lx\n",
223 if (paddr > 0x1fffffff) {
226 (
"vdma_map: Invalid physical address: %08lx\n",
234 printk(
"vdma_remap: first=%x, pages=%x\n", first, pages);
237 printk(
"vdma_alloc: Invalid size: %08lx\n", size);
243 if (pgtbl[first].
owner != laddr) {
245 printk(
"Trying to remap other's pages.\n");
264 for (i = first; i < first +
pages; i++)
267 for (i = first; i < first +
pages; i++)
270 for (i = first; i < first +
pages; i++)
291 if (pgtbl[i].frame == frame)
295 if (i == VDMA_PGTBL_ENTRIES)
320 printk(
"vdma_stats: CONFIG: %08x\n",
322 printk(
"R4030 translation table base: %08x\n",
324 printk(
"R4030 translation table limit: %08x\n",
326 printk(
"vdma_stats: INV_ADDR: %08x\n",
328 printk(
"vdma_stats: R_FAIL_ADDR: %08x\n",
330 printk(
"vdma_stats: M_FAIL_ADDR: %08x\n",
332 printk(
"vdma_stats: IRQ_SOURCE: %08x\n",
334 printk(
"vdma_stats: I386_ERROR: %08x\n",
336 printk(
"vdma_chnl_modes: ");
337 for (i = 0; i < 8; i++)
342 printk(
"vdma_chnl_enables: ");
343 for (i = 0; i < 8; i++)
362 printk(
"vdma_enable: channel %d\n", channel);
369 printk(
"VDMA: Channel %d: Address error!\n", channel);
371 printk(
"VDMA: Channel %d: Memory error!\n", channel);
402 printk(
"vdma_disable: channel %d\n", channel);
403 printk(
"VDMA: channel %d status: %04x (%s) mode: "
404 "%02x addr: %06x count: %06x\n",
406 ((status & 0x600) ?
"ERROR" :
"OK"),
441 printk(
"vdma_set_mode: channel %d, mode 0x%x\n", channel,
465 printk(
"VDMA: Audio DMA not supported yet.\n");
470 (
"VDMA: vdma_set_mode() called with unsupported channel %d!\n",
491 (
"VDMA: vdma_set_mode() called with unknown dma mode 0x%x\n",
504 printk(
"vdma_set_addr: channel %d, addr %lx\n", channel,
518 printk(
"vdma_set_count: channel %d, count %08x\n", channel,
536 printk(
"vdma_get_residual: channel %d: residual=%d\n",
552 printk(
"vdma_get_enable: channel %d: enable=%d\n", channel,