xref: /linux/arch/alpha/include/asm/floppy.h (revision 06cc5cf16591c3b1d63af2bbc9d33a66419ced98)
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 
14e72e8bf1SWilly Tarreau #define fd_inb(base, reg)		inb_p((base) + (reg))
15e72e8bf1SWilly 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 
46*06cc5cf1SChristophe JAILLET 	dir = (mode != DMA_MODE_READ) ? DMA_FROM_DEVICE : DMA_TO_DEVICE;
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 */
51*06cc5cf1SChristophe JAILLET 		dma_unmap_single(&isa_bridge->dev, bus_addr, prev_size,
52*06cc5cf1SChristophe JAILLET 				 prev_dir);
53024b246eSLinus Torvalds 		bus_addr = 0;
54024b246eSLinus Torvalds 	}
55024b246eSLinus Torvalds 
56024b246eSLinus Torvalds 	if (!bus_addr)	/* need to map it */
57*06cc5cf1SChristophe JAILLET 		bus_addr = dma_map_single(&isa_bridge->dev, addr, size, dir);
58024b246eSLinus Torvalds 
59024b246eSLinus Torvalds 	/* remember this one as prev */
60024b246eSLinus Torvalds 	prev_addr = addr;
61024b246eSLinus Torvalds 	prev_size = size;
62024b246eSLinus Torvalds 	prev_dir = dir;
63024b246eSLinus Torvalds 
64024b246eSLinus Torvalds 	fd_clear_dma_ff();
65024b246eSLinus Torvalds 	fd_set_dma_mode(mode);
66024b246eSLinus Torvalds 	set_dma_addr(FLOPPY_DMA, bus_addr);
67024b246eSLinus Torvalds 	fd_set_dma_count(size);
68024b246eSLinus Torvalds 	virtual_dma_port = io;
69024b246eSLinus Torvalds 	fd_enable_dma();
70024b246eSLinus Torvalds 
71024b246eSLinus Torvalds 	return 0;
72024b246eSLinus Torvalds }
73024b246eSLinus Torvalds 
74024b246eSLinus Torvalds #endif /* CONFIG_PCI */
75024b246eSLinus Torvalds 
76024b246eSLinus Torvalds __inline__ void virtual_dma_init(void)
77024b246eSLinus Torvalds {
78024b246eSLinus Torvalds 	/* Nothing to do on an Alpha */
79024b246eSLinus Torvalds }
80024b246eSLinus Torvalds 
81024b246eSLinus Torvalds static int FDC1 = 0x3f0;
82024b246eSLinus Torvalds static int FDC2 = -1;
83024b246eSLinus Torvalds 
84024b246eSLinus Torvalds /*
85024b246eSLinus Torvalds  * Again, the CMOS information doesn't work on the alpha..
86024b246eSLinus Torvalds  */
87024b246eSLinus Torvalds #define FLOPPY0_TYPE 6
88024b246eSLinus Torvalds #define FLOPPY1_TYPE 0
89024b246eSLinus Torvalds 
90024b246eSLinus Torvalds #define N_FDC 2
91024b246eSLinus Torvalds #define N_DRIVE 8
92024b246eSLinus Torvalds 
93024b246eSLinus Torvalds /*
94024b246eSLinus Torvalds  * Most Alphas have no problems with floppy DMA crossing 64k borders,
95024b246eSLinus Torvalds  * except for certain ones, like XL and RUFFIAN.
96024b246eSLinus Torvalds  *
97024b246eSLinus Torvalds  * However, the test is simple and fast, and this *is* floppy, after all,
98024b246eSLinus Torvalds  * so we do it for all platforms, just to make sure.
99024b246eSLinus Torvalds  *
100024b246eSLinus Torvalds  * This is advantageous in other circumstances as well, as in moving
101024b246eSLinus Torvalds  * about the PCI DMA windows and forcing the floppy to start doing
102024b246eSLinus Torvalds  * scatter-gather when it never had before, and there *is* a problem
103024b246eSLinus Torvalds  * on that platform... ;-}
104024b246eSLinus Torvalds  */
105024b246eSLinus Torvalds 
106024b246eSLinus Torvalds static inline unsigned long CROSS_64KB(void *a, unsigned long s)
107024b246eSLinus Torvalds {
108024b246eSLinus Torvalds 	unsigned long p = (unsigned long)a;
109024b246eSLinus Torvalds 	return ((p + s - 1) ^ p) & ~0xffffUL;
110024b246eSLinus Torvalds }
111024b246eSLinus Torvalds 
112024b246eSLinus Torvalds #define EXTRA_FLOPPY_PARAMS
113024b246eSLinus Torvalds 
114024b246eSLinus Torvalds #endif /* __ASM_ALPHA_FLOPPY_H */
115