xref: /netbsd-src/sys/dev/tc/tcds.c (revision aa73cae19608873cc4d1f712c4a0f8f8435f1ffa)
1 /* $NetBSD: tcds.c,v 1.14 2005/02/27 00:27:49 perry Exp $ */
2 
3 /*-
4  * Copyright (c) 1998 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9  * NASA Ames Research Center.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  * 3. All advertising materials mentioning features or use of this software
20  *    must display the following acknowledgement:
21  *	This product includes software developed by the NetBSD
22  *	Foundation, Inc. and its contributors.
23  * 4. Neither the name of The NetBSD Foundation nor the names of its
24  *    contributors may be used to endorse or promote products derived
25  *    from this software without specific prior written permission.
26  *
27  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37  * POSSIBILITY OF SUCH DAMAGE.
38  */
39 
40 /*
41  * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
42  * All rights reserved.
43  *
44  * Author: Keith Bostic, Chris G. Demetriou
45  *
46  * Permission to use, copy, modify and distribute this software and
47  * its documentation is hereby granted, provided that both the copyright
48  * notice and this permission notice appear in all copies of the
49  * software, derivative works or modified versions, and any portions
50  * thereof, and that both notices appear in supporting documentation.
51  *
52  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
53  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
54  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
55  *
56  * Carnegie Mellon requests users of this software to return to
57  *
58  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
59  *  School of Computer Science
60  *  Carnegie Mellon University
61  *  Pittsburgh PA 15213-3890
62  *
63  * any improvements or extensions that they make and grant Carnegie the
64  * rights to redistribute these changes.
65  */
66 
67 #include <sys/cdefs.h>
68 __KERNEL_RCSID(0, "$NetBSD: tcds.c,v 1.14 2005/02/27 00:27:49 perry Exp $");
69 
70 #include <sys/param.h>
71 #include <sys/kernel.h>
72 #include <sys/systm.h>
73 #include <sys/device.h>
74 #include <sys/malloc.h>
75 
76 #ifdef __alpha__
77 #include <machine/rpb.h>
78 #endif /* __alpha__ */
79 
80 #include <dev/scsipi/scsi_all.h>
81 #include <dev/scsipi/scsipi_all.h>
82 #include <dev/scsipi/scsiconf.h>
83 
84 #include <dev/ic/ncr53c9xvar.h>
85 
86 #include <machine/bus.h>
87 
88 #include <dev/tc/tcvar.h>
89 #include <dev/tc/tcdsreg.h>
90 #include <dev/tc/tcdsvar.h>
91 
92 #include "locators.h"
93 
94 struct tcds_softc {
95 	struct	device sc_dv;
96 	bus_space_tag_t sc_bst;
97 	bus_space_handle_t sc_bsh;
98 	bus_dma_tag_t sc_dmat;
99 	void	*sc_cookie;
100 	int	sc_flags;
101 	struct tcds_slotconfig sc_slots[2];
102 };
103 
104 /* sc_flags */
105 #define	TCDSF_BASEBOARD		0x01	/* baseboard on DEC 3000 */
106 #define	TCDSF_FASTSCSI		0x02	/* supports Fast SCSI */
107 
108 /* Definition of the driver for autoconfig. */
109 int	tcdsmatch(struct device *, struct cfdata *, void *);
110 void	tcdsattach(struct device *, struct device *, void *);
111 int     tcdsprint(void *, const char *);
112 int	tcdssubmatch(struct device *, struct cfdata *,
113 			  const locdesc_t *, void *);
114 
115 CFATTACH_DECL(tcds, sizeof(struct tcds_softc),
116     tcdsmatch, tcdsattach, NULL, NULL);
117 
118 /*static*/ int	tcds_intr(void *);
119 /*static*/ int	tcds_intrnull(void *);
120 
121 struct tcds_device {
122 	const char *td_name;
123 	int td_flags;
124 } tcds_devices[] = {
125 #ifdef __alpha__
126 	{ "PMAZ-DS ",	TCDSF_BASEBOARD },
127 	{ "PMAZ-FS ",	TCDSF_BASEBOARD|TCDSF_FASTSCSI },
128 #endif /* __alpha__ */
129 	{ "PMAZB-AA",	0 },
130 	{ "PMAZC-AA",	TCDSF_FASTSCSI },
131 	{ NULL,		0 },
132 };
133 
134 struct tcds_device *tcds_lookup(const char *);
135 void	tcds_params(struct tcds_softc *, int, int *, int *);
136 
137 struct tcds_device *
138 tcds_lookup(modname)
139 	const char *modname;
140 {
141 	struct tcds_device *td;
142 
143 	for (td = tcds_devices; td->td_name != NULL; td++)
144 		if (strncmp(td->td_name, modname, TC_ROM_LLEN) == 0)
145 			return (td);
146 
147 	return (NULL);
148 }
149 
150 int
151 tcdsmatch(parent, cfdata, aux)
152 	struct device *parent;
153 	struct cfdata *cfdata;
154 	void *aux;
155 {
156 	struct tc_attach_args *ta = aux;
157 
158 	return (tcds_lookup(ta->ta_modname) != NULL);
159 }
160 
161 void
162 tcdsattach(parent, self, aux)
163 	struct device *parent, *self;
164 	void *aux;
165 {
166 	struct tcds_softc *sc = (struct tcds_softc *)self;
167 	struct tc_attach_args *ta = aux;
168 	struct tcdsdev_attach_args tcdsdev;
169 	struct tcds_slotconfig *slotc;
170 	struct tcds_device *td;
171 	bus_space_handle_t sbsh[2];
172 	int i, gpi2;
173 	const struct evcnt *pevcnt;
174 	int help[2];
175 	locdesc_t *ldesc = (void *)help; /* XXX */
176 
177 	td = tcds_lookup(ta->ta_modname);
178 	if (td == NULL)
179 		panic("\ntcdsattach: impossible");
180 
181 	printf(": TurboChannel Dual SCSI");
182 	if (td->td_flags & TCDSF_BASEBOARD)
183 		printf(" (baseboard)");
184 	printf("\n");
185 
186 	sc->sc_flags = td->td_flags;
187 
188 	sc->sc_bst = ta->ta_memt;
189 	sc->sc_dmat = ta->ta_dmat;
190 
191 	/*
192 	 * Map the device.
193 	 */
194 	if (bus_space_map(sc->sc_bst, ta->ta_addr,
195 	    (TCDS_SCSI1_OFFSET + 0x100), 0, &sc->sc_bsh)) {
196 		printf("%s: unable to map device\n", sc->sc_dv.dv_xname);
197 		return;
198 	}
199 
200 	/*
201 	 * Now, slice off two subregions for the individual NCR SCSI chips.
202 	 */
203 	if (bus_space_subregion(sc->sc_bst, sc->sc_bsh, TCDS_SCSI0_OFFSET,
204 	    0x100, &sbsh[0]) ||
205 	    bus_space_subregion(sc->sc_bst, sc->sc_bsh, TCDS_SCSI1_OFFSET,
206 	    0x100, &sbsh[1])) {
207 		printf("%s: unable to subregion SCSI chip space\n",
208 		    sc->sc_dv.dv_xname);
209 		return;
210 	}
211 
212 	sc->sc_cookie = ta->ta_cookie;
213 
214 	pevcnt = tc_intr_evcnt(parent, sc->sc_cookie);
215 	tc_intr_establish(parent, sc->sc_cookie, TC_IPL_BIO, tcds_intr, sc);
216 
217 	/*
218 	 * XXX
219 	 * IMER apparently has some random (or, not so random, but still
220 	 * not useful) bits set in it when the system boots.  Clear it.
221 	 */
222 	bus_space_write_4(sc->sc_bst, sc->sc_bsh, TCDS_IMER, 0);
223 
224 	/* XXX Initial contents of CIR? */
225 
226 	/*
227 	 * Remember if GPI2 is set in the CIR; we'll need it later.
228 	 */
229 	gpi2 = (bus_space_read_4(sc->sc_bst, sc->sc_bsh, TCDS_CIR) &
230 	    TCDS_CIR_GPI_2) != 0;
231 
232 	/*
233 	 * Set up the per-slot definitions for later use.
234 	 */
235 
236 	/* fill in common information first */
237 	for (i = 0; i < 2; i++) {
238 		char *cp;
239 
240 		slotc = &sc->sc_slots[i];
241 		bzero(slotc, sizeof *slotc);	/* clear everything */
242 
243 		cp = slotc->sc_name;
244 		snprintf(cp, sizeof(slotc->sc_name), "chip %d", i);
245 		evcnt_attach_dynamic(&slotc->sc_evcnt, EVCNT_TYPE_INTR,
246 		    pevcnt, sc->sc_dv.dv_xname, cp);
247 
248 		slotc->sc_slot = i;
249 		slotc->sc_bst = sc->sc_bst;
250 		slotc->sc_bsh = sc->sc_bsh;
251 		slotc->sc_intrhand = tcds_intrnull;
252 		slotc->sc_intrarg = (void *)(long)i;
253 	}
254 
255 	/* information for slot 0 */
256 	slotc = &sc->sc_slots[0];
257 	slotc->sc_resetbits = TCDS_CIR_SCSI0_RESET;
258 	slotc->sc_intrmaskbits =
259 	    TCDS_IMER_SCSI0_MASK | TCDS_IMER_SCSI0_ENB;
260 	slotc->sc_intrbits = TCDS_CIR_SCSI0_INT;
261 	slotc->sc_dmabits = TCDS_CIR_SCSI0_DMAENA;
262 	slotc->sc_errorbits = 0;				/* XXX */
263 	slotc->sc_sda = TCDS_SCSI0_DMA_ADDR;
264 	slotc->sc_dic = TCDS_SCSI0_DMA_INTR;
265 	slotc->sc_dud0 = TCDS_SCSI0_DMA_DUD0;
266 	slotc->sc_dud1 = TCDS_SCSI0_DMA_DUD1;
267 
268 	/* information for slot 1 */
269 	slotc = &sc->sc_slots[1];
270 	slotc->sc_resetbits = TCDS_CIR_SCSI1_RESET;
271 	slotc->sc_intrmaskbits =
272 	    TCDS_IMER_SCSI1_MASK | TCDS_IMER_SCSI1_ENB;
273 	slotc->sc_intrbits = TCDS_CIR_SCSI1_INT;
274 	slotc->sc_dmabits = TCDS_CIR_SCSI1_DMAENA;
275 	slotc->sc_errorbits = 0;				/* XXX */
276 	slotc->sc_sda = TCDS_SCSI1_DMA_ADDR;
277 	slotc->sc_dic = TCDS_SCSI1_DMA_INTR;
278 	slotc->sc_dud0 = TCDS_SCSI1_DMA_DUD0;
279 	slotc->sc_dud1 = TCDS_SCSI1_DMA_DUD1;
280 
281 	/* find the hardware attached to the TCDS ASIC */
282 	for (i = 0; i < 2; i++) {
283 		tcds_params(sc, i, &tcdsdev.tcdsda_id,
284 		    &tcdsdev.tcdsda_fast);
285 
286 		tcdsdev.tcdsda_bst = sc->sc_bst;
287 		tcdsdev.tcdsda_bsh = sbsh[i];
288 		tcdsdev.tcdsda_dmat = sc->sc_dmat;
289 		tcdsdev.tcdsda_chip = i;
290 		tcdsdev.tcdsda_sc = &sc->sc_slots[i];
291 		/*
292 		 * Determine the chip frequency.  TCDSF_FASTSCSI will be set
293 		 * for TC option cards.  For baseboard chips, GPI2 is set, for a
294 		 * 25MHz clock, else a 40MHz clock.
295 		 */
296 		if ((sc->sc_flags & TCDSF_BASEBOARD && gpi2 == 0) ||
297 		    sc->sc_flags & TCDSF_FASTSCSI) {
298 			tcdsdev.tcdsda_freq = 40000000;
299 			tcdsdev.tcdsda_period = tcdsdev.tcdsda_fast ? 4 : 8;
300 		} else {
301 			tcdsdev.tcdsda_freq = 25000000;
302 			tcdsdev.tcdsda_period = 5;
303 		}
304 		if (sc->sc_flags & TCDSF_BASEBOARD)
305 			tcdsdev.tcdsda_variant = NCR_VARIANT_NCR53C94;
306 		else
307 			tcdsdev.tcdsda_variant = NCR_VARIANT_NCR53C96;
308 
309 		tcds_scsi_reset(tcdsdev.tcdsda_sc);
310 
311 		ldesc->len = 1;
312 		ldesc->locs[TCDSCF_CHIP] = i;
313 
314 		config_found_sm_loc(self, "tcds", ldesc, &tcdsdev,
315 				    tcdsprint, tcdssubmatch);
316 #ifdef __alpha__
317 		/*
318 		 * The second SCSI chip isn't present on the baseboard TCDS
319 		 * on the DEC Alpha 3000/300 series.
320 		 */
321 		if (sc->sc_flags & TCDSF_BASEBOARD &&
322 		    cputype == ST_DEC_3000_300)
323 			break;
324 #endif /* __alpha__ */
325 	}
326 }
327 
328 int
329 tcdssubmatch(parent, cf, ldesc, aux)
330 	struct device *parent;
331 	struct cfdata *cf;
332 	const locdesc_t *ldesc;
333 	void *aux;
334 {
335 
336 	if (cf->cf_loc[TCDSCF_CHIP] != TCDSCF_CHIP_DEFAULT &&
337 	    cf->cf_loc[TCDSCF_CHIP] != ldesc->locs[TCDSCF_CHIP])
338 		return (0);
339 
340 	return (config_match(parent, cf, aux));
341 }
342 
343 int
344 tcdsprint(aux, pnp)
345 	void *aux;
346 	const char *pnp;
347 {
348 	struct tcdsdev_attach_args *tcdsdev = aux;
349 
350 	/* Only ASCs can attach to TCDSs; easy. */
351 	if (pnp)
352 		aprint_normal("asc at %s", pnp);
353 
354 	aprint_normal(" chip %d", tcdsdev->tcdsda_chip);
355 
356 	return (UNCONF);
357 }
358 
359 void
360 tcds_intr_establish(tcds, slot, func, arg)
361 	struct device *tcds;
362 	int slot;
363 	int (*func)(void *);
364 	void *arg;
365 {
366 	struct tcds_softc *sc = (struct tcds_softc *)tcds;
367 
368 	if (sc->sc_slots[slot].sc_intrhand != tcds_intrnull)
369 		panic("tcds_intr_establish: chip %d twice", slot);
370 
371 	sc->sc_slots[slot].sc_intrhand = func;
372 	sc->sc_slots[slot].sc_intrarg = arg;
373 	tcds_scsi_reset(&sc->sc_slots[slot]);
374 }
375 
376 void
377 tcds_intr_disestablish(tcds, slot)
378 	struct device *tcds;
379 	int slot;
380 {
381 	struct tcds_softc *sc = (struct tcds_softc *)tcds;
382 
383 	if (sc->sc_slots[slot].sc_intrhand == tcds_intrnull)
384 		panic("tcds_intr_disestablish: chip %d missing intr",
385 		    slot);
386 
387 	sc->sc_slots[slot].sc_intrhand = tcds_intrnull;
388 	sc->sc_slots[slot].sc_intrarg = (void *)(u_long)slot;
389 
390 	tcds_dma_enable(&sc->sc_slots[slot], 0);
391 	tcds_scsi_enable(&sc->sc_slots[slot], 0);
392 }
393 
394 int
395 tcds_intrnull(val)
396 	void *val;
397 {
398 
399 	panic("tcds_intrnull: uncaught TCDS intr for chip %lu",
400 	    (u_long)val);
401 }
402 
403 void
404 tcds_scsi_reset(sc)
405 	struct tcds_slotconfig *sc;
406 {
407 	u_int32_t cir;
408 
409 	tcds_dma_enable(sc, 0);
410 	tcds_scsi_enable(sc, 0);
411 
412 	cir = bus_space_read_4(sc->sc_bst, sc->sc_bsh, TCDS_CIR);
413 	TCDS_CIR_CLR(cir, sc->sc_resetbits);
414 	bus_space_write_4(sc->sc_bst, sc->sc_bsh, TCDS_CIR, cir);
415 
416 	DELAY(1);
417 
418 	cir = bus_space_read_4(sc->sc_bst, sc->sc_bsh, TCDS_CIR);
419 	TCDS_CIR_SET(cir, sc->sc_resetbits);
420 	bus_space_write_4(sc->sc_bst, sc->sc_bsh, TCDS_CIR, cir);
421 
422 	tcds_scsi_enable(sc, 1);
423 	tcds_dma_enable(sc, 1);
424 }
425 
426 void
427 tcds_scsi_enable(sc, on)
428 	struct tcds_slotconfig *sc;
429 	int on;
430 {
431 	u_int32_t imer;
432 
433 	imer = bus_space_read_4(sc->sc_bst, sc->sc_bsh, TCDS_IMER);
434 
435 	if (on)
436 		imer |= sc->sc_intrmaskbits;
437 	else
438 		imer &= ~sc->sc_intrmaskbits;
439 
440 	bus_space_write_4(sc->sc_bst, sc->sc_bsh, TCDS_IMER, imer);
441 }
442 
443 void
444 tcds_dma_enable(sc, on)
445 	struct tcds_slotconfig *sc;
446 	int on;
447 {
448 	u_int32_t cir;
449 
450 	cir = bus_space_read_4(sc->sc_bst, sc->sc_bsh, TCDS_CIR);
451 
452 	/* XXX Clear/set IOSLOT/PBS bits. */
453 	if (on)
454 		TCDS_CIR_SET(cir, sc->sc_dmabits);
455 	else
456 		TCDS_CIR_CLR(cir, sc->sc_dmabits);
457 
458 	bus_space_write_4(sc->sc_bst, sc->sc_bsh, TCDS_CIR, cir);
459 }
460 
461 int
462 tcds_scsi_isintr(sc, clear)
463 	struct tcds_slotconfig *sc;
464 	int clear;
465 {
466 	u_int32_t cir;
467 
468 	cir = bus_space_read_4(sc->sc_bst, sc->sc_bsh, TCDS_CIR);
469 
470 	if ((cir & sc->sc_intrbits) != 0) {
471 		if (clear) {
472 			TCDS_CIR_CLR(cir, sc->sc_intrbits);
473 			bus_space_write_4(sc->sc_bst, sc->sc_bsh, TCDS_CIR,
474 			    cir);
475 		}
476 		return (1);
477 	} else
478 		return (0);
479 }
480 
481 int
482 tcds_scsi_iserr(sc)
483 	struct tcds_slotconfig *sc;
484 {
485 	u_int32_t cir;
486 
487 	cir = bus_space_read_4(sc->sc_bst, sc->sc_bsh, TCDS_CIR);
488 	return ((cir & sc->sc_errorbits) != 0);
489 }
490 
491 int
492 tcds_intr(arg)
493 	void *arg;
494 {
495 	struct tcds_softc *sc = arg;
496 	u_int32_t ir, ir0;
497 
498 	/*
499 	 * XXX
500 	 * Copy and clear (gag!) the interrupts.
501 	 */
502 	ir = ir0 = bus_space_read_4(sc->sc_bst, sc->sc_bsh, TCDS_CIR);
503 	TCDS_CIR_CLR(ir0, TCDS_CIR_ALLINTR);
504 	bus_space_write_4(sc->sc_bst, sc->sc_bsh, TCDS_CIR, ir0);
505 	tc_syncbus();
506 
507 #define	INCRINTRCNT(slot)	sc->sc_slots[slot].sc_evcnt.ev_count++
508 
509 #define	CHECKINTR(slot)							\
510 	if (ir & sc->sc_slots[slot].sc_intrbits) {			\
511 		INCRINTRCNT(slot);					\
512 		(void)(*sc->sc_slots[slot].sc_intrhand)			\
513 		    (sc->sc_slots[slot].sc_intrarg);			\
514 	}
515 	CHECKINTR(0);
516 	CHECKINTR(1);
517 #undef CHECKINTR
518 
519 #ifdef DIAGNOSTIC
520 	/*
521 	 * Interrupts not currently handled, but would like to know if they
522 	 * occur.
523 	 *
524 	 * XXX
525 	 * Don't know if we have to set the interrupt mask and enable bits
526 	 * in the IMER to allow some of them to happen?
527 	 */
528 #define	PRINTINTR(msg, bits)						\
529 	if (ir & bits)							\
530 		printf("%s: %s", sc->sc_dv.dv_xname, msg);
531 	PRINTINTR("SCSI0 DREQ interrupt.\n", TCDS_CIR_SCSI0_DREQ);
532 	PRINTINTR("SCSI1 DREQ interrupt.\n", TCDS_CIR_SCSI1_DREQ);
533 	PRINTINTR("SCSI0 prefetch interrupt.\n", TCDS_CIR_SCSI0_PREFETCH);
534 	PRINTINTR("SCSI1 prefetch interrupt.\n", TCDS_CIR_SCSI1_PREFETCH);
535 	PRINTINTR("SCSI0 DMA error.\n", TCDS_CIR_SCSI0_DMA);
536 	PRINTINTR("SCSI1 DMA error.\n", TCDS_CIR_SCSI1_DMA);
537 	PRINTINTR("SCSI0 DB parity error.\n", TCDS_CIR_SCSI0_DB);
538 	PRINTINTR("SCSI1 DB parity error.\n", TCDS_CIR_SCSI1_DB);
539 	PRINTINTR("SCSI0 DMA buffer parity error.\n", TCDS_CIR_SCSI0_DMAB_PAR);
540 	PRINTINTR("SCSI1 DMA buffer parity error.\n", TCDS_CIR_SCSI1_DMAB_PAR);
541 	PRINTINTR("SCSI0 DMA read parity error.\n", TCDS_CIR_SCSI0_DMAR_PAR);
542 	PRINTINTR("SCSI1 DMA read parity error.\n", TCDS_CIR_SCSI1_DMAR_PAR);
543 	PRINTINTR("TC write parity error.\n", TCDS_CIR_TCIOW_PAR);
544 	PRINTINTR("TC I/O address parity error.\n", TCDS_CIR_TCIOA_PAR);
545 #undef PRINTINTR
546 #endif
547 
548 	/*
549 	 * XXX
550 	 * The MACH source had this, with the comment:
551 	 *	This is wrong, but machine keeps dying.
552 	 */
553 	DELAY(1);
554 
555 	return (1);
556 }
557 
558 void
559 tcds_params(sc, chip, idp, fastp)
560 	struct tcds_softc *sc;
561 	int chip, *idp, *fastp;
562 {
563 	int id, fast;
564 	u_int32_t ids;
565 
566 #ifdef __alpha__
567 	if (sc->sc_flags & TCDSF_BASEBOARD) {
568 		extern u_int8_t dec_3000_scsiid[], dec_3000_scsifast[];
569 
570 		id = dec_3000_scsiid[chip];
571 		fast = dec_3000_scsifast[chip];
572 	} else
573 #endif /* __alpha__ */
574 	{
575 		/*
576 		 * SCSI IDs are stored in the EEPROM, along with whether or
577 		 * not the device is "fast".  Chip 0 is the high nibble,
578 		 * chip 1 the low nibble.
579 		 */
580 		ids = bus_space_read_4(sc->sc_bst, sc->sc_bsh, TCDS_EEPROM_IDS);
581 		if (chip == 0)
582 			ids >>= 4;
583 
584 		id = ids & 0x7;
585 		fast = ids & 0x8;
586 	}
587 
588 	if (id < 0 || id > 7) {
589 		printf("%s: WARNING: bad SCSI ID %d for chip %d, using 7\n",
590 		    sc->sc_dv.dv_xname, id, chip);
591 		id = 7;
592 	}
593 
594 	if (fast)
595 		printf("%s: fast mode set for chip %d\n",
596 		    sc->sc_dv.dv_xname, chip);
597 
598 	*idp = id;
599 	*fastp = fast;
600 }
601