Resent-Date: Mon, 11 Jan 1999 09:59:03 +0100 (MET)
Date: Mon, 11 Jan 1999 10:00:30 +0100 (CET)
From: "Christian T. Steigies" <cts@ap031.experimentalphysik.uni-kiel.de>
Reply-To: "Christian T. Steigies" <steigies@physik.uni-kiel.de>
To: linux-m68k <linux-m68k@lists.linux-m68k.org>
Subject: Re: 2.0.36pre2
In-Reply-To: <199901071825.TAA10324@valhall.cern.ch>
Resent-From: linux-m68k@phil.uni-sb.de

Hi,
I made a very stupid mistake in the ariadne2 code I sent in least week.
Please apply this on top of that patch (the ether addr is not set, when
ARIADNE2_DEBUG is not set...)
And still, I only get it to work when its compiled into the kernel, not as a
module. Did I mess up something else, Roman Z.?

--- drivers/net/ariadne2.c.org	Sun Jan 10 20:08:25 1999
+++ drivers/net/ariadne2.c	Sun Jan 10 20:06:23 1999
@@ -197,11 +197,13 @@
 
     ((struct ei_device *)dev->priv)->priv = key; 
 
-#ifdef ARIADNE2_DEBUG
     for(i = 0; i < ETHER_ADDR_LEN; i++) {
+#ifdef ARIADNE2_DEBUG
 	printk(" %2.2x", SA_prom[i]);
+#endif
 	dev->dev_addr[i] = SA_prom[i];
     } /* do we have to print the address twice? */
+#ifdef ARIADNE2_DEBUG
     printk("\n");
 #endif
 
This one adds Buddha/Catweasel support for the first controller only (ie
only one out of two (three for the Catweasel)). Its working for me, I dont
know why I get a kernel oops if I try with more controllers, but I didnt try
too hard. Maybe it should be capsuled in something like #ifdef EXPERIMENTAL?
But I didnt see that this is defined somewhere, it could be added in
Config.in. Is this needed? Will this go in as its new code?
Oh yes, and it corrects a small typo :-)

Ciao,
Christian.

--- drivers/block/ide.c.orig	Tue Dec  1 17:32:35 1998
+++ drivers/block/ide.c	Sun Jan 10 19:45:01 1999
@@ -854,11 +854,11 @@
  * individually reset without clobbering other devices on the same interface.
  *
  * Unfortunately, the IDE interface does not generate an interrupt to let
