import of upstream 2.4.34.4 from kernel.org
[linux-2.4.git] / arch / arm / kernel / dma-riscstation.c
1 /*
2  *  linux/arch/arm/kernel/dma-riscstation.c
3  *
4  *  Copyright (C) 1998 Russell King
5  *  Copyright (C) 2002 Ben Dooks / Simtec Electronics
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.
10  *
11  *  DMA functions specific to RiscStatiun architecture
12  *
13  * sliced down version of the RiscPC DMA code by RMK
14  */
15 #include <linux/sched.h>
16 #include <linux/slab.h>
17 #include <linux/mman.h>
18 #include <linux/init.h>
19 #include <linux/pci.h>
20
21 #include <asm/page.h>
22 #include <asm/dma.h>
23 #include <asm/fiq.h>
24 #include <asm/io.h>
25 #include <asm/irq.h>
26 #include <asm/hardware.h>
27 #include <asm/uaccess.h>
28
29 #include <asm/mach/dma.h>
30 #include <asm/hardware/iomd.h>
31
32 static struct fiq_handler fh = {
33         name: "floppydma"
34 };
35
36 static void floppy_enable_dma(dmach_t channel, dma_t *dma)
37 {
38         void *fiqhandler_start;
39         unsigned int fiqhandler_length;
40         struct pt_regs regs;
41
42         if (dma->dma_mode == DMA_MODE_READ) {
43                 extern unsigned char floppy_fiqin_start, floppy_fiqin_end;
44                 fiqhandler_start = &floppy_fiqin_start;
45                 fiqhandler_length = &floppy_fiqin_end - &floppy_fiqin_start;
46         } else {
47                 extern unsigned char floppy_fiqout_start, floppy_fiqout_end;
48                 fiqhandler_start = &floppy_fiqout_start;
49                 fiqhandler_length = &floppy_fiqout_end - &floppy_fiqout_start;
50         }
51
52         regs.ARM_r9  = dma->buf.length;
53         regs.ARM_r10 = (unsigned long)dma->buf.address;
54         regs.ARM_fp  = FLOPPYDMA_BASE;
55
56         if (claim_fiq(&fh)) {
57                 printk("floppydma: couldn't claim FIQ.\n");
58                 return;
59         }
60
61         set_fiq_handler(fiqhandler_start, fiqhandler_length);
62         set_fiq_regs(&regs);
63         enable_fiq(dma->dma_irq);
64 }
65
66 static void floppy_disable_dma(dmach_t channel, dma_t *dma)
67 {
68         disable_fiq(dma->dma_irq);
69         release_fiq(&fh);
70 }
71
72 static int floppy_get_residue(dmach_t channel, dma_t *dma)
73 {
74         struct pt_regs regs;
75         get_fiq_regs(&regs);
76         return regs.ARM_r9;
77 }
78
79 static struct dma_ops floppy_dma_ops = {
80         type:           "FIQDMA",
81         enable:         floppy_enable_dma,
82         disable:        floppy_disable_dma,
83         residue:        floppy_get_residue,
84 };
85
86 /*
87  * This is virtual DMA - we don't need anything here.
88  */
89 static void sound_enable_disable_dma(dmach_t channel, dma_t *dma)
90 {
91 }
92
93 static struct dma_ops sound_dma_ops = {
94         type:           "VIRTUAL",
95         enable:         sound_enable_disable_dma,
96         disable:        sound_enable_disable_dma,
97 };
98
99 void __init arch_dma_init(dma_t *dma)
100 {
101 #if 0
102         iomd_writeb(0, IOMD_IO0CR);
103         iomd_writeb(0, IOMD_IO1CR);
104         iomd_writeb(0, IOMD_IO2CR);
105         iomd_writeb(0, IOMD_IO3CR);
106
107         iomd_writeb(0xa0, IOMD_DMATCR);
108 #endif
109
110         dma[DMA_VIRTUAL_FLOPPY].dma_irq = FIQ_FLOPPYDATA;
111         dma[DMA_VIRTUAL_FLOPPY].d_ops   = &floppy_dma_ops;
112         dma[DMA_VIRTUAL_SOUND].d_ops    = &sound_dma_ops;
113 }