cleanup
[linux-2.4.21-pre4.git] / include / asm-m68k / ide.h
1 /*
2  *  linux/include/asm-m68k/ide.h
3  *
4  *  Copyright (C) 1994-1996  Linus Torvalds & authors
5  */
6  
7 /* Copyright(c) 1996 Kars de Jong */
8 /* Based on the ide driver from 1.2.13pl8 */
9
10 /*
11  * Credits (alphabetical):
12  *
13  *  - Bjoern Brauel
14  *  - Kars de Jong
15  *  - Torsten Ebeling
16  *  - Dwight Engen
17  *  - Thorsten Floeck
18  *  - Roman Hodek
19  *  - Guenther Kelleter
20  *  - Chris Lawrence
21  *  - Michael Rausch
22  *  - Christian Sauer
23  *  - Michael Schmitz
24  *  - Jes Soerensen
25  *  - Michael Thurm
26  *  - Geert Uytterhoeven
27  */
28
29 #ifndef _M68K_IDE_H
30 #define _M68K_IDE_H
31
32 #ifdef __KERNEL__
33
34 #include <linux/config.h>
35
36 #include <asm/setup.h>
37 #include <asm/io.h>
38 #include <asm/irq.h>
39
40 #ifdef CONFIG_ATARI
41 #include <linux/interrupt.h>
42 #include <asm/atari_stdma.h>
43 #endif
44
45 #ifdef CONFIG_MAC
46 #include <asm/macints.h>
47 #endif
48
49 #ifndef MAX_HWIFS
50 #define MAX_HWIFS       4       /* same as the other archs */
51 #endif
52
53 /*
54  * FIXME: IOPS struct calls needed for taskfile.
55  */
56
57 static __inline__ int ide_default_irq(ide_ioreg_t base)
58 {
59           return 0;
60 }
61
62 static __inline__ ide_ioreg_t ide_default_io_base(int index)
63 {
64           return 0;
65 }
66
67
68 /*
69  * Set up a hw structure for a specified data port, control port and IRQ.
70  * This should follow whatever the default interface uses.
71  */
72 static __inline__ void ide_init_hwif_ports(hw_regs_t *hw, ide_ioreg_t data_port, ide_ioreg_t ctrl_port, int *irq)
73 {
74         if (data_port || ctrl_port)
75                 printk("ide_init_hwif_ports: must not be called\n");
76 }
77
78 /*
79  * This registers the standard ports for this architecture with the IDE
80  * driver.
81  */
82 static __inline__ void ide_init_default_hwifs(void)
83 {
84 }
85
86 static __inline__ int ide_request_irq(unsigned int irq, void (*handler)(int, void *, struct pt_regs *),
87                         unsigned long flags, const char *device, void *dev_id)
88 {
89 #ifdef CONFIG_AMIGA
90         if (MACH_IS_AMIGA)
91                 return request_irq(irq, handler, 0, device, dev_id);
92 #endif /* CONFIG_AMIGA */
93 #ifdef CONFIG_Q40
94         if (MACH_IS_Q40)
95                 return request_irq(irq, handler, 0, device, dev_id);
96 #endif /* CONFIG_Q40*/
97 #ifdef CONFIG_MAC
98         if (MACH_IS_MAC)
99                 return request_irq(irq, handler, 0, device, dev_id);
100 #endif /* CONFIG_MAC */
101         return 0;
102 }
103
104 static __inline__ void ide_free_irq(unsigned int irq, void *dev_id)
105 {
106 #ifdef CONFIG_AMIGA
107         if (MACH_IS_AMIGA)
108                 free_irq(irq, dev_id);
109 #endif /* CONFIG_AMIGA */
110 #ifdef CONFIG_Q40
111         if (MACH_IS_Q40)
112                 free_irq(irq, dev_id);
113 #endif /* CONFIG_Q40*/
114 #ifdef CONFIG_MAC
115         if (MACH_IS_MAC)
116                 free_irq(irq, dev_id);
117 #endif /* CONFIG_MAC */
118 }
119
120 /*
121  * We should really implement those some day.
122  */
123 static __inline__ int ide_check_region (ide_ioreg_t from, unsigned int extent)
124 {
125         return 0;
126 }
127
128 static __inline__ void ide_request_region (ide_ioreg_t from, unsigned int extent, const char *name)
129 {
130 #ifdef CONFIG_Q40
131         if (MACH_IS_Q40)
132             request_region((q40ide_ioreg_t)from,extent,name);
133 #endif
134 }
135
136 static __inline__ void ide_release_region (ide_ioreg_t from, unsigned int extent)
137 {
138 #ifdef CONFIG_Q40
139         if (MACH_IS_Q40)
140             release_region((q40ide_ioreg_t)from,extent);
141 #endif
142 }
143
144 #undef SUPPORT_SLOW_DATA_PORTS
145 #define SUPPORT_SLOW_DATA_PORTS 0
146
147 #undef SUPPORT_VLB_SYNC
148 #define SUPPORT_VLB_SYNC 0
149
150 /* this definition is used only on startup .. */
151 #undef HD_DATA
152 #define HD_DATA NULL
153
154
155 /*
156  * get rid of defs from io.h
157  * ide still has some private and conflicting versions
158  */
159 #undef insw
160 #undef insl
161 #undef outsw
162 #undef outsl
163
164
165 /*
166  * define IO method and translation,
167  * so far only Q40 has ide-if on ISA
168  */
169 #ifndef CONFIG_Q40
170
171 #define ADDR_TRANS_B(_addr_) (_addr_)
172 #define ADDR_TRANS_W(_addr_) (_addr_)
173 #define ADDR_TRANS_L(_addr_) (_addr_)
174
175 #else
176
177 #define ADDR_TRANS_B(_addr_) (MACH_IS_Q40 ? ((unsigned char *)Q40_ISA_IO_B(_addr_)) : (_addr_))
178 #define ADDR_TRANS_W(_addr_) (MACH_IS_Q40 ? ((unsigned char *)Q40_ISA_IO_W(_addr_)) : (_addr_))
179 #define ADDR_TRANS_L(_addr_) (MACH_IS_Q40 ? ((unsigned char *)Q40_ISA_IO_L(_addr_)) : (_addr_))
180 #endif
181
182 #define HAVE_ARCH_OUT_BYTE 1
183
184 #define OUT_BYTE(v,p)   out_8(ADDR_TRANS_B((p)), (v))
185 #define OUT_WORD(v,p)   out_be16(ADDR_TRANS_W((p)), (v))
186 #define OUT_LONG(v,p)   out_be32(ADDR_TRANS_L((p)), (v))
187
188 #define HAVE_ARCH_IN_BYTE 1
189
190 #define IN_BYTE(p)      in_8(ADDR_TRANS_B((p)))
191 #define IN_WORD(p)      in_be16(ADDR_TRANS_W((p)))
192 #define IN_LONG(p)      in_be32(ADDR_TRANS_L((p)))
193
194 #define insw(port, buf, nr) raw_insw(ADDR_TRANS_W(port), buf, nr)
195 #define outsw(port, buf, nr) raw_outsw(ADDR_TRANS_W(port), buf, nr)
196
197 #define insl(data_reg, buffer, wcount) insw(data_reg, buffer, (wcount)<<1)
198 #define outsl(data_reg, buffer, wcount) outsw(data_reg, buffer, (wcount)<<1)
199
200
201 #if defined(CONFIG_ATARI) || defined(CONFIG_Q40)
202
203 #define insl_swapw(data_reg, buffer, wcount) \
204     insw_swapw(data_reg, buffer, (wcount)<<1)
205 #define outsl_swapw(data_reg, buffer, wcount) \
206     outsw_swapw(data_reg, buffer, (wcount)<<1)
207
208 #define insw_swapw(port, buf, nr) raw_insw_swapw(ADDR_TRANS_W(port), buf, nr)
209 #define outsw_swapw(port, buf, nr) raw_outsw_swapw(ADDR_TRANS_W(port),buf,nr)
210
211 #endif /* CONFIG_ATARI || CONFIG_Q40 */
212
213
214 /* Q40 and Atari have byteswapped IDE bus and since many interesting
215  * values in the identification string are text, chars and words they
216  * happened to be almost correct without swapping.. However *_capacity 
217  * is needed for drives over 8 GB. RZ */
218 #if defined(CONFIG_Q40) || defined(CONFIG_ATARI)
219 #define M68K_IDE_SWAPW  (MACH_IS_Q40 || MACH_IS_ATARI)
220 #endif
221
222 #ifdef CONFIG_ATARI
223 #define IDE_ARCH_LOCK 1
224
225 static __inline__ void ide_release_lock (int *ide_lock)
226 {
227         if (MACH_IS_ATARI) {
228                 if (*ide_lock == 0) {
229                         printk("ide_release_lock: bug\n");
230                         return;
231                 }
232                 *ide_lock = 0;
233                 stdma_release();
234         }
235 }
236
237 static __inline__ void ide_get_lock (int *ide_lock, void (*handler)(int, void *, struct pt_regs *), void *data)
238 {
239         if (MACH_IS_ATARI) {
240                 if (*ide_lock == 0) {
241                         if (in_interrupt() > 0)
242                                 panic( "Falcon IDE hasn't ST-DMA lock in interrupt" );
243                         stdma_lock(handler, data);
244                         *ide_lock = 1;
245                 }
246         }
247 }
248 #endif /* CONFIG_ATARI */
249
250 #endif /* __KERNEL__ */
251
252 #endif /* _M68K_IDE_H */