- * us know when the reset operation has finished, so we must poll for this.
- * Equally poor, though, is the fact that this may a very long time to complete,
- * (up to 30 seconds worstcase).  So, instead of busy-waiting here for it,
- * we set a timer to poll at 50ms intervals.
- */
+ * us know when the reset operation has finished, so we must poll for this. 
+ * Equally poor, though, is the fact that this may take a very long time to
+ * complete, (up to 30 seconds worstcase).  So, instead of busy-waiting here
+ * for it, we set a timer to poll at 50ms intervals.
+ */ 
 static void do_reset1 (ide_drive_t *drive, int  do_not_try_atapi)
 {
 	unsigned int unit;
@@ -3848,6 +3848,8 @@
 static void ide_probe_amiga (void)
 {
 	ide_hwif_t *hwif = &ide_hwifs[0];
+	ide_hwif_t *hwif2 = &ide_hwifs[1]; /* Buddha/Catweasel */
+	ide_hwif_t *hwif3 = &ide_hwifs[2]; /* Catweasel */
 
 	if (!MACH_IS_AMIGA)
 		return;
@@ -3865,9 +3867,81 @@
 		printk("Gayle IDE interface (A1200 style)\n");
 	} else /* Not A4000 nor A1200, 
 		  doesn't have a supported IDE controller */
-		{
-			hwif->noprobe = 1;
-			return;
+		{ /* maybe we have a Buddha or Catweasel controller? */
+			int key; 
+			const struct ConfigDev *cd;
+	#include "buddha.h"
+			
+			if ((key = zorro_find(MANUF_INDIVIDUAL_COMP, PROD_BUDDHA, 0, 0))) {
+				buddha_num_hwifs = BUDDHA_NUM_HWIFS;
+				printk("Buddha IDE interface\n");
+			} else if ((key = zorro_find(MANUF_INDIVIDUAL_COMP, PROD_CATWEASEL, 0, 0))) {
+				buddha_num_hwifs = CATWEASEL_NUM_HWIFS;
+				printk("Catweasel IDE interface\n");
+			}
+			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);
+
+					hwif->io_base = (unsigned char *)(buddha_board + BUDDHA_BASE1); 
+					hwif->hd_regs.hd_irq = (unsigned char *)(buddha_board + BUDDHA_IRQ1);
+					hwif->hd_regs.hd_error   = hwif->io_base + BUDDHA_ERROR;
+					hwif->hd_regs.hd_nsector = hwif->io_base + BUDDHA_NSECTOR;
+					hwif->hd_regs.hd_sector  = hwif->io_base + BUDDHA_SECTOR;
+					hwif->hd_regs.hd_lcyl    = hwif->io_base + BUDDHA_LCYL;
+					hwif->hd_regs.hd_hcyl    = hwif->io_base + BUDDHA_HCYL;
+					hwif->hd_regs.hd_select  = hwif->io_base + BUDDHA_SELECT;
+					hwif->hd_regs.hd_status  = hwif->io_base + BUDDHA_STATUS;
+					hwif->ctl_port           = hwif->io_base + BUDDHA_CONTROL;
+#if 1
+					buddha_num_hwifs = 1; /* we support only the first controller for now */
+#endif
+					if (buddha_num_hwifs > 1) {
+						hwif2->io_base = (unsigned char *)(buddha_board + BUDDHA_BASE2); 
+						hwif2->hd_regs.hd_irq = (unsigned char *)(buddha_board + BUDDHA_IRQ2);
+						hwif2->hd_regs.hd_error   = hwif2->io_base + BUDDHA_ERROR;
+						hwif2->hd_regs.hd_nsector = hwif2->io_base + BUDDHA_NSECTOR;
+						hwif2->hd_regs.hd_sector  = hwif2->io_base + BUDDHA_SECTOR;
+						hwif2->hd_regs.hd_lcyl    = hwif2->io_base + BUDDHA_LCYL;
+						hwif2->hd_regs.hd_hcyl    = hwif2->io_base + BUDDHA_HCYL;
+						hwif2->hd_regs.hd_select  = hwif2->io_base + BUDDHA_SELECT;
+						hwif2->hd_regs.hd_status  = hwif2->io_base + BUDDHA_STATUS;
+						hwif2->ctl_port           = hwif2->io_base + BUDDHA_CONTROL;
+					}
+					if (buddha_num_hwifs > 2) {
+						hwif3->io_base = (unsigned char *)(buddha_board + BUDDHA_BASE3); 
+						hwif3->hd_regs.hd_irq = (unsigned char *)(buddha_board + BUDDHA_IRQ3);
+						hwif3->hd_regs.hd_error   = hwif3->io_base + BUDDHA_ERROR;
+						hwif3->hd_regs.hd_nsector = hwif3->io_base + BUDDHA_NSECTOR;
+						hwif3->hd_regs.hd_sector  = hwif3->io_base + BUDDHA_SECTOR;
+						hwif3->hd_regs.hd_lcyl    = hwif3->io_base + BUDDHA_LCYL;
+						hwif3->hd_regs.hd_hcyl    = hwif3->io_base + BUDDHA_HCYL;
+						hwif3->hd_regs.hd_select  = hwif3->io_base + BUDDHA_SELECT;
+						hwif3->hd_regs.hd_status  = hwif3->io_base + BUDDHA_STATUS;
+						hwif3->ctl_port           = hwif3->io_base + BUDDHA_CONTROL;
+					}
+
+					/* Disable interrupt for probing */
+					disable_irq(hwif->irq);
+					if (buddha_num_hwifs > 1) 
+						disable_irq(hwif2->irq); /* interrupts for the other controllers */
+					if (buddha_num_hwifs > 2) 
+						disable_irq(hwif3->irq); /* have to be enabled also? */
+					return;
+				} else { /* can this happen ? */
+					hwif->noprobe = 1;
+					return;
+				}
+			} else /* so we don't have Buddha or Catweasel either */
+			{
+				hwif->noprobe = 1;
+				return;
+			}
 		}
 
 	/* Now set the hd_regs struct */
--- drivers/block/buddha.h.orig	Sun Jan 10 19:35:31 1999
+++ drivers/block/buddha.h	Sun Jan 10 19:52:25 1999
@@ -0,0 +1,80 @@
+/*  This file as well as the changes in ide.c are based on 
+ *  linux/drivers/block/buddha.c from linux-2.1.131
+ *
+ *  - tested on A2000, currently only one controller is working
+ *    19-01-1999 CTS
+ *
+ *
+ *  linux/drivers/block/buddha.c -- Amiga Buddha and Catweasel IDE Driver
+ *
+ *      Copyright (C) 1997 by Geert Uytterhoeven
+ *
+ *  This driver was written by based on the specifications in README.buddha.
+ *
+ *  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.
+ *
+ *  TODO:
+ *    - test it :-)
+ *    - tune the timings using the speed-register
+ */
+              
+#ifndef _BUDDHA_H
+#define _BUDDHA_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
+
+
+    /*
+     *  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
+
+
+    /*
+     *  Other registers
+     */
+
+#define BUDDHA_IRQ1	0xf00		/* MSB = 1, Harddisk is source of */
+#define BUDDHA_IRQ2	0xf40		/* interrupt */
+#define BUDDHA_IRQ3	0xf80
+
+
+#define BUDDHA_IRQ_MR	0xfc0		/* master interrupt enable */
+
+
+    /*
+     *  Board information
+     */
+
+static u_long buddha_board = 0;
+static int buddha_num_hwifs = -1;
+
+
+
+#endif /* _BUDDHA_H */

