2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file "COPYING" in the main directory of this archive
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1994-1996 Linus Torvalds & authors
|
|
|
|
*
|
|
|
|
* Copied from i386; many of the especially older MIPS or ISA-based platforms
|
|
|
|
* are basically identical. Using this file probably implies i8259 PIC
|
|
|
|
* support in a system but the very least interrupt numbers 0 - 15 need to
|
|
|
|
* be put aside for legacy devices.
|
|
|
|
*/
|
|
|
|
#ifndef __ASM_MACH_GENERIC_IDE_H
|
|
|
|
#define __ASM_MACH_GENERIC_IDE_H
|
|
|
|
|
|
|
|
#ifdef __KERNEL__
|
|
|
|
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/stddef.h>
|
2005-04-19 06:26:59 -06:00
|
|
|
#include <asm/processor.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
#ifndef MAX_HWIFS
|
|
|
|
# ifdef CONFIG_BLK_DEV_IDEPCI
|
|
|
|
#define MAX_HWIFS 10
|
|
|
|
# else
|
|
|
|
#define MAX_HWIFS 6
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define IDE_ARCH_OBSOLETE_DEFAULTS
|
|
|
|
|
2007-09-04 08:02:02 -06:00
|
|
|
static __inline__ int ide_probe_legacy(void)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_PCI
|
|
|
|
struct pci_dev *dev;
|
|
|
|
/*
|
|
|
|
* This can be called on the ide_setup() path, super-early in
|
|
|
|
* boot. But the down_read() will enable local interrupts,
|
|
|
|
* which can cause some machines to crash. So here we detect
|
|
|
|
* and flag that situation and bail out early.
|
|
|
|
*/
|
|
|
|
if (no_pci_devices())
|
|
|
|
return 0;
|
|
|
|
dev = pci_get_class(PCI_CLASS_BRIDGE_EISA << 8, NULL);
|
|
|
|
if (dev)
|
|
|
|
goto found;
|
|
|
|
dev = pci_get_class(PCI_CLASS_BRIDGE_ISA << 8, NULL);
|
|
|
|
if (dev)
|
|
|
|
goto found;
|
|
|
|
return 0;
|
|
|
|
found:
|
|
|
|
pci_dev_put(dev);
|
|
|
|
return 1;
|
|
|
|
#elif defined(CONFIG_EISA) || defined(CONFIG_ISA)
|
|
|
|
return 1;
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
static __inline__ int ide_default_irq(unsigned long base)
|
|
|
|
{
|
2007-08-07 10:18:28 -06:00
|
|
|
switch (base) {
|
|
|
|
case 0x1f0: return 14;
|
|
|
|
case 0x170: return 15;
|
|
|
|
case 0x1e8: return 11;
|
|
|
|
case 0x168: return 10;
|
|
|
|
case 0x1e0: return 8;
|
|
|
|
case 0x160: return 12;
|
2005-04-16 16:20:36 -06:00
|
|
|
default:
|
|
|
|
return 0;
|
2007-08-07 10:18:28 -06:00
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline__ unsigned long ide_default_io_base(int index)
|
|
|
|
{
|
2007-09-04 08:02:02 -06:00
|
|
|
if (!ide_probe_legacy())
|
|
|
|
return 0;
|
2007-08-07 10:18:28 -06:00
|
|
|
/*
|
|
|
|
* If PCI is present then it is not safe to poke around
|
|
|
|
* the other legacy IDE ports. Only 0x1f0 and 0x170 are
|
|
|
|
* defined compatibility mode ports for PCI. A user can
|
|
|
|
* override this using ide= but we must default safe.
|
|
|
|
*/
|
|
|
|
if (no_pci_devices()) {
|
2005-04-16 16:20:36 -06:00
|
|
|
switch (index) {
|
2007-08-07 10:18:28 -06:00
|
|
|
case 2: return 0x1e8;
|
|
|
|
case 3: return 0x168;
|
|
|
|
case 4: return 0x1e0;
|
|
|
|
case 5: return 0x160;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
2007-08-07 10:18:28 -06:00
|
|
|
}
|
|
|
|
switch (index) {
|
|
|
|
case 0: return 0x1f0;
|
|
|
|
case 1: return 0x170;
|
|
|
|
default:
|
2005-04-16 16:20:36 -06:00
|
|
|
return 0;
|
2007-08-07 10:18:28 -06:00
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#define ide_default_io_ctl(base) ((base) + 0x206) /* obsolete */
|
|
|
|
|
|
|
|
#ifdef CONFIG_BLK_DEV_IDEPCI
|
|
|
|
#define ide_init_default_irq(base) (0)
|
|
|
|
#else
|
|
|
|
#define ide_init_default_irq(base) ide_default_irq(base)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* MIPS port and memory-mapped I/O string operations. */
|
2006-04-05 13:42:04 -06:00
|
|
|
static inline void __ide_flush_prologue(void)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
if (cpu_has_dc_aliases)
|
|
|
|
preempt_disable();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void __ide_flush_epilogue(void)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
if (cpu_has_dc_aliases)
|
|
|
|
preempt_enable();
|
|
|
|
#endif
|
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-04-19 06:26:59 -06:00
|
|
|
static inline void __ide_flush_dcache_range(unsigned long addr, unsigned long size)
|
|
|
|
{
|
|
|
|
if (cpu_has_dc_aliases) {
|
|
|
|
unsigned long end = addr + size;
|
2006-04-05 13:42:04 -06:00
|
|
|
|
|
|
|
while (addr < end) {
|
|
|
|
local_flush_data_cache_page((void *)addr);
|
|
|
|
addr += PAGE_SIZE;
|
|
|
|
}
|
2005-04-19 06:26:59 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-05 13:42:04 -06:00
|
|
|
/*
|
|
|
|
* insw() and gang might be called with interrupts disabled, so we can't
|
|
|
|
* send IPIs for flushing due to the potencial of deadlocks, see the comment
|
|
|
|
* above smp_call_function() in arch/mips/kernel/smp.c. We work around the
|
|
|
|
* problem by disabling preemption so we know we actually perform the flush
|
|
|
|
* on the processor that actually has the lines to be flushed which hopefully
|
|
|
|
* is even better for performance anyway.
|
|
|
|
*/
|
2005-04-19 06:26:59 -06:00
|
|
|
static inline void __ide_insw(unsigned long port, void *addr,
|
|
|
|
unsigned int count)
|
|
|
|
{
|
2006-04-05 13:42:04 -06:00
|
|
|
__ide_flush_prologue();
|
2005-04-19 06:26:59 -06:00
|
|
|
insw(port, addr, count);
|
|
|
|
__ide_flush_dcache_range((unsigned long)addr, count * 2);
|
2006-04-05 13:42:04 -06:00
|
|
|
__ide_flush_epilogue();
|
2005-04-19 06:26:59 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void __ide_insl(unsigned long port, void *addr, unsigned int count)
|
|
|
|
{
|
2006-04-05 13:42:04 -06:00
|
|
|
__ide_flush_prologue();
|
2005-04-19 06:26:59 -06:00
|
|
|
insl(port, addr, count);
|
|
|
|
__ide_flush_dcache_range((unsigned long)addr, count * 4);
|
2006-04-05 13:42:04 -06:00
|
|
|
__ide_flush_epilogue();
|
2005-04-19 06:26:59 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void __ide_outsw(unsigned long port, const void *addr,
|
|
|
|
unsigned long count)
|
|
|
|
{
|
2006-04-05 13:42:04 -06:00
|
|
|
__ide_flush_prologue();
|
2005-04-19 06:26:59 -06:00
|
|
|
outsw(port, addr, count);
|
|
|
|
__ide_flush_dcache_range((unsigned long)addr, count * 2);
|
2006-04-05 13:42:04 -06:00
|
|
|
__ide_flush_epilogue();
|
2005-04-19 06:26:59 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void __ide_outsl(unsigned long port, const void *addr,
|
|
|
|
unsigned long count)
|
|
|
|
{
|
2006-04-05 13:42:04 -06:00
|
|
|
__ide_flush_prologue();
|
2005-04-19 06:26:59 -06:00
|
|
|
outsl(port, addr, count);
|
|
|
|
__ide_flush_dcache_range((unsigned long)addr, count * 4);
|
2006-04-05 13:42:04 -06:00
|
|
|
__ide_flush_epilogue();
|
2005-04-19 06:26:59 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void __ide_mm_insw(void __iomem *port, void *addr, u32 count)
|
|
|
|
{
|
2006-04-05 13:42:04 -06:00
|
|
|
__ide_flush_prologue();
|
2005-04-19 06:26:59 -06:00
|
|
|
readsw(port, addr, count);
|
|
|
|
__ide_flush_dcache_range((unsigned long)addr, count * 2);
|
2006-04-05 13:42:04 -06:00
|
|
|
__ide_flush_epilogue();
|
2005-04-19 06:26:59 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void __ide_mm_insl(void __iomem *port, void *addr, u32 count)
|
|
|
|
{
|
2006-04-05 13:42:04 -06:00
|
|
|
__ide_flush_prologue();
|
2005-04-19 06:26:59 -06:00
|
|
|
readsl(port, addr, count);
|
|
|
|
__ide_flush_dcache_range((unsigned long)addr, count * 4);
|
2006-04-05 13:42:04 -06:00
|
|
|
__ide_flush_epilogue();
|
2005-04-19 06:26:59 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void __ide_mm_outsw(void __iomem *port, void *addr, u32 count)
|
|
|
|
{
|
2006-04-05 13:42:04 -06:00
|
|
|
__ide_flush_prologue();
|
2005-04-19 06:26:59 -06:00
|
|
|
writesw(port, addr, count);
|
|
|
|
__ide_flush_dcache_range((unsigned long)addr, count * 2);
|
2006-04-05 13:42:04 -06:00
|
|
|
__ide_flush_epilogue();
|
2005-04-19 06:26:59 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void __ide_mm_outsl(void __iomem * port, void *addr, u32 count)
|
|
|
|
{
|
2006-04-05 13:42:04 -06:00
|
|
|
__ide_flush_prologue();
|
2005-04-19 06:26:59 -06:00
|
|
|
writesl(port, addr, count);
|
|
|
|
__ide_flush_dcache_range((unsigned long)addr, count * 4);
|
2006-04-05 13:42:04 -06:00
|
|
|
__ide_flush_epilogue();
|
2005-04-19 06:26:59 -06:00
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-04-19 06:26:59 -06:00
|
|
|
/* ide_insw calls insw, not __ide_insw. Why? */
|
|
|
|
#undef insw
|
|
|
|
#undef insl
|
2005-11-06 07:58:21 -07:00
|
|
|
#undef outsw
|
|
|
|
#undef outsl
|
2005-04-19 06:26:59 -06:00
|
|
|
#define insw(port, addr, count) __ide_insw(port, addr, count)
|
|
|
|
#define insl(port, addr, count) __ide_insl(port, addr, count)
|
2005-11-06 07:58:21 -07:00
|
|
|
#define outsw(port, addr, count) __ide_outsw(port, addr, count)
|
|
|
|
#define outsl(port, addr, count) __ide_outsl(port, addr, count)
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
#endif /* __KERNEL__ */
|
|
|
|
|
|
|
|
#endif /* __ASM_MACH_GENERIC_IDE_H */
|