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