Home | History | Annotate | Line # | Download | only in isa
ahc_isa.c revision 1.13
      1 /*	$NetBSD: ahc_isa.c,v 1.13 2000/03/15 02:05:19 fvdl Exp $	*/
      2 
      3 /*
      4  * Product specific probe and attach routines for:
      5  * 	AHA-284X VL-bus SCSI controllers
      6  *
      7  * Copyright (c) 1994, 1995, 1996, 1997, 1998 Justin T. Gibbs.
      8  * All rights reserved.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice immediately at the beginning of the file, without modification,
     15  *    this list of conditions, and the following disclaimer.
     16  * 2. The name of the author may not be used to endorse or promote products
     17  *    derived from this software without specific prior written permission.
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     22  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
     23  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     29  * SUCH DAMAGE.
     30  *
     31  * $FreeBSD: src/sys/dev/aic7xxx/ahc_eisa.c,v 1.15 2000/01/29 14:22:19 peter Exp $
     32  */
     33 
     34 /*-
     35  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
     36  * All rights reserved.
     37  *
     38  * This code is derived from software contributed to The NetBSD Foundation
     39  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
     40  * NASA Ames Research Center.
     41  *
     42  * Redistribution and use in source and binary forms, with or without
     43  * modification, are permitted provided that the following conditions
     44  * are met:
     45  * 1. Redistributions of source code must retain the above copyright
     46  *    notice, this list of conditions and the following disclaimer.
     47  * 2. Redistributions in binary form must reproduce the above copyright
     48  *    notice, this list of conditions and the following disclaimer in the
     49  *    documentation and/or other materials provided with the distribution.
     50  * 3. All advertising materials mentioning features or use of this software
     51  *    must display the following acknowledgement:
     52  *	This product includes software developed by the NetBSD
     53  *	Foundation, Inc. and its contributors.
     54  * 4. Neither the name of The NetBSD Foundation nor the names of its
     55  *    contributors may be used to endorse or promote products derived
     56  *    from this software without specific prior written permission.
     57  *
     58  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     59  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     60  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     61  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     62  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     63  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     64  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     65  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     66  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     67  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     68  * POSSIBILITY OF SUCH DAMAGE.
     69  */
     70 
     71 /*
     72  * Copyright (c) 1995, 1996 Christopher G. Demetriou
     73  * All rights reserved.
     74  *
     75  * Redistribution and use in source and binary forms, with or without
     76  * modification, are permitted provided that the following conditions
     77  * are met:
     78  * 1. Redistributions of source code must retain the above copyright
     79  *    notice, this list of conditions and the following disclaimer.
     80  * 2. Redistributions in binary form must reproduce the above copyright
     81  *    notice, this list of conditions and the following disclaimer in the
     82  *    documentation and/or other materials provided with the distribution.
     83  * 3. All advertising materials mentioning features or use of this software
     84  *    must display the following acknowledgement:
     85  *      This product includes software developed by Christopher G. Demetriou
     86  *      for the NetBSD Project.
     87  * 4. The name of the author may not be used to endorse or promote products
     88  *    derived from this software without specific prior written permission
     89  *
     90  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     91  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     92  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     93  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     94  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     95  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     96  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     97  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     98  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     99  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    100  */
    101 
    102 /*
    103  * This front-end driver is really sort of a hack.  The AHA-284X likes
    104  * to masquerade as an EISA device.  However, on VLbus machines with
    105  * no EISA signature in the BIOS, the EISA bus will never be scanned.
    106  * This is intended to catch the 284X controllers on those systems
    107  * by looking in "EISA i/o space" for 284X controllers.
    108  *
    109  * This relies heavily on i/o port accounting.  We also just use the
    110  * EISA macros for everything ... it's a real waste to redefine them.
    111  *
    112  * Note: there isn't any #ifdef for FreeBSD in this file, since the
    113  * FreeBSD EISA driver handles all cases of the 284X.
    114  *
    115  *	-- Jason R. Thorpe <thorpej (at) NetBSD.ORG>
    116  *	   July 12, 1996
    117  */
    118 
    119 #include <sys/param.h>
    120 #include <sys/systm.h>
    121 #include <sys/kernel.h>
    122 #include <sys/device.h>
    123 #include <sys/queue.h>
    124 #include <sys/malloc.h>
    125 
    126 #include <machine/bus.h>
    127 #include <machine/intr.h>
    128 
    129 #include <dev/scsipi/scsi_all.h>
    130 #include <dev/scsipi/scsipi_all.h>
    131 #include <dev/scsipi/scsiconf.h>
    132 
    133 #include <dev/isa/isavar.h>
    134 
    135 #include <dev/eisa/eisareg.h>
    136 #include <dev/eisa/eisavar.h>
    137 #include <dev/eisa/eisadevs.h>
    138 
    139 #include <dev/microcode/aic7xxx/aic7xxx_reg.h>
    140 #include <dev/ic/aic7xxxvar.h>
    141 #include <dev/ic/aic77xxreg.h>
    142 #include <dev/ic/aic77xxvar.h>
    143 #include <dev/ic/smc93cx6var.h>
    144 
    145 /*
    146  * Under normal circumstances, these messages are unnecessary
    147  * and not terribly cosmetic.
    148  */
    149 #ifdef DEBUG
    150 #define bootverbose	1
    151 #else
    152 #define bootverbose	1
    153 #endif
    154 
    155 /* IO port address setting range as EISA slot number */
    156 #define AHC_ISA_MIN_SLOT	0x1	/* from iobase = 0x1c00 */
    157 #define AHC_ISA_MAX_SLOT	0xe	/* to   iobase = 0xec00 */
    158 
    159 #define AHC_ISA_SLOT_OFFSET	AHC_EISA_SLOT_OFFSET
    160 #define AHC_ISA_IOSIZE		AHC_EISA_IOSIZE
    161 
    162 /*
    163  * I/O port offsets
    164  */
    165 #define	AHC_ISA_VID		(EISA_SLOTOFF_VID - AHC_ISA_SLOT_OFFSET)
    166 #define	AHC_ISA_PID		(EISA_SLOTOFF_PID - AHC_ISA_SLOT_OFFSET)
    167 #define	AHC_ISA_PRIMING		AHC_ISA_VID	/* enable vendor/product ID */
    168 
    169 /*
    170  * AHC_ISA_PRIMING register values (write)
    171  */
    172 #define	AHC_ISA_PRIMING_VID(index)	(AHC_ISA_VID + (index))
    173 #define	AHC_ISA_PRIMING_PID(index)	(AHC_ISA_PID + (index))
    174 
    175 int	ahc_isa_idstring __P((bus_space_tag_t, bus_space_handle_t, char *));
    176 int	ahc_isa_match __P((struct isa_attach_args *, bus_addr_t));
    177 
    178 int	ahc_isa_probe __P((struct device *, struct cfdata *, void *));
    179 void	ahc_isa_attach __P((struct device *, struct device *, void *));
    180 void	aha2840_load_seeprom __P((struct ahc_softc *ahc));
    181 
    182 struct cfattach ahc_isa_ca = {
    183 	sizeof(struct ahc_softc), ahc_isa_probe, ahc_isa_attach
    184 };
    185 
    186 /*
    187  * This keeps track of which slots are to be checked next if the
    188  * iobase locator is a wildcard.  A simple static variable isn't enough,
    189  * since it's conceivable that a system might have more than one ISA
    190  * bus.
    191  *
    192  * The "bus" member is the unit number of the parent ISA bus, e.g. "0"
    193  * for "isa0".
    194  */
    195 struct ahc_isa_slot {
    196 	LIST_ENTRY(ahc_isa_slot)	link;
    197 	int				bus;
    198 	int				slot;
    199 };
    200 static LIST_HEAD(, ahc_isa_slot) ahc_isa_all_slots;
    201 static int ahc_isa_slot_initialized;
    202 
    203 int
    204 ahc_isa_idstring(iot, ioh, idstring)
    205 	bus_space_tag_t iot;
    206 	bus_space_handle_t ioh;
    207 	char *idstring;
    208 {
    209 	u_int8_t vid[EISA_NVIDREGS], pid[EISA_NPIDREGS];
    210 	int i;
    211 
    212 	/* Get the vendor ID bytes */
    213 	for (i = 0; i < EISA_NVIDREGS; i++) {
    214 		bus_space_write_1(iot, ioh, AHC_ISA_PRIMING,
    215 		    AHC_ISA_PRIMING_VID(i));
    216 		vid[i] = bus_space_read_1(iot, ioh, AHC_ISA_VID + i);
    217 	}
    218 
    219 	/* Check for device existence */
    220 	if (EISA_VENDID_NODEV(vid)) {
    221 #if 0
    222 		printf("ahc_isa_idstring: no device at 0x%lx\n",
    223 		    ioh); /* XXX knows about ioh guts */
    224 		printf("\t(0x%x, 0x%x)\n", vid[0], vid[1]);
    225 #endif
    226 		return (0);
    227 	}
    228 
    229 	/* And check that the firmware didn't biff something badly */
    230 	if (EISA_VENDID_IDDELAY(vid)) {
    231 		printf("ahc_isa_idstring: BIOS biffed it at 0x%lx\n",
    232 		    ioh);	/* XXX knows about ioh guts */
    233 		return (0);
    234 	}
    235 
    236 	/* Get the product ID bytes */
    237 	for (i = 0; i < EISA_NPIDREGS; i++) {
    238 		bus_space_write_1(iot, ioh, AHC_ISA_PRIMING,
    239 		    AHC_ISA_PRIMING_PID(i));
    240 		pid[i] = bus_space_read_1(iot, ioh, AHC_ISA_PID + i);
    241 	}
    242 
    243 	/* Create the ID string from the vendor and product IDs */
    244 	idstring[0] = EISA_VENDID_0(vid);
    245 	idstring[1] = EISA_VENDID_1(vid);
    246 	idstring[2] = EISA_VENDID_2(vid);
    247 	idstring[3] = EISA_PRODID_0(pid);
    248 	idstring[4] = EISA_PRODID_1(pid);
    249 	idstring[5] = EISA_PRODID_2(pid);
    250 	idstring[6] = EISA_PRODID_3(pid);
    251 	idstring[7] = '\0';		/* sanity */
    252 
    253 	return (1);
    254 }
    255 
    256 int
    257 ahc_isa_match(ia, iobase)
    258 	struct isa_attach_args *ia;
    259 	bus_addr_t iobase;
    260 {
    261 	bus_space_tag_t iot = ia->ia_iot;
    262 	bus_space_handle_t ioh;
    263 	int irq;
    264 	char idstring[EISA_IDSTRINGLEN];
    265 
    266 	/*
    267 	 * Get a mapping for the while slot-specific address
    268 	 * space.  If we can't, assume nothing's there, but
    269 	 * warn about it.
    270 	 */
    271 	if (bus_space_map(iot, iobase, AHC_ISA_IOSIZE, 0, &ioh)) {
    272 #if 0
    273 		/*
    274 		 * Don't print anything out here, since this could
    275 		 * be common on machines configured to look for
    276 		 * ahc_eisa and ahc_isa.
    277 		 */
    278 		printf("ahc_isa_match: can't map I/O space for 0x%x\n",
    279 		    iobase);
    280 #endif
    281 		return (0);
    282 	}
    283 
    284 	if (!ahc_isa_idstring(iot, ioh, idstring))
    285 		irq = -1;	/* cannot get the ID string */
    286 	else if (strcmp(idstring, "ADP7756") &&
    287 	    strcmp(idstring, "ADP7757"))
    288 		irq = -1;	/* unknown ID strings */
    289 	else
    290 		irq = ahc_aic77xx_irq(iot, ioh);
    291 
    292 	bus_space_unmap(iot, ioh, AHC_ISA_IOSIZE);
    293 
    294 	if (irq < 0)
    295 		return (0);
    296 
    297 	if (ia->ia_irq != IRQUNK &&
    298 	    ia->ia_irq != irq) {
    299 		printf("ahc_isa_match: irq mismatch (kernel %d, card %d)\n",
    300 		    ia->ia_irq, irq);
    301 		return (0);
    302 	}
    303 
    304 	/* We have a match */
    305 	ia->ia_iobase = iobase;
    306 	ia->ia_irq = irq;
    307 	ia->ia_iosize = AHC_ISA_IOSIZE;
    308 	ia->ia_msize = 0;
    309 	return (1);
    310 }
    311 
    312 /*
    313  * Check the slots looking for a board we recognise
    314  * If we find one, note it's address (slot) and call
    315  * the actual probe routine to check it out.
    316  */
    317 int
    318 ahc_isa_probe(parent, match, aux)
    319         struct device *parent;
    320         struct cfdata *match;
    321 	void *aux;
    322 {
    323 	struct isa_attach_args *ia = aux;
    324 	struct ahc_isa_slot *as;
    325 
    326 	if (ahc_isa_slot_initialized == 0) {
    327 		LIST_INIT(&ahc_isa_all_slots);
    328 		ahc_isa_slot_initialized = 1;
    329 	}
    330 
    331 	if (ia->ia_iobase != IOBASEUNK)
    332 		return (ahc_isa_match(ia, ia->ia_iobase));
    333 
    334 	/*
    335 	 * Find this bus's state.  If we don't yet have a slot
    336 	 * marker, allocate and initialize one.
    337 	 */
    338 	for (as = ahc_isa_all_slots.lh_first; as != NULL;
    339 	    as = as->link.le_next)
    340 		if (as->bus == parent->dv_unit)
    341 			goto found_slot_marker;
    342 
    343 	/*
    344 	 * Don't have one, so make one.
    345 	 */
    346 	as = (struct ahc_isa_slot *)
    347 	    malloc(sizeof(struct ahc_isa_slot), M_DEVBUF, M_NOWAIT);
    348 	if (as == NULL)
    349 		panic("ahc_isa_probe: can't allocate slot marker");
    350 
    351 	as->bus = parent->dv_unit;
    352 	as->slot = AHC_ISA_MIN_SLOT;
    353 	LIST_INSERT_HEAD(&ahc_isa_all_slots, as, link);
    354 
    355  found_slot_marker:
    356 
    357 	for (; as->slot <= AHC_ISA_MAX_SLOT; as->slot++) {
    358 		if (ahc_isa_match(ia, EISA_SLOT_ADDR(as->slot) +
    359 		    AHC_ISA_SLOT_OFFSET)) {
    360 			as->slot++; /* next slot to search */
    361 			return (1);
    362 		}
    363 	}
    364 
    365 	/* No matching cards were found. */
    366 	return (0);
    367 }
    368 
    369 void
    370 ahc_isa_attach(parent, self, aux)
    371 	struct device *parent, *self;
    372 	void *aux;
    373 {
    374 	struct ahc_softc *ahc = (void *)self;
    375 	struct isa_attach_args *ia = aux;
    376 	bus_space_tag_t iot = ia->ia_iot;
    377 	bus_space_handle_t ioh;
    378 	int irq, intrtype;
    379 	const char *intrtypestr;
    380 	char idstring[EISA_IDSTRINGLEN];
    381 
    382 	if (bus_space_map(iot, ia->ia_iobase, ia->ia_iosize, 0, &ioh)) {
    383 		printf(": can't map i/o space\n");
    384 		return;
    385 	}
    386 	if (!ahc_isa_idstring(iot, ioh, idstring)) {
    387 		printf(": can't read ID string\n");
    388 		goto free_io;
    389 	}
    390 	if ((irq = ahc_aic77xx_irq(iot, ioh)) < 0) {
    391 		printf(": ahc_aic77xx_irq failed\n");
    392 		goto free_io;
    393 	}
    394 
    395 	if (strcmp(idstring, "ADP7756") == 0) {
    396 		printf(": %s\n", EISA_PRODUCT_ADP7756);
    397 	} else if (strcmp(idstring, "ADP7757") == 0) {
    398 		printf(": %s\n", EISA_PRODUCT_ADP7757);
    399 	} else {
    400 		printf(": unknown device type %s\n", idstring);
    401 		goto free_io;
    402 	}
    403 
    404 	if (ahc_alloc(ahc, ioh, iot, ia->ia_dmat,
    405 	    AHC_AIC7770|AHC_VL, AHC_AIC7770_FE, AHC_FNONE))
    406 		goto free_io;
    407 
    408 	/*
    409 	 * Tell the bus-dma interface that we can do 32bit dma
    410 	 * NOTE: this variable is first referenced in ahc_init().
    411 	 */
    412 	ahc->sc_dmaflags = ISABUS_DMA_32BIT;
    413 
    414 	ahc->channel = 'A';
    415 	ahc->channel_b = 'B';
    416 	if (ahc_reset(ahc) != 0)
    417 		goto free_ahc;
    418 
    419 	/*
    420 	 * The IRQMS bit enables level sensitive interrupts. Only allow
    421 	 * IRQ sharing if it's set.
    422 	 * NOTE: ahc->pause is initialized in ahc_alloc().
    423 	 */
    424 	if (ahc->pause & IRQMS) {
    425 		intrtype = IST_LEVEL;
    426 		intrtypestr = "level sensitive";
    427 	} else {
    428 		intrtype = IST_EDGE;
    429 		intrtypestr = "edge triggered";
    430 	}
    431 	ahc->ih = isa_intr_establish(ia->ia_ic, irq,
    432 	    intrtype, IPL_BIO, ahc_intr, ahc);
    433 	if (ahc->ih == NULL) {
    434 		printf("%s: couldn't establish %s interrupt\n",
    435 		       ahc->sc_dev.dv_xname, intrtypestr);
    436 		goto free_ahc;
    437 	}
    438 
    439 	/*
    440 	 * Tell the user what type of interrupts we're using.
    441 	 * usefull for debugging irq problems
    442 	 */
    443 	if (bootverbose) {
    444 		printf("%s: Using %s interrupts\n",
    445 		       ahc->sc_dev.dv_xname, intrtypestr);
    446 	}
    447 
    448 	/*
    449 	 * Now that we know we own the resources we need, do the
    450 	 * card initialization.
    451 	 */
    452 	aha2840_load_seeprom(ahc);
    453 
    454 	/* Attach sub-devices */
    455 	if (ahc_aic77xx_attach(ahc) == 0)
    456 		return; /* succeed */
    457 
    458 	/* failed */
    459 	isa_intr_disestablish(ia->ia_ic, ahc->ih);
    460 free_ahc:
    461 	ahc_free(ahc);
    462 free_io:
    463 	bus_space_unmap(iot, ioh, ia->ia_iosize);
    464 }
    465 
    466 /*
    467  * Read the 284x SEEPROM.
    468  */
    469 void
    470 aha2840_load_seeprom(struct ahc_softc *ahc)
    471 {
    472 	struct	  seeprom_descriptor sd;
    473 	struct	  seeprom_config sc;
    474 	u_int16_t checksum = 0;
    475 	u_int8_t  scsi_conf;
    476 	int	  have_seeprom;
    477 
    478 	sd.sd_tag = ahc->tag;
    479 	sd.sd_bsh = ahc->bsh;
    480 	sd.sd_control_offset = SEECTL_2840;
    481 	sd.sd_status_offset = STATUS_2840;
    482 	sd.sd_dataout_offset = STATUS_2840;
    483 	sd.sd_chip = C46;
    484 	sd.sd_MS = 0;
    485 	sd.sd_RDY = EEPROM_TF;
    486 	sd.sd_CS = CS_2840;
    487 	sd.sd_CK = CK_2840;
    488 	sd.sd_DO = DO_2840;
    489 	sd.sd_DI = DI_2840;
    490 
    491 	if (bootverbose)
    492 		printf("%s: Reading SEEPROM...", ahc_name(ahc));
    493 	have_seeprom = read_seeprom(&sd,
    494 				    (u_int16_t *)&sc,
    495 				    /*start_addr*/0,
    496 				    sizeof(sc)/2);
    497 
    498 	if (have_seeprom) {
    499 		/* Check checksum */
    500 		int i;
    501 		int maxaddr = (sizeof(sc)/2) - 1;
    502 		u_int16_t *scarray = (u_int16_t *)&sc;
    503 
    504 		for (i = 0; i < maxaddr; i++)
    505 			checksum = checksum + scarray[i];
    506 		if (checksum != sc.checksum) {
    507 			if(bootverbose)
    508 				printf ("checksum error\n");
    509 			have_seeprom = 0;
    510 		} else if (bootverbose) {
    511 			printf("done.\n");
    512 		}
    513 	}
    514 
    515 	if (!have_seeprom) {
    516 		if (bootverbose)
    517 			printf("%s: No SEEPROM available\n", ahc_name(ahc));
    518 		ahc->flags |= AHC_USEDEFAULTS;
    519 	} else {
    520 		/*
    521 		 * Put the data we've collected down into SRAM
    522 		 * where ahc_init will find it.
    523 		 */
    524 		int i;
    525 		int max_targ = (ahc->features & AHC_WIDE) != 0 ? 16 : 8;
    526 		u_int16_t discenable;
    527 
    528 		discenable = 0;
    529 		for (i = 0; i < max_targ; i++){
    530 	                u_int8_t target_settings;
    531 			target_settings = (sc.device_flags[i] & CFXFER) << 4;
    532 			if (sc.device_flags[i] & CFSYNCH)
    533 				target_settings |= SOFS;
    534 			if (sc.device_flags[i] & CFWIDEB)
    535 				target_settings |= WIDEXFER;
    536 			if (sc.device_flags[i] & CFDISC)
    537 				discenable |= (0x01 << i);
    538 			ahc_outb(ahc, TARG_SCSIRATE + i, target_settings);
    539 		}
    540 		ahc_outb(ahc, DISC_DSB, ~(discenable & 0xff));
    541 		ahc_outb(ahc, DISC_DSB + 1, ~((discenable >> 8) & 0xff));
    542 
    543 		ahc->our_id = sc.brtime_id & CFSCSIID;
    544 
    545 		scsi_conf = (ahc->our_id & 0x7);
    546 		if (sc.adapter_control & CFSPARITY)
    547 			scsi_conf |= ENSPCHK;
    548 		if (sc.adapter_control & CFRESETB)
    549 			scsi_conf |= RESET_SCSI;
    550 
    551 		if (sc.bios_control & CF284XEXTEND)
    552 			ahc->flags |= AHC_EXTENDED_TRANS_A;
    553 		/* Set SCSICONF info */
    554 		ahc_outb(ahc, SCSICONF, scsi_conf);
    555 
    556 		if (sc.adapter_control & CF284XSTERM)
    557 			ahc->flags |= AHC_TERM_ENB_A;
    558 	}
    559 }
    560