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
6 * Copyright (C) 1994-1996 Linus Torvalds & authors
8 * Copied from i386; many of the especially older MIPS or ISA-based platforms
9 * are basically identical. Using this file probably implies i8259 PIC
10 * support in a system but the very least interrupt numbers 0 - 15 need to
11 * be put aside for legacy devices.
13 #ifndef __ASM_MACH_GENERIC_IDE_H
14 #define __ASM_MACH_GENERIC_IDE_H
18 #include <linux/pci.h>
19 #include <linux/stddef.h>
20 #include <asm/processor.h>
23 # ifdef CONFIG_BLK_DEV_IDEPCI
30 static __inline__ int ide_probe_legacy(void)
35 * This can be called on the ide_setup() path, super-early in
36 * boot. But the down_read() will enable local interrupts,
37 * which can cause some machines to crash. So here we detect
38 * and flag that situation and bail out early.
42 dev = pci_get_class(PCI_CLASS_BRIDGE_EISA << 8, NULL);
45 dev = pci_get_class(PCI_CLASS_BRIDGE_ISA << 8, NULL);
52 #elif defined(CONFIG_EISA) || defined(CONFIG_ISA)
59 static __inline__ int ide_default_irq(unsigned long base)
62 case 0x1f0: return 14;
63 case 0x170: return 15;
64 case 0x1e8: return 11;
65 case 0x168: return 10;
67 case 0x160: return 12;
73 static __inline__ unsigned long ide_default_io_base(int index)
75 if (!ide_probe_legacy())
78 * If PCI is present then it is not safe to poke around
79 * the other legacy IDE ports. Only 0x1f0 and 0x170 are
80 * defined compatibility mode ports for PCI. A user can
81 * override this using ide= but we must default safe.
83 if (no_pci_devices()) {
99 /* MIPS port and memory-mapped I/O string operations. */
100 static inline void __ide_flush_prologue(void)
103 if (cpu_has_dc_aliases)
108 static inline void __ide_flush_epilogue(void)
111 if (cpu_has_dc_aliases)
116 static inline void __ide_flush_dcache_range(unsigned long addr, unsigned long size)
118 if (cpu_has_dc_aliases) {
119 unsigned long end = addr + size;
122 local_flush_data_cache_page((void *)addr);
129 * insw() and gang might be called with interrupts disabled, so we can't
130 * send IPIs for flushing due to the potencial of deadlocks, see the comment
131 * above smp_call_function() in arch/mips/kernel/smp.c. We work around the
132 * problem by disabling preemption so we know we actually perform the flush
133 * on the processor that actually has the lines to be flushed which hopefully
134 * is even better for performance anyway.
136 static inline void __ide_insw(unsigned long port, void *addr,
139 __ide_flush_prologue();
140 insw(port, addr, count);
141 __ide_flush_dcache_range((unsigned long)addr, count * 2);
142 __ide_flush_epilogue();
145 static inline void __ide_insl(unsigned long port, void *addr, unsigned int count)
147 __ide_flush_prologue();
148 insl(port, addr, count);
149 __ide_flush_dcache_range((unsigned long)addr, count * 4);
150 __ide_flush_epilogue();
153 static inline void __ide_outsw(unsigned long port, const void *addr,
156 __ide_flush_prologue();
157 outsw(port, addr, count);
158 __ide_flush_dcache_range((unsigned long)addr, count * 2);
159 __ide_flush_epilogue();
162 static inline void __ide_outsl(unsigned long port, const void *addr,
165 __ide_flush_prologue();
166 outsl(port, addr, count);
167 __ide_flush_dcache_range((unsigned long)addr, count * 4);
168 __ide_flush_epilogue();
171 static inline void __ide_mm_insw(void __iomem *port, void *addr, u32 count)
173 __ide_flush_prologue();
174 readsw(port, addr, count);
175 __ide_flush_dcache_range((unsigned long)addr, count * 2);
176 __ide_flush_epilogue();
179 static inline void __ide_mm_insl(void __iomem *port, void *addr, u32 count)
181 __ide_flush_prologue();
182 readsl(port, addr, count);
183 __ide_flush_dcache_range((unsigned long)addr, count * 4);
184 __ide_flush_epilogue();
187 static inline void __ide_mm_outsw(void __iomem *port, void *addr, u32 count)
189 __ide_flush_prologue();
190 writesw(port, addr, count);
191 __ide_flush_dcache_range((unsigned long)addr, count * 2);
192 __ide_flush_epilogue();
195 static inline void __ide_mm_outsl(void __iomem * port, void *addr, u32 count)
197 __ide_flush_prologue();
198 writesl(port, addr, count);
199 __ide_flush_dcache_range((unsigned long)addr, count * 4);
200 __ide_flush_epilogue();
203 /* ide_insw calls insw, not __ide_insw. Why? */
208 #define insw(port, addr, count) __ide_insw(port, addr, count)
209 #define insl(port, addr, count) __ide_insl(port, addr, count)
210 #define outsw(port, addr, count) __ide_outsw(port, addr, count)
211 #define outsl(port, addr, count) __ide_outsl(port, addr, count)
213 #endif /* __KERNEL__ */
215 #endif /* __ASM_MACH_GENERIC_IDE_H */