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 #define IDE_ARCH_OBSOLETE_DEFAULTS
32 static __inline__ int ide_probe_legacy(void)
36 if ((dev = pci_get_class(PCI_CLASS_BRIDGE_EISA << 8, NULL)) != NULL ||
37 (dev = pci_get_class(PCI_CLASS_BRIDGE_ISA << 8, NULL)) != NULL) {
43 #elif defined(CONFIG_EISA) || defined(CONFIG_ISA)
50 static __inline__ int ide_default_irq(unsigned long base)
52 if (ide_probe_legacy())
73 static __inline__ unsigned long ide_default_io_base(int index)
75 if (ide_probe_legacy())
96 #define IDE_ARCH_OBSOLETE_INIT
97 #define ide_default_io_ctl(base) ((base) + 0x206) /* obsolete */
99 #ifdef CONFIG_BLK_DEV_IDEPCI
100 #define ide_init_default_irq(base) (0)
102 #define ide_init_default_irq(base) ide_default_irq(base)
105 /* MIPS port and memory-mapped I/O string operations. */
106 static inline void __ide_flush_prologue(void)
109 if (cpu_has_dc_aliases)
114 static inline void __ide_flush_epilogue(void)
117 if (cpu_has_dc_aliases)
122 static inline void __ide_flush_dcache_range(unsigned long addr, unsigned long size)
124 if (cpu_has_dc_aliases) {
125 unsigned long end = addr + size;
128 local_flush_data_cache_page((void *)addr);
135 * insw() and gang might be called with interrupts disabled, so we can't
136 * send IPIs for flushing due to the potencial of deadlocks, see the comment
137 * above smp_call_function() in arch/mips/kernel/smp.c. We work around the
138 * problem by disabling preemption so we know we actually perform the flush
139 * on the processor that actually has the lines to be flushed which hopefully
140 * is even better for performance anyway.
142 static inline void __ide_insw(unsigned long port, void *addr,
145 __ide_flush_prologue();
146 insw(port, addr, count);
147 __ide_flush_dcache_range((unsigned long)addr, count * 2);
148 __ide_flush_epilogue();
151 static inline void __ide_insl(unsigned long port, void *addr, unsigned int count)
153 __ide_flush_prologue();
154 insl(port, addr, count);
155 __ide_flush_dcache_range((unsigned long)addr, count * 4);
156 __ide_flush_epilogue();
159 static inline void __ide_outsw(unsigned long port, const void *addr,
162 __ide_flush_prologue();
163 outsw(port, addr, count);
164 __ide_flush_dcache_range((unsigned long)addr, count * 2);
165 __ide_flush_epilogue();
168 static inline void __ide_outsl(unsigned long port, const void *addr,
171 __ide_flush_prologue();
172 outsl(port, addr, count);
173 __ide_flush_dcache_range((unsigned long)addr, count * 4);
174 __ide_flush_epilogue();
177 static inline void __ide_mm_insw(void __iomem *port, void *addr, u32 count)
179 __ide_flush_prologue();
180 readsw(port, addr, count);
181 __ide_flush_dcache_range((unsigned long)addr, count * 2);
182 __ide_flush_epilogue();
185 static inline void __ide_mm_insl(void __iomem *port, void *addr, u32 count)
187 __ide_flush_prologue();
188 readsl(port, addr, count);
189 __ide_flush_dcache_range((unsigned long)addr, count * 4);
190 __ide_flush_epilogue();
193 static inline void __ide_mm_outsw(void __iomem *port, void *addr, u32 count)
195 __ide_flush_prologue();
196 writesw(port, addr, count);
197 __ide_flush_dcache_range((unsigned long)addr, count * 2);
198 __ide_flush_epilogue();
201 static inline void __ide_mm_outsl(void __iomem * port, void *addr, u32 count)
203 __ide_flush_prologue();
204 writesl(port, addr, count);
205 __ide_flush_dcache_range((unsigned long)addr, count * 4);
206 __ide_flush_epilogue();
209 /* ide_insw calls insw, not __ide_insw. Why? */
214 #define insw(port, addr, count) __ide_insw(port, addr, count)
215 #define insl(port, addr, count) __ide_insl(port, addr, count)
216 #define outsw(port, addr, count) __ide_outsw(port, addr, count)
217 #define outsl(port, addr, count) __ide_outsl(port, addr, count)
219 #endif /* __KERNEL__ */
221 #endif /* __ASM_MACH_GENERIC_IDE_H */