Date: Tue, 19 Aug 1997 08:13:33 +0200 (CEST)
From: Geert Uytterhoeven <Geert.Uytterhoeven@cs.kuleuven.ac.be>
To: linux-m68k@phil.uni-sb.de
Subject: Re: L68K: newer kernels
In-Reply-To: <Pine.LNX.3.96.970818093124.15962B-100000@mercator.cs.kuleuven.ac.be>
Sender: owner-linux-m68k@phil.uni-sb.de
Reply-To: linux-m68k@phil.uni-sb.de

On Mon, 18 Aug 1997, I wrote:
> We're also getting a bit out of sync with IDE (support for IDE doublers and
> Buddha/Catweasel), but I think Mark Lord and Gadi Oxman will accept my patches
> if I send them. But I'm _not_ going to do that until the code was actually
> tested (Hi doubler and Buddha/Catweasel beta testers!)!!.

This patch fixes the only objection that `the IDE guys' had against my patch.
It moves all low-level hardware drivers from *.c to *.h files and #includes
them in ide.c instead of compiling them as separate object files. This allows
ide.o to be a module again.

--- linux-2.1.47/drivers/block/falcon_ide.c.orig	Tue Jul 29 19:59:08 1997
+++ linux-2.1.47/drivers/block/falcon_ide.c	Mon Aug 18 21:24:50 1997
@@ -1,74 +0,0 @@
-/*
- *  linux/drivers/block/falcon-ide.c -- Atari Falcon IDE Driver
- *
- *	Created 12 Jul 1997 by Geert Uytterhoeven
- *
- *  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.
- */
-
-
-#include <linux/types.h>
-#include <linux/mm.h>
-#include <linux/interrupt.h>
-#include <linux/blkdev.h>
-#include <linux/hdreg.h>
-
-#include "ide.h"
-
-#include <asm/atarihw.h>
-#include <asm/atarihdreg.h>
-#include <asm/atariints.h>
-#include <asm/atari_stdma.h>
-
-
-    /*
-     *  Base of the IDE interface
-     */
-
-#define ATA_HD_BASE	0xfff00000
-
-    /*
-     *  Offsets from the above base
-     */
-
-#define ATA_HD_DATA	0x00
-#define ATA_HD_ERROR	0x05		/* see err-bits */
-#define ATA_HD_NSECTOR	0x09		/* nr of sectors to read/write */
-#define ATA_HD_SECTOR	0x0d		/* starting sector */
-#define ATA_HD_LCYL	0x11		/* starting cylinder */
-#define ATA_HD_HCYL	0x15		/* high byte of starting cyl */
-#define ATA_HD_SELECT	0x19		/* 101dhhhh , d=drive, hhhh=head */
-#define ATA_HD_STATUS	0x1d		/* see status-bits */
-#define ATA_HD_CONTROL	0x39
-
-const int falconide_offsets[IDE_NR_PORTS] = {
-    ATA_HD_DATA, ATA_HD_ERROR, ATA_HD_NSECTOR, ATA_HD_SECTOR, ATA_HD_LCYL,
-    ATA_HD_HCYL, ATA_HD_SELECT, ATA_HD_STATUS, ATA_HD_CONTROL
-};
-
-
-    /*
-     *  Probe for a Falcon IDE interface
-     */
-
-int falconide_probe_hwif(int index, ide_hwif_t *hwif)
-{
-    static int falcon_index = 0;
-
-    if (!MACH_IS_ATARI || !ATARIHW_PRESENT(IDE))
-	return 0;
-
-    if (!falcon_index) {
-	printk("ide%d: Falcon IDE interface\n", index);
-	falcon_index = index+1;
-    }
-    if (falcon_index == index+1) {
-	ide_setup_ports(hwif, (ide_ioreg_t)ATA_HD_BASE, falconide_offsets, 0,
-			NULL);
-	hwif->irq = IRQ_MFP_IDE;
-	return 1;
-    }
-    return 0;
-}
--- linux-2.1.47/drivers/block/falcon_ide.h.orig	Mon Aug 18 21:21:49 1997
+++ linux-2.1.47/drivers/block/falcon_ide.h	Mon Aug 18 21:38:51 1997
@@ -0,0 +1,78 @@
+/*
+ *  linux/drivers/block/falcon-ide.h -- Atari Falcon IDE Driver
+ *
+ *	Created 12 Jul 1997 by Geert Uytterhoeven
+ *
+ *  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.
+ */
+
+
+#include <asm/atarihw.h>
+#include <asm/atarihdreg.h>
+#include <asm/atariints.h>
+#include <asm/atari_stdma.h>
+
+
+    /*
+     *  Base of the IDE interface
+     */
+
+#define ATA_HD_BASE	0xfff00000
+
+    /*
+     *  Offsets from the above base
+     */
+
+#define ATA_HD_DATA	0x00
+#define ATA_HD_ERROR	0x05		/* see err-bits */
+#define ATA_HD_NSECTOR	0x09		/* nr of sectors to read/write */
+#define ATA_HD_SECTOR	0x0d		/* starting sector */
+#define ATA_HD_LCYL	0x11		/* starting cylinder */
+#define ATA_HD_HCYL	0x15		/* high byte of starting cyl */
+#define ATA_HD_SELECT	0x19		/* 101dhhhh , d=drive, hhhh=head */
+#define ATA_HD_STATUS	0x1d		/* see status-bits */
+#define ATA_HD_CONTROL	0x39
+
+const int falconide_offsets[IDE_NR_PORTS] = {
+    ATA_HD_DATA, ATA_HD_ERROR, ATA_HD_NSECTOR, ATA_HD_SECTOR, ATA_HD_LCYL,
+    ATA_HD_HCYL, ATA_HD_SELECT, ATA_HD_STATUS, ATA_HD_CONTROL
+};
+
+
+    /*
+     *  Probe for a Falcon IDE interface
+     */
+
+int falconide_probe_hwif(int index, ide_hwif_t *hwif)
+{
+    static int falcon_index = 0;
+
+    if (!MACH_IS_ATARI || !ATARIHW_PRESENT(IDE))
+	return 0;
+
+    if (!falcon_index) {
+	printk("ide%d: Falcon IDE interface\n", index);
+	falcon_index = index+1;
+    }
+    if (falcon_index == index+1) {
+	ide_setup_ports(hwif, (ide_ioreg_t)ATA_HD_BASE, falconide_offsets, 0,
+			NULL);
+	hwif->irq = IRQ_MFP_IDE;
+	return 1;
+    }
+    return 0;
+}
+
+
+#undef ATA_HD_BASE
+#undef ATA_HD_DATA
+#undef ATA_HD_ERROR
+#undef ATA_HD_NSECTOR
+#undef ATA_HD_SECTOR
+#undef ATA_HD_LCYL
+#undef ATA_HD_HCYL
+#undef ATA_HD_SELECT
+#undef ATA_HD_STATUS
+#undef ATA_HD_CONTROL
--- linux-2.1.47/drivers/block/buddha.c.orig	Tue Jul 29 19:59:08 1997
+++ linux-2.1.47/drivers/block/buddha.c	Mon Aug 18 21:22:30 1997
@@ -1,373 +0,0 @@
-/*
- *  linux/drivers/block/buddha.c -- Amiga Buddha and Catweasel IDE Driver
- *
- *	Copyright (C) 1997 by Geert Uytterhoeven
- *
- *  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.
- *
- *  The driver was written based on the following specifications:
- *
- *  ---------------------------------------------------------------------------
- *  Register map of the Buddha IDE controller and the
- *  Buddha-part of the Catweasel Zorro-II version
- *  
- *  The Autoconfiguration has been implemented just as Commodore
- *  described  in  their  manuals, no tricks have been used (for
- *  example leaving some address lines out of the equations...).
- *  If you want to configure the board yourself (for example let
- *  a  Linux  kernel  configure the card), look at the Commodore
- *  Docs.  Reading the nibbles should give this information:
- *  
- *  Vendor number: 4626 ($1212)
- *  product number: 0 (42 for Catweasel Z-II)
- *  Serial number: 0
- *  Rom-vector: $1000
- *  
- *  The  card  should be a Z-II board, size 64K, not for freemem
- *  list, Rom-Vektor is valid, no second Autoconfig-board on the
- *  same card, no space preferrence, supports "Shutup_forever".
- *  
- *  Setting  the  base address should be done in two steps, just
- *  as  the Amiga Kickstart does:  The lower nibble of the 8-Bit
- *  address is written to $4a, then the whole Byte is written to
- *  $48, while it doesn't matter how often you're writing to $4a
- *  as  long as $48 is not touched.  After $48 has been written,
- *  the  whole card disappears from $e8 and is mapped to the new
- *  addrress just written.  Make shure $4a is written befor $48,
- *  otherwise your chance is only 1:16 to find the board :-).
- *  
- *  The local memory-map is even active when mapped to $e8:
- *  
- *  $0-$7e	Autokonfig-space, see Z-II docs.
- *  
- *  $80-$7fd	reserved
- *  
- *  $7fe	Speed-select Register: Read & Write
- *  		(description see further down)
- *  
- *  $800-$8ff	IDE-Select 0 (Port 0, Register set 0)
- *  
- *  $900-$9ff	IDE-Select 1 (Port 0, Register set 1)
- *  
- *  $a00-$aff	IDE-Select 2 (Port 1, Register set 0)
- *  
- *  $b00-$bff	IDE-Select 3 (Port 1, Register set 1)
- *  
- *  $c00-$cff	IDE-Select 4 (Port 2, Register set 0,
- *                            Catweasel only!)
- *  
- *  $d00-$dff	IDE-Select 5 (Port 3, Register set 1,
- *  			      Catweasel only!)
- *  
- *  $e00-$eff	local expansion port, on Catweasel Z-II the 
- *  		Catweasel registers are also mapped here.
- *  		Never touch, use multidisk.device!
- *  		
- *  $f00	read only, Byte-access: Bit 7 shows the 
- *  		level of the IRQ-line of IDE port 0. 
- *  
- *  $f01-$f3f	mirror of $f00
- *  
- *  $f40	read only, Byte-access: Bit 7 shows the 
- *  		level of the IRQ-line of IDE port 1. 
- *  
- *  $f41-$f7f	mirror of $f40
- *  
- *  $f80	read only, Byte-access: Bit 7 shows the 
- *  		level of the IRQ-line of IDE port 2. 
- *  		(Catweasel only!)
- *  
- *  $f81-$fbf	mirror of $f80
- *  
- *  $fc0	write-only: Writing any value to this
- *  		register enables IRQs to be passed from the 
- *  		IDE ports to the Zorro bus. This mechanism 
- *  		has been implemented to be compatible with 
- *  		harddisks that are either defective or have
- *  		a buggy firmware and pull the IRQ line up 
- *  		while starting up. If interrupts would 
- *  		always be passed to the bus, the computer 
- *  		might not start up. Once enabled, this flag 
- *  		can not be disabled again. The level of the 
- *  		flag can not be determined by software 
- *  		(what for? Write to me if it's necessary!).
- *  
- *  $fc1-$fff	mirror of $fc0
- *  
- *  $1000-$ffff	Buddha-Rom with offset $1000 in the rom
- *  		chip. The addresses $0 to $fff of the rom 
- *  		chip cannot be read. Rom is Byte-wide and
- *  		mapped to even addresses.
- *  
- *  The  IDE ports issue an INT2.  You can read the level of the
- *  IRQ-lines  of  the  IDE-ports by reading from the three (two
- *  for  Buddha-only)  registers  $f00, $f40 and $f80.  This way
- *  more  than one I/O request can be handled and you can easily
- *  determine  what  driver  has  to serve the INT2.  Buddha and
- *  Catweasel  expansion  boards  can issue an INT6.  A seperate
- *  memory  map  is available for the I/O module and the sysop's
- *  I/O module.
- *  
- *  The IDE ports are fed by the address lines A2 to A4, just as
- *  the  Amiga  1200  and  Amiga  4000  IDE ports are.  This way
- *  existing  drivers  can be easily ported to Buddha.  A move.l
- *  polls  two  words  out of the same address of IDE port since
- *  every  word  is  mirrored  once.  movem is not possible, but
- *  it's  not  necessary  either,  because  you can only speedup
- *  68000  systems  with  this  technique.   A 68020 system with
- *  fastmem is faster with move.l.
- *  
- *  If you're using the mirrored registers of the IDE-ports with
- *  A6=1,  the Buddha doesn't care about the speed that you have
- *  selected  in  the  speed  register (see further down).  With
- *  A6=1  (for example $840 for port 0, register set 0), a 780ns
- *  access  is being made.  These registers should be used for a
- *  command   access   to  the  harddisk/CD-Rom,  since  command
- *  accesses  are Byte-wide and have to be made slower according
- *  to the ATA-X3T9 manual.
- *  
- *  Now  for the speed-register:  The register is byte-wide, and
- *  only  the  upper  three  bits are used (Bits 7 to 5).  Bit 4
- *  must  always  be set to 1 to be compatible with later Buddha
- *  versions  (if  I'll  ever  update this one).  I presume that
- *  I'll  never use the lower four bits, but they have to be set
- *  to 1 by definition.
- *    The  values in this table have to be shifted 5 bits to the
- *  left and or'd with $1f (this sets the lower 5 bits).
- *  
- *  All  the timings have in common:  Select and IOR/IOW rise at
- *  the  same  time.   IOR  and  IOW have a propagation delay of
- *  about  30ns  to  the clocks on the Zorro bus, that's why the
- *  values  are no multiple of 71.  One clock-cycle is 71ns long
- *  (exactly 70,5 at 14,18 Mhz on PAL systems).
- *  
- *  value 0 (Default after reset)
- *  
- *  497ns Select (7 clock cycles) , IOR/IOW after 172ns (2 clock cycles)
- *  (same timing as the Amiga 1200 does on it's IDE port without
- *  accelerator card)
- *  
- *  value 1
- *  
- *  639ns Select (9 clock cycles), IOR/IOW after 243ns (3 clock cycles)
- *  
- *  value 2
- *  
- *  781ns Select (11 clock cycles), IOR/IOW after 314ns (4 clock cycles)
- *  
- *  value 3
- *  
- *  355ns Select (5 clock cycles), IOR/IOW after 101ns (1 clock cycle)
- *  
- *  value 4
- *  
- *  355ns Select (5 clock cycles), IOR/IOW after 172ns (2 clock cycles)
- *  
- *  value 5
- *  
- *  355ns Select (5 clock cycles), IOR/IOW after 243ns (3 clock cycles)
- *  
- *  value 6
- *  
- *  1065ns Select (15 clock cycles), IOR/IOW after 314ns (4 clock cycles)
- *  
- *  value 7
- *  
- *  355ns Select, (5 clock cycles), IOR/IOW after 101ns (1 clock cycle)
- *  
- *  When accessing IDE registers with A6=1 (for example $84x),
- *  the timing will always be mode 0 8-bit compatible, no matter
- *  what you have selected in the speed register:
- *  
- *  781ns select, IOR/IOW after 4 clock cycles (=314ns) aktive. 
- *  
- *  All  the  timings with a very short select-signal (the 355ns
- *  fast  accesses)  depend  on the accelerator card used in the
- *  system:  Sometimes two more clock cycles are inserted by the
- *  bus  interface,  making  the  whole access 497ns long.  This
- *  doesn't  affect  the  reliability  of the controller nor the
- *  performance  of  the  card,  since  this doesn't happen very
- *  often.
- *  
- *  All  the  timings  are  calculated  and  only  confirmed  by
- *  measurements  that allowed me to count the clock cycles.  If
- *  the  system  is clocked by an oscillator other than 28,37516
- *  Mhz  (for  example  the  NTSC-frequency  28,63636 Mhz), each
- *  clock  cycle is shortened to a bit less than 70ns (not worth
- *  mentioning).   You  could think of a small performance boost
- *  by  overclocking  the  system,  but  you would either need a
- *  multisync  monitor,  or  a  graphics card, and your internal
- *  diskdrive would go crazy, that's why you shouldn't tune your
- *  Amiga this way.
- *  
- *  Giving  you  the  possibility  to  write  software  that  is
- *  compatible  with both the Buddha and the Catweasel Z-II, The
- *  Buddha  acts  just  like  a  Catweasel  Z-II  with no device
- *  connected  to  the  third  IDE-port.   The IRQ-register $f80
- *  always  shows a "no IRQ here" on the Buddha, and accesses to
- *  the  third  IDE  port  are  going into data's Nirwana on the
- *  Buddha.
- *  
- *  			    Jens Schönfeld february 19th, 1997
- *  					updated may 27th, 1997
- *                           eMail: sysop@nostlgic.tng.oche.de
- *  ---------------------------------------------------------------------------
- *
- *  TODO:
- *    - test it :-)
- *    - tune the timings using the speed-register
- */
-
-
-#include <linux/types.h>
-#include <linux/mm.h>
-#include <linux/interrupt.h>
-#include <linux/blkdev.h>
-#include <linux/hdreg.h>
-#include <linux/zorro.h>
-
-#include "ide.h"
-
-#include <asm/amigahw.h>
-#include <asm/amigaints.h>
-
-
-    /*
-     *  The Buddha has 2 IDE interfaces, the Catweasel has 3
-     */
-
-#define NUM_BUDDHA_HWIFS	2
-#define NUM_CATWEASEL_HWIFS	3
-
-
-    /*
-     *  Bases of the IDE interfaces (relative to the board address)
-     */
-
-#define BUDDHA_BASE1	0x800
-#define BUDDHA_BASE2	0xa00
-#define BUDDHA_BASE3	0xc00
-
-const u_int buddha_bases[NUM_CATWEASEL_HWIFS] = {
-    BUDDHA_BASE1, BUDDHA_BASE2, BUDDHA_BASE3
-};
-
-
-    /*
-     *  Offsets from one of the above bases
-     */
-
-#define BUDDHA_DATA	0x00
-#define BUDDHA_ERROR	0x06		/* see err-bits */
-#define BUDDHA_NSECTOR	0x0a		/* nr of sectors to read/write */
-#define BUDDHA_SECTOR	0x0e		/* starting sector */
-#define BUDDHA_LCYL	0x12		/* starting cylinder */
-#define BUDDHA_HCYL	0x16		/* high byte of starting cyl */
-#define BUDDHA_SELECT	0x1a		/* 101dhhhh , d=drive, hhhh=head */
-#define BUDDHA_STATUS	0x1e		/* see status-bits */
-#define BUDDHA_CONTROL	0x11a
-
-const u_int buddha_offsets[IDE_NR_PORTS] = {
-    BUDDHA_DATA, BUDDHA_ERROR, BUDDHA_NSECTOR, BUDDHA_SECTOR, BUDDHA_LCYL,
-    BUDDHA_HCYL, BUDDHA_SELECT, BUDDHA_STATUS, BUDDHA_CONTROL
-};
-
-
-    /*
-     *  Other registers
-     */
-
-#define BUDDHA_IRQ1	0xf00		/* MSB = 1, Harddisk is source of */
-#define BUDDHA_IRQ2	0xf40		/* interrupt */
-#define BUDDHA_IRQ3	0xf80
-
-const int buddha_irqports[NUM_CATWEASEL_HWIFS] = {
-    BUDDHA_IRQ1, BUDDHA_IRQ2, BUDDHA_IRQ3
-};
-
-#define BUDDHA_IRQ_MR	0xfc0		/* master interrupt enable */
-
-
-    /*
-     *  Board information
-     */
-
-static u_long board = 0;
-static int numhwifs = -1;
-
-
-    /*
-     *  Check and acknowledge the interrupt status
-     */
-
-static int buddha_ack_intr(ide_hwif_t *hwif)
-{
-    unsigned char ch;
-
-    ch = inb(hwif->io_ports[IDE_IRQ_OFFSET]);
-    if (!(ch & 0x80))
-	return 0;
-    return 1;
-}
-
-
-    /*
-     *  Any Buddha or Catweasel boards present?
-     */
-
-int find_buddha(void)
-{
-    u_int key;
-    const struct ConfigDev *cd;
-
-    numhwifs = 0;
-    if ((key = zorro_find(ZORRO_PROD_INDIVIDUAL_COMPUTERS_BUDDHA, 0, 0)))
-	numhwifs = NUM_BUDDHA_HWIFS;
-    else if ((key = zorro_find(ZORRO_PROD_INDIVIDUAL_COMPUTERS_CATWEASEL, 0,
-			       0)))
-	numhwifs = NUM_CATWEASEL_HWIFS;
-    if (key) {
-	cd = zorro_get_board(key);
-	board = (u_long)cd->cd_BoardAddr;
-	if (board) {
-	    board = ZTWO_VADDR(board);
-	    /* write to BUDDHA_IRQ_MR to enable the board IRQ */
-	    *(char *)(board+BUDDHA_IRQ_MR) = 0;
-	}
-    }
-    return numhwifs;
-}
-
-
-    /*
-     *  Probe for a Buddha or Catweasel IDE interface
-     *  We support only _one_ of them, no multiple boards
-     */
-
-int buddha_probe_hwif(int index, ide_hwif_t *hwif)
-{
-    static int buddha_index[NUM_CATWEASEL_HWIFS] = { 0, };
-    int i;
-
-    if (numhwifs < 0 && !find_buddha())
-	return 0;
-
-    for (i = 0; i < numhwifs; i++) {
-	if (!buddha_index[i]) {
-	    printk("ide%d: %s IDE interface\n", index,
-		   numhwifs == NUM_BUDDHA_HWIFS ? "Buddha" : "Catweasel");
-	    buddha_index[i] = index+1;
-	}
-	if (buddha_index[i] == index+1) {
-	    ide_setup_ports(hwif, (ide_ioreg_t)(board+buddha_bases[i]),
-	    		    buddha_offsets,
-			    (ide_ioreg_t)(board+buddha_irqports[i]),
-			    buddha_ack_intr);
-	    hwif->irq = IRQ_AMIGA_PORTS;
-	    return 1;
-	}
-    }
-    return 0;
-}
--- linux-2.1.47/drivers/block/buddha.h.orig	Mon Aug 18 21:22:14 1997
+++ linux-2.1.47/drivers/block/buddha.h	Mon Aug 18 21:45:25 1997
@@ -0,0 +1,387 @@
+/*
+ *  linux/drivers/block/buddha.h -- Amiga Buddha and Catweasel IDE Driver
+ *
+ *	Copyright (C) 1997 by Geert Uytterhoeven
+ *
+ *  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.
+ *
+ *  The driver was written based on the following specifications:
+ *
+ *  ---------------------------------------------------------------------------
+ *  Register map of the Buddha IDE controller and the
+ *  Buddha-part of the Catweasel Zorro-II version
+ *  
+ *  The Autoconfiguration has been implemented just as Commodore
+ *  described  in  their  manuals, no tricks have been used (for
+ *  example leaving some address lines out of the equations...).
+ *  If you want to configure the board yourself (for example let
+ *  a  Linux  kernel  configure the card), look at the Commodore
+ *  Docs.  Reading the nibbles should give this information:
+ *  
+ *  Vendor number: 4626 ($1212)
+ *  product number: 0 (42 for Catweasel Z-II)
+ *  Serial number: 0
+ *  Rom-vector: $1000
+ *  
+ *  The  card  should be a Z-II board, size 64K, not for freemem
+ *  list, Rom-Vektor is valid, no second Autoconfig-board on the
+ *  same card, no space preferrence, supports "Shutup_forever".
+ *  
+ *  Setting  the  base address should be done in two steps, just
+ *  as  the Amiga Kickstart does:  The lower nibble of the 8-Bit
+ *  address is written to $4a, then the whole Byte is written to
+ *  $48, while it doesn't matter how often you're writing to $4a
+ *  as  long as $48 is not touched.  After $48 has been written,
+ *  the  whole card disappears from $e8 and is mapped to the new
+ *  addrress just written.  Make shure $4a is written befor $48,
+ *  otherwise your chance is only 1:16 to find the board :-).
+ *  
+ *  The local memory-map is even active when mapped to $e8:
+ *  
+ *  $0-$7e	Autokonfig-space, see Z-II docs.
+ *  
+ *  $80-$7fd	reserved
+ *  
+ *  $7fe	Speed-select Register: Read & Write
+ *  		(description see further down)
+ *  
+ *  $800-$8ff	IDE-Select 0 (Port 0, Register set 0)
+ *  
+ *  $900-$9ff	IDE-Select 1 (Port 0, Register set 1)
+ *  
+ *  $a00-$aff	IDE-Select 2 (Port 1, Register set 0)
+ *  
+ *  $b00-$bff	IDE-Select 3 (Port 1, Register set 1)
+ *  
+ *  $c00-$cff	IDE-Select 4 (Port 2, Register set 0,
+ *                            Catweasel only!)
+ *  
+ *  $d00-$dff	IDE-Select 5 (Port 3, Register set 1,
+ *  			      Catweasel only!)
+ *  
+ *  $e00-$eff	local expansion port, on Catweasel Z-II the 
+ *  		Catweasel registers are also mapped here.
+ *  		Never touch, use multidisk.device!
+ *  		
+ *  $f00	read only, Byte-access: Bit 7 shows the 
+ *  		level of the IRQ-line of IDE port 0. 
+ *  
+ *  $f01-$f3f	mirror of $f00
+ *  
+ *  $f40	read only, Byte-access: Bit 7 shows the 
+ *  		level of the IRQ-line of IDE port 1. 
+ *  
+ *  $f41-$f7f	mirror of $f40
+ *  
+ *  $f80	read only, Byte-access: Bit 7 shows the 
+ *  		level of the IRQ-line of IDE port 2. 
+ *  		(Catweasel only!)
+ *  
+ *  $f81-$fbf	mirror of $f80
+ *  
+ *  $fc0	write-only: Writing any value to this
+ *  		register enables IRQs to be passed from the 
+ *  		IDE ports to the Zorro bus. This mechanism 
+ *  		has been implemented to be compatible with 
+ *  		harddisks that are either defective or have
+ *  		a buggy firmware and pull the IRQ line up 
+ *  		while starting up. If interrupts would 
+ *  		always be passed to the bus, the computer 
+ *  		might not start up. Once enabled, this flag 
+ *  		can not be disabled again. The level of the 
+ *  		flag can not be determined by software 
+ *  		(what for? Write to me if it's necessary!).
+ *  
+ *  $fc1-$fff	mirror of $fc0
+ *  
+ *  $1000-$ffff	Buddha-Rom with offset $1000 in the rom
+ *  		chip. The addresses $0 to $fff of the rom 
+ *  		chip cannot be read. Rom is Byte-wide and
+ *  		mapped to even addresses.
+ *  
+ *  The  IDE ports issue an INT2.  You can read the level of the
+ *  IRQ-lines  of  the  IDE-ports by reading from the three (two
+ *  for  Buddha-only)  registers  $f00, $f40 and $f80.  This way
+ *  more  than one I/O request can be handled and you can easily
+ *  determine  what  driver  has  to serve the INT2.  Buddha and
+ *  Catweasel  expansion  boards  can issue an INT6.  A seperate
+ *  memory  map  is available for the I/O module and the sysop's
+ *  I/O module.
+ *  
+ *  The IDE ports are fed by the address lines A2 to A4, just as
+ *  the  Amiga  1200  and  Amiga  4000  IDE ports are.  This way
+ *  existing  drivers  can be easily ported to Buddha.  A move.l
+ *  polls  two  words  out of the same address of IDE port since
+ *  every  word  is  mirrored  once.  movem is not possible, but
+ *  it's  not  necessary  either,  because  you can only speedup
+ *  68000  systems  with  this  technique.   A 68020 system with
+ *  fastmem is faster with move.l.
+ *  
+ *  If you're using the mirrored registers of the IDE-ports with
+ *  A6=1,  the Buddha doesn't care about the speed that you have
+ *  selected  in  the  speed  register (see further down).  With
+ *  A6=1  (for example $840 for port 0, register set 0), a 780ns
+ *  access  is being made.  These registers should be used for a
+ *  command   access   to  the  harddisk/CD-Rom,  since  command
+ *  accesses  are Byte-wide and have to be made slower according
+ *  to the ATA-X3T9 manual.
+ *  
+ *  Now  for the speed-register:  The register is byte-wide, and
+ *  only  the  upper  three  bits are used (Bits 7 to 5).  Bit 4
+ *  must  always  be set to 1 to be compatible with later Buddha
+ *  versions  (if  I'll  ever  update this one).  I presume that
+ *  I'll  never use the lower four bits, but they have to be set
+ *  to 1 by definition.
+ *    The  values in this table have to be shifted 5 bits to the
+ *  left and or'd with $1f (this sets the lower 5 bits).
+ *  
+ *  All  the timings have in common:  Select and IOR/IOW rise at
+ *  the  same  time.   IOR  and  IOW have a propagation delay of
+ *  about  30ns  to  the clocks on the Zorro bus, that's why the
+ *  values  are no multiple of 71.  One clock-cycle is 71ns long
+ *  (exactly 70,5 at 14,18 Mhz on PAL systems).
+ *  
+ *  value 0 (Default after reset)
+ *  
+ *  497ns Select (7 clock cycles) , IOR/IOW after 172ns (2 clock cycles)
+ *  (same timing as the Amiga 1200 does on it's IDE port without
+ *  accelerator card)
+ *  
+ *  value 1
+ *  
+ *  639ns Select (9 clock cycles), IOR/IOW after 243ns (3 clock cycles)
+ *  
+ *  value 2
+ *  
+ *  781ns Select (11 clock cycles), IOR/IOW after 314ns (4 clock cycles)
+ *  
+ *  value 3
+ *  
+ *  355ns Select (5 clock cycles), IOR/IOW after 101ns (1 clock cycle)
+ *  
+ *  value 4
+ *  
+ *  355ns Select (5 clock cycles), IOR/IOW after 172ns (2 clock cycles)
+ *  
+ *  value 5
+ *  
+ *  355ns Select (5 clock cycles), IOR/IOW after 243ns (3 clock cycles)
+ *  
+ *  value 6
+ *  
+ *  1065ns Select (15 clock cycles), IOR/IOW after 314ns (4 clock cycles)
+ *  
+ *  value 7
+ *  
+ *  355ns Select, (5 clock cycles), IOR/IOW after 101ns (1 clock cycle)
+ *  
+ *  When accessing IDE registers with A6=1 (for example $84x),
+ *  the timing will always be mode 0 8-bit compatible, no matter
+ *  what you have selected in the speed register:
+ *  
+ *  781ns select, IOR/IOW after 4 clock cycles (=314ns) aktive. 
+ *  
+ *  All  the  timings with a very short select-signal (the 355ns
+ *  fast  accesses)  depend  on the accelerator card used in the
+ *  system:  Sometimes two more clock cycles are inserted by the
+ *  bus  interface,  making  the  whole access 497ns long.  This
+ *  doesn't  affect  the  reliability  of the controller nor the
+ *  performance  of  the  card,  since  this doesn't happen very
+ *  often.
+ *  
+ *  All  the  timings  are  calculated  and  only  confirmed  by
+ *  measurements  that allowed me to count the clock cycles.  If
+ *  the  system  is clocked by an oscillator other than 28,37516
+ *  Mhz  (for  example  the  NTSC-frequency  28,63636 Mhz), each
+ *  clock  cycle is shortened to a bit less than 70ns (not worth
+ *  mentioning).   You  could think of a small performance boost
+ *  by  overclocking  the  system,  but  you would either need a
+ *  multisync  monitor,  or  a  graphics card, and your internal
+ *  diskdrive would go crazy, that's why you shouldn't tune your
+ *  Amiga this way.
+ *  
+ *  Giving  you  the  possibility  to  write  software  that  is
+ *  compatible  with both the Buddha and the Catweasel Z-II, The
+ *  Buddha  acts  just  like  a  Catweasel  Z-II  with no device
+ *  connected  to  the  third  IDE-port.   The IRQ-register $f80
+ *  always  shows a "no IRQ here" on the Buddha, and accesses to
+ *  the  third  IDE  port  are  going into data's Nirwana on the
+ *  Buddha.
+ *  
+ *  			    Jens Schönfeld february 19th, 1997
+ *  					updated may 27th, 1997
+ *                           eMail: sysop@nostlgic.tng.oche.de
+ *  ---------------------------------------------------------------------------
+ *
+ *  TODO:
+ *    - test it :-)
+ *    - tune the timings using the speed-register
+ */
+
+
+#include <linux/zorro.h>
+#include <asm/amigahw.h>
+#include <asm/amigaints.h>
+
+
+    /*
+     *  The Buddha has 2 IDE interfaces, the Catweasel has 3
+     */
+
+#define BUDDHA_NUM_HWIFS	2
+#define CATWEASEL_NUM_HWIFS	3
+
+
+    /*
+     *  Bases of the IDE interfaces (relative to the board address)
+     */
+
+#define BUDDHA_BASE1	0x800
+#define BUDDHA_BASE2	0xa00
+#define BUDDHA_BASE3	0xc00
+
+const u_int buddha_bases[CATWEASEL_NUM_HWIFS] = {
+    BUDDHA_BASE1, BUDDHA_BASE2, BUDDHA_BASE3
+};
+
+
+    /*
+     *  Offsets from one of the above bases
+     */
+
+#define BUDDHA_DATA	0x00
+#define BUDDHA_ERROR	0x06		/* see err-bits */
+#define BUDDHA_NSECTOR	0x0a		/* nr of sectors to read/write */
+#define BUDDHA_SECTOR	0x0e		/* starting sector */
+#define BUDDHA_LCYL	0x12		/* starting cylinder */
+#define BUDDHA_HCYL	0x16		/* high byte of starting cyl */
+#define BUDDHA_SELECT	0x1a		/* 101dhhhh , d=drive, hhhh=head */
+#define BUDDHA_STATUS	0x1e		/* see status-bits */
+#define BUDDHA_CONTROL	0x11a
+
+const u_int buddha_offsets[IDE_NR_PORTS] = {
+    BUDDHA_DATA, BUDDHA_ERROR, BUDDHA_NSECTOR, BUDDHA_SECTOR, BUDDHA_LCYL,
+    BUDDHA_HCYL, BUDDHA_SELECT, BUDDHA_STATUS, BUDDHA_CONTROL
+};
+
+
+    /*
+     *  Other registers
+     */
+
+#define BUDDHA_IRQ1	0xf00		/* MSB = 1, Harddisk is source of */
+#define BUDDHA_IRQ2	0xf40		/* interrupt */
+#define BUDDHA_IRQ3	0xf80
+
+const int buddha_irqports[CATWEASEL_NUM_HWIFS] = {
+    BUDDHA_IRQ1, BUDDHA_IRQ2, BUDDHA_IRQ3
+};
+
+#define BUDDHA_IRQ_MR	0xfc0		/* master interrupt enable */
+
+
+    /*
+     *  Board information
+     */
+
+static u_long buddha_board = 0;
+static int buddha_num_hwifs = -1;
+
+
+    /*
+     *  Check and acknowledge the interrupt status
+     */
+
+static int buddha_ack_intr(ide_hwif_t *hwif)
+{
+    unsigned char ch;
+
+    ch = inb(hwif->io_ports[IDE_IRQ_OFFSET]);
+    if (!(ch & 0x80))
+	return 0;
+    return 1;
+}
+
+
+    /*
+     *  Any Buddha or Catweasel boards present?
+     */
+
+int find_buddha(void)
+{
+    u_int key;
+    const struct ConfigDev *cd;
+
+    buddha_num_hwifs = 0;
+    if ((key = zorro_find(ZORRO_PROD_INDIVIDUAL_COMPUTERS_BUDDHA, 0, 0)))
+	buddha_num_hwifs = BUDDHA_NUM_HWIFS;
+    else if ((key = zorro_find(ZORRO_PROD_INDIVIDUAL_COMPUTERS_CATWEASEL, 0,
+			       0)))
+	buddha_num_hwifs = CATWEASEL_NUM_HWIFS;
+    if (key) {
+	cd = zorro_get_board(key);
+	buddha_board = (u_long)cd->cd_BoardAddr;
+	if (buddha_board) {
+	    buddha_board = ZTWO_VADDR(buddha_board);
+	    /* write to BUDDHA_IRQ_MR to enable the board IRQ */
+	    *(char *)(buddha_board+BUDDHA_IRQ_MR) = 0;
+	    zorro_config_board(key, 0);
+	}
+    }
+    return buddha_num_hwifs;
+}
+
+
+    /*
+     *  Probe for a Buddha or Catweasel IDE interface
+     *  We support only _one_ of them, no multiple boards!
+     */
+
+int buddha_probe_hwif(int index, ide_hwif_t *hwif)
+{
+    static int buddha_index[CATWEASEL_NUM_HWIFS] = { 0, };
+    int i;
+
+    if (buddha_num_hwifs < 0 && !find_buddha())
+	return 0;
+
+    for (i = 0; i < buddha_num_hwifs; i++) {
+	if (!buddha_index[i]) {
+	    printk("ide%d: %s IDE interface\n", index,
+		   buddha_num_hwifs == BUDDHA_NUM_HWIFS ? "Buddha" :
+		   					  "Catweasel");
+	    buddha_index[i] = index+1;
+	}
+	if (buddha_index[i] == index+1) {
+	    ide_setup_ports(hwif, (ide_ioreg_t)(buddha_board+buddha_bases[i]),
+	    		    buddha_offsets,
+			    (ide_ioreg_t)(buddha_board+buddha_irqports[i]),
+			    buddha_ack_intr);
+	    hwif->irq = IRQ_AMIGA_PORTS;
+	    return 1;
+	}
+    }
+    return 0;
+}
+
+
+#undef BUDDHA_NUM_HWIFS
+#undef CATWEASEL_NUM_HWIFS
+#undef BUDDHA_BASE1
+#undef BUDDHA_BASE2
+#undef BUDDHA_BASE3
+#undef BUDDHA_DATA
+#undef BUDDHA_ERROR
+#undef BUDDHA_NSECTOR
+#undef BUDDHA_SECTOR
+#undef BUDDHA_LCYL
+#undef BUDDHA_HCYL
+#undef BUDDHA_SELECT
+#undef BUDDHA_STATUS
+#undef BUDDHA_CONTROL
+#undef BUDDHA_IRQ1
+#undef BUDDHA_IRQ2
+#undef BUDDHA_IRQ3
+#undef BUDDHA_IRQ_MR
--- linux-2.1.47/drivers/block/gayle.c.orig	Tue Jul 29 19:59:08 1997
+++ linux-2.1.47/drivers/block/gayle.c	Mon Aug 18 21:22:53 1997
@@ -1,168 +0,0 @@
-/*
- *  linux/drivers/block/gayle.c -- Amiga Gayle IDE Driver
- *
- *	Created 9 Jul 1997 by Geert Uytterhoeven
- *
- *  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.
- */
-
-
-#include <linux/config.h>
-#include <linux/types.h>
-#include <linux/mm.h>
-#include <linux/interrupt.h>
-#include <linux/blkdev.h>
-#include <linux/hdreg.h>
-
-#include "ide.h"
-
-#include <asm/amigahw.h>
-#include <asm/amigaints.h>
-
-
-    /*
-     *  Bases of the IDE interfaces
-     */
-
-#define GAYLE_BASE_4000	0xdd2020	/* A4000/A4000T */
-#define GAYLE_BASE_1200	0xda0000	/* A1200/A600 */
-
-    /*
-     *  Offsets from one of the above bases
-     */
-
-#define GAYLE_DATA	0x00
-#define GAYLE_ERROR	0x06		/* see err-bits */
-#define GAYLE_NSECTOR	0x0a		/* nr of sectors to read/write */
-#define GAYLE_SECTOR	0x0e		/* starting sector */
-#define GAYLE_LCYL	0x12		/* starting cylinder */
-#define GAYLE_HCYL	0x16		/* high byte of starting cyl */
-#define GAYLE_SELECT	0x1a		/* 101dhhhh , d=drive, hhhh=head */
-#define GAYLE_STATUS	0x1e		/* see status-bits */
-#define GAYLE_CONTROL	0x101a
-
-u_int gayle_offsets[IDE_NR_PORTS] = {
-    GAYLE_DATA, GAYLE_ERROR, GAYLE_NSECTOR, GAYLE_SECTOR, GAYLE_LCYL,
-    GAYLE_HCYL, GAYLE_SELECT, GAYLE_STATUS, GAYLE_CONTROL
-};
-
-
-    /*
-     *  These are at different offsets from the base
-     */
-
-#define GAYLE_IRQ_4000	0xdd3020	/* MSB = 1, Harddisk is source of */
-#define GAYLE_IRQ_1200	0xda9000	/* interrupt */
-
-
-    /*
-     *  Offset of the secondary port for IDE doublers
-     *  Note that GAYLE_CONTROL is NOT available then!
-     */
-
-#define NEXT_PORT	0x1000
-
-#ifndef CONFIG_BLK_DEV_IDEDOUBLER
-#define NUM_GAYLE_HWIFS	1
-#define NUM_PROBE_HWIFS	NUM_GAYLE_HWIFS
-#define HAS_CONTROL_REG	1
-#else /* CONFIG_BLK_DEV_IDEDOUBLER */
-#define NUM_GAYLE_HWIFS	2
-#define NUM_PROBE_HWIFS	(ide_doubler ? NUM_GAYLE_HWIFS : NUM_GAYLE_HWIFS-1)
-#define HAS_CONTROL_REG	(!ide_doubler)
-int ide_doubler = 0;	/* support IDE doublers? */
-#endif /* CONFIG_BLK_DEV_IDEDOUBLER */
-
-
-    /*
-     *  Check and acknowledge the interrupt status
-     */
-
-static int gayle_ack_intr_a4000(ide_hwif_t *hwif)
-{
-    unsigned char ch;
-
-    ch = inb(hwif->io_ports[IDE_IRQ_OFFSET]);
-    if (!(ch & 0x80))
-	return 0;
-    return 1;
-}
-
-static int gayle_ack_intr_a1200(ide_hwif_t *hwif)
-{
-    unsigned char ch;
-
-    ch = inb(hwif->io_ports[IDE_IRQ_OFFSET]);
-    if (!(ch & 0x80))
-	return 0;
-    (void)inb(hwif->io_ports[IDE_STATUS_OFFSET]);
-    outb(0x7c | (ch & 0x03), hwif->io_ports[IDE_IRQ_OFFSET]);
-    return 1;
-}
-
-
-    /*
-     *  Probe for a Gayle IDE interface (and optionally for an IDE doubler)
-     */
-
-int gayle_probe_hwif(int index, ide_hwif_t *hwif)
-{
-    static int gayle_index[NUM_GAYLE_HWIFS] = { 0, };
-    int a4000, i;
-
-    if (!MACH_IS_AMIGA)
-	return 0;
-
-    if (!(a4000 = AMIGAHW_PRESENT(A4000_IDE)) && !AMIGAHW_PRESENT(A1200_IDE))
-	return 0;
-
-    if (!HAS_CONTROL_REG)
-	gayle_offsets[IDE_CONTROL_OFFSET] = -1;
-
-    for (i = 0; i < NUM_PROBE_HWIFS; i++) {
-	if (!gayle_index[i]) {
-	    switch (i) {
-		case 0:
-		    printk("ide%d: Gayle IDE interface (A%d style)\n", index,
-			   a4000 ? 4000 : 1200);
-		    break;
-#ifdef CONFIG_BLK_DEV_IDEDOUBLER
-		case 1:
-		    printk("ide%d: IDE doubler\n", index);
-		    break;
-#endif /* CONFIG_BLK_DEV_IDEDOUBLER */
-	    }
-	    gayle_index[i] = index+1;
-	}
-	if (gayle_index[i] == index+1) {
-	    ide_ioreg_t base, irqport;
-	    ide_ack_intr_t *ack_intr;
-	    if (a4000) {
-		base = (ide_ioreg_t)ZTWO_VADDR(GAYLE_BASE_4000);
-		irqport = (ide_ioreg_t)ZTWO_VADDR(GAYLE_IRQ_4000);
-		ack_intr = gayle_ack_intr_a4000;
-	    } else {
-		base = (ide_ioreg_t)ZTWO_VADDR(GAYLE_BASE_1200);
-		irqport = (ide_ioreg_t)ZTWO_VADDR(GAYLE_IRQ_1200);
-		ack_intr = gayle_ack_intr_a1200;
-	    }
-	    base += i*NEXT_PORT;
-	    ide_setup_ports(hwif, base, gayle_offsets, irqport, ack_intr);
-#if 1 /* TESTING */
-	    if (i == 1) {
-		volatile u_short *addr = (u_short *)base;
-		u_short data;
-		printk("+++ Probing for IDE doubler... ");
-		*addr = 0xffff;
-		data = *addr;
-		printk("probe returned 0x%02x (PLEASE REPORT THIS!!)\n", data);
-	    }
-#endif /* TESTING */
-	    hwif->irq = IRQ_AMIGA_PORTS;
-	    return 1;
-	}
-    }
-    return 0;
-}
--- linux-2.1.47/drivers/block/gayle.h.orig	Mon Aug 18 21:22:51 1997
+++ linux-2.1.47/drivers/block/gayle.h	Mon Aug 18 21:38:20 1997
@@ -0,0 +1,179 @@
+/*
+ *  linux/drivers/block/gayle.h -- Amiga Gayle IDE Driver
+ *
+ *	Created 9 Jul 1997 by Geert Uytterhoeven
+ *
+ *  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.
+ */
+
+
+#include <asm/amigahw.h>
+#include <asm/amigaints.h>
+
+
+    /*
+     *  Bases of the IDE interfaces
+     */
+
+#define GAYLE_BASE_4000	0xdd2020	/* A4000/A4000T */
+#define GAYLE_BASE_1200	0xda0000	/* A1200/A600 */
+
+    /*
+     *  Offsets from one of the above bases
+     */
+
+#define GAYLE_DATA	0x00
+#define GAYLE_ERROR	0x06		/* see err-bits */
+#define GAYLE_NSECTOR	0x0a		/* nr of sectors to read/write */
+#define GAYLE_SECTOR	0x0e		/* starting sector */
+#define GAYLE_LCYL	0x12		/* starting cylinder */
+#define GAYLE_HCYL	0x16		/* high byte of starting cyl */
+#define GAYLE_SELECT	0x1a		/* 101dhhhh , d=drive, hhhh=head */
+#define GAYLE_STATUS	0x1e		/* see status-bits */
+#define GAYLE_CONTROL	0x101a
+
+u_int gayle_offsets[IDE_NR_PORTS] = {
+    GAYLE_DATA, GAYLE_ERROR, GAYLE_NSECTOR, GAYLE_SECTOR, GAYLE_LCYL,
+    GAYLE_HCYL, GAYLE_SELECT, GAYLE_STATUS, GAYLE_CONTROL
+};
+
+
+    /*
+     *  These are at different offsets from the base
+     */
+
+#define GAYLE_IRQ_4000	0xdd3020	/* MSB = 1, Harddisk is source of */
+#define GAYLE_IRQ_1200	0xda9000	/* interrupt */
+
+
+    /*
+     *  Offset of the secondary port for IDE doublers
+     *  Note that GAYLE_CONTROL is NOT available then!
+     */
+
+#define GAYLE_NEXT_PORT	0x1000
+
+#ifndef CONFIG_BLK_DEV_IDEDOUBLER
+#define GAYLE_NUM_HWIFS		1
+#define GAYLE_NUM_PROBE_HWIFS	GAYLE_NUM_HWIFS
+#define GAYLE_HAS_CONTROL_REG	1
+#else /* CONFIG_BLK_DEV_IDEDOUBLER */
+#define GAYLE_NUM_HWIFS		2
+#define GAYLE_NUM_PROBE_HWIFS	(ide_doubler ? GAYLE_NUM_HWIFS : \
+					       GAYLE_NUM_HWIFS-1)
+#define GAYLE_HAS_CONTROL_REG	(!ide_doubler)
+int ide_doubler = 0;	/* support IDE doublers? */
+#endif /* CONFIG_BLK_DEV_IDEDOUBLER */
+
+
+    /*
+     *  Check and acknowledge the interrupt status
+     */
+
+static int gayle_ack_intr_a4000(ide_hwif_t *hwif)
+{
+    unsigned char ch;
+
+    ch = inb(hwif->io_ports[IDE_IRQ_OFFSET]);
+    if (!(ch & 0x80))
+	return 0;
+    return 1;
+}
+
+static int gayle_ack_intr_a1200(ide_hwif_t *hwif)
+{
+    unsigned char ch;
+
+    ch = inb(hwif->io_ports[IDE_IRQ_OFFSET]);
+    if (!(ch & 0x80))
+	return 0;
+    (void)inb(hwif->io_ports[IDE_STATUS_OFFSET]);
+    outb(0x7c | (ch & 0x03), hwif->io_ports[IDE_IRQ_OFFSET]);
+    return 1;
+}
+
+
+    /*
+     *  Probe for a Gayle IDE interface (and optionally for an IDE doubler)
+     */
+
+int gayle_probe_hwif(int index, ide_hwif_t *hwif)
+{
+    static int gayle_index[GAYLE_NUM_HWIFS] = { 0, };
+    int a4000, i;
+
+    if (!MACH_IS_AMIGA)
+	return 0;
+
+    if (!(a4000 = AMIGAHW_PRESENT(A4000_IDE)) && !AMIGAHW_PRESENT(A1200_IDE))
+	return 0;
+
+    if (!GAYLE_HAS_CONTROL_REG)
+	gayle_offsets[IDE_CONTROL_OFFSET] = -1;
+
+    for (i = 0; i < GAYLE_NUM_PROBE_HWIFS; i++) {
+	if (!gayle_index[i]) {
+	    switch (i) {
+		case 0:
+		    printk("ide%d: Gayle IDE interface (A%d style)\n", index,
+			   a4000 ? 4000 : 1200);
+		    break;
+#ifdef CONFIG_BLK_DEV_IDEDOUBLER
+		case 1:
+		    printk("ide%d: IDE doubler\n", index);
+		    break;
+#endif /* CONFIG_BLK_DEV_IDEDOUBLER */
+	    }
+	    gayle_index[i] = index+1;
+	}
+	if (gayle_index[i] == index+1) {
+	    ide_ioreg_t base, irqport;
+	    ide_ack_intr_t *ack_intr;
+	    if (a4000) {
+		base = (ide_ioreg_t)ZTWO_VADDR(GAYLE_BASE_4000);
+		irqport = (ide_ioreg_t)ZTWO_VADDR(GAYLE_IRQ_4000);
+		ack_intr = gayle_ack_intr_a4000;
+	    } else {
+		base = (ide_ioreg_t)ZTWO_VADDR(GAYLE_BASE_1200);
+		irqport = (ide_ioreg_t)ZTWO_VADDR(GAYLE_IRQ_1200);
+		ack_intr = gayle_ack_intr_a1200;
+	    }
+	    base += i*GAYLE_NEXT_PORT;
+	    ide_setup_ports(hwif, base, gayle_offsets, irqport, ack_intr);
+#if 1 /* TESTING */
+	    if (i == 1) {
+		volatile u_short *addr = (u_short *)base;
+		u_short data;
+		printk("+++ Probing for IDE doubler... ");
+		*addr = 0xffff;
+		data = *addr;
+		printk("probe returned 0x%02x (PLEASE REPORT THIS!!)\n", data);
+	    }
+#endif /* TESTING */
+	    hwif->irq = IRQ_AMIGA_PORTS;
+	    return 1;
+	}
+    }
+    return 0;
+}
+
+
+#undef GAYLE_BASE_4000
+#undef GAYLE_BASE_1200
+#undef GAYLE_DATA
+#undef GAYLE_ERROR
+#undef GAYLE_NSECTOR
+#undef GAYLE_SECTOR
+#undef GAYLE_LCYL
+#undef GAYLE_HCYL
+#undef GAYLE_SELECT
+#undef GAYLE_STATUS
+#undef GAYLE_CONTROL
+#undef GAYLE_IRQ_4000
+#undef GAYLE_IRQ_1200
+#undef GAYLE_NEXT_PORT
+#undef GAYLE_NUM_HWIFS
+#undef GAYLE_NUM_PROBE_HWIFS
+#undef GAYLE_HAS_CONTROL_REG
--- linux-2.1.47/drivers/block/Makefile.orig	Tue Jul 29 19:59:07 1997
+++ linux-2.1.47/drivers/block/Makefile	Mon Aug 18 21:30:46 1997
@@ -105,21 +105,6 @@
   endif
 endif
 
-ifneq ($(CONFIG_BLK_DEV_IDE),n)
-  ifneq ($(ARCH),m68k)
-  L_OBJS += pc_ide.o
-  endif
-  ifeq ($(CONFIG_BLK_DEV_GAYLE),y)
-  L_OBJS += gayle.o
-  endif
-  ifeq ($(CONFIG_BLK_DEV_FALCON_IDE),y)
-  L_OBJS += falcon_ide.o
-  endif
-  ifeq ($(CONFIG_BLK_DEV_BUDDHA),y)
-  L_OBJS += buddha.o
-  endif
-endif
-
 ifeq ($(CONFIG_BLK_DEV_RZ1000),y)
 L_OBJS += rz1000.o
 endif
--- linux-2.1.47/drivers/block/pc_ide.c.orig	Tue Jul 29 19:59:12 1997
+++ linux-2.1.47/drivers/block/pc_ide.c	Mon Aug 18 21:23:32 1997
@@ -1,71 +0,0 @@
-/*
- *  linux/drivers/block/pc-ide.c -- PC I/O port IDE Driver
- *
- *	Created 12 Jul 1997 by Geert Uytterhoeven
- *
- *  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.
- */
-
-
-#include <linux/types.h>
-#include <linux/mm.h>
-#include <linux/interrupt.h>
-#include <linux/blkdev.h>
-#include <linux/hdreg.h>
-
-#include "ide.h"
-
-
-    /*
-     *  Bases of the IDE interfaces
-     */
-
-#define NUM_PCIDE_HWIFS	4
-
-#define PCIDE_BASE1	0x1f0
-#define PCIDE_BASE2	0x170
-#define PCIDE_BASE3	0x1e8
-#define PCIDE_BASE4	0x168
-
-const ide_ioreg_t pcide_bases[NUM_PCIDE_HWIFS] = {
-    PCIDE_BASE1, PCIDE_BASE2, PCIDE_BASE3, PCIDE_BASE4
-};
-
-
-    /*
-     *  Offsets from one of the above bases
-     */
-
-#define PCIDE_REG(x)	(HD_##x-PCIDE_BASE1)
-
-const int pcide_offsets[IDE_NR_PORTS] = {
-    PCIDE_REG(DATA), PCIDE_REG(ERROR), PCIDE_REG(NSECTOR), PCIDE_REG(SECTOR),
-    PCIDE_REG(LCYL), PCIDE_REG(HCYL), PCIDE_REG(CURRENT), PCIDE_REG(STATUS),
-    PCIDE_REG(CMD)
-};
-
-
-    /*
-     *  Probe for PC IDE interfaces
-     */
-
-int pcide_probe_hwif(int index, ide_hwif_t *hwif)
-{
-    static int pcide_index[NUM_PCIDE_HWIFS] = { 0, };
-    int i;
-
-    for (i = 0; i < NUM_PCIDE_HWIFS; i++) {
-	if (!pcide_index[i]) {
-	    printk("ide%d: PC IDE interface\n", index);
-	    pcide_index[i] = index+1;
-	}
-	if (pcide_index[i] == index+1) {
-	    ide_setup_ports(hwif, pcide_bases[i], pcide_offsets, 0, NULL);
-	    hwif->irq = 0;
-	    return 1;
-	}
-    }
-    return 0;
-}
--- linux-2.1.47/drivers/block/pc_ide.h.orig	Mon Aug 18 21:23:32 1997
+++ linux-2.1.47/drivers/block/pc_ide.h	Mon Aug 18 21:38:58 1997
@@ -0,0 +1,70 @@
+/*
+ *  linux/drivers/block/pc-ide.h -- PC I/O port IDE Driver
+ *
+ *	Created 12 Jul 1997 by Geert Uytterhoeven
+ *
+ *  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.
+ */
+
+
+    /*
+     *  Bases of the IDE interfaces
+     */
+
+#define PCIDE_NUM_HWIFS	4
+
+#define PCIDE_BASE1	0x1f0
+#define PCIDE_BASE2	0x170
+#define PCIDE_BASE3	0x1e8
+#define PCIDE_BASE4	0x168
+
+const ide_ioreg_t pcide_bases[PCIDE_NUM_HWIFS] = {
+    PCIDE_BASE1, PCIDE_BASE2, PCIDE_BASE3, PCIDE_BASE4
+};
+
+
+    /*
+     *  Offsets from one of the above bases
+     */
+
+#define PCIDE_REG(x)	(HD_##x-PCIDE_BASE1)
+
+const int pcide_offsets[IDE_NR_PORTS] = {
+    PCIDE_REG(DATA), PCIDE_REG(ERROR), PCIDE_REG(NSECTOR), PCIDE_REG(SECTOR),
+    PCIDE_REG(LCYL), PCIDE_REG(HCYL), PCIDE_REG(CURRENT), PCIDE_REG(STATUS),
+    PCIDE_REG(CMD)
+};
+
+
+    /*
+     *  Probe for PC IDE interfaces
+     */
+
+int pcide_probe_hwif(int index, ide_hwif_t *hwif)
+{
+    static int pcide_index[PCIDE_NUM_HWIFS] = { 0, };
+    int i;
+
+    for (i = 0; i < PCIDE_NUM_HWIFS; i++) {
+	if (!pcide_index[i]) {
+	    printk("ide%d: PC IDE interface\n", index);
+	    pcide_index[i] = index+1;
+	}
+	if (pcide_index[i] == index+1) {
+	    ide_setup_ports(hwif, pcide_bases[i], pcide_offsets, 0, NULL);
+	    hwif->irq = 0;
+	    return 1;
+	}
+    }
+    return 0;
+}
+
+
+#undef PCIDE_NUM_HWIFS
+#undef PCIDE_BASE1
+#undef PCIDE_BASE2
+#undef PCIDE_BASE3
+#undef PCIDE_BASE4
+#undef PCIDE_REG
--- linux-2.1.47/drivers/block/ide.c.orig	Wed Jul 30 22:29:17 1997
+++ linux-2.1.47/drivers/block/ide.c	Mon Aug 18 21:30:07 1997
@@ -323,6 +323,19 @@
 #include <linux/kerneld.h>
 #endif /* CONFIG_KERNELD */
 
+#ifndef __mc68000__
+#include "pc_ide.h"
+#endif
+#ifdef CONFIG_BLK_DEV_GAYLE
+#include "gayle.h"
+#endif
+#ifdef CONFIG_BLK_DEV_FALCON_IDE
+#include "falcon_ide.h"
+#endif
+#ifdef CONFIG_BLK_DEV_BUDDHA
+#include "buddha.h"
+#endif
+
 static const byte	ide_hwif_to_major[] = {IDE0_MAJOR, IDE1_MAJOR, IDE2_MAJOR, IDE3_MAJOR};
 
 static int	idebus_parameter; /* holds the "idebus=" parameter */
--- linux-2.1.47/drivers/block/ide.h.orig	Mon Aug  4 00:49:36 1997
+++ linux-2.1.47/drivers/block/ide.h	Mon Aug 18 21:26:26 1997
@@ -617,19 +617,6 @@
 void ide_setup_ports(ide_hwif_t *hwif, ide_ioreg_t base, const int *offsets,
 		     ide_ioreg_t irqport, ide_ack_intr_t *ack_intr);
 
-#ifndef __mc68000__
-int pcide_probe_hwif(int index, ide_hwif_t *hwif);
-#endif
-#ifdef CONFIG_BLK_DEV_GAYLE
-int gayle_probe_hwif(int index, ide_hwif_t *hwif);
-#endif
-#ifdef CONFIG_BLK_DEV_FALCON_IDE
-int falconide_probe_hwif(int index, ide_hwif_t *hwif);
-#endif
-#ifdef CONFIG_BLK_DEV_BUDDHA
-int buddha_probe_hwif(int index, ide_hwif_t *hwif);
-#endif
-
 #ifdef CONFIG_BLK_DEV_TRITON
 void ide_init_triton (byte, byte);
 #endif /* CONFIG_BLK_DEV_TRITON */

Greetings,

						Geert

--
Geert Uytterhoeven                     Geert.Uytterhoeven@cs.kuleuven.ac.be
Wavelets, Linux/m68k on Amiga          http://www.cs.kuleuven.ac.be/~geert/
Department of Computer Science -- Katholieke Universiteit Leuven -- Belgium

