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
10 #ifndef __ASM_POWERPC_FLOPPY_H
11 #define __ASM_POWERPC_FLOPPY_H
14 #include <asm/machdep.h>
16 #define fd_inb(port) inb_p(port)
17 #define fd_outb(value,port) outb_p(value,port)
19 #define fd_enable_dma() enable_dma(FLOPPY_DMA)
20 #define fd_disable_dma() fd_ops->_disable_dma(FLOPPY_DMA)
21 #define fd_free_dma() fd_ops->_free_dma(FLOPPY_DMA)
22 #define fd_clear_dma_ff() clear_dma_ff(FLOPPY_DMA)
23 #define fd_set_dma_mode(mode) set_dma_mode(FLOPPY_DMA, mode)
24 #define fd_set_dma_count(count) set_dma_count(FLOPPY_DMA, count)
25 #define fd_get_dma_residue() fd_ops->_get_dma_residue(FLOPPY_DMA)
26 #define fd_enable_irq() enable_irq(FLOPPY_IRQ)
27 #define fd_disable_irq() disable_irq(FLOPPY_IRQ)
28 #define fd_free_irq() free_irq(FLOPPY_IRQ, NULL);
30 #include <linux/pci.h>
31 #include <asm/ppc-pci.h> /* for isa_bridge_pcidev */
33 #define fd_dma_setup(addr,size,mode,io) fd_ops->_dma_setup(addr,size,mode,io)
35 static int fd_request_dma(void);
38 void (*_disable_dma
)(unsigned int dmanr
);
39 void (*_free_dma
)(unsigned int dmanr
);
40 int (*_get_dma_residue
)(unsigned int dummy
);
41 int (*_dma_setup
)(char *addr
, unsigned long size
, int mode
, int io
);
44 static int virtual_dma_count
;
45 static int virtual_dma_residue
;
46 static char *virtual_dma_addr
;
47 static int virtual_dma_mode
;
48 static int doing_vdma
;
49 static struct fd_dma_ops
*fd_ops
;
51 static irqreturn_t
floppy_hardint(int irq
, void *dev_id
)
58 return floppy_interrupt(irq
, dev_id
);
62 for (lcount
=virtual_dma_count
, lptr
=virtual_dma_addr
;
63 lcount
; lcount
--, lptr
++) {
64 st
=inb(virtual_dma_port
+4) & 0xa0 ;
68 outb_p(*lptr
, virtual_dma_port
+5);
70 *lptr
= inb_p(virtual_dma_port
+5);
72 virtual_dma_count
= lcount
;
73 virtual_dma_addr
= lptr
;
74 st
= inb(virtual_dma_port
+4);
79 virtual_dma_residue
+= virtual_dma_count
;
82 floppy_interrupt(irq
, dev_id
);
88 static void vdma_disable_dma(unsigned int dummy
)
91 virtual_dma_residue
+= virtual_dma_count
;
95 static void vdma_nop(unsigned int dummy
)
100 static int vdma_get_dma_residue(unsigned int dummy
)
102 return virtual_dma_count
+ virtual_dma_residue
;
106 static int fd_request_irq(void)
108 if (can_use_virtual_dma
)
109 return request_irq(FLOPPY_IRQ
, floppy_hardint
,
112 return request_irq(FLOPPY_IRQ
, floppy_interrupt
,
116 static int vdma_dma_setup(char *addr
, unsigned long size
, int mode
, int io
)
119 virtual_dma_port
= io
;
120 virtual_dma_mode
= (mode
== DMA_MODE_WRITE
);
121 virtual_dma_addr
= addr
;
122 virtual_dma_count
= size
;
123 virtual_dma_residue
= 0;
127 static int hard_dma_setup(char *addr
, unsigned long size
, int mode
, int io
)
129 static unsigned long prev_size
;
130 static dma_addr_t bus_addr
= 0;
131 static char *prev_addr
;
136 dir
= (mode
== DMA_MODE_READ
) ? PCI_DMA_FROMDEVICE
: PCI_DMA_TODEVICE
;
139 && (addr
!= prev_addr
|| size
!= prev_size
|| dir
!= prev_dir
)) {
140 /* different from last time -- unmap prev */
141 pci_unmap_single(isa_bridge_pcidev
, bus_addr
, prev_size
, prev_dir
);
145 if (!bus_addr
) /* need to map it */
146 bus_addr
= pci_map_single(isa_bridge_pcidev
, addr
, size
, dir
);
148 /* remember this one as prev */
154 fd_set_dma_mode(mode
);
155 set_dma_addr(FLOPPY_DMA
, bus_addr
);
156 fd_set_dma_count(size
);
157 virtual_dma_port
= io
;
163 static struct fd_dma_ops real_dma_ops
=
165 ._disable_dma
= disable_dma
,
166 ._free_dma
= free_dma
,
167 ._get_dma_residue
= get_dma_residue
,
168 ._dma_setup
= hard_dma_setup
171 static struct fd_dma_ops virt_dma_ops
=
173 ._disable_dma
= vdma_disable_dma
,
174 ._free_dma
= vdma_nop
,
175 ._get_dma_residue
= vdma_get_dma_residue
,
176 ._dma_setup
= vdma_dma_setup
179 static int fd_request_dma(void)
181 if (can_use_virtual_dma
& 1) {
182 fd_ops
= &virt_dma_ops
;
186 fd_ops
= &real_dma_ops
;
187 return request_dma(FLOPPY_DMA
, "floppy");
191 static int FDC1
= 0x3f0;
192 static int FDC2
= -1;
195 * Again, the CMOS information not available
197 #define FLOPPY0_TYPE 6
198 #define FLOPPY1_TYPE 0
200 #define N_FDC 2 /* Don't change this! */
204 * The PowerPC has no problems with floppy DMA crossing 64k borders.
206 #define CROSS_64KB(a,s) (0)
208 #define EXTRA_FLOPPY_PARAMS
210 #endif /* __KERNEL__ */
211 #endif /* __ASM_POWERPC_FLOPPY_H */