2 * linux/drivers/ide/legacy/macide.c -- Macintosh IDE Driver
4 * Copyright (C) 1998 by Michael Schmitz
6 * This driver was written based on information obtained from the MacOS IDE
7 * driver binary by Mikael Forselius
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
14 #include <linux/types.h>
16 #include <linux/interrupt.h>
17 #include <linux/blkdev.h>
18 #include <linux/hdreg.h>
19 #include <linux/delay.h>
20 #include <linux/ide.h>
22 #include <asm/machw.h>
23 #include <asm/macintosh.h>
24 #include <asm/macints.h>
25 #include <asm/mac_baboon.h>
27 #define IDE_BASE 0x50F1A000 /* Base address of IDE controller */
30 * Generic IDE registers as offsets from the base
31 * These match MkLinux so they should be correct.
35 #define IDE_ERROR 0x04 /* see err-bits */
36 #define IDE_NSECTOR 0x08 /* nr of sectors to read/write */
37 #define IDE_SECTOR 0x0c /* starting sector */
38 #define IDE_LCYL 0x10 /* starting cylinder */
39 #define IDE_HCYL 0x14 /* high byte of starting cyl */
40 #define IDE_SELECT 0x18 /* 101dhhhh , d=drive, hhhh=head */
41 #define IDE_STATUS 0x1c /* see status-bits */
42 #define IDE_CONTROL 0x38 /* control/altstatus */
45 * Mac-specific registers
49 * this register is odd; it doesn't seem to do much and it's
50 * not word-aligned like virtually every other hardware register
54 #define IDE_IFR 0x101 /* (0x101) IDE interrupt flags on Quadra:
56 * Bit 0+1: some interrupt flags
57 * Bit 2+3: some interrupt enable
59 * Bit 5: IDE interrupt flag (any hwif)
60 * Bit 6: maybe IDE interrupt enable (any hwif) ??
61 * Bit 7: Any interrupt condition
64 volatile unsigned char *ide_ifr
= (unsigned char *) (IDE_BASE
+ IDE_IFR
);
66 static int macide_offsets
[IDE_NR_PORTS
] = {
67 IDE_DATA
, IDE_ERROR
, IDE_NSECTOR
, IDE_SECTOR
, IDE_LCYL
,
68 IDE_HCYL
, IDE_SELECT
, IDE_STATUS
, IDE_CONTROL
71 int macide_ack_intr(ide_hwif_t
* hwif
)
73 if (*ide_ifr
& 0x20) {
81 * Probe for a Macintosh IDE interface
84 void macide_init(void)
90 switch (macintosh_config
->ide_type
) {
92 ide_setup_ports(&hw
, IDE_BASE
, macide_offsets
,
93 0, 0, macide_ack_intr
,
96 index
= ide_register_hw(&hw
, 1, &hwif
);
99 ide_setup_ports(&hw
, IDE_BASE
, macide_offsets
,
100 0, 0, macide_ack_intr
,
103 index
= ide_register_hw(&hw
, 1, &hwif
);
106 ide_setup_ports(&hw
, BABOON_BASE
, macide_offsets
,
108 // macide_baboon_iops,
110 index
= ide_register_hw(&hw
, 1, &hwif
);
111 if (index
== -1) break;
112 if (macintosh_config
->ident
== MAC_MODEL_PB190
) {
114 /* Fix breakage in ide-disk.c: drive capacity */
115 /* is not initialized for drives without a */
116 /* hardware ID, and we can't get that without */
117 /* probing the drive which freezes a 190. */
119 ide_drive_t
*drive
= &ide_hwifs
[index
].drives
[0];
120 drive
->capacity64
= drive
->cyl
*drive
->head
*drive
->sect
;
131 if (macintosh_config
->ide_type
== MAC_IDE_QUADRA
)
132 printk(KERN_INFO
"ide%d: Macintosh Quadra IDE interface\n", index
);
133 else if (macintosh_config
->ide_type
== MAC_IDE_PB
)
134 printk(KERN_INFO
"ide%d: Macintosh Powerbook IDE interface\n", index
);
135 else if (macintosh_config
->ide_type
== MAC_IDE_BABOON
)
136 printk(KERN_INFO
"ide%d: Macintosh Powerbook Baboon IDE interface\n", index
);
138 printk(KERN_INFO
"ide%d: Unknown Macintosh IDE interface\n", index
);