2 * 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
11 #ifndef __ASM_PPC_FLOPPY_H
12 #define __ASM_PPC_FLOPPY_H
14 #define fd_inb(port) inb_p(port)
15 #define fd_outb(value,port) outb_p(value,port)
17 #define fd_disable_dma() fd_ops->_disable_dma(FLOPPY_DMA)
18 #define fd_free_dma() fd_ops->_free_dma(FLOPPY_DMA)
19 #define fd_get_dma_residue() fd_ops->_get_dma_residue(FLOPPY_DMA)
20 #define fd_dma_setup(addr, size, mode, io) fd_ops->_dma_setup(addr, size, mode, io)
21 #define fd_enable_irq() enable_irq(FLOPPY_IRQ)
22 #define fd_disable_irq() disable_irq(FLOPPY_IRQ)
23 #define fd_free_irq() free_irq(FLOPPY_IRQ, NULL);
25 static int fd_request_dma(void);
28 void (*_disable_dma)(unsigned int dmanr);
29 void (*_free_dma)(unsigned int dmanr);
30 int (*_get_dma_residue)(unsigned int dummy);
31 int (*_dma_setup)(char *addr, unsigned long size, int mode, int io);
34 static int virtual_dma_count;
35 static int virtual_dma_residue;
36 static char *virtual_dma_addr;
37 static int virtual_dma_mode;
38 static int doing_vdma;
39 static struct fd_dma_ops *fd_ops;
41 static irqreturn_t floppy_hardint(int irq, void *dev_id, struct pt_regs * regs)
48 return floppy_interrupt(irq, dev_id, regs);
52 for (lcount=virtual_dma_count, lptr=virtual_dma_addr;
53 lcount; lcount--, lptr++) {
54 st=inb(virtual_dma_port+4) & 0xa0 ;
58 outb_p(*lptr, virtual_dma_port+5);
60 *lptr = inb_p(virtual_dma_port+5);
62 virtual_dma_count = lcount;
63 virtual_dma_addr = lptr;
64 st = inb(virtual_dma_port+4);
69 virtual_dma_residue += virtual_dma_count;
72 floppy_interrupt(irq, dev_id, regs);
78 static void vdma_disable_dma(unsigned int dummy)
81 virtual_dma_residue += virtual_dma_count;
85 static void vdma_nop(unsigned int dummy)
90 static int vdma_get_dma_residue(unsigned int dummy)
92 return virtual_dma_count + virtual_dma_residue;
96 static int fd_request_irq(void)
98 if (can_use_virtual_dma)
99 return request_irq(FLOPPY_IRQ, floppy_hardint,SA_INTERRUPT,
102 return request_irq(FLOPPY_IRQ, floppy_interrupt,
103 SA_INTERRUPT|SA_SAMPLE_RANDOM,
108 static int vdma_dma_setup(char *addr, unsigned long size, int mode, int io)
111 virtual_dma_port = io;
112 virtual_dma_mode = (mode == DMA_MODE_WRITE);
113 virtual_dma_addr = addr;
114 virtual_dma_count = size;
115 virtual_dma_residue = 0;
119 static int hard_dma_setup(char *addr, unsigned long size, int mode, int io)
121 /* actual, physical DMA */
123 clear_dma_ff(FLOPPY_DMA);
124 set_dma_mode(FLOPPY_DMA,mode);
125 set_dma_addr(FLOPPY_DMA,(unsigned int)virt_to_bus(addr));
126 set_dma_count(FLOPPY_DMA,size);
127 enable_dma(FLOPPY_DMA);
131 static struct fd_dma_ops real_dma_ops =
133 ._disable_dma = disable_dma,
134 ._free_dma = free_dma,
135 ._get_dma_residue = get_dma_residue,
136 ._dma_setup = hard_dma_setup
139 static struct fd_dma_ops virt_dma_ops =
141 ._disable_dma = vdma_disable_dma,
142 ._free_dma = vdma_nop,
143 ._get_dma_residue = vdma_get_dma_residue,
144 ._dma_setup = vdma_dma_setup
147 static int fd_request_dma()
149 if (can_use_virtual_dma & 1) {
150 fd_ops = &virt_dma_ops;
154 fd_ops = &real_dma_ops;
155 return request_dma(FLOPPY_DMA, "floppy");
159 static int FDC1 = 0x3f0;
160 static int FDC2 = -1;
163 * Again, the CMOS information not available
165 #define FLOPPY0_TYPE 6
166 #define FLOPPY1_TYPE 0
168 #define N_FDC 2 /* Don't change this! */
171 #define FLOPPY_MOTOR_MASK 0xf0
174 * The PowerPC has no problems with floppy DMA crossing 64k borders.
176 #define CROSS_64KB(a,s) (0)
178 #endif /* __ASM_PPC_FLOPPY_H */
180 #define EXTRA_FLOPPY_PARAMS
182 #endif /* __KERNEL__ */