* added 0.99 linux version
[mascara-docs.git] / i386 / linux / linux-2.3.21 / arch / arm / kernel / dma-arc.c
blob53ef12b1c5866a551adad93f9a3438ddac7e65c4
1 /*
2 * arch/arm/kernel/dma-arc.c
4 * Copyright (C) 1998-1999 Dave Gilbert / Russell King
6 * DMA functions specific to Archimedes architecture
7 */
8 #include <linux/config.h>
9 #include <linux/sched.h>
10 #include <linux/init.h>
12 #include <asm/dma.h>
13 #include <asm/io.h>
14 #include <asm/hardware.h>
16 #include "dma.h"
18 #define DEBUG
20 int arch_request_dma(dmach_t channel, dma_t *dma, const char * dev_id)
22 printk("arch_request_dma channel=%d F0=%d F1=%d\n",channel,DMA_VIRTUAL_FLOPPY0,DMA_VIRTUAL_FLOPPY1);
23 if (channel == DMA_VIRTUAL_FLOPPY0 ||
24 channel == DMA_VIRTUAL_FLOPPY1)
25 return 0;
26 else
27 return -EINVAL;
30 void arch_free_dma(dmach_t channel, dma_t *dma)
34 void arch_enable_dma(dmach_t channel, dma_t *dma)
36 printk("arch_enable_dma channel=%d F0=%d F1=%d\n",channel,DMA_VIRTUAL_FLOPPY0,DMA_VIRTUAL_FLOPPY1);
37 switch (channel) {
38 #ifdef CONFIG_BLK_DEV_FD1772
39 case DMA_VIRTUAL_FLOPPY0: { /* Data DMA */
40 switch (dma->dma_mode) {
41 case DMA_MODE_READ: /* read */
43 extern unsigned char fdc1772_dma_read, fdc1772_dma_read_end;
44 extern void fdc1772_setupdma(unsigned int count,unsigned int addr);
45 unsigned long flags;
46 #ifdef DEBUG
47 printk("enable_dma fdc1772 data read\n");
48 #endif
49 save_flags(flags);
50 cliIF();
52 memcpy ((void *)0x1c, (void *)&fdc1772_dma_read,
53 &fdc1772_dma_read_end - &fdc1772_dma_read);
54 fdc1772_setupdma(dma->buf.length, __bus_to_virt(dma->buf.address)); /* Sets data pointer up */
55 enable_irq (64);
56 restore_flags(flags);
58 break;
60 case DMA_MODE_WRITE: /* write */
62 extern unsigned char fdc1772_dma_write, fdc1772_dma_write_end;
63 extern void fdc1772_setupdma(unsigned int count,unsigned int addr);
64 unsigned long flags;
66 #ifdef DEBUG
67 printk("enable_dma fdc1772 data write\n");
68 #endif
69 save_flags(flags);
70 cliIF();
71 memcpy ((void *)0x1c, (void *)&fdc1772_dma_write,
72 &fdc1772_dma_write_end - &fdc1772_dma_write);
73 fdc1772_setupdma(dma->buf.length, __bus_to_virt(dma->buf.address)); /* Sets data pointer up */
74 enable_irq (64);
76 restore_flags(flags);
78 break;
79 default:
80 printk ("enable_dma: dma%d not initialised\n", channel);
81 return;
84 break;
86 case DMA_VIRTUAL_FLOPPY1: { /* Command end FIQ - actually just sets a flag */
87 /* Need to build a branch at the FIQ address */
88 extern void fdc1772_comendhandler(void);
89 unsigned long flags;
91 /*printk("enable_dma fdc1772 command end FIQ\n");*/
92 save_flags(flags);
93 cliIF();
95 *((unsigned int *)0x1c)=0xea000000 | (((unsigned int)fdc1772_comendhandler-(0x1c+8))/4); /* B fdc1772_comendhandler */
97 restore_flags(flags);
99 break;
100 #endif
104 int arch_get_dma_residue(dmach_t channel, dma_t *dma)
106 switch (channel) {
107 #ifdef CONFIG_BLK_DEV_FD1772
108 case DMA_VIRTUAL_FLOPPY0: { /* Data DMA */
109 extern unsigned int fdc1772_bytestogo;
111 /* 10/1/1999 DAG - I presume its the number of bytes left? */
112 return fdc1772_bytestogo;
114 break;
116 case DMA_VIRTUAL_FLOPPY1: { /* Command completed */
117 /* 10/1/1999 DAG - Presume whether there is an outstanding command? */
118 extern unsigned int fdc1772_fdc_int_done;
120 return (fdc1772_fdc_int_done==0)?1:0; /* Explicit! If the int done is 0 then 1 int to go */
122 break;
124 #endif
126 default:
127 printk("dma-arc.c:arch_get_dma_residue called with unknown/unconfigured DMA channel\n");
128 return 0;
132 void arch_disable_dma(dmach_t channel, dma_t *dma)
134 if (channel != DMA_VIRTUAL_FLOPPY0 &&
135 channel != DMA_VIRTUAL_FLOPPY1)
136 printk("arch_disable_dma: invalid channel %d\n", channel);
137 else
138 disable_irq(dma->dma_irq);
141 int arch_set_dma_speed(dmach_t channel, dma_t *dma, int cycle_ns)
143 return 0;
146 void __init arch_dma_init(dma_t *dma)
148 dma[DMA_VIRTUAL_FLOPPY0].dma_irq = 64;
149 dma[DMA_VIRTUAL_FLOPPY1].dma_irq = 65;