ide.h 4.06 KB
Newer Older
Linus Torvalds's avatar
Linus Torvalds committed
1 2 3 4 5
/*
 *  linux/include/asm-m68k/ide.h
 *
 *  Copyright (C) 1994-1996  Linus Torvalds & authors
 */
6

Linus Torvalds's avatar
Linus Torvalds committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
/* Copyright(c) 1996 Kars de Jong */
/* Based on the ide driver from 1.2.13pl8 */

/*
 * Credits (alphabetical):
 *
 *  - Bjoern Brauel
 *  - Kars de Jong
 *  - Torsten Ebeling
 *  - Dwight Engen
 *  - Thorsten Floeck
 *  - Roman Hodek
 *  - Guenther Kelleter
 *  - Chris Lawrence
 *  - Michael Rausch
 *  - Christian Sauer
 *  - Michael Schmitz
 *  - Jes Soerensen
 *  - Michael Thurm
 *  - Geert Uytterhoeven
 */

#ifndef _M68K_IDE_H
#define _M68K_IDE_H

#ifdef __KERNEL__

#include <linux/config.h>

#include <asm/setup.h>
#include <asm/io.h>
#include <asm/irq.h>

#ifdef CONFIG_ATARI
#include <linux/interrupt.h>
#include <asm/atari_stdma.h>
#endif

#ifdef CONFIG_MAC
#include <asm/macints.h>
#endif

#ifndef MAX_HWIFS
#define MAX_HWIFS	4	/* same as the other archs */
#endif


54
static __inline__ int ide_default_irq(unsigned long base)
Linus Torvalds's avatar
Linus Torvalds committed
55 56 57 58
{
	  return 0;
}

59
static __inline__ unsigned long ide_default_io_base(int index)
Linus Torvalds's avatar
Linus Torvalds committed
60 61 62 63 64 65 66 67 68
{
          return 0;
}


/*
 * Set up a hw structure for a specified data port, control port and IRQ.
 * This should follow whatever the default interface uses.
 */
69 70 71
static __inline__ void ide_init_hwif_ports(hw_regs_t *hw,
					   unsigned long data_port,
					   unsigned long ctrl_port, int *irq)
Linus Torvalds's avatar
Linus Torvalds committed
72 73 74 75 76
{
	if (data_port || ctrl_port)
		printk("ide_init_hwif_ports: must not be called\n");
}

77
#define ide_init_default_irq(base)	(0)
Linus Torvalds's avatar
Linus Torvalds committed
78

Geert Uytterhoeven's avatar
Geert Uytterhoeven committed
79 80 81 82 83
/*
 * Get rid of defs from io.h - ide has its private and conflicting versions
 * Since so far no single m68k platform uses ISA/PCI I/O space for IDE, we
 * always use the `raw' MMIO versions
 */
Linus Torvalds's avatar
Linus Torvalds committed
84 85
#undef inb
#undef inw
Geert Uytterhoeven's avatar
Geert Uytterhoeven committed
86 87 88
#undef insw
#undef inl
#undef insl
Linus Torvalds's avatar
Linus Torvalds committed
89 90 91
#undef outb
#undef outw
#undef outsw
Geert Uytterhoeven's avatar
Geert Uytterhoeven committed
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
#undef outl
#undef outsl
#undef readb
#undef readw
#undef readl
#undef writeb
#undef writew
#undef writel

#define inb				in_8
#define inw				in_be16
#define insw(port, addr, n)		raw_insw((u16 *)port, addr, n)
#define inl				in_be32
#define insl(port, addr, n)		raw_insl((u32 *)port, addr, n)
#define outb(val, port)			out_8(port, val)
#define outw(val, port)			out_be16(port, val)
#define outsw(port, addr, n)		raw_outsw((u16 *)port, addr, n)
#define outl(val, port)			out_be32(port, val)
#define outsl(port, addr, n)		raw_outsl((u32 *)port, addr, n)
#define readb				in_8
#define readw				in_be16
#define __ide_mm_insw(port, addr, n)	raw_insw((u16 *)port, addr, n)
#define readl				in_be32
#define __ide_mm_insl(port, addr, n)	raw_insl((u32 *)port, addr, n)
#define writeb(val, port)		out_8(port, val)
#define writew(val, port)		out_be16(port, val)
#define __ide_mm_outsw(port, addr, n)	raw_outsw((u16 *)port, addr, n)
#define writel(val, port)		out_be32(port, val)
#define __ide_mm_outsl(port, addr, n)	raw_outsl((u32 *)port, addr, n)
Linus Torvalds's avatar
Linus Torvalds committed
121
#if defined(CONFIG_ATARI) || defined(CONFIG_Q40)
Geert Uytterhoeven's avatar
Geert Uytterhoeven committed
122 123 124
#define insw_swapw(port, addr, n)	raw_insw_swapw((u16 *)port, addr, n)
#define outsw_swapw(port, addr, n)	raw_outsw_swapw((u16 *)port, addr, n)
#endif
Linus Torvalds's avatar
Linus Torvalds committed
125

Linus Torvalds's avatar
Linus Torvalds committed
126

Geert Uytterhoeven's avatar
Geert Uytterhoeven committed
127 128 129 130 131 132 133
/* Q40 and Atari have byteswapped IDE busses and since many interesting
 * values in the identification string are text, chars and words they
 * happened to be almost correct without swapping.. However *_capacity
 * is needed for drives over 8 GB. RZ */
#if defined(CONFIG_Q40) || defined(CONFIG_ATARI)
#define M68K_IDE_SWAPW  (MACH_IS_Q40 || MACH_IS_ATARI)
#endif
Martin Dalecki's avatar
Martin Dalecki committed
134

135
#ifdef CONFIG_BLK_DEV_FALCON_IDE
Geert Uytterhoeven's avatar
Geert Uytterhoeven committed
136
#define IDE_ARCH_LOCK
Linus Torvalds's avatar
Linus Torvalds committed
137

138
extern int falconide_intr_lock;
139 140

static __inline__ void ide_release_lock (void)
Linus Torvalds's avatar
Linus Torvalds committed
141 142
{
	if (MACH_IS_ATARI) {
143
		if (falconide_intr_lock == 0) {
Linus Torvalds's avatar
Linus Torvalds committed
144 145 146
			printk("ide_release_lock: bug\n");
			return;
		}
147
		falconide_intr_lock = 0;
Linus Torvalds's avatar
Linus Torvalds committed
148 149 150 151
		stdma_release();
	}
}

152 153
static __inline__ void
ide_get_lock(irqreturn_t (*handler)(int, void *, struct pt_regs *), void *data)
Linus Torvalds's avatar
Linus Torvalds committed
154 155
{
	if (MACH_IS_ATARI) {
156
		if (falconide_intr_lock == 0) {
Linus Torvalds's avatar
Linus Torvalds committed
157 158 159
			if (in_interrupt() > 0)
				panic( "Falcon IDE hasn't ST-DMA lock in interrupt" );
			stdma_lock(handler, data);
160
			falconide_intr_lock = 1;
Linus Torvalds's avatar
Linus Torvalds committed
161 162 163
		}
	}
}
164
#endif /* CONFIG_BLK_DEV_FALCON_IDE */
Geert Uytterhoeven's avatar
Geert Uytterhoeven committed
165 166 167 168

#define IDE_ARCH_ACK_INTR
#define ide_ack_intr(hwif)	((hwif)->hw.ack_intr ? (hwif)->hw.ack_intr(hwif) : 1)

Linus Torvalds's avatar
Linus Torvalds committed
169 170
#endif /* __KERNEL__ */
#endif /* _M68K_IDE_H */