xref: /linux/arch/alpha/include/asm/floppy.h (revision 024b246ed24492d6c2ee14c34d742b137fce1b94)
1*024b246eSLinus Torvalds /*
2*024b246eSLinus Torvalds  * Architecture specific parts of the Floppy driver
3*024b246eSLinus Torvalds  *
4*024b246eSLinus Torvalds  * This file is subject to the terms and conditions of the GNU General Public
5*024b246eSLinus Torvalds  * License.  See the file "COPYING" in the main directory of this archive
6*024b246eSLinus Torvalds  * for more details.
7*024b246eSLinus Torvalds  *
8*024b246eSLinus Torvalds  * Copyright (C) 1995
9*024b246eSLinus Torvalds  */
10*024b246eSLinus Torvalds #ifndef __ASM_ALPHA_FLOPPY_H
11*024b246eSLinus Torvalds #define __ASM_ALPHA_FLOPPY_H
12*024b246eSLinus Torvalds 
13*024b246eSLinus Torvalds 
14*024b246eSLinus Torvalds #define fd_inb(port)			inb_p(port)
15*024b246eSLinus Torvalds #define fd_outb(value,port)		outb_p(value,port)
16*024b246eSLinus Torvalds 
17*024b246eSLinus Torvalds #define fd_enable_dma()         enable_dma(FLOPPY_DMA)
18*024b246eSLinus Torvalds #define fd_disable_dma()        disable_dma(FLOPPY_DMA)
19*024b246eSLinus Torvalds #define fd_request_dma()        request_dma(FLOPPY_DMA,"floppy")
20*024b246eSLinus Torvalds #define fd_free_dma()           free_dma(FLOPPY_DMA)
21*024b246eSLinus Torvalds #define fd_clear_dma_ff()       clear_dma_ff(FLOPPY_DMA)
22*024b246eSLinus Torvalds #define fd_set_dma_mode(mode)   set_dma_mode(FLOPPY_DMA,mode)
23*024b246eSLinus Torvalds #define fd_set_dma_addr(addr)   set_dma_addr(FLOPPY_DMA,virt_to_bus(addr))
24*024b246eSLinus Torvalds #define fd_set_dma_count(count) set_dma_count(FLOPPY_DMA,count)
25*024b246eSLinus Torvalds #define fd_enable_irq()         enable_irq(FLOPPY_IRQ)
26*024b246eSLinus Torvalds #define fd_disable_irq()        disable_irq(FLOPPY_IRQ)
27*024b246eSLinus Torvalds #define fd_cacheflush(addr,size) /* nothing */
28*024b246eSLinus Torvalds #define fd_request_irq()        request_irq(FLOPPY_IRQ, floppy_interrupt,\
29*024b246eSLinus Torvalds 					    IRQF_DISABLED, "floppy", NULL)
30*024b246eSLinus Torvalds #define fd_free_irq()           free_irq(FLOPPY_IRQ, NULL);
31*024b246eSLinus Torvalds 
32*024b246eSLinus Torvalds #ifdef CONFIG_PCI
33*024b246eSLinus Torvalds 
34*024b246eSLinus Torvalds #include <linux/pci.h>
35*024b246eSLinus Torvalds 
36*024b246eSLinus Torvalds #define fd_dma_setup(addr,size,mode,io) alpha_fd_dma_setup(addr,size,mode,io)
37*024b246eSLinus Torvalds 
38*024b246eSLinus Torvalds static __inline__ int
39*024b246eSLinus Torvalds alpha_fd_dma_setup(char *addr, unsigned long size, int mode, int io)
40*024b246eSLinus Torvalds {
41*024b246eSLinus Torvalds 	static unsigned long prev_size;
42*024b246eSLinus Torvalds 	static dma_addr_t bus_addr = 0;
43*024b246eSLinus Torvalds 	static char *prev_addr;
44*024b246eSLinus Torvalds 	static int prev_dir;
45*024b246eSLinus Torvalds 	int dir;
46*024b246eSLinus Torvalds 
47*024b246eSLinus Torvalds 	dir = (mode != DMA_MODE_READ) ? PCI_DMA_FROMDEVICE : PCI_DMA_TODEVICE;
48*024b246eSLinus Torvalds 
49*024b246eSLinus Torvalds 	if (bus_addr
50*024b246eSLinus Torvalds 	    && (addr != prev_addr || size != prev_size || dir != prev_dir)) {
51*024b246eSLinus Torvalds 		/* different from last time -- unmap prev */
52*024b246eSLinus Torvalds 		pci_unmap_single(isa_bridge, bus_addr, prev_size, prev_dir);
53*024b246eSLinus Torvalds 		bus_addr = 0;
54*024b246eSLinus Torvalds 	}
55*024b246eSLinus Torvalds 
56*024b246eSLinus Torvalds 	if (!bus_addr)	/* need to map it */
57*024b246eSLinus Torvalds 		bus_addr = pci_map_single(isa_bridge, addr, size, dir);
58*024b246eSLinus Torvalds 
59*024b246eSLinus Torvalds 	/* remember this one as prev */
60*024b246eSLinus Torvalds 	prev_addr = addr;
61*024b246eSLinus Torvalds 	prev_size = size;
62*024b246eSLinus Torvalds 	prev_dir = dir;
63*024b246eSLinus Torvalds 
64*024b246eSLinus Torvalds 	fd_clear_dma_ff();
65*024b246eSLinus Torvalds 	fd_cacheflush(addr, size);
66*024b246eSLinus Torvalds 	fd_set_dma_mode(mode);
67*024b246eSLinus Torvalds 	set_dma_addr(FLOPPY_DMA, bus_addr);
68*024b246eSLinus Torvalds 	fd_set_dma_count(size);
69*024b246eSLinus Torvalds 	virtual_dma_port = io;
70*024b246eSLinus Torvalds 	fd_enable_dma();
71*024b246eSLinus Torvalds 
72*024b246eSLinus Torvalds 	return 0;
73*024b246eSLinus Torvalds }
74*024b246eSLinus Torvalds 
75*024b246eSLinus Torvalds #endif /* CONFIG_PCI */
76*024b246eSLinus Torvalds 
77*024b246eSLinus Torvalds __inline__ void virtual_dma_init(void)
78*024b246eSLinus Torvalds {
79*024b246eSLinus Torvalds 	/* Nothing to do on an Alpha */
80*024b246eSLinus Torvalds }
81*024b246eSLinus Torvalds 
82*024b246eSLinus Torvalds static int FDC1 = 0x3f0;
83*024b246eSLinus Torvalds static int FDC2 = -1;
84*024b246eSLinus Torvalds 
85*024b246eSLinus Torvalds /*
86*024b246eSLinus Torvalds  * Again, the CMOS information doesn't work on the alpha..
87*024b246eSLinus Torvalds  */
88*024b246eSLinus Torvalds #define FLOPPY0_TYPE 6
89*024b246eSLinus Torvalds #define FLOPPY1_TYPE 0
90*024b246eSLinus Torvalds 
91*024b246eSLinus Torvalds #define N_FDC 2
92*024b246eSLinus Torvalds #define N_DRIVE 8
93*024b246eSLinus Torvalds 
94*024b246eSLinus Torvalds /*
95*024b246eSLinus Torvalds  * Most Alphas have no problems with floppy DMA crossing 64k borders,
96*024b246eSLinus Torvalds  * except for certain ones, like XL and RUFFIAN.
97*024b246eSLinus Torvalds  *
98*024b246eSLinus Torvalds  * However, the test is simple and fast, and this *is* floppy, after all,
99*024b246eSLinus Torvalds  * so we do it for all platforms, just to make sure.
100*024b246eSLinus Torvalds  *
101*024b246eSLinus Torvalds  * This is advantageous in other circumstances as well, as in moving
102*024b246eSLinus Torvalds  * about the PCI DMA windows and forcing the floppy to start doing
103*024b246eSLinus Torvalds  * scatter-gather when it never had before, and there *is* a problem
104*024b246eSLinus Torvalds  * on that platform... ;-}
105*024b246eSLinus Torvalds  */
106*024b246eSLinus Torvalds 
107*024b246eSLinus Torvalds static inline unsigned long CROSS_64KB(void *a, unsigned long s)
108*024b246eSLinus Torvalds {
109*024b246eSLinus Torvalds 	unsigned long p = (unsigned long)a;
110*024b246eSLinus Torvalds 	return ((p + s - 1) ^ p) & ~0xffffUL;
111*024b246eSLinus Torvalds }
112*024b246eSLinus Torvalds 
113*024b246eSLinus Torvalds #define EXTRA_FLOPPY_PARAMS
114*024b246eSLinus Torvalds 
115*024b246eSLinus Torvalds #endif /* __ASM_ALPHA_FLOPPY_H */
116