NetBSD Problem Report #1594

From gnats  Fri Oct 13 16:13:43 1995
Received: from sraigw.sra.co.jp by pain.lcs.mit.edu (8.6.9/8.6.9) with ESMTP id PAA04714 for <gnats-bugs@NetBSD.ORG>; Fri, 13 Oct 1995 15:56:04 -0400
Message-Id: <199510132016.FAA02881@dialup5.sra.co.jp>
Date: Sat, 14 Oct 1995 05:16:42 +0900
From: soda@sra.co.jp
Reply-To: soda@sra.co.jp
To: gnats-bugs@netbsd.org
Cc: soda@sra.co.jp
Subject: Adaptec AHA-2740/2840 support patch
X-Send-Pr-Version: 3.2

>Number:         1594
>Category:       port-i386
>Synopsis:       Adaptec AHA-2740/2840 support patch
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    gnats-admin
>State:          closed
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Fri Oct 13 16:20:05 +0000 1995
>Closed-Date:    Sat Jan 13 02:09:21 +0000 1996
>Last-Modified:  Sat Jan 13 02:10:11 +0000 1996
>Originator:     Noriyuki Soda
>Release:        1.0A
>Organization:
Software Research Associates, Inc., Japan
software tools and technology group
>Environment:
System: NetBSD james 1.0A NetBSD 1.0A (PALM) #1: Fri Oct 13 04:33:17 JST 1995 soda@james:/usr/src/sys/arch/i386/compile/PALM i386

	This patch is based on NetBSD-current 1995/10/10 kernel.

>Description:

	Adaptec AHA-2740/2840 support patch for sys/dev/pci/aic7870.c,
	based on FreeBSD's aic7770.c revision 1.15 by Justin T. Gibbs.
	($Id: aic7770.c,v 1.15 1995/07/04 21:14:16 gibbs Exp $)

>How-To-Repeat:
>Fix:

	% cd /usr/src/sys/dev/pci
	% patch < THE-FOLLOWING-PATCH

	change /usr/src/sys/dev/pci/files.pci
	from
				# Adaptec AIC-7870 ICs
		this line ->	device	ahc at pci: scsi
				file	dev/pci/aic7870.c		ahc
				file	dev/ic/aic7xxx.c		ahc
	to
				# Adaptec AIC-7770/7870 ICs
		this line ->	device	ahc at isa, pci: scsi
				file	dev/pci/aic7870.c		ahc
				file	dev/ic/aic7xxx.c		ahc
	(sorry for inconvenience, I cannot make diff, because I haven't get
	 latest files.pci, yet)

	NOTE:
	- indentation is not changed, due to reduce patch size.
	- probably aic7870.c is not suitable name, now.
	- probably sys/dev/pci is not suitable place, now. (sys/dev/isa ?)

--- CUT HERE --- CUT HERE --- CUT HERE --- CUT HERE --- CUT HERE ---
diff -ur ../org/aic7870.c ./aic7870.c
--- ../org/aic7870.c	Sat Oct 14 04:18:24 1995
+++ ./aic7870.c	Sat Oct 14 04:16:37 1995
@@ -31,15 +31,52 @@
 #include <scsi/scsi_all.h>
 #include <scsi/scsiconf.h>

+#include "isa.h"
+#include "pci.h"
+
+#if NISA > 0
+#include <dev/isa/isareg.h>
+#include <dev/isa/isavar.h>
+#include <dev/isa/isadmavar.h>
+#include <machine/pio.h>
+#endif
+
+#if NPCI > 0
 #include <dev/pci/pcireg.h>
 #include <dev/pci/pcivar.h>
+#endif
+
 #include <dev/ic/aic7xxxvar.h>

+#if NISA > 0
+/*
+ * Standard EISA Host ID regs  (Offset from slot base)
+ */
+
+#define HID0		0xC80	/* 0,1: msb of ID2, 2-7: ID1      */
+#define HID1		0xC81	/* 0-4: ID3, 5-7: LSB ID2         */
+#define HID2		0xC82	/* product                        */
+#define HID3		0xC83	/* firmware revision              */
+
+#define CHAR1(B1,B2) (((B1>>2) & 0x1F) | '@')
+#define CHAR2(B1,B2) (((B1<<3) & 0x18) | ((B2>>5) & 0x7)|'@')
+#define CHAR3(B1,B2) ((B2 & 0x1F) | '@')
+
+#define	EISA_MAX_SLOTS	16	/* XXX should be defined in a common header */
+static	ahc_slot = 0;		/* slot last board was found in */
+
+typedef struct {
+	ahc_type type;
+	unsigned char id; /* The Last EISA Host ID reg */
+} aic7770_sig;
+
+#endif /* NISA */

+#if NPCI > 0
 #define PCI_BASEADR0	PCI_MAP_REG_START
 #define PCI_DEVICE_ID_ADAPTEC_2940	0x71789004ul
 #define PCI_DEVICE_ID_ADAPTEC_AIC7870	0x70789004ul
-
+#endif

 static int aic7870_probe();
 static void aic7870_attach();
