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