Resent-Date: Sat, 24 Jul 1999 16:45:32 +0200 (MET DST)
Date: Sat, 24 Jul 1999 16:45:23 +0200 (MET DST)
From: Roman Zippel <zippel@fh-brandenburg.de>
X-Sender: zippel@zeus
To: Linux/m68k <linux-m68k@lists.linux-m68k.org>
Subject: 2.3 patch
Resent-From: linux-m68k@phil.uni-sb.de

Hi,

This patch allows IDE to compile and to work, I did not to much tests with
that kernel as I don't want to risk a new installation. :-)
Anyway, the solution was quite easy - simply backout most of our changes,
as someone else did already quite a good job with trying to integrate
everything.

bye, Roman

Index: drivers/block/buddha.c
===================================================================
RCS file: /usr/src/cvsroot/linux-2.3/drivers/block/buddha.c,v
retrieving revision 1.1.1.1.4.1
diff -u -r1.1.1.1.4.1 buddha.c
--- buddha.c	1999/07/02 22:33:22	1.1.1.1.4.1
+++ buddha.c	1999/07/19 20:05:20
@@ -20,9 +20,8 @@
 #include <linux/blkdev.h>
 #include <linux/hdreg.h>
 #include <linux/zorro.h>
+#include <linux/ide.h>
 
-#include "ide.h"
-
 #include <asm/amigahw.h>
 #include <asm/amigaints.h>
 
@@ -62,7 +61,7 @@
 #define BUDDHA_STATUS	0x1e		/* see status-bits */
 #define BUDDHA_CONTROL	0x11a
 