@@ -57,11 +94,78 @@
         struct device *parent;
         void *match, *aux; 
 {       
-        struct pci_attach_args *pa = aux;
+	extern struct cfdriver isacd, pcicd;
+#if NISA > 0
+	struct ahc_softc *sc = match;
+	int iobase;
+	int i;
+	u_char sig_id[4];
+
+	aic7770_sig valid_ids[] = {
+	/* Entries of other tested adaptors should be added here */
+		{ AHC_274,	0x71 }, /*274x*/
+		{ AHC_274,	0x70 }, /*aic7770 on Motherboard*/
+		{ AHC_284,	0x56 }, /*284x, BIOS enabled*/
+		{ AHC_284,	0x57 }  /*284x, BIOS disabled*/
+	};
+
+	if (parent->dv_cfdata->cf_driver == &isacd) {
+		struct isa_attach_args *ia = aux;
+
+		ahc_slot++;
+		for (; ahc_slot < EISA_MAX_SLOTS; ahc_slot++) {
+			iobase = 0x1000 * ahc_slot;
+			for (i = 0; i < sizeof(sig_id); i++) {
+				/*
+				 * An outb is required to prime these
+				 * registers on VL cards
+				 */
+				outb(iobase + HID0, HID0 + i);
+				sig_id[i] = inb(iobase + HID0 + i);
+			}
+			if (sig_id[0] == 0xff)
+				continue;
+			/* Check manufacturer's ID. */
+			if (CHAR1(sig_id[0], sig_id[1]) != 'A' ||
+			    CHAR2(sig_id[0], sig_id[1]) != 'D' ||
+			    CHAR3(sig_id[0], sig_id[1]) != 'P' ||
+			    sig_id[2] != 0x77)
+				continue;
+			for (i = 0; i < sizeof(valid_ids)/sizeof(aic7770_sig);
+			     i++) {
+				if (sig_id[3] != valid_ids[i].id)
+					continue;
+				sc->type = valid_ids[i].type;
+				if (!ahcprobe(sc, iobase))
+					continue;
+				if (ia->ia_irq == IRQUNK) {
+					ia->ia_irq = sc->sc_irq;
+				} else if (ia->ia_irq != sc->sc_irq) {
+					printf("%s: irq mismatch; kernel configured %d != board configured %d\n",
+					       sc->sc_dev.dv_xname,
+					       ia->ia_irq, sc->sc_irq);
+					return 0;
+				}
+
+				ia->ia_msize = 0;
+				ia->ia_iobase =	iobase + 0xc00;
+				/* XXX - should #define in a common header */
+				ia->ia_iosize = 256; /* IO_EISASIZE */
+				return 1;
+			}
+		}
+	}
+#endif /* NISA */
+
+#if NPCI > 0
+	if (parent->dv_cfdata->cf_driver == &pcicd) {
+	struct pci_attach_args *pa = aux;

 	if (pa->pa_id != PCI_DEVICE_ID_ADAPTEC_2940 &&
 	    pa->pa_id != PCI_DEVICE_ID_ADAPTEC_AIC7870)
 		return (0);
+	}
+#endif /* NPCI */

 	return (1);
 }
@@ -71,8 +175,12 @@
         struct device *parent, *self;
         void *aux;
 {       
-        struct pci_attach_args *pa = aux;
-        struct ahc_softc *ahc = (void *)self;
+	struct ahc_softc *ahc = (void *)self;
+	extern struct cfdriver isacd, pcicd;
+
+#if NPCI > 0
+	if (parent->dv_cfdata->cf_driver == &pcicd) {
+	struct pci_attach_args *pa = aux;
 	int iobase; 

         switch (pa->pa_id) {
@@ -98,4 +206,17 @@
 	ahcattach(ahc);

 	ahc->sc_ih = pci_map_int(pa->pa_tag, PCI_IPL_BIO, ahcintr, ahc);
-}       
+	}
+#endif /* NPCI */
+
+#if NISA > 0
+	if (parent->dv_cfdata->cf_driver == &isacd) {
+		struct isa_attach_args *ia = aux;
+
+		ahcattach(ahc);
+		ahc->sc_ih = isa_intr_establish(ia->ia_irq,
+						ISA_IST_EDGE, ISA_IPL_BIO,
+						ahcintr, ahc);
+	}
+#endif /* NISA */
+}
--- CUT HERE --- CUT HERE --- CUT HERE --- CUT HERE --- CUT HERE ---
--
soda@sra.co.jp		Software Research Associates, Inc., Japan
(Noriyuki Soda)		   software tools and technology group
>Release-Note:
>Audit-Trail:

From: Noriyuki Soda <soda@sra.co.jp>
To: gnats-bugs@gnats.netbsd.org
Cc: gnats-admin@netbsd.org, soda@sra.co.jp
Subject: Re: port-i386/1594: Adaptec AHA-2740/2840 support patch
Date: Thu, 2 Nov 1995 03:48:01 +0900

 Sorry, my PR of AHA-2740/2840 support patch for AHA-2940 driver
 has obvious error, fix is the following.

 ------------------------------------------------------------------------
 --- aic7870.c-	Thu Nov  2 04:05:43 1995
 +++ aic7870.c	Mon Oct 30 05:31:23 1995
 @@ -164,10 +164,12 @@
  	if (pa->pa_id != PCI_DEVICE_ID_ADAPTEC_2940 &&
  	    pa->pa_id != PCI_DEVICE_ID_ADAPTEC_AIC7870)
  		return (0);
 +
 +	return (1);
  	}
  #endif /* NPCI */

 -	return (1);
 +	return (0);
  }

  void    
 ------------------------------------------------------------------------
 --
 soda@sra.co.jp		Software Research Associates, Inc., Japan
 (Noriyuki Soda)		   software tools and technology group
State-Changed-From-To: open->closed 
State-Changed-By: thorpej 
State-Changed-When: Fri Jan 12 18:09:21 PST 1996 
State-Changed-Why:  
Added "ahe" driver from Michael Graff which incorporates these changes, 
but uses a different driver name to avoid cross-dependency. 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.