ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.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 static __inline__ int ide_default_irq(unsigned long base)
55 {
56           return 0;
57 }
58
59 static __inline__ unsigned long ide_default_io_base(int index)
60 {
61           return 0;
62 }
63
64
65 /*
66  * Set up a hw structure for a specified data port, control port and IRQ.
67  * This should follow whatever the default interface uses.
68  */
69 static __inline__ void ide_init_hwif_ports(hw_regs_t *hw,
70                                            unsigned long data_port,
71                                            unsigned long ctrl_port, int *irq)
72 {
73         if (data_port || ctrl_port)
74                 printk("ide_init_hwif_ports: must not be called\n");
75 }
76
77 #define ide_init_default_irq(base)      (0)
78
79 /*
80  * Get rid of defs from io.h - ide has its private and conflicting versions
81  * Since so far no single m68k platform uses ISA/PCI I/O space for IDE, we
82  * always use the `raw' MMIO versions
83  */
84 #undef inb
85 #undef inw
86 #undef insw
87 #undef inl
88 #undef insl
89 #undef outb
90 #undef outw
91 #undef outsw
92 #undef outl
93 #undef outsl
94 #undef readb
95 #undef readw
96 #undef readl
97 #undef writeb
98 #undef writew
99 #undef writel
100
101 #define inb                             in_8
102 #define inw                             in_be16
103 #define insw(port, addr, n)             raw_insw((u16 *)port, addr, n)
104 #define inl                             in_be32
105 #define insl(port, addr, n)             raw_insl((u32 *)port, addr, n)
106 #define outb(val, port)                 out_8(port, val)
107 #define outw(val, port)                 out_be16(port, val)
108 #define outsw(port, addr, n)            raw_outsw((u16 *)port, addr, n)
109 #define outl(val, port)                 out_be32(port, val)
110 #define outsl(port, addr, n)            raw_outsl((u32 *)port, addr, n)
111 #define readb                           in_8
112 #define readw                           in_be16
113 #define __ide_mm_insw(port, addr, n)    raw_insw((u16 *)port, addr, n)
114 #define readl                           in_be32
115 #define __ide_mm_insl(port, addr, n)    raw_insl((u32 *)port, addr, n)
116 #define writeb(val, port)               out_8(port, val)
117 #define writew(val, port)               out_be16(port, val)
118 #define __ide_mm_outsw(port, addr, n)   raw_outsw((u16 *)port, addr, n)
119 #define writel(val, port)               out_be32(port, val)
120 #define __ide_mm_outsl(port, addr, n)   raw_outsl((u32 *)port, addr, n)
121 #if defined(CONFIG_ATARI) || defined(CONFIG_Q40)
122 #define insw_swapw(port, addr, n)       raw_insw_swapw((u16 *)port, addr, n)
123 #define outsw_swapw(port, addr, n)      raw_outsw_swapw((u16 *)port, addr, n)
124 #endif
125
126
127 /* Q40 and Atari have byteswapped IDE busses and since many interesting
128  * values in the identification string are text, chars and words they
129  * happened to be almost correct without swapping.. However *_capacity
130  * is needed for drives over 8 GB. RZ */
131 #if defined(CONFIG_Q40) || defined(CONFIG_ATARI)
132 #define M68K_IDE_SWAPW  (MACH_IS_Q40 || MACH_IS_ATARI)
133 #endif
134
135 #ifdef CONFIG_BLK_DEV_FALCON_IDE
136 #define IDE_ARCH_LOCK
137
138 extern int falconide_intr_lock;
139
140 static __inline__ void ide_release_lock (void)
141 {
142         if (MACH_IS_ATARI) {
143                 if (falconide_intr_lock == 0) {
144                         printk("ide_release_lock: bug\n");
145                         return;
146                 }
147                 falconide_intr_lock = 0;
148                 stdma_release();
149         }
150 }
151
152 static __inline__ void
153 ide_get_lock(irqreturn_t (*handler)(int, void *, struct pt_regs *), void *data)
154 {
155         if (MACH_IS_ATARI) {
156                 if (falconide_intr_lock == 0) {
157                         if (in_interrupt() > 0)
158                                 panic( "Falcon IDE hasn't ST-DMA lock in interrupt" );
159                         stdma_lock(handler, data);
160                         falconide_intr_lock = 1;
161                 }
162         }
163 }
164 #endif /* CONFIG_BLK_DEV_FALCON_IDE */
165
166 #define IDE_ARCH_ACK_INTR
167 #define ide_ack_intr(hwif)      ((hwif)->hw.ack_intr ? (hwif)->hw.ack_intr(hwif) : 1)
168
169 #endif /* __KERNEL__ */
170 #endif /* _M68K_IDE_H */