-static const u_int buddha_offsets[IDE_NR_PORTS] = {
+static int buddha_offsets[IDE_NR_PORTS] = {
     BUDDHA_DATA, BUDDHA_ERROR, BUDDHA_NSECTOR, BUDDHA_SECTOR, BUDDHA_LCYL,
     BUDDHA_HCYL, BUDDHA_SELECT, BUDDHA_STATUS, BUDDHA_CONTROL
 };
@@ -140,29 +139,23 @@
      *  We support only _one_ of them, no multiple boards!
      */
 
-int buddha_probe_hwif(int index, ide_hwif_t *hwif)
+void buddha_init(void)
 {
-    static int buddha_index[CATWEASEL_NUM_HWIFS] = { 0, };
-    int i;
+    hw_regs_t hw;
+    int i, index;
 
     if (buddha_num_hwifs < 0 && !find_buddha())
-	return 0;
+	return;
 
     for (i = 0; i < buddha_num_hwifs; i++) {
-	if (!buddha_index[i]) {
+	ide_setup_ports(&hw, (ide_ioreg_t)(buddha_board+buddha_bases[i]),
+			buddha_offsets, 0,
+			(ide_ioreg_t)(buddha_board+buddha_irqports[i]),
+			buddha_ack_intr, IRQ_AMIGA_PORTS);
+	index = ide_register_hw(&hw, NULL);
+	if (index != -1)
 	    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;
 }
Index: drivers/block/falconide.c
===================================================================
RCS file: /usr/src/cvsroot/linux-2.3/drivers/block/falconide.c,v
retrieving revision 1.1.1.1.4.1
diff -u -r1.1.1.1.4.1 falconide.c
--- falconide.c	1999/07/02 22:33:23	1.1.1.1.4.1
+++ falconide.c	1999/07/19 20:07:48
@@ -13,9 +13,8 @@
 #include <linux/interrupt.h>
 #include <linux/blkdev.h>
 #include <linux/hdreg.h>
+#include <linux/ide.h>
 
-#include "ide.h"
-
 #include <asm/atarihw.h>
 #include <asm/atariints.h>
 #include <asm/atari_stdma.h>
@@ -41,9 +40,9 @@
 #define ATA_HD_STATUS	0x1d		/* see status-bits */
 #define ATA_HD_CONTROL	0x39
 
-static const int falconide_offsets[IDE_NR_PORTS] = {
+static 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
+    ATA_HD_HCYL, ATA_HD_SELECT, ATA_HD_STATUS, ATA_HD_CONTROL, -1
 };
 
 
@@ -51,22 +50,17 @@
      *  Probe for a Falcon IDE interface
      */
 
-int falconide_probe_hwif(int index, ide_hwif_t *hwif)
+void falconide_init(void)
 {
-    static int falcon_index = 0;
-
-    if (!MACH_IS_ATARI || !ATARIHW_PRESENT(IDE))
-	return 0;
+    if (MACH_IS_ATARI && ATARIHW_PRESENT(IDE)) {
+	hw_regs_t hw;
+	int index;
+
+	ide_setup_ports(&hw, (ide_ioreg_t)ATA_HD_BASE, falconide_offsets,
+			0, 0, NULL, IRQ_MFP_IDE);
+	index = ide_register_hw(&hw, NULL);
 
-    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;
+	if (index != -1)
+	    printk("ide%d: Falcon IDE interface\n", index);
     }
-    return 0;
 }
Index: drivers/block/gayle.c
===================================================================
RCS file: /usr/src/cvsroot/linux-2.3/drivers/block/gayle.c,v
retrieving revision 1.1.1.1.4.1
diff -u -r1.1.1.1.4.1 gayle.c
--- gayle.c	1999/07/02 22:33:24	1.1.1.1.4.1
+++ gayle.c	1999/07/18 21:31:03
@@ -42,9 +42,9 @@
 #define GAYLE_STATUS	0x1e		/* see status-bits */
 #define GAYLE_CONTROL	0x101a
 
-static u_int gayle_offsets[IDE_NR_PORTS] = {
+static int gayle_offsets[IDE_NR_PORTS] = {
     GAYLE_DATA, GAYLE_ERROR, GAYLE_NSECTOR, GAYLE_SECTOR, GAYLE_LCYL,
-    GAYLE_HCYL, GAYLE_SELECT, GAYLE_STATUS, GAYLE_CONTROL
+    GAYLE_HCYL, GAYLE_SELECT, GAYLE_STATUS, -1, -1
 };
 
 
@@ -102,27 +102,48 @@
     return 1;
 }
 
-
     /*
      *  Probe for a Gayle IDE interface (and optionally for an IDE doubler)
      */
 
-int gayle_probe_hwif(int index, ide_hwif_t *hwif)
+void gayle_init(void)
 {
-    static int gayle_index[GAYLE_NUM_HWIFS] = { 0, };
     int a4000, i;
 
     if (!MACH_IS_AMIGA)
-	return 0;
+	return;
 
     if (!(a4000 = AMIGAHW_PRESENT(A4000_IDE)) && !AMIGAHW_PRESENT(A1200_IDE))
-	return 0;
-
-    if (!GAYLE_HAS_CONTROL_REG)
-	gayle_offsets[IDE_CONTROL_OFFSET] = -1;
+	return;
 
     for (i = 0; i < GAYLE_NUM_PROBE_HWIFS; i++) {
-	if (!gayle_index[i]) {
+	ide_ioreg_t base, ctrlport, irqport;
+	ide_ack_intr_t *ack_intr;
+	hw_regs_t hw;
+	int index;
+
+	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;
+	}
+
+	if (GAYLE_HAS_CONTROL_REG)
+	    ctrlport = base + GAYLE_CONTROL;
+	else
+	    ctrlport = 0;
+
+	base += i*GAYLE_NEXT_PORT;
+
+	ide_setup_ports(&hw, base, gayle_offsets,
+			ctrlport, irqport, ack_intr, IRQ_AMIGA_PORTS);
+
+	index = ide_register_hw(&hw, NULL);
+	if (index != -1) {
 	    switch (i) {
 		case 0:
 		    printk("ide%d: Gayle IDE interface (A%d style)\n", index,
@@ -134,35 +155,16 @@
 		    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;
+	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 */
     }
-    return 0;
 }
Index: drivers/block/ide-probe.c
===================================================================
RCS file: /usr/src/cvsroot/linux-2.3/drivers/block/ide-probe.c,v
retrieving revision 1.1.1.3.2.1
diff -u -r1.1.1.3.2.1 ide-probe.c
--- ide-probe.c	1999/07/02 22:33:26	1.1.1.3.2.1
+++ ide-probe.c	1999/07/18 21:10:25
@@ -404,7 +404,6 @@
 {
 	unsigned int unit;
 	unsigned long flags;
-	ide_ioreg_t ide_control_reg = hwif->io_ports[IDE_CONTROL_OFFSET];
 
 	ide_ioreg_t ide_control_reg 	= hwif->io_ports[IDE_CONTROL_OFFSET];
 	ide_ioreg_t region_low 		= hwif->io_ports[IDE_DATA_OFFSET];
Index: drivers/block/ide.c
===================================================================
RCS file: /usr/src/cvsroot/linux-2.3/drivers/block/ide.c,v
retrieving revision 1.1.1.4.2.1
diff -u -r1.1.1.4.2.1 ide.c
--- ide.c	1999/07/02 22:33:29	1.1.1.4.2.1
+++ ide.c	1999/07/19 20:09:45
@@ -140,7 +140,6 @@
 #include <linux/kmod.h>
 #endif /* CONFIG_KMOD */
 
-
 #ifdef CONFIG_BLK_DEV_VIA82C586
 extern byte fifoconfig;           /* defined in via82c586.c used by ide_setup()*/
 #endif
@@ -198,55 +197,6 @@
 }
 
 /*
- * Setup the machine dependent stuff of an IDE interface
- */
-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)
-{
-    int i;
-
-    for (i = 0; i < IDE_IRQ_OFFSET; i++)
-	/* offset -1 means not present */
-	hwif->io_ports[i] = offsets[i] != -1 ? base+offsets[i] : 0;
-    hwif->io_ports[IDE_IRQ_OFFSET] = irqport;
-    hwif->ack_intr = ack_intr;
-}
-
-/*
- * Probe for available interfaces
- */
-static int probe_hwif(int index, ide_hwif_t *hwif)
-{
-    extern int pcide_probe_hwif(int index, ide_hwif_t *hwif);
-    extern int gayle_probe_hwif(int index, ide_hwif_t *hwif);
-    extern int falconide_probe_hwif(int index, ide_hwif_t *hwif);
-    extern int macide_probe_hwif(int index, ide_hwif_t *hwif);
-    extern int buddha_probe_hwif(int index, ide_hwif_t *hwif);
-    extern int q40ide_probe_hwif(int index, ide_hwif_t *hwif);
-
-    return 0
-#ifdef CONFIG_BLK_DEV_PCIDE
-	|| pcide_probe_hwif(index, hwif)
-#endif
-#ifdef CONFIG_BLK_DEV_GAYLE
-	|| gayle_probe_hwif(index, hwif)
-#endif
-#ifdef CONFIG_BLK_DEV_FALCON_IDE
-	|| falconide_probe_hwif(index, hwif)
-#endif
-#ifdef CONFIG_BLK_DEV_MAC_IDE
-	|| macide_probe_hwif(index, hwif)
-#endif
-#ifdef CONFIG_BLK_DEV_BUDDHA
-	|| buddha_probe_hwif(index, hwif)
-#endif
-#ifdef CONFIG_Q40
-        || q40ide_probe_hwif(index, hwif)
-#endif
-    ;
-}
-
-/*
  * Do not even *think* about calling this!
  */
 static void init_hwif_data (unsigned int index)
@@ -264,7 +214,7 @@
 	ide_init_hwif_ports(&hw, ide_default_io_base(index), 0, &hwif->irq);
 	memcpy(&hwif->hw, &hw, sizeof(hw));
 	memcpy(hwif->io_ports, hw.io_ports, sizeof(hw.io_ports));
-	hwif->noprobe = !probe_hwif(index, hwif);
+	hwif->noprobe   = !hwif->io_ports[IDE_DATA_OFFSET];
 #ifdef CONFIG_BLK_DEV_HD
 	if (hwif->io_ports[IDE_DATA_OFFSET] == HD_DATA)
 		hwif->noprobe = 1; /* may be overridden by ide_setup() */
@@ -728,7 +678,7 @@
 
 #if OK_TO_RESET_CONTROLLER
 	if (!IDE_CONTROL_REG) {
-		__restore_flags (flags);
+		__restore_flags(flags);
 		return;
 	}
 	/*
@@ -2675,16 +2625,6 @@
 	const char max_drive = 'a' + ((MAX_HWIFS * MAX_DRIVES) - 1);
 	const char max_hwif  = '0' + (MAX_HWIFS - 1);
 
-#ifdef CONFIG_BLK_DEV_IDEDOUBLER
-	if (!strcmp(s, "ide=doubler")) {
-		extern int ide_doubler;
-
-		printk("ide: Enabled support for IDE doublers\n");
-		ide_doubler = 1;
-		return;
-	}
-#endif /* CONFIG_BLK_DEV_IDEDOUBLER */
-
 	printk("ide_setup: %s", s);
 
 #ifdef CONFIG_BLK_DEV_IDEDOUBLER
@@ -3180,7 +3120,7 @@
 		enable_irq(ide_hwifs[0].irq);
 		ide_release_lock(&ide_lock);
 	}
-#endif /* __mc68000__ || CONFIG_APUS*/
+#endif /* __mc68000__ || CONFIG_APUS */
 #endif /* CONFIG_BLK_DEV_IDE */
 
 #ifdef CONFIG_PROC_FS
Index: drivers/block/macide.c
===================================================================
RCS file: /usr/src/cvsroot/linux-2.3/drivers/block/macide.c,v
retrieving revision 1.1.1.1.4.1
diff -u -r1.1.1.1.4.1 macide.c
--- macide.c	1999/07/02 22:33:30	1.1.1.1.4.1
+++ macide.c	1999/07/19 20:13:02
@@ -17,9 +17,8 @@
 #include <linux/blkdev.h>
 #include <linux/hdreg.h>
 #include <linux/zorro.h>
+#include <linux/ide.h>
 
-#include "ide.h"
-
 #include <asm/machw.h>
 #include <asm/macintosh.h>
 #include <asm/macints.h>
@@ -44,7 +43,7 @@
 #define MAC_HD_STATUS	0x1c		/* see status-bits */
 #define MAC_HD_CONTROL	0x38		/* control/altstatus */
 
-static const int macide_offsets[IDE_NR_PORTS] = {
+static int macide_offsets[IDE_NR_PORTS] = {
     MAC_HD_DATA, MAC_HD_ERROR, MAC_HD_NSECTOR, MAC_HD_SECTOR, MAC_HD_LCYL,
     MAC_HD_HCYL, MAC_HD_SELECT, MAC_HD_STATUS, MAC_HD_CONTROL
 };
@@ -104,24 +103,6 @@
 	ide_intr(mac_hwif->irq, mac_hwif->hwgroup, regs);
 }
 
-	/*
-	 * Seems we need this for the Quadra 630 to make sure IDE interrupts
-	 * aren't lost while we were processing other slot interrupts :-(
-	 */
-
-int (*mac_ide_irq_p_hook)(void) = NULL;
-
-int mac_ide_irq_p (void)
-{
-	unsigned char ch;
-	ide_hwif_t *hwif = mac_hwif;
-
-	ch = inb(hwif->io_ports[IDE_IRQ_OFFSET]);
-	if (!(ch & 0x20))
-		return 0;
-	return 1;
-}
-
     /*
      *  Check the interrupt status
      *
@@ -151,40 +132,36 @@
      *  Probe for a Macintosh IDE interface
      */
 
-int macide_probe_hwif(int index, ide_hwif_t *hwif)
+void macide_init(void)
 {
-    static int mac_index = 0;
+    hw_regs_t hw;
+    int index = -1;
 
-    if (!MACH_IS_MAC || macintosh_config->ide_type == 0)
-	return 0;
+    if (MACH_IS_MAC) {
+	switch(macintosh_config->ide_type) {
+	case 0:
+	    break;
+
+	case MAC_IDE_QUADRA:
+	    ide_setup_ports(&hw, (ide_ioreg_t)MAC_HD_BASE, macide_offsets,
+	    		    0, (ide_ioreg_t)(MAC_HD_BASE+MAC_HD_ISR),
+			    mac_ack_intr, IRQ_MAC_NUBUS);
+	    index = ide_register_hw(&hw, &mac_hwif);
+	    mac_ide_intr_hook = mac_ide_intr;
+	    break;
+
+	default:
+	    ide_setup_ports(&hw, (ide_ioreg_t)MAC_HD_BASE, macide_offsets,
+	    		    0, 0, NULL, IRQ_MAC_NUBUS);
+	    index = ide_register_hw(&hw, &mac_hwif);
+	    break;
+	}
 
-    if (!mac_index) {
-	if (macintosh_config->ide_type == MAC_IDE_QUADRA)
+        if (index != -1) {
+	    if (macintosh_config->ide_type == MAC_IDE_QUADRA)
 		printk("ide%d: Macintosh Quadra IDE interface\n", index);
-	else
+	    else
 		printk("ide%d: Macintosh Powerbook IDE interface\n", index);
-	mac_index = index+1;
-    }
-    if (mac_index == index+1) {
-	/* Quadra (pseudo Nubus interrupt) needs to check interrupt status */
-	if (macintosh_config->ide_type == MAC_IDE_QUADRA)
-		ide_setup_ports(hwif, (ide_ioreg_t)MAC_HD_BASE, macide_offsets, 
-				(ide_ioreg_t)(MAC_HD_BASE+MAC_HD_ISR), 
-				mac_ack_intr);
-	else
-		ide_setup_ports(hwif, (ide_ioreg_t)MAC_HD_BASE, macide_offsets, 
-				0, NULL);
-
-	hwif->irq = IRQ_MAC_NUBUS;
-
-	/* set IDE interrupt hook for Nubus dispatch (Quadra only) */
-	if (macintosh_config->ide_type == MAC_IDE_QUADRA)
-		mac_ide_intr_hook = mac_ide_intr;
-
-	/* XXX remember interface struct for reference in interrupt wrapper */
-	mac_hwif = hwif;
-
-	return 1;
+	}
     }
-    return 0;
 }
Index: include/asm-m68k/ide.h
===================================================================
RCS file: /usr/src/cvsroot/linux-2.3/include/asm-m68k/ide.h,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 ide.h
--- ide.h	1999/05/18 14:10:57	1.1.1.2
+++ ide.h	1999/07/23 19:55:42
@@ -63,7 +63,7 @@
 static __inline__ ide_ioreg_t ide_default_io_base(int index)
 {
 	if (MACH_IS_Q40)
-		return q40ide_default_io_base(index);
+		return (ide_ioreg_t)q40ide_default_io_base(index);
 	else return 0;
 }
 
@@ -82,7 +82,8 @@
 	if (MACH_IS_Q40)
 		return q40_ide_init_hwif_ports(hw, (q40ide_ioreg_t) data_port, (q40ide_ioreg_t) ctrl_port, irq);
 #endif
-	printk("ide_init_hwif_ports: must not be called\n");
+	if (data_port || ctrl_port)
+		printk("ide_init_hwif_ports: must not be called\n");
 }
 
 /*

