ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / asm-mips / mach-generic / floppy.h
1 /*
2  * This file is subject to the terms and conditions of the GNU General Public
3  * License.  See the file "COPYING" in the main directory of this archive
4  * for more details.
5  *
6  * Copyright (C) 1996, 1997, 1998, 2003 by Ralf Baechle
7  */
8 #ifndef __ASM_MACH_GENERIC_FLOPPY_H
9 #define __ASM_MACH_GENERIC_FLOPPY_H
10
11 #include <linux/delay.h>
12 #include <linux/init.h>
13 #include <linux/ioport.h>
14 #include <linux/sched.h>
15 #include <linux/kernel.h>
16 #include <linux/linkage.h>
17 #include <linux/types.h>
18 #include <linux/mm.h>
19
20 #include <asm/bootinfo.h>
21 #include <asm/cachectl.h>
22 #include <asm/dma.h>
23 #include <asm/floppy.h>
24 #include <asm/io.h>
25 #include <asm/irq.h>
26 #include <asm/pgtable.h>
27
28 /*
29  * How to access the FDC's registers.
30  */
31 static inline unsigned char fd_inb(unsigned int port)
32 {
33         return inb_p(port);
34 }
35
36 static inline void fd_outb(unsigned char value, unsigned int port)
37 {
38         outb_p(value, port);
39 }
40
41 /*
42  * How to access the floppy DMA functions.
43  */
44 static inline void fd_enable_dma(void)
45 {
46         enable_dma(FLOPPY_DMA);
47 }
48
49 static inline void fd_disable_dma(void)
50 {
51         disable_dma(FLOPPY_DMA);
52 }
53
54 static inline int fd_request_dma(void)
55 {
56         return request_dma(FLOPPY_DMA, "floppy");
57 }
58
59 static inline void fd_free_dma(void)
60 {
61         free_dma(FLOPPY_DMA);
62 }
63
64 static inline void fd_clear_dma_ff(void)
65 {
66         clear_dma_ff(FLOPPY_DMA);
67 }
68
69 static inline void fd_set_dma_mode(char mode)
70 {
71         set_dma_mode(FLOPPY_DMA, mode);
72 }
73
74 static inline void fd_set_dma_addr(char *addr)
75 {
76         set_dma_addr(FLOPPY_DMA, (unsigned long) addr);
77 }
78
79 static inline void fd_set_dma_count(unsigned int count)
80 {
81         set_dma_count(FLOPPY_DMA, count);
82 }
83
84 static inline int fd_get_dma_residue(void)
85 {
86         return get_dma_residue(FLOPPY_DMA);
87 }
88
89 static inline void fd_enable_irq(void)
90 {
91         enable_irq(FLOPPY_IRQ);
92 }
93
94 static inline void fd_disable_irq(void)
95 {
96         disable_irq(FLOPPY_IRQ);
97 }
98
99 static inline int fd_request_irq(void)
100 {
101         return request_irq(FLOPPY_IRQ, floppy_interrupt,
102                            SA_INTERRUPT | SA_SAMPLE_RANDOM, "floppy", NULL);
103 }
104
105 static inline void fd_free_irq(void)
106 {
107         free_irq(FLOPPY_IRQ, NULL);
108 }
109
110 #define fd_free_irq()           free_irq(FLOPPY_IRQ, NULL);
111
112
113 static inline unsigned long fd_getfdaddr1(void)
114 {
115         return 0x3f0;
116 }
117
118 static inline unsigned long fd_dma_mem_alloc(unsigned long size)
119 {
120         unsigned long mem;
121
122         mem = __get_dma_pages(GFP_KERNEL, get_order(size));
123
124         return mem;
125 }
126
127 static inline void fd_dma_mem_free(unsigned long addr, unsigned long size)
128 {
129         free_pages(addr, get_order(size));
130 }
131
132 static inline unsigned long fd_drive_type(unsigned long n)
133 {
134         if (n == 0)
135                 return 4;       /* 3,5", 1.44mb */
136
137         return 0;
138 }
139
140 #endif /* __ASM_MACH_GENERIC_FLOPPY_H */