aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/legacy/macide.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/ide/legacy/macide.c
Linux-2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'drivers/ide/legacy/macide.c')
-rw-r--r--drivers/ide/legacy/macide.c155
1 files changed, 155 insertions, 0 deletions
diff --git a/drivers/ide/legacy/macide.c b/drivers/ide/legacy/macide.c
new file mode 100644
index 00000000000..90cac609d9c
--- /dev/null
+++ b/drivers/ide/legacy/macide.c
@@ -0,0 +1,155 @@
1/*
2 * linux/drivers/ide/legacy/macide.c -- Macintosh IDE Driver
3 *
4 * Copyright (C) 1998 by Michael Schmitz
5 *
6 * This driver was written based on information obtained from the MacOS IDE
7 * driver binary by Mikael Forselius
8 *
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file COPYING in the main directory of this archive for
11 * more details.
12 */
13
14#include <linux/config.h>
15#include <linux/types.h>
16#include <linux/mm.h>
17#include <linux/interrupt.h>
18#include <linux/blkdev.h>
19#include <linux/hdreg.h>
20#include <linux/delay.h>
21#include <linux/ide.h>
22
23#include <asm/machw.h>
24#include <asm/macintosh.h>
25#include <asm/macints.h>
26#include <asm/mac_baboon.h>
27
28#define IDE_BASE 0x50F1A000 /* Base address of IDE controller */
29
30/*
31 * Generic IDE registers as offsets from the base
32 * These match MkLinux so they should be correct.
33 */
34
35#define IDE_DATA 0x00
36#define IDE_ERROR 0x04 /* see err-bits */
37#define IDE_NSECTOR 0x08 /* nr of sectors to read/write */
38#define IDE_SECTOR 0x0c /* starting sector */
39#define IDE_LCYL 0x10 /* starting cylinder */
40#define IDE_HCYL 0x14 /* high byte of starting cyl */
41#define IDE_SELECT 0x18 /* 101dhhhh , d=drive, hhhh=head */
42#define IDE_STATUS 0x1c /* see status-bits */
43#define IDE_CONTROL 0x38 /* control/altstatus */
44
45/*
46 * Mac-specific registers
47 */
48
49/*
50 * this register is odd; it doesn't seem to do much and it's
51 * not word-aligned like virtually every other hardware register
52 * on the Mac...
53 */
54
55#define IDE_IFR 0x101 /* (0x101) IDE interrupt flags on Quadra:
56 *
57 * Bit 0+1: some interrupt flags
58 * Bit 2+3: some interrupt enable
59 * Bit 4: ??
60 * Bit 5: IDE interrupt flag (any hwif)
61 * Bit 6: maybe IDE interrupt enable (any hwif) ??
62 * Bit 7: Any interrupt condition
63 */
64
65volatile unsigned char *ide_ifr = (unsigned char *) (IDE_BASE + IDE_IFR);
66
67static int macide_offsets[IDE_NR_PORTS] = {
68 IDE_DATA, IDE_ERROR, IDE_NSECTOR, IDE_SECTOR, IDE_LCYL,
69 IDE_HCYL, IDE_SELECT, IDE_STATUS, IDE_CONTROL
70};
71
72int macide_ack_intr(ide_hwif_t* hwif)
73{
74 if (*ide_ifr & 0x20) {
75 *ide_ifr &= ~0x20;
76 return 1;
77 }
78 return 0;
79}
80
81#ifdef CONFIG_BLK_DEV_MAC_MEDIABAY
82static void macide_mediabay_interrupt(int irq, void *dev_id, struct pt_regs *regs)
83{
84 int state = baboon->mb_status & 0x04;
85
86 printk(KERN_INFO "macide: media bay %s detected\n", state? "removal":"insertion");
87}
88#endif
89
90/*
91 * Probe for a Macintosh IDE interface
92 */
93
94void macide_init(void)
95{
96 hw_regs_t hw;
97 ide_hwif_t *hwif;
98 int index = -1;
99
100 switch (macintosh_config->ide_type) {
101 case MAC_IDE_QUADRA:
102 ide_setup_ports(&hw, IDE_BASE, macide_offsets,
103 0, 0, macide_ack_intr,
104// quadra_ide_iops,
105 IRQ_NUBUS_F);
106 index = ide_register_hw(&hw, &hwif);
107 break;
108 case MAC_IDE_PB:
109 ide_setup_ports(&hw, IDE_BASE, macide_offsets,
110 0, 0, macide_ack_intr,
111// macide_pb_iops,
112 IRQ_NUBUS_C);
113 index = ide_register_hw(&hw, &hwif);
114 break;
115 case MAC_IDE_BABOON:
116 ide_setup_ports(&hw, BABOON_BASE, macide_offsets,
117 0, 0, NULL,
118// macide_baboon_iops,
119 IRQ_BABOON_1);
120 index = ide_register_hw(&hw, &hwif);
121 if (index == -1) break;
122 if (macintosh_config->ident == MAC_MODEL_PB190) {
123
124 /* Fix breakage in ide-disk.c: drive capacity */
125 /* is not initialized for drives without a */
126 /* hardware ID, and we can't get that without */
127 /* probing the drive which freezes a 190. */
128
129 ide_drive_t *drive = &ide_hwifs[index].drives[0];
130 drive->capacity64 = drive->cyl*drive->head*drive->sect;
131
132#ifdef CONFIG_BLK_DEV_MAC_MEDIABAY
133 request_irq(IRQ_BABOON_2, macide_mediabay_interrupt,
134 IRQ_FLG_FAST, "mediabay",
135 macide_mediabay_interrupt);
136#endif
137 }
138 break;
139
140 default:
141 return;
142 }
143
144 if (index != -1) {
145 hwif->mmio = 2;
146 if (macintosh_config->ide_type == MAC_IDE_QUADRA)
147 printk(KERN_INFO "ide%d: Macintosh Quadra IDE interface\n", index);
148 else if (macintosh_config->ide_type == MAC_IDE_PB)
149 printk(KERN_INFO "ide%d: Macintosh Powerbook IDE interface\n", index);
150 else if (macintosh_config->ide_type == MAC_IDE_BABOON)
151 printk(KERN_INFO "ide%d: Macintosh Powerbook Baboon IDE interface\n", index);
152 else
153 printk(KERN_INFO "ide%d: Unknown Macintosh IDE interface\n", index);
154 }
155}