[TG3]: Set minimal hw interrupt mitigation.
[linux-2.6/verdex.git] / arch / arm26 / machine / dma.c
blobcbc7c61d5b3208b152920b9d96d13b2de30d17c0
1 /*
2 * linux/arch/arm26/kernel/dma.c
4 * Copyright (C) 1998-1999 Dave Gilbert / Russell King
5 * Copyright (C) 2003 Ian Molton
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.
11 * DMA functions specific to Archimedes and A5000 architecture
13 #include <linux/config.h>
14 #include <linux/sched.h>
15 #include <linux/init.h>
17 #include <asm/dma.h>
18 #include <asm/fiq.h>
19 #include <asm/irq.h>
20 #include <asm/io.h>
21 #include <asm/hardware.h>
22 #include <asm/mach-types.h>
24 #define DPRINTK(x...) printk(KERN_DEBUG x)
26 #if defined(CONFIG_BLK_DEV_FD1772) || defined(CONFIG_BLK_DEV_FD1772_MODULE)
28 extern unsigned char fdc1772_dma_read, fdc1772_dma_read_end;
29 extern unsigned char fdc1772_dma_write, fdc1772_dma_write_end;
30 extern void fdc1772_setupdma(unsigned int count,unsigned int addr);
32 static void arc_floppy_data_enable_dma(dmach_t channel, dma_t *dma)
34 DPRINTK("arc_floppy_data_enable_dma\n");
36 if (dma->using_sg)
37 BUG();
39 switch (dma->dma_mode) {
40 case DMA_MODE_READ: { /* read */
41 unsigned long flags;
42 DPRINTK("enable_dma fdc1772 data read\n");
43 local_save_flags_cli(flags);
44 clf();
46 memcpy ((void *)0x1c, (void *)&fdc1772_dma_read,
47 &fdc1772_dma_read_end - &fdc1772_dma_read);
48 fdc1772_setupdma(dma->buf.length, dma->buf.__address); /* Sets data pointer up */
49 enable_fiq(FIQ_FLOPPYDATA);
50 local_irq_restore(flags);
52 break;
54 case DMA_MODE_WRITE: { /* write */
55 unsigned long flags;
56 DPRINTK("enable_dma fdc1772 data write\n");
57 local_save_flags_cli(flags);
58 clf();
59 memcpy ((void *)0x1c, (void *)&fdc1772_dma_write,
60 &fdc1772_dma_write_end - &fdc1772_dma_write);
61 fdc1772_setupdma(dma->buf.length, dma->buf.__address); /* Sets data pointer up */
62 enable_fiq(FIQ_FLOPPYDATA);
64 local_irq_restore(flags);
66 break;
67 default:
68 printk ("enable_dma: dma%d not initialised\n", channel);
72 static int arc_floppy_data_get_dma_residue(dmach_t channel, dma_t *dma)
74 extern unsigned int fdc1772_bytestogo;
76 /* 10/1/1999 DAG - I presume its the number of bytes left? */
77 return fdc1772_bytestogo;
80 static void arc_floppy_cmdend_enable_dma(dmach_t channel, dma_t *dma)
82 /* Need to build a branch at the FIQ address */
83 extern void fdc1772_comendhandler(void);
84 unsigned long flags;
86 DPRINTK("arc_floppy_cmdend_enable_dma\n");
87 /*printk("enable_dma fdc1772 command end FIQ\n");*/
88 save_flags(flags);
89 clf();
91 /* B fdc1772_comendhandler */
92 *((unsigned int *)0x1c)=0xea000000 |
93 (((unsigned int)fdc1772_comendhandler-(0x1c+8))/4);
95 local_irq_restore(flags);
98 static int arc_floppy_cmdend_get_dma_residue(dmach_t channel, dma_t *dma)
100 /* 10/1/1999 DAG - Presume whether there is an outstanding command? */
101 extern unsigned int fdc1772_fdc_int_done;
103 /* Explicit! If the int done is 0 then 1 int to go */
104 return (fdc1772_fdc_int_done==0)?1:0;
107 static void arc_disable_dma(dmach_t channel, dma_t *dma)
109 disable_fiq(dma->dma_irq);
112 static struct dma_ops arc_floppy_data_dma_ops = {
113 .type = "FIQDMA",
114 .enable = arc_floppy_data_enable_dma,
115 .disable = arc_disable_dma,
116 .residue = arc_floppy_data_get_dma_residue,
119 static struct dma_ops arc_floppy_cmdend_dma_ops = {
120 .type = "FIQCMD",
121 .enable = arc_floppy_cmdend_enable_dma,
122 .disable = arc_disable_dma,
123 .residue = arc_floppy_cmdend_get_dma_residue,
125 #endif
127 #ifdef CONFIG_ARCH_A5K
128 static struct fiq_handler fh = {
129 .name = "floppydata"
132 static int a5k_floppy_get_dma_residue(dmach_t channel, dma_t *dma)
134 struct pt_regs regs;
135 get_fiq_regs(&regs);
136 return regs.ARM_r9;
139 static void a5k_floppy_enable_dma(dmach_t channel, dma_t *dma)
141 struct pt_regs regs;
142 void *fiqhandler_start;
143 unsigned int fiqhandler_length;
144 extern void floppy_fiqsetup(unsigned long len, unsigned long addr,
145 unsigned long port);
147 if (dma->using_sg)
148 BUG();
150 if (dma->dma_mode == DMA_MODE_READ) {
151 extern unsigned char floppy_fiqin_start, floppy_fiqin_end;
152 fiqhandler_start = &floppy_fiqin_start;
153 fiqhandler_length = &floppy_fiqin_end - &floppy_fiqin_start;
154 } else {
155 extern unsigned char floppy_fiqout_start, floppy_fiqout_end;
156 fiqhandler_start = &floppy_fiqout_start;
157 fiqhandler_length = &floppy_fiqout_end - &floppy_fiqout_start;
159 if (claim_fiq(&fh)) {
160 printk("floppydma: couldn't claim FIQ.\n");
161 return;
163 memcpy((void *)0x1c, fiqhandler_start, fiqhandler_length);
164 regs.ARM_r9 = dma->buf.length;
165 regs.ARM_r10 = (unsigned long)dma->buf.__address;
166 regs.ARM_fp = FLOPPYDMA_BASE;
167 set_fiq_regs(&regs);
168 enable_fiq(dma->dma_irq);
171 static void a5k_floppy_disable_dma(dmach_t channel, dma_t *dma)
173 disable_fiq(dma->dma_irq);
174 release_fiq(&fh);
177 static struct dma_ops a5k_floppy_dma_ops = {
178 .type = "FIQDMA",
179 .enable = a5k_floppy_enable_dma,
180 .disable = a5k_floppy_disable_dma,
181 .residue = a5k_floppy_get_dma_residue,
183 #endif
186 * This is virtual DMA - we don't need anything here
188 static void sound_enable_disable_dma(dmach_t channel, dma_t *dma)
192 static struct dma_ops sound_dma_ops = {
193 .type = "VIRTUAL",
194 .enable = sound_enable_disable_dma,
195 .disable = sound_enable_disable_dma,
198 void __init arch_dma_init(dma_t *dma)
200 #if defined(CONFIG_BLK_DEV_FD1772) || defined(CONFIG_BLK_DEV_FD1772_MODULE)
201 if (machine_is_archimedes()) {
202 dma[DMA_VIRTUAL_FLOPPY0].dma_irq = FIQ_FLOPPYDATA;
203 dma[DMA_VIRTUAL_FLOPPY0].d_ops = &arc_floppy_data_dma_ops;
204 dma[DMA_VIRTUAL_FLOPPY1].dma_irq = 1;
205 dma[DMA_VIRTUAL_FLOPPY1].d_ops = &arc_floppy_cmdend_dma_ops;
207 #endif
208 #ifdef CONFIG_ARCH_A5K
209 if (machine_is_a5k()) {
210 dma[DMA_VIRTUAL_FLOPPY0].dma_irq = FIQ_FLOPPYDATA;
211 dma[DMA_VIRTUAL_FLOPPY0].d_ops = &a5k_floppy_dma_ops;
213 #endif
214 dma[DMA_VIRTUAL_SOUND].d_ops = &sound_dma_ops;