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