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
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)
25 spin_lock_irqsave(&dma_spin_lock
, 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)
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()
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
,
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
129 static int dma_wait
=0;
132 floppy_interrupt(irq
, dev_id
, regs
);
136 #ifdef TRACE_FLPY_INT
138 bytes
= virtual_dma_count
;
145 /* serve 1st byte fast: */
148 for(lcount
=virtual_dma_count
, lptr
=virtual_dma_addr
;
149 lcount
; lcount
--, lptr
++) {
150 st
=inb(virtual_dma_port
+4) & 0xa0 ;
154 outb_p(*lptr
, virtual_dma_port
+5);
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
170 virtual_dma_residue
+= virtual_dma_count
;
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
,
180 floppy_interrupt(irq
, dev_id
, regs
);
183 #ifdef TRACE_FLPY_INT
184 if(!virtual_dma_count
)
191 static int vdma_request_dma(unsigned int dmanr
, const char * device_id
)
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
)
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
)
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;
231 static void fd_disable_dma(void)
234 virtual_dma_residue
+= virtual_dma_count
;