xref: /linux/arch/alpha/include/asm/floppy.h (revision e72e8bf1c9847a12de74f2fd3ea1f5511866526b)
1024b246eSLinus Torvalds /*
2024b246eSLinus Torvalds  * Architecture specific parts of the Floppy driver
3024b246eSLinus Torvalds  *
4024b246eSLinus Torvalds  * This file is subject to the terms and conditions of the GNU General Public
5024b246eSLinus Torvalds  * License.  See the file "COPYING" in the main directory of this archive
6024b246eSLinus Torvalds  * for more details.
7024b246eSLinus Torvalds  *
8024b246eSLinus Torvalds  * Copyright (C) 1995
9024b246eSLinus Torvalds  */
10024b246eSLinus Torvalds #ifndef __ASM_ALPHA_FLOPPY_H
11024b246eSLinus Torvalds #define __ASM_ALPHA_FLOPPY_H
12024b246eSLinus Torvalds 
13024b246eSLinus Torvalds 
14*e72e8bf1SWilly Tarreau #define fd_inb(base, reg)		inb_p((base) + (reg))
15*e72e8bf1SWilly Tarreau #define fd_outb(value, base, reg)	outb_p(value, (base) + (reg))
16024b246eSLinus Torvalds 
17024b246eSLinus Torvalds #define fd_enable_dma()         enable_dma(FLOPPY_DMA)
18024b246eSLinus Torvalds #define fd_disable_dma()        disable_dma(FLOPPY_DMA)
19024b246eSLinus Torvalds #define fd_request_dma()        request_dma(FLOPPY_DMA,"floppy")
20024b246eSLinus Torvalds #define fd_free_dma()           free_dma(FLOPPY_DMA)
21024b246eSLinus Torvalds #define fd_clear_dma_ff()       clear_dma_ff(FLOPPY_DMA)
22024b246eSLinus Torvalds #define fd_set_dma_mode(mode)   set_dma_mode(FLOPPY_DMA,mode)
23024b246eSLinus Torvalds #define fd_set_dma_addr(addr)   set_dma_addr(FLOPPY_DMA,virt_to_bus(addr))
24024b246eSLinus Torvalds #define fd_set_dma_count(count) set_dma_count(FLOPPY_DMA,count)
25024b246eSLinus Torvalds #define fd_enable_irq()         enable_irq(FLOPPY_IRQ)
26024b246eSLinus Torvalds #define fd_disable_irq()        disable_irq(FLOPPY_IRQ)
27024b246eSLinus Torvalds #define fd_request_irq()        request_irq(FLOPPY_IRQ, floppy_interrupt,\
28e74e2592SWill Deacon 					    0, "floppy", NULL)
29497888cfSPhil Carmody #define fd_free_irq()           free_irq(FLOPPY_IRQ, NULL)
30024b246eSLinus Torvalds 
31024b246eSLinus Torvalds #ifdef CONFIG_PCI
32024b246eSLinus Torvalds 
33024b246eSLinus Torvalds #include <linux/pci.h>
34024b246eSLinus Torvalds 
35024b246eSLinus Torvalds #define fd_dma_setup(addr,size,mode,io) alpha_fd_dma_setup(addr,size,mode,io)
36024b246eSLinus Torvalds 
37024b246eSLinus Torvalds static __inline__ int
38024b246eSLinus Torvalds alpha_fd_dma_setup(char *addr, unsigned long size, int mode, int io)
39024b246eSLinus Torvalds {
40024b246eSLinus Torvalds 	static unsigned long prev_size;
41024b246eSLinus Torvalds 	static dma_addr_t bus_addr = 0;
42024b246eSLinus Torvalds 	static char *prev_addr;
43024b246eSLinus Torvalds 	static int prev_dir;
44024b246eSLinus Torvalds 	int dir;
45024b246eSLinus Torvalds 
46024b246eSLinus Torvalds 	dir = (mode != DMA_MODE_READ) ? PCI_DMA_FROMDEVICE : PCI_DMA_TODEVICE;
47024b246eSLinus Torvalds 
48024b246eSLinus Torvalds 	if (bus_addr
49024b246eSLinus Torvalds 	    && (addr != prev_addr || size != prev_size || dir != prev_dir)) {
50024b246eSLinus Torvalds 		/* different from last time -- unmap prev */
51024b246eSLinus Torvalds 		pci_unmap_single(isa_bridge, bus_addr, prev_size, prev_dir);
52024b246eSLinus Torvalds 		bus_addr = 0;
53024b246eSLinus Torvalds 	}
54024b246eSLinus Torvalds 
55024b246eSLinus Torvalds 	if (!bus_addr)	/* need to map it */
56024b246eSLinus Torvalds 		bus_addr = pci_map_single(isa_bridge, addr, size, dir);
57024b246eSLinus Torvalds 
58024b246eSLinus Torvalds 	/* remember this one as prev */
59024b246eSLinus Torvalds 	prev_addr = addr;
60024b246eSLinus Torvalds 	prev_size = size;
61024b246eSLinus Torvalds 	prev_dir = dir;
62024b246eSLinus Torvalds 
63024b246eSLinus Torvalds 	fd_clear_dma_ff();
64024b246eSLinus Torvalds 	fd_set_dma_mode(mode);
65024b246eSLinus Torvalds 	set_dma_addr(FLOPPY_DMA, bus_addr);
66024b246eSLinus Torvalds 	fd_set_dma_count(size);
67024b246eSLinus Torvalds 	virtual_dma_port = io;
68024b246eSLinus Torvalds 	fd_enable_dma();
69024b246eSLinus Torvalds 
70024b246eSLinus Torvalds 	return 0;
71024b246eSLinus Torvalds }
72024b246eSLinus Torvalds 
73024b246eSLinus Torvalds #endif /* CONFIG_PCI */
74024b246eSLinus Torvalds 
75024b246eSLinus Torvalds __inline__ void virtual_dma_init(void)
76024b246eSLinus Torvalds {
77024b246eSLinus Torvalds 	/* Nothing to do on an Alpha */
78024b246eSLinus Torvalds }
79024b246eSLinus Torvalds 
80024b246eSLinus Torvalds static int FDC1 = 0x3f0;
81024b246eSLinus Torvalds static int FDC2 = -1;
82024b246eSLinus Torvalds 
83024b246eSLinus Torvalds /*
84024b246eSLinus Torvalds  * Again, the CMOS information doesn't work on the alpha..
85024b246eSLinus Torvalds  */
86024b246eSLinus Torvalds #define FLOPPY0_TYPE 6
87024b246eSLinus Torvalds #define FLOPPY1_TYPE 0
88024b246eSLinus Torvalds 
89024b246eSLinus Torvalds #define N_FDC 2
90024b246eSLinus Torvalds #define N_DRIVE 8
91024b246eSLinus Torvalds 
92024b246eSLinus Torvalds /*
93024b246eSLinus Torvalds  * Most Alphas have no problems with floppy DMA crossing 64k borders,
94024b246eSLinus Torvalds  * except for certain ones, like XL and RUFFIAN.
95024b246eSLinus Torvalds  *
96024b246eSLinus Torvalds  * However, the test is simple and fast, and this *is* floppy, after all,
97024b246eSLinus Torvalds  * so we do it for all platforms, just to make sure.
98024b246eSLinus Torvalds  *
99024b246eSLinus Torvalds  * This is advantageous in other circumstances as well, as in moving
100024b246eSLinus Torvalds  * about the PCI DMA windows and forcing the floppy to start doing
101024b246eSLinus Torvalds  * scatter-gather when it never had before, and there *is* a problem
102024b246eSLinus Torvalds  * on that platform... ;-}
103024b246eSLinus Torvalds  */
104024b246eSLinus Torvalds 
105024b246eSLinus Torvalds static inline unsigned long CROSS_64KB(void *a, unsigned long s)
106024b246eSLinus Torvalds {
107024b246eSLinus Torvalds 	unsigned long p = (unsigned long)a;
108024b246eSLinus Torvalds 	return ((p + s - 1) ^ p) & ~0xffffUL;
109024b246eSLinus Torvalds }
110024b246eSLinus Torvalds 
111024b246eSLinus Torvalds #define EXTRA_FLOPPY_PARAMS
112024b246eSLinus Torvalds 
113024b246eSLinus Torvalds #endif /* __ASM_ALPHA_FLOPPY_H */
114