Home | History | Annotate | Line # | Download | only in isa
ahc_isa.c revision 1.7
      1  1.7   thorpej /*	$NetBSD: ahc_isa.c,v 1.7 1997/10/04 17:30:15 thorpej Exp $	*/
      2  1.7   thorpej 
      3  1.7   thorpej /*-
      4  1.7   thorpej  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
      5  1.7   thorpej  * All rights reserved.
      6  1.7   thorpej  *
      7  1.7   thorpej  * This code is derived from software contributed to The NetBSD Foundation
      8  1.7   thorpej  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
      9  1.7   thorpej  * NASA Ames Research Center.
     10  1.7   thorpej  *
     11  1.7   thorpej  * Redistribution and use in source and binary forms, with or without
     12  1.7   thorpej  * modification, are permitted provided that the following conditions
     13  1.7   thorpej  * are met:
     14  1.7   thorpej  * 1. Redistributions of source code must retain the above copyright
     15  1.7   thorpej  *    notice, this list of conditions and the following disclaimer.
     16  1.7   thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     17  1.7   thorpej  *    notice, this list of conditions and the following disclaimer in the
     18  1.7   thorpej  *    documentation and/or other materials provided with the distribution.
     19  1.7   thorpej  * 3. All advertising materials mentioning features or use of this software
     20  1.7   thorpej  *    must display the following acknowledgement:
     21  1.7   thorpej  *	This product includes software developed by the NetBSD
     22  1.7   thorpej  *	Foundation, Inc. and its contributors.
     23  1.7   thorpej  * 4. Neither the name of The NetBSD Foundation nor the names of its
     24  1.7   thorpej  *    contributors may be used to endorse or promote products derived
     25  1.7   thorpej  *    from this software without specific prior written permission.
     26  1.7   thorpej  *
     27  1.7   thorpej  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     28  1.7   thorpej  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     29  1.7   thorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     30  1.7   thorpej  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     31  1.7   thorpej  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     32  1.7   thorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     33  1.7   thorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     34  1.7   thorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     35  1.7   thorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     36  1.7   thorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     37  1.7   thorpej  * POSSIBILITY OF SUCH DAMAGE.
     38  1.7   thorpej  */
     39  1.1      soda 
     40  1.1      soda /*
     41  1.1      soda  * Product specific probe and attach routines for:
     42  1.1      soda  * 	284X VLbus SCSI controllers
     43  1.1      soda  *
     44  1.1      soda  * Copyright (c) 1995, 1996 Christopher G. Demetriou.
     45  1.1      soda  * All rights reserved.
     46  1.1      soda  *
     47  1.1      soda  * Copyright (c) 1994, 1995, 1996 Justin T. Gibbs.
     48  1.1      soda  * All rights reserved.
     49  1.1      soda  *
     50  1.1      soda  * Redistribution and use in source and binary forms, with or without
     51  1.1      soda  * modification, are permitted provided that the following conditions
     52  1.1      soda  * are met:
     53  1.1      soda  * 1. Redistributions of source code must retain the above copyright
     54  1.1      soda  *    notice immediately at the beginning of the file, without modification,
     55  1.1      soda  *    this list of conditions, and the following disclaimer.
     56  1.1      soda  * 2. Redistributions in binary form must reproduce the above copyright
     57  1.1      soda  *    notice, this list of conditions and the following disclaimer in the
     58  1.1      soda  *    documentation and/or other materials provided with the distribution.
     59  1.1      soda  * 3. All advertising materials mentioning features or use of this software
     60  1.1      soda  *    must display the following acknowledgement:
     61  1.1      soda  *	This product includes software developed by Christopher G. Demetriou
     62  1.1      soda  *	for the NetBSD Project.
     63  1.1      soda  * 4. The name of the author may not be used to endorse or promote products
     64  1.1      soda  *    derived from this software without specific prior written permission.
     65  1.1      soda  *
     66  1.1      soda  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     67  1.1      soda  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     68  1.1      soda  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     69  1.1      soda  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
     70  1.1      soda  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     71  1.1      soda  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     72  1.1      soda  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     73  1.1      soda  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     74  1.1      soda  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     75  1.1      soda  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     76  1.1      soda  * SUCH DAMAGE.
     77  1.1      soda  */
     78  1.1      soda 
     79  1.1      soda /*
     80  1.1      soda  * This front-end driver is really sort of a hack.  The AHA-284X likes
     81  1.1      soda  * to masquerade as an EISA device.  However, on VLbus machines with
     82  1.1      soda  * no EISA signature in the BIOS, the EISA bus will never be scanned.
     83  1.1      soda  * This is intended to catch the 284X controllers on those systems
     84  1.1      soda  * by looking in "EISA i/o space" for 284X controllers.
     85  1.1      soda  *
     86  1.1      soda  * This relies heavily on i/o port accounting.  We also just use the
     87  1.1      soda  * EISA macros for everything ... it's a real waste to redefine them.
     88  1.1      soda  *
     89  1.1      soda  * Note: there isn't any #ifdef for FreeBSD in this file, since the
     90  1.1      soda  * FreeBSD EISA driver handles all cases of the 284X.
     91  1.1      soda  *
     92  1.1      soda  *	-- Jason R. Thorpe <thorpej (at) NetBSD.ORG>
     93  1.1      soda  *	   July 12, 1996
     94  1.1      soda  *
     95  1.1      soda  * TODO: some code could be shared with ahc_eisa.c, but it would probably
     96  1.1      soda  * be a logistical mightmare to even try.
     97  1.1      soda  */
     98  1.1      soda 
     99  1.1      soda #include <sys/param.h>
    100  1.1      soda #include <sys/systm.h>
    101  1.1      soda #include <sys/kernel.h>
    102  1.1      soda #include <sys/device.h>
    103  1.1      soda #include <sys/queue.h>
    104  1.1      soda #include <sys/malloc.h>
    105  1.1      soda 
    106  1.1      soda #include <machine/bus.h>
    107  1.1      soda #include <machine/intr.h>
    108  1.1      soda 
    109  1.6    bouyer #include <dev/scsipi/scsi_all.h>
    110  1.6    bouyer #include <dev/scsipi/scsipi_all.h>
    111  1.6    bouyer #include <dev/scsipi/scsiconf.h>
    112  1.1      soda 
    113  1.1      soda #include <dev/isa/isavar.h>
    114  1.1      soda 
    115  1.1      soda #include <dev/eisa/eisareg.h>
    116  1.1      soda #include <dev/eisa/eisavar.h>
    117  1.1      soda #include <dev/eisa/eisadevs.h>
    118  1.1      soda 
    119  1.1      soda #include <dev/ic/aic7xxxreg.h>
    120  1.1      soda #include <dev/ic/aic7xxxvar.h>
    121  1.1      soda 
    122  1.1      soda /* IO port address setting range as EISA slot number */
    123  1.1      soda #define AHC_ISA_MIN_SLOT	0x1	/* from iobase = 0x1c00 */
    124  1.1      soda #define AHC_ISA_MAX_SLOT	0xe	/* to   iobase = 0xec00 */
    125  1.1      soda 
    126  1.1      soda #define AHC_ISA_SLOT_OFFSET	0xc00	/* offset from EISA IO space */
    127  1.1      soda #define AHC_ISA_IOSIZE		0x100
    128  1.1      soda 
    129  1.1      soda /*
    130  1.1      soda  * I/O port offsets
    131  1.1      soda  */
    132  1.1      soda #define INTDEF			0x5cul	/* Interrupt Definition Register */
    133  1.1      soda #define	AHC_ISA_VID		(EISA_SLOTOFF_VID - AHC_ISA_SLOT_OFFSET)
    134  1.1      soda #define	AHC_ISA_PID		(EISA_SLOTOFF_PID - AHC_ISA_SLOT_OFFSET)
    135  1.1      soda #define	AHC_ISA_PRIMING		AHC_ISA_VID	/* enable vendor/product ID */
    136  1.1      soda 
    137  1.1      soda /*
    138  1.1      soda  * AHC_ISA_PRIMING register values (write)
    139  1.1      soda  */
    140  1.1      soda #define	AHC_ISA_PRIMING_VID(index)	(AHC_ISA_VID + (index))
    141  1.1      soda #define	AHC_ISA_PRIMING_PID(index)	(AHC_ISA_PID + (index))
    142  1.1      soda 
    143  1.5   thorpej int	ahc_isa_irq __P((bus_space_tag_t, bus_space_handle_t));
    144  1.5   thorpej int	ahc_isa_idstring __P((bus_space_tag_t, bus_space_handle_t, char *));
    145  1.5   thorpej int	ahc_isa_match __P((struct isa_attach_args *, bus_addr_t));
    146  1.1      soda 
    147  1.1      soda int	ahc_isa_probe __P((struct device *, void *, void *));
    148  1.1      soda void	ahc_isa_attach __P((struct device *, struct device *, void *));
    149  1.1      soda 
    150  1.1      soda struct cfattach ahc_isa_ca = {
    151  1.1      soda 	sizeof(struct ahc_data), ahc_isa_probe, ahc_isa_attach
    152  1.1      soda };
    153  1.1      soda 
    154  1.1      soda /*
    155  1.1      soda  * This keeps track of which slots are to be checked next if the
    156  1.1      soda  * iobase locator is a wildcard.  A simple static variable isn't enough,
    157  1.1      soda  * since it's conceivable that a system might have more than one ISA
    158  1.1      soda  * bus.
    159  1.1      soda  *
    160  1.1      soda  * The "bus" member is the unit number of the parent ISA bus, e.g. "0"
    161  1.1      soda  * for "isa0".
    162  1.1      soda  */
    163  1.1      soda struct ahc_isa_slot {
    164  1.1      soda 	LIST_ENTRY(ahc_isa_slot)	link;
    165  1.1      soda 	int				bus;
    166  1.1      soda 	int				slot;
    167  1.1      soda };
    168  1.1      soda static LIST_HEAD(, ahc_isa_slot) ahc_isa_all_slots;
    169  1.1      soda static int ahc_isa_slot_initialized;
    170  1.1      soda 
    171  1.1      soda /*
    172  1.1      soda  * Return irq setting of the board, otherwise -1.
    173  1.1      soda  */
    174  1.1      soda int
    175  1.5   thorpej ahc_isa_irq(iot, ioh)
    176  1.5   thorpej 	bus_space_tag_t iot;
    177  1.5   thorpej 	bus_space_handle_t ioh;
    178  1.1      soda {
    179  1.1      soda 	int irq;
    180  1.1      soda 	u_char intdef;
    181  1.1      soda 
    182  1.5   thorpej 	ahc_reset("ahc_isa", iot, ioh);
    183  1.5   thorpej 	intdef = bus_space_read_1(iot, ioh, INTDEF);
    184  1.1      soda 	switch (irq = (intdef & 0xf)) {
    185  1.1      soda 	case 9:
    186  1.1      soda 	case 10:
    187  1.1      soda 	case 11:
    188  1.1      soda 	case 12:
    189  1.1      soda 	case 14:
    190  1.1      soda 	case 15:
    191  1.1      soda 		break;
    192  1.1      soda 	default:
    193  1.4  christos 		printf("ahc_isa_irq: illegal irq setting %d\n", intdef);
    194  1.1      soda 		return -1;
    195  1.1      soda 	}
    196  1.1      soda 
    197  1.1      soda 	/* Note that we are going and return (to probe) */
    198  1.1      soda 	return irq;
    199  1.1      soda }
    200  1.1      soda 
    201  1.1      soda int
    202  1.5   thorpej ahc_isa_idstring(iot, ioh, idstring)
    203  1.5   thorpej 	bus_space_tag_t iot;
    204  1.5   thorpej 	bus_space_handle_t ioh;
    205  1.1      soda 	char *idstring;
    206  1.1      soda {
    207  1.1      soda 	u_int8_t vid[EISA_NVIDREGS], pid[EISA_NPIDREGS];
    208  1.1      soda 	int i;
    209  1.1      soda 
    210  1.1      soda 	/* Get the vendor ID bytes */
    211  1.1      soda 	for (i = 0; i < EISA_NVIDREGS; i++) {
    212  1.5   thorpej 		bus_space_write_1(iot, ioh, AHC_ISA_PRIMING,
    213  1.1      soda 		    AHC_ISA_PRIMING_VID(i));
    214  1.5   thorpej 		vid[i] = bus_space_read_1(iot, ioh, AHC_ISA_VID + i);
    215  1.1      soda 	}
    216  1.1      soda 
    217  1.1      soda 	/* Check for device existence */
    218  1.1      soda 	if (EISA_VENDID_NODEV(vid)) {
    219  1.1      soda #if 0
    220  1.4  christos 		printf("ahc_isa_idstring: no device at 0x%lx\n",
    221  1.1      soda 		    ioh); /* XXX knows about ioh guts */
    222  1.4  christos 		printf("\t(0x%x, 0x%x)\n", vid[0], vid[1]);
    223  1.1      soda #endif
    224  1.1      soda 		return (0);
    225  1.1      soda 	}
    226  1.1      soda 
    227  1.1      soda 	/* And check that the firmware didn't biff something badly */
    228  1.1      soda 	if (EISA_VENDID_IDDELAY(vid)) {
    229  1.4  christos 		printf("ahc_isa_idstring: BIOS biffed it at 0x%lx\n",
    230  1.1      soda 		    ioh);	/* XXX knows about ioh guts */
    231  1.1      soda 		return (0);
    232  1.1      soda 	}
    233  1.1      soda 
    234  1.1      soda 	/* Get the product ID bytes */
    235  1.1      soda 	for (i = 0; i < EISA_NPIDREGS; i++) {
    236  1.5   thorpej 		bus_space_write_1(iot, ioh, AHC_ISA_PRIMING,
    237  1.1      soda 		    AHC_ISA_PRIMING_PID(i));
    238  1.5   thorpej 		pid[i] = bus_space_read_1(iot, ioh, AHC_ISA_PID + i);
    239  1.1      soda 	}
    240  1.1      soda 
    241  1.1      soda 	/* Create the ID string from the vendor and product IDs */
    242  1.1      soda 	idstring[0] = EISA_VENDID_0(vid);
    243  1.1      soda 	idstring[1] = EISA_VENDID_1(vid);
    244  1.1      soda 	idstring[2] = EISA_VENDID_2(vid);
    245  1.1      soda 	idstring[3] = EISA_PRODID_0(pid);
    246  1.1      soda 	idstring[4] = EISA_PRODID_1(pid);
    247  1.1      soda 	idstring[5] = EISA_PRODID_2(pid);
    248  1.1      soda 	idstring[6] = EISA_PRODID_3(pid);
    249  1.1      soda 	idstring[7] = '\0';		/* sanity */
    250  1.1      soda 
    251  1.1      soda 	return (1);
    252  1.1      soda }
    253  1.1      soda 
    254  1.1      soda int
    255  1.1      soda ahc_isa_match(ia, iobase)
    256  1.1      soda 	struct isa_attach_args *ia;
    257  1.5   thorpej 	bus_addr_t iobase;
    258  1.1      soda {
    259  1.5   thorpej 	bus_space_tag_t iot = ia->ia_iot;
    260  1.5   thorpej 	bus_space_handle_t ioh;
    261  1.1      soda 	int irq;
    262  1.1      soda 	char idstring[EISA_IDSTRINGLEN];
    263  1.1      soda 
    264  1.1      soda 	/*
    265  1.1      soda 	 * Get a mapping for the while slot-specific address
    266  1.1      soda 	 * space.  If we can't, assume nothing's there, but
    267  1.1      soda 	 * warn about it.
    268  1.1      soda 	 */
    269  1.5   thorpej 	if (bus_space_map(iot, iobase, AHC_ISA_IOSIZE, 0, &ioh)) {
    270  1.1      soda #if 0
    271  1.1      soda 		/*
    272  1.1      soda 		 * Don't print anything out here, since this could
    273  1.1      soda 		 * be common on machines configured to look for
    274  1.1      soda 		 * ahc_eisa and ahc_isa.
    275  1.1      soda 		 */
    276  1.4  christos 		printf("ahc_isa_match: can't map I/O space for 0x%x\n",
    277  1.1      soda 		    iobase);
    278  1.1      soda #endif
    279  1.1      soda 		return (0);
    280  1.1      soda 	}
    281  1.1      soda 
    282  1.5   thorpej 	if (!ahc_isa_idstring(iot, ioh, idstring))
    283  1.1      soda 		irq = -1;	/* cannot get the ID string */
    284  1.1      soda 	else if (strcmp(idstring, "ADP7756") &&
    285  1.1      soda 	    strcmp(idstring, "ADP7757"))
    286  1.1      soda 		irq = -1;	/* unknown ID strings */
    287  1.1      soda 	else
    288  1.5   thorpej 		irq = ahc_isa_irq(iot, ioh);
    289  1.1      soda 
    290  1.5   thorpej 	bus_space_unmap(iot, ioh, AHC_ISA_IOSIZE);
    291  1.1      soda 
    292  1.1      soda 	if (irq < 0)
    293  1.1      soda 		return (0);
    294  1.1      soda 
    295  1.1      soda 	if (ia->ia_irq != IRQUNK &&
    296  1.1      soda 	    ia->ia_irq != irq) {
    297  1.4  christos 		printf("ahc_isa_match: irq mismatch (kernel %d, card %d)\n",
    298  1.1      soda 		    ia->ia_irq, irq);
    299  1.1      soda 		return (0);
    300  1.1      soda 	}
    301  1.1      soda 
    302  1.1      soda 	/* We have a match */
    303  1.1      soda 	ia->ia_iobase = iobase;
    304  1.1      soda 	ia->ia_irq = irq;
    305  1.1      soda 	ia->ia_iosize = AHC_ISA_IOSIZE;
    306  1.1      soda 	ia->ia_msize = 0;
    307  1.1      soda 	return (1);
    308  1.1      soda }
    309  1.1      soda 
    310  1.1      soda /*
    311  1.1      soda  * Check the slots looking for a board we recognise
    312  1.1      soda  * If we find one, note it's address (slot) and call
    313  1.1      soda  * the actual probe routine to check it out.
    314  1.1      soda  */
    315  1.1      soda int
    316  1.1      soda ahc_isa_probe(parent, match, aux)
    317  1.1      soda         struct device *parent;
    318  1.1      soda         void *match, *aux;
    319  1.1      soda {
    320  1.1      soda 	struct isa_attach_args *ia = aux;
    321  1.1      soda 	struct ahc_isa_slot *as;
    322  1.1      soda 
    323  1.1      soda 	if (ahc_isa_slot_initialized == 0) {
    324  1.1      soda 		LIST_INIT(&ahc_isa_all_slots);
    325  1.1      soda 		ahc_isa_slot_initialized = 1;
    326  1.1      soda 	}
    327  1.1      soda 
    328  1.1      soda 	if (ia->ia_iobase != IOBASEUNK)
    329  1.1      soda 		return (ahc_isa_match(ia, ia->ia_iobase));
    330  1.1      soda 
    331  1.1      soda 	/*
    332  1.1      soda 	 * Find this bus's state.  If we don't yet have a slot
    333  1.1      soda 	 * marker, allocate and initialize one.
    334  1.1      soda 	 */
    335  1.1      soda 	for (as = ahc_isa_all_slots.lh_first; as != NULL;
    336  1.1      soda 	    as = as->link.le_next)
    337  1.1      soda 		if (as->bus == parent->dv_unit)
    338  1.1      soda 			goto found_slot_marker;
    339  1.1      soda 
    340  1.1      soda 	/*
    341  1.1      soda 	 * Don't have one, so make one.
    342  1.1      soda 	 */
    343  1.1      soda 	as = (struct ahc_isa_slot *)
    344  1.1      soda 	    malloc(sizeof(struct ahc_isa_slot), M_DEVBUF, M_NOWAIT);
    345  1.1      soda 	if (as == NULL)
    346  1.1      soda 		panic("ahc_isa_probe: can't allocate slot marker");
    347  1.1      soda 
    348  1.1      soda 	as->bus = parent->dv_unit;
    349  1.1      soda 	as->slot = AHC_ISA_MIN_SLOT;
    350  1.1      soda 	LIST_INSERT_HEAD(&ahc_isa_all_slots, as, link);
    351  1.1      soda 
    352  1.1      soda  found_slot_marker:
    353  1.1      soda 
    354  1.1      soda 	for (; as->slot <= AHC_ISA_MAX_SLOT; as->slot++) {
    355  1.1      soda 		if (ahc_isa_match(ia, EISA_SLOT_ADDR(as->slot) +
    356  1.1      soda 		    AHC_ISA_SLOT_OFFSET)) {
    357  1.1      soda 			as->slot++; /* next slot to search */
    358  1.1      soda 			return (1);
    359  1.1      soda 		}
    360  1.1      soda 	}
    361  1.1      soda 
    362  1.1      soda 	/* No matching cards were found. */
    363  1.1      soda 	return (0);
    364  1.1      soda }
    365  1.1      soda 
    366  1.1      soda void
    367  1.1      soda ahc_isa_attach(parent, self, aux)
    368  1.1      soda 	struct device *parent, *self;
    369  1.1      soda 	void *aux;
    370  1.1      soda {
    371  1.1      soda 	ahc_type type;
    372  1.1      soda 	struct ahc_data *ahc = (void *)self;
    373  1.1      soda 	struct isa_attach_args *ia = aux;
    374  1.5   thorpej 	bus_space_tag_t iot = ia->ia_iot;
    375  1.5   thorpej 	bus_space_handle_t ioh;
    376  1.1      soda 	int irq;
    377  1.1      soda 	char idstring[EISA_IDSTRINGLEN];
    378  1.1      soda 	const char *model;
    379  1.1      soda 
    380  1.5   thorpej 	if (bus_space_map(iot, ia->ia_iobase, ia->ia_iosize, 0, &ioh))
    381  1.1      soda 		panic("ahc_isa_attach: could not map slot I/O addresses");
    382  1.5   thorpej 	if (!ahc_isa_idstring(iot, ioh, idstring))
    383  1.1      soda 		panic("ahc_isa_attach: could not read ID string");
    384  1.5   thorpej 	if ((irq = ahc_isa_irq(iot, ioh)) < 0)
    385  1.1      soda 		panic("ahc_isa_attach: ahc_isa_irq failed!");
    386  1.1      soda 
    387  1.1      soda 	if (strcmp(idstring, "ADP7756") == 0) {
    388  1.1      soda 		model = EISA_PRODUCT_ADP7756;
    389  1.1      soda 		type = AHC_284;
    390  1.1      soda 	} else if (strcmp(idstring, "ADP7757") == 0) {
    391  1.1      soda 		model = EISA_PRODUCT_ADP7757;
    392  1.1      soda 		type = AHC_284;
    393  1.1      soda 	} else {
    394  1.1      soda 		panic("ahc_isa_attach: Unknown device type %s\n", idstring);
    395  1.1      soda 	}
    396  1.4  christos 	printf(": %s\n", model);
    397  1.1      soda 
    398  1.5   thorpej 	ahc_construct(ahc, iot, ioh, type, AHC_FNONE);
    399  1.1      soda 
    400  1.2   thorpej #ifdef DEBUG
    401  1.1      soda 	/*
    402  1.1      soda 	 * Tell the user what type of interrupts we're using.
    403  1.1      soda 	 * usefull for debugging irq problems
    404  1.1      soda 	 */
    405  1.4  christos 	printf( "%s: Using %s Interrupts\n", ahc_name(ahc),
    406  1.1      soda 	    ahc->pause & IRQMS ?  "Level Sensitive" : "Edge Triggered");
    407  1.2   thorpej #endif
    408  1.1      soda 
    409  1.1      soda 	/*
    410  1.1      soda 	 * Now that we know we own the resources we need, do the
    411  1.1      soda 	 * card initialization.
    412  1.1      soda 	 *
    413  1.1      soda 	 * First, the aic7770 card specific setup.
    414  1.1      soda 	 */
    415  1.1      soda 
    416  1.1      soda 	/* XXX
    417  1.1      soda 	 * On AHA-284x,
    418  1.1      soda 	 * all values are automagically intialized at
    419  1.1      soda 	 * POST for these cards, so we can always rely
    420  1.1      soda 	 * on the Scratch Ram values.  However, we should
    421  1.1      soda 	 * read the SEEPROM here (Dan has the code to do
    422  1.1      soda 	 * it) so we can say what kind of translation the
    423  1.1      soda 	 * BIOS is using.  Printing out the geometry could
    424  1.1      soda 	 * save a lot of users the grief of failed installs.
    425  1.1      soda 	 */
    426  1.1      soda 
    427  1.1      soda 	/*
    428  1.1      soda 	 * See if we have a Rev E or higher aic7770. Anything below a
    429  1.1      soda 	 * Rev E will have a R/O autoflush disable configuration bit.
    430  1.1      soda 	 * It's still not clear exactly what is differenent about the Rev E.
    431  1.1      soda 	 * We think it allows 8 bit entries in the QOUTFIFO to support
    432  1.1      soda 	 * "paging" SCBs so you can have more than 4 commands active at
    433  1.1      soda 	 * once.
    434  1.1      soda 	 */
    435  1.1      soda 	{
    436  1.1      soda 		char *id_string;
    437  1.1      soda 		u_char sblkctl;
    438  1.1      soda 		u_char sblkctl_orig;
    439  1.1      soda 
    440  1.1      soda 		sblkctl_orig = AHC_INB(ahc, SBLKCTL);
    441  1.1      soda 		sblkctl = sblkctl_orig ^ AUTOFLUSHDIS;
    442  1.1      soda 		AHC_OUTB(ahc, SBLKCTL, sblkctl);
    443  1.1      soda 		sblkctl = AHC_INB(ahc, SBLKCTL);
    444  1.1      soda 		if(sblkctl != sblkctl_orig)
    445  1.1      soda 		{
    446  1.1      soda 			id_string = "aic7770 >= Rev E, ";
    447  1.1      soda 			/*
    448  1.1      soda 			 * Ensure autoflush is enabled
    449  1.1      soda 			 */
    450  1.1      soda 			sblkctl &= ~AUTOFLUSHDIS;
    451  1.1      soda 			AHC_OUTB(ahc, SBLKCTL, sblkctl);
    452  1.1      soda 
    453  1.1      soda 			/* Allow paging on this adapter */
    454  1.1      soda 			ahc->flags |= AHC_PAGESCBS;
    455  1.1      soda 		}
    456  1.1      soda 		else
    457  1.1      soda 			id_string = "aic7770 <= Rev C, ";
    458  1.1      soda 
    459  1.4  christos 		printf("%s: %s", ahc_name(ahc), id_string);
    460  1.1      soda 	}
    461  1.1      soda 
    462  1.1      soda 	/* Setup the FIFO threshold and the bus off time */
    463  1.1      soda 	{
    464  1.1      soda 		u_char hostconf = AHC_INB(ahc, HOSTCONF);
    465  1.1      soda 		AHC_OUTB(ahc, BUSSPD, hostconf & DFTHRSH);
    466  1.1      soda 		AHC_OUTB(ahc, BUSTIME, (hostconf << 2) & BOFF);
    467  1.1      soda 	}
    468  1.1      soda 
    469  1.1      soda 	/*
    470  1.1      soda 	 * Generic aic7xxx initialization.
    471  1.1      soda 	 */
    472  1.1      soda 	if(ahc_init(ahc)){
    473  1.1      soda 		ahc_free(ahc);
    474  1.1      soda 		return;
    475  1.1      soda 	}
    476  1.1      soda 
    477  1.1      soda 	/*
    478  1.1      soda 	 * Enable the board's BUS drivers
    479  1.1      soda 	 */
    480  1.1      soda 	AHC_OUTB(ahc, BCTL, ENABLE);
    481  1.1      soda 
    482  1.1      soda 	/*
    483  1.1      soda 	 * The IRQMS bit enables level sensitive interrupts only allow
    484  1.1      soda 	 * IRQ sharing if its set.
    485  1.1      soda 	 */
    486  1.1      soda 	ahc->sc_ih = isa_intr_establish(ia->ia_ic, irq,
    487  1.1      soda 	    ahc->pause & IRQMS ? IST_LEVEL : IST_EDGE, IPL_BIO, ahc_intr, ahc);
    488  1.1      soda 	if (ahc->sc_ih == NULL) {
    489  1.4  christos 		printf("%s: couldn't establish interrupt\n",
    490  1.1      soda 		       ahc->sc_dev.dv_xname);
    491  1.1      soda 		ahc_free(ahc);
    492  1.1      soda 		return;
    493  1.1      soda 	}
    494  1.1      soda 
    495  1.1      soda 	/* Attach sub-devices - always succeeds */
    496  1.1      soda 	ahc_attach(ahc);
    497  1.1      soda }
    498