Revert last change. Bug noticed by Linus.
[linux-2.6/linux-mips.git] / include / asm-m68k / floppy.h
blobeace8b552dd687bebe6eec28f0ac41c9fafa7857
1 /*
2 * Q40 Architecture specific parts of the Floppy driver
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
8 * Copyright (C) 1999
9 */
11 #include <asm/io.h>
13 #include <linux/vmalloc.h>
16 asmlinkage void floppy_hardint(int irq, void *dev_id, struct pt_regs * regs);
18 #define MAX_DMA_ADDRESS 0x00 /* nothing like that */
20 extern spinlock_t dma_spin_lock;
22 static __inline__ unsigned long claim_dma_lock(void)
24 unsigned long flags;
25 spin_lock_irqsave(&dma_spin_lock, flags);
26 return flags;
29 static __inline__ void release_dma_lock(unsigned long flags)
31 spin_unlock_irqrestore(&dma_spin_lock, flags);
36 #define fd_inb(port) inb_p(port)
37 #define fd_outb(port,value) outb_p(port,value)
40 #define fd_request_dma() vdma_request_dma(FLOPPY_DMA,"floppy")
41 /*#define fd_free_dma() */
44 #define fd_get_dma_residue() vdma_get_dma_residue(FLOPPY_DMA)
45 #define fd_dma_mem_alloc(size) vdma_mem_alloc(size)
46 #define fd_dma_setup(addr, size, mode, io) vdma_dma_setup(addr, size, mode, io)
49 #define fd_enable_irq() /* nothing... */
50 #define fd_disable_irq() /* nothing... */
51 #define fd_free_irq() free_irq(FLOPPY_IRQ, NULL)
53 #define fd_free_dma() /* nothing */
55 /* No 64k boundary crossing problems on Q40 - no DMA at all */
56 #define CROSS_64KB(a,s) (0)
58 #define DMA_MODE_READ 0x44 /* i386 look-alike */
59 #define DMA_MODE_WRITE 0x48
62 static int q40_floppy_init(void)
64 use_virtual_dma =1;
65 /* FLOPPY_IRQ=6; */
67 if (MACH_IS_Q40)
68 return 0x3f0;
69 else
70 return -1;
77 * Again, the CMOS information doesn't work on the Q40..
79 #define FLOPPY0_TYPE 6
80 #define FLOPPY1_TYPE 0
85 #define FLOPPY_MOTOR_MASK 0xf0
90 /* basically PC init + set use_virtual_dma */
91 #define FDC1 q40_floppy_init()
92 static int FDC2 = -1;
95 #define N_FDC 1
96 #define N_DRIVE 8
100 /* vdma stuff adapted from asm-i386/floppy.h */
102 static int virtual_dma_count=0;
103 static int virtual_dma_residue=0;
104 static char *virtual_dma_addr=0;
105 static int virtual_dma_mode=0;
106 static int doing_pdma=0;
110 static int fd_request_irq(void)
112 return request_irq(FLOPPY_IRQ, floppy_hardint,SA_INTERRUPT,
113 "floppy", NULL);
116 /*#define SLOW_DOWN do{outb(0,0x80);}while(0)*/
117 #define SLOW_DOWN do{int count=1;do{if(!jiffies)break;}while(count-->0);}while(0)
119 asmlinkage void floppy_hardint(int irq, void *dev_id, struct pt_regs * regs)
121 register unsigned char st;
123 #undef TRACE_FLPY_INT
124 #define NO_FLOPPY_ASSEMBLER
126 #ifdef TRACE_FLPY_INT
127 static int calls=0;
128 static int bytes=0;
129 static int dma_wait=0;
130 #endif
131 if(!doing_pdma) {
132 floppy_interrupt(irq, dev_id, regs);
133 return;
136 #ifdef TRACE_FLPY_INT
137 if(!calls)
138 bytes = virtual_dma_count;
139 #endif
142 register int lcount;
143 register char *lptr;
145 /* serve 1st byte fast: */
147 st=1;
148 for(lcount=virtual_dma_count, lptr=virtual_dma_addr;
149 lcount; lcount--, lptr++) {
150 st=inb(virtual_dma_port+4) & 0xa0 ;
151 if(st != 0xa0)
152 break;
153 if(virtual_dma_mode)
154 outb_p(*lptr, virtual_dma_port+5);
155 else
156 *lptr = inb_p(virtual_dma_port+5);
159 virtual_dma_count = lcount;
160 virtual_dma_addr = lptr;
161 st = inb(virtual_dma_port+4);
164 #ifdef TRACE_FLPY_INT
165 calls++;
166 #endif
167 if(st == 0x20)
168 return;
169 if(!(st & 0x20)) {
170 virtual_dma_residue += virtual_dma_count;
171 virtual_dma_count=0;
172 #ifdef TRACE_FLPY_INT
173 printk("count=%x, residue=%x calls=%d bytes=%d dma_wait=%d\n",
174 virtual_dma_count, virtual_dma_residue, calls, bytes,
175 dma_wait);
176 calls = 0;
177 dma_wait=0;
178 #endif
179 doing_pdma = 0;
180 floppy_interrupt(irq, dev_id, regs);
181 return;
183 #ifdef TRACE_FLPY_INT
184 if(!virtual_dma_count)
185 dma_wait++;
186 #endif
191 static int vdma_request_dma(unsigned int dmanr, const char * device_id)
193 return 0;
197 static int vdma_get_dma_residue(unsigned int dummy)
199 return virtual_dma_count + virtual_dma_residue;
203 static unsigned long vdma_mem_alloc(unsigned long size)
205 return (unsigned long) vmalloc(size);
209 static void _fd_dma_mem_free(unsigned long addr, unsigned long size)
211 vfree((void *)addr);
213 #define fd_dma_mem_free(addr,size) _fd_dma_mem_free(addr, size)
216 /* choose_dma_mode ???*/
218 static int vdma_dma_setup(char *addr, unsigned long size, int mode, int io)
220 doing_pdma = 1;
221 virtual_dma_port = io;
222 virtual_dma_mode = (mode == DMA_MODE_WRITE);
223 virtual_dma_addr = addr;
224 virtual_dma_count = size;
225 virtual_dma_residue = 0;
226 return 0;
231 static void fd_disable_dma(void)
233 doing_pdma = 0;
234 virtual_dma_residue += virtual_dma_count;
235 virtual_dma_count=0;