Home | History | Annotate | Line # | Download | only in isa
nca_isa.c revision 1.6.8.5
      1  1.6.8.5  nathanw /*	$NetBSD: nca_isa.c,v 1.6.8.5 2002/10/18 02:42:28 nathanw Exp $	*/
      2      1.1  mycroft 
      3      1.1  mycroft /*-
      4      1.3  mycroft  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
      5      1.1  mycroft  * All rights reserved.
      6      1.1  mycroft  *
      7      1.1  mycroft  * This code is derived from software contributed to The NetBSD Foundation
      8      1.1  mycroft  * by John M. Ruschmeyer.
      9      1.1  mycroft  *
     10      1.1  mycroft  * Redistribution and use in source and binary forms, with or without
     11      1.1  mycroft  * modification, are permitted provided that the following conditions
     12      1.1  mycroft  * are met:
     13      1.1  mycroft  * 1. Redistributions of source code must retain the above copyright
     14      1.1  mycroft  *    notice, this list of conditions and the following disclaimer.
     15      1.1  mycroft  * 2. Redistributions in binary form must reproduce the above copyright
     16      1.1  mycroft  *    notice, this list of conditions and the following disclaimer in the
     17      1.1  mycroft  *    documentation and/or other materials provided with the distribution.
     18      1.1  mycroft  * 3. All advertising materials mentioning features or use of this software
     19      1.1  mycroft  *    must display the following acknowledgement:
     20      1.1  mycroft  *        This product includes software developed by the NetBSD
     21      1.1  mycroft  *        Foundation, Inc. and its contributors.
     22      1.1  mycroft  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23      1.1  mycroft  *    contributors may be used to endorse or promote products derived
     24      1.1  mycroft  *    from this software without specific prior written permission.
     25      1.1  mycroft  *
     26      1.1  mycroft  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27      1.1  mycroft  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28      1.1  mycroft  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29      1.1  mycroft  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30      1.1  mycroft  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31      1.1  mycroft  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32      1.1  mycroft  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33      1.1  mycroft  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34      1.1  mycroft  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35      1.1  mycroft  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36      1.1  mycroft  * POSSIBILITY OF SUCH DAMAGE.
     37      1.1  mycroft  */
     38      1.1  mycroft 
     39      1.1  mycroft /*
     40      1.1  mycroft  * FreeBSD generic NCR-5380/NCR-53C400 SCSI driver
     41      1.1  mycroft  *
     42      1.1  mycroft  * Copyright (C) 1994 Serge Vakulenko (vak (at) cronyx.ru)
     43      1.1  mycroft  *
     44      1.1  mycroft  * Redistribution and use in source and binary forms, with or without
     45      1.1  mycroft  * modification, are permitted provided that the following conditions
     46      1.1  mycroft  * are met:
     47      1.1  mycroft  * 1. Redistributions of source code must retain the above copyright
     48      1.1  mycroft  *    notice, this list of conditions and the following disclaimer.
     49      1.1  mycroft  * 2. Redistributions in binary form must reproduce the above copyright
     50      1.1  mycroft  *    notice, this list of conditions and the following disclaimer in the
     51      1.1  mycroft  *    documentation and/or other materials provided with the distribution.
     52      1.1  mycroft  *
     53      1.1  mycroft  * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND
     54      1.1  mycroft  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     55      1.1  mycroft  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     56      1.1  mycroft  * ARE DISCLAIMED.  IN NO EVENT SHALL THE DEVELOPERS BE LIABLE
     57      1.1  mycroft  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     58      1.1  mycroft  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     59      1.1  mycroft  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     60      1.1  mycroft  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     61      1.1  mycroft  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     62      1.1  mycroft  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     63      1.1  mycroft  * SUCH DAMAGE.
     64      1.1  mycroft  */
     65  1.6.8.2  nathanw 
     66  1.6.8.2  nathanw #include <sys/cdefs.h>
     67  1.6.8.5  nathanw __KERNEL_RCSID(0, "$NetBSD: nca_isa.c,v 1.6.8.5 2002/10/18 02:42:28 nathanw Exp $");
     68      1.1  mycroft 
     69      1.1  mycroft #include <sys/param.h>
     70      1.1  mycroft #include <sys/systm.h>
     71      1.1  mycroft #include <sys/device.h>
     72      1.1  mycroft #include <sys/buf.h>
     73      1.1  mycroft 
     74      1.1  mycroft #include <machine/bus.h>
     75      1.1  mycroft #include <machine/intr.h>
     76      1.1  mycroft 
     77      1.1  mycroft #include <dev/scsipi/scsi_all.h>
     78      1.1  mycroft #include <dev/scsipi/scsipi_all.h>
     79      1.1  mycroft #include <dev/scsipi/scsiconf.h>
     80      1.1  mycroft 
     81      1.1  mycroft #include <dev/isa/isavar.h>
     82      1.1  mycroft #include <dev/isa/isadmavar.h>
     83      1.1  mycroft 
     84      1.1  mycroft #include <dev/ic/ncr5380reg.h>
     85      1.1  mycroft #include <dev/ic/ncr5380var.h>
     86      1.1  mycroft #include <dev/ic/ncr53c400reg.h>
     87      1.1  mycroft 
     88      1.4  mycroft struct nca_isa_softc {
     89      1.4  mycroft 	struct ncr5380_softc	sc_ncr5380;	/* glue to MI code */
     90      1.4  mycroft 
     91      1.4  mycroft         void *sc_ih;
     92      1.4  mycroft         int sc_irq;
     93      1.4  mycroft 	int sc_options;
     94      1.4  mycroft };
     95      1.4  mycroft 
     96      1.4  mycroft struct nca_isa_probe_data {
     97      1.4  mycroft 	struct device sc_dev;
     98      1.4  mycroft 	int sc_reg_offset;
     99      1.4  mycroft 	int sc_host_type;
    100      1.4  mycroft };
    101      1.1  mycroft 
    102      1.2  mycroft int	nca_isa_find __P((bus_space_tag_t, bus_space_handle_t, bus_size_t,
    103      1.2  mycroft 	    struct nca_isa_probe_data *));
    104      1.2  mycroft int	nca_isa_match __P((struct device *, struct cfdata *, void *));
    105      1.2  mycroft void	nca_isa_attach __P((struct device *, struct device *, void *));
    106      1.2  mycroft int	nca_isa_test __P((bus_space_tag_t, bus_space_handle_t, bus_size_t));
    107      1.1  mycroft 
    108  1.6.8.5  nathanw CFATTACH_DECL(nca_isa, sizeof(struct nca_isa_softc),
    109  1.6.8.5  nathanw     nca_isa_match, nca_isa_attach, NULL, NULL);
    110      1.1  mycroft 
    111      1.1  mycroft 
    112      1.1  mycroft /* Supported controller types */
    113      1.1  mycroft #define MAX_NCA_CONTROLLER	3
    114      1.1  mycroft #define CTLR_NCR_5380	1
    115      1.1  mycroft #define	CTLR_NCR_53C400	2
    116      1.1  mycroft #define CTLR_PAS16	3
    117      1.1  mycroft 
    118      1.1  mycroft #define NCA_ISA_IOSIZE 16
    119      1.1  mycroft #define MIN_DMA_LEN 128
    120      1.1  mycroft 
    121      1.1  mycroft /* Options for disconnect/reselect, DMA, and interrupts. */
    122      1.1  mycroft #define NCA_NO_DISCONNECT    0xff
    123      1.1  mycroft #define NCA_NO_PARITY_CHK  0xff00
    124      1.1  mycroft #define NCA_FORCE_POLLING 0x10000
    125      1.1  mycroft 
    126      1.1  mycroft 
    127      1.1  mycroft /*
    128      1.2  mycroft  * Initialization and test function used by nca_isa_find()
    129      1.1  mycroft  */
    130      1.1  mycroft int
    131      1.2  mycroft nca_isa_test(iot, ioh, reg_offset)
    132      1.1  mycroft 	bus_space_tag_t	iot;
    133      1.1  mycroft 	bus_space_handle_t ioh;
    134      1.1  mycroft 	bus_size_t reg_offset;
    135      1.1  mycroft {
    136      1.1  mycroft 	/* Reset the SCSI bus. */
    137      1.1  mycroft 	bus_space_write_1(iot, ioh, reg_offset + C80_ICR, SCI_ICMD_RST);
    138      1.1  mycroft 	bus_space_write_1(iot, ioh, reg_offset + C80_ODR, 0);
    139      1.1  mycroft 	/* Hold reset for at least 25 microseconds. */
    140      1.1  mycroft 	delay(500);
    141      1.1  mycroft 	/* Check that status cleared. */
    142      1.1  mycroft 	if (bus_space_read_1(iot, ioh, reg_offset + C80_CSBR) != SCI_BUS_RST) {
    143      1.1  mycroft #ifdef DEBUG
    144      1.2  mycroft 		printf("nca_isa_find: reset status not cleared [0x%x]\n",
    145      1.1  mycroft 		    bus_space_read_1(iot, ioh, reg_offset+C80_CSBR));
    146      1.1  mycroft #endif
    147      1.1  mycroft 		bus_space_write_1(iot, ioh, reg_offset+C80_ICR, 0);
    148      1.1  mycroft 		return 0;
    149      1.1  mycroft 	}
    150      1.1  mycroft 	/* Clear reset. */
    151      1.1  mycroft 	bus_space_write_1(iot, ioh, reg_offset + C80_ICR, 0);
    152      1.1  mycroft 	/* Wait a Bus Clear Delay (800 ns + bus free delay 800 ns). */
    153      1.1  mycroft 	delay(16000);
    154      1.1  mycroft 
    155      1.1  mycroft 	/* Read RPI port, resetting parity/interrupt state. */
    156      1.1  mycroft 	bus_space_read_1(iot, ioh, reg_offset + C80_RPIR);
    157      1.1  mycroft 
    158      1.1  mycroft 	/* Test BSR: parity error, interrupt request and busy loss state
    159      1.1  mycroft 	 * should be cleared. */
    160      1.1  mycroft 	if (bus_space_read_1(iot, ioh, reg_offset + C80_BSR) & (SCI_CSR_PERR |
    161      1.1  mycroft 	    SCI_CSR_INT | SCI_CSR_DISC)) {
    162      1.1  mycroft #ifdef DEBUG
    163      1.2  mycroft 		printf("nca_isa_find: Parity/Interrupt/Busy not cleared [0x%x]\n",
    164      1.1  mycroft 		    bus_space_read_1(iot, ioh, reg_offset+C80_BSR));
    165      1.1  mycroft #endif
    166      1.1  mycroft 		return 0;
    167      1.1  mycroft 	}
    168      1.1  mycroft 
    169      1.1  mycroft 	/* We must have found one */
    170      1.1  mycroft 	return 1;
    171      1.1  mycroft }
    172      1.1  mycroft 
    173      1.1  mycroft 
    174      1.1  mycroft /*
    175      1.1  mycroft  * Look for the board
    176      1.1  mycroft  */
    177      1.1  mycroft int
    178      1.2  mycroft nca_isa_find(iot, ioh, max_offset, epd)
    179      1.1  mycroft 	bus_space_tag_t iot;
    180      1.1  mycroft 	bus_space_handle_t ioh;
    181      1.1  mycroft 	bus_size_t max_offset;
    182      1.2  mycroft 	struct nca_isa_probe_data *epd;
    183      1.1  mycroft {
    184      1.1  mycroft 	/*
    185      1.1  mycroft 	 * We check for the existence of a board by trying to initialize it,
    186      1.1  mycroft 	 * Then sending the commands to reset the SCSI bus.
    187      1.1  mycroft 	 * (Unfortunately, this duplicates code which is already in the MI
    188      1.1  mycroft 	 * driver. Unavoidable as that code is not suited to this task.)
    189      1.1  mycroft 	 * This is largely stolen from FreeBSD.
    190      1.1  mycroft 	 */
    191      1.1  mycroft 
    192      1.1  mycroft 	int 		cont_type;
    193      1.1  mycroft 	bus_size_t	base_offset, reg_offset = 0;
    194      1.1  mycroft 
    195      1.1  mycroft 	/*
    196      1.1  mycroft 	 * Some notes:
    197      1.1  mycroft 	 * In the case of a port-mapped board, we should be pointing
    198      1.1  mycroft 	 * right at the chip registers (if they are there at all).
    199      1.1  mycroft 	 * For a memory-mapped card, we loop through the 16K paragraph,
    200      1.1  mycroft 	 * 8 bytes at a time, until we either find it or run out
    201      1.1  mycroft 	 * of region. This means we will probably be doing things like
    202      1.1  mycroft 	 * trying to write to ROMS, etc. Hopefully, this is not a problem.
    203      1.1  mycroft 	 */
    204      1.1  mycroft 
    205      1.1  mycroft 	for (base_offset = 0; base_offset < max_offset; base_offset += 0x08) {
    206      1.1  mycroft #ifdef DEBUG
    207      1.2  mycroft 		printf("nca_isa_find: testing offset 0x%x\n", (int)base_offset);
    208      1.1  mycroft #endif
    209      1.1  mycroft 
    210      1.1  mycroft 		/* See if anything is there */
    211      1.1  mycroft 		if (bus_space_read_1(iot, ioh, base_offset) == 0xff)
    212      1.1  mycroft 			continue;
    213      1.1  mycroft 
    214      1.1  mycroft 		/* Loop around for each board type */
    215      1.1  mycroft 		for (cont_type = 1; cont_type <= MAX_NCA_CONTROLLER; cont_type++) {
    216      1.1  mycroft 			/* Per-controller initialization */
    217      1.1  mycroft 			switch (cont_type) {
    218      1.1  mycroft 			case CTLR_NCR_5380:
    219      1.1  mycroft 				/* No special inits */
    220      1.1  mycroft 				reg_offset = 0;
    221      1.1  mycroft 				break;
    222      1.1  mycroft 			case CTLR_NCR_53C400:
    223      1.1  mycroft 				/* Reset into 5380-compat. mode */
    224      1.1  mycroft 				bus_space_write_1(iot, ioh,
    225      1.1  mycroft 				    base_offset + C400_CSR,
    226      1.1  mycroft 				    C400_CSR_5380_ENABLE);
    227      1.1  mycroft 				reg_offset = C400_5380_REG_OFFSET;
    228      1.1  mycroft 				break;
    229      1.1  mycroft 			case CTLR_PAS16:
    230      1.1  mycroft 				/* Not currently supported */
    231      1.1  mycroft 				reg_offset = 0;
    232      1.1  mycroft 				cont_type = 0;
    233      1.1  mycroft 				continue;
    234      1.1  mycroft 			}
    235      1.1  mycroft 
    236      1.1  mycroft 			/* Initialize controller and bus */
    237      1.2  mycroft 			if (nca_isa_test(iot, ioh, base_offset+reg_offset)) {
    238      1.1  mycroft 				epd->sc_reg_offset = base_offset;
    239      1.1  mycroft 				epd->sc_host_type = cont_type;
    240      1.1  mycroft 				return cont_type;	/* This must be it */
    241      1.1  mycroft 			}
    242      1.1  mycroft 		}
    243      1.1  mycroft 	}
    244      1.1  mycroft 
    245      1.1  mycroft 	/* If we got here, we didn't find one */
    246      1.1  mycroft 	return 0;
    247      1.1  mycroft }
    248      1.1  mycroft 
    249      1.1  mycroft 
    250      1.1  mycroft /*
    251      1.1  mycroft  * See if there is anything at the config'd address.
    252      1.1  mycroft  * If so, call the real probe to see what it is.
    253      1.1  mycroft  */
    254      1.1  mycroft int
    255      1.2  mycroft nca_isa_match(parent, match, aux)
    256      1.1  mycroft 	struct device *parent;
    257      1.1  mycroft 	struct cfdata *match;
    258      1.1  mycroft 	void *aux;
    259      1.1  mycroft {
    260      1.1  mycroft 	struct isa_attach_args *ia = aux;
    261      1.1  mycroft 	bus_space_tag_t iot = ia->ia_iot;
    262      1.1  mycroft 	bus_space_tag_t memt = ia->ia_memt;
    263      1.1  mycroft 	bus_space_handle_t ioh;
    264      1.2  mycroft 	struct nca_isa_probe_data epd;
    265      1.1  mycroft 	int rv = 0;
    266      1.1  mycroft 
    267  1.6.8.3  nathanw 	if (ISA_DIRECT_CONFIG(ia))
    268  1.6.8.3  nathanw 		return (0);
    269  1.6.8.3  nathanw 
    270      1.1  mycroft 	/* See if we are looking for a port- or memory-mapped adapter */
    271  1.6.8.3  nathanw 	if (ia->ia_nio > 0 || ia->ia_io[0].ir_addr != ISACF_PORT_DEFAULT) {
    272      1.1  mycroft 		/* Port-mapped card */
    273  1.6.8.3  nathanw 		if (bus_space_map(iot, ia->ia_io[0].ir_addr, NCA_ISA_IOSIZE,
    274  1.6.8.3  nathanw 		    0, &ioh))
    275      1.1  mycroft 			return 0;
    276      1.1  mycroft 
    277      1.1  mycroft 		/* See if a 53C80/53C400 is there */
    278      1.2  mycroft 		rv = nca_isa_find(iot, ioh, 0x07, &epd);
    279      1.1  mycroft 
    280      1.1  mycroft 		bus_space_unmap(iot, ioh, NCA_ISA_IOSIZE);
    281  1.6.8.3  nathanw 
    282  1.6.8.3  nathanw 		if (rv) {
    283  1.6.8.3  nathanw 			ia->ia_nio = 1;
    284  1.6.8.3  nathanw 			ia->ia_io[0].ir_size = NCA_ISA_IOSIZE;
    285  1.6.8.3  nathanw 
    286  1.6.8.3  nathanw 			ia->ia_niomem = 0;
    287  1.6.8.3  nathanw 			ia->ia_ndrq = 0;
    288  1.6.8.3  nathanw 		}
    289  1.6.8.3  nathanw 	} else if (ia->ia_niomem > 0) {
    290      1.1  mycroft 		/* Memory-mapped card */
    291  1.6.8.3  nathanw 		if (bus_space_map(memt, ia->ia_iomem[0].ir_addr, 0x4000,
    292  1.6.8.3  nathanw 		    0, &ioh))
    293      1.1  mycroft 			return 0;
    294      1.1  mycroft 
    295      1.1  mycroft 		/* See if a 53C80/53C400 is somewhere in this para. */
    296      1.2  mycroft 		rv = nca_isa_find(memt, ioh, 0x03ff0, &epd);
    297      1.1  mycroft 
    298      1.1  mycroft 		bus_space_unmap(memt, ioh, 0x04000);
    299      1.1  mycroft 
    300  1.6.8.3  nathanw 		if (rv) {
    301  1.6.8.3  nathanw 			ia->ia_niomem = 1;
    302  1.6.8.3  nathanw 			ia->ia_iomem[0].ir_addr += epd.sc_reg_offset;
    303  1.6.8.3  nathanw 			ia->ia_iomem[0].ir_size = NCA_ISA_IOSIZE;
    304  1.6.8.3  nathanw 
    305  1.6.8.3  nathanw 			ia->ia_nio = 0;
    306  1.6.8.3  nathanw 			ia->ia_ndrq = 0;
    307      1.1  mycroft 		}
    308      1.1  mycroft 	}
    309      1.1  mycroft 
    310      1.1  mycroft 	return rv;
    311      1.1  mycroft }
    312      1.1  mycroft 
    313      1.1  mycroft /*
    314      1.1  mycroft  * Attach this instance, and then all the sub-devices
    315      1.1  mycroft  */
    316      1.1  mycroft void
    317      1.2  mycroft nca_isa_attach(parent, self, aux)
    318      1.1  mycroft 	struct device *parent, *self;
    319      1.1  mycroft 	void *aux;
    320      1.1  mycroft {
    321      1.1  mycroft 	struct isa_attach_args *ia = aux;
    322      1.2  mycroft 	struct nca_isa_softc *esc = (void *)self;
    323      1.1  mycroft 	struct ncr5380_softc *sc = &esc->sc_ncr5380;
    324      1.1  mycroft 	bus_space_tag_t iot = ia->ia_iot;
    325      1.1  mycroft 	bus_space_handle_t ioh;
    326      1.2  mycroft 	struct nca_isa_probe_data epd;
    327      1.1  mycroft 	isa_chipset_tag_t ic = ia->ia_ic;
    328      1.1  mycroft 
    329      1.1  mycroft 	printf("\n");
    330      1.1  mycroft 
    331  1.6.8.3  nathanw 	if (ia->ia_nio > 0) {
    332      1.1  mycroft 		iot = ia->ia_iot;
    333  1.6.8.3  nathanw 		if (bus_space_map(iot, ia->ia_io[0].ir_addr, NCA_ISA_IOSIZE,
    334  1.6.8.3  nathanw 		    0, &ioh)) {
    335      1.1  mycroft 			printf("%s: can't map i/o space\n",
    336      1.1  mycroft 			    sc->sc_dev.dv_xname);
    337      1.1  mycroft 			return;
    338      1.1  mycroft 		}
    339      1.1  mycroft 	} else {
    340  1.6.8.3  nathanw 		KASSERT(ia->ia_niomem > 0);
    341      1.1  mycroft 		iot = ia->ia_memt;
    342  1.6.8.3  nathanw 		if (bus_space_map(iot, ia->ia_iomem[0].ir_addr, NCA_ISA_IOSIZE,
    343  1.6.8.3  nathanw 		    0, &ioh)) {
    344      1.1  mycroft 			printf("%s: can't map mem space\n",
    345      1.1  mycroft 			    sc->sc_dev.dv_xname);
    346      1.1  mycroft 			return;
    347      1.1  mycroft 		}
    348      1.1  mycroft 	}
    349      1.1  mycroft 
    350      1.2  mycroft 	switch (nca_isa_find(iot, ioh, NCA_ISA_IOSIZE, &epd)) {
    351      1.1  mycroft 	case 0:
    352      1.1  mycroft 		/* Not found- must have gone away */
    353      1.2  mycroft 		printf("%s: nca_isa_find failed\n", sc->sc_dev.dv_xname);
    354      1.1  mycroft 		return;
    355      1.1  mycroft 	case CTLR_NCR_5380:
    356      1.1  mycroft 		printf("%s: NCR 53C80 detected\n", sc->sc_dev.dv_xname);
    357      1.1  mycroft 		sc->sci_r0 = 0;
    358      1.1  mycroft 		sc->sci_r1 = 1;
    359      1.1  mycroft 		sc->sci_r2 = 2;
    360      1.1  mycroft 		sc->sci_r3 = 3;
    361      1.1  mycroft 		sc->sci_r4 = 4;
    362      1.1  mycroft 		sc->sci_r5 = 5;
    363      1.1  mycroft 		sc->sci_r6 = 6;
    364      1.1  mycroft 		sc->sci_r7 = 7;
    365      1.6  tsutsui 		sc->sc_rev = NCR_VARIANT_NCR5380;
    366      1.1  mycroft 		break;
    367      1.1  mycroft 	case CTLR_NCR_53C400:
    368      1.1  mycroft 		printf("%s: NCR 53C400 detected\n", sc->sc_dev.dv_xname);
    369      1.1  mycroft 		sc->sci_r0 = C400_5380_REG_OFFSET + 0;
    370      1.1  mycroft 		sc->sci_r1 = C400_5380_REG_OFFSET + 1;
    371      1.1  mycroft 		sc->sci_r2 = C400_5380_REG_OFFSET + 2;
    372      1.1  mycroft 		sc->sci_r3 = C400_5380_REG_OFFSET + 3;
    373      1.1  mycroft 		sc->sci_r4 = C400_5380_REG_OFFSET + 4;
    374      1.1  mycroft 		sc->sci_r5 = C400_5380_REG_OFFSET + 5;
    375      1.1  mycroft 		sc->sci_r6 = C400_5380_REG_OFFSET + 6;
    376      1.1  mycroft 		sc->sci_r7 = C400_5380_REG_OFFSET + 7;
    377      1.6  tsutsui 		sc->sc_rev = NCR_VARIANT_NCR53C400;
    378      1.1  mycroft 		break;
    379      1.1  mycroft 	case CTLR_PAS16:
    380  1.6.8.3  nathanw 		printf("%s: ProAudio Spectrum 16 detected\n",
    381  1.6.8.3  nathanw 		    sc->sc_dev.dv_xname);
    382      1.6  tsutsui 		sc->sc_rev = NCR_VARIANT_PAS16;
    383      1.1  mycroft 		break;
    384      1.1  mycroft 	}
    385      1.1  mycroft 
    386      1.1  mycroft 	/*
    387      1.1  mycroft 	 * MD function pointers used by the MI code.
    388      1.1  mycroft 	 */
    389      1.1  mycroft 	sc->sc_pio_out = ncr5380_pio_out;
    390      1.1  mycroft 	sc->sc_pio_in =  ncr5380_pio_in;
    391      1.1  mycroft 	sc->sc_dma_alloc = NULL;
    392      1.1  mycroft 	sc->sc_dma_free  = NULL;
    393      1.1  mycroft 	sc->sc_dma_setup = NULL;
    394      1.1  mycroft 	sc->sc_dma_start = NULL;
    395      1.1  mycroft 	sc->sc_dma_poll  = NULL;
    396      1.1  mycroft 	sc->sc_dma_eop   = NULL;
    397      1.1  mycroft 	sc->sc_dma_stop  = NULL;
    398      1.1  mycroft 	sc->sc_intr_on   = NULL;
    399      1.1  mycroft 	sc->sc_intr_off  = NULL;
    400      1.1  mycroft 
    401  1.6.8.3  nathanw 	if (ia->ia_nirq > 0 && ia->ia_irq[0].ir_irq != ISACF_IRQ_DEFAULT) {
    402  1.6.8.3  nathanw 		esc->sc_ih = isa_intr_establish(ic, ia->ia_irq[0].ir_irq,
    403  1.6.8.3  nathanw 		    IST_EDGE, IPL_BIO, ncr5380_intr, esc);
    404      1.1  mycroft 		if (esc->sc_ih == NULL) {
    405  1.6.8.3  nathanw 			printf("%s: couldn't establish interrupt\n",
    406  1.6.8.3  nathanw 			    sc->sc_dev.dv_xname);
    407      1.1  mycroft 			return;
    408      1.1  mycroft 		}
    409      1.1  mycroft 	} else
    410      1.1  mycroft 		sc->sc_flags |= NCR5380_FORCE_POLLING;
    411      1.1  mycroft 
    412      1.1  mycroft 
    413      1.1  mycroft 	/*
    414      1.1  mycroft 	 * Support the "options" (config file flags).
    415      1.1  mycroft 	 * Disconnect/reselect is a per-target mask.
    416      1.1  mycroft 	 * Interrupts and DMA are per-controller.
    417      1.1  mycroft 	 */
    418      1.1  mycroft #if 0
    419      1.1  mycroft 	esc->sc_options = 0x00000;	/* no options */
    420      1.1  mycroft #else
    421      1.3  mycroft 	esc->sc_options = 0x0ffff;	/* all options except force poll */
    422      1.1  mycroft #endif
    423      1.1  mycroft 
    424      1.1  mycroft 	sc->sc_no_disconnect =
    425      1.1  mycroft 		(esc->sc_options & NCA_NO_DISCONNECT);
    426      1.1  mycroft 	sc->sc_parity_disable =
    427      1.1  mycroft 		(esc->sc_options & NCA_NO_PARITY_CHK) >> 8;
    428      1.1  mycroft 	if (esc->sc_options & NCA_FORCE_POLLING)
    429      1.1  mycroft 		sc->sc_flags |= NCR5380_FORCE_POLLING;
    430      1.1  mycroft 	sc->sc_min_dma_len = MIN_DMA_LEN;
    431      1.1  mycroft 
    432      1.1  mycroft 
    433      1.1  mycroft 	/*
    434      1.1  mycroft 	 * Initialize fields used by the MI code
    435      1.1  mycroft 	 */
    436      1.1  mycroft 	sc->sc_regt = iot;
    437      1.1  mycroft 	sc->sc_regh = ioh;
    438      1.1  mycroft 
    439  1.6.8.1  nathanw 	/*
    440  1.6.8.1  nathanw 	 * Fill in our portion of the scsipi_adapter.
    441  1.6.8.1  nathanw 	 */
    442  1.6.8.1  nathanw 	sc->sc_adapter.adapt_request = ncr5380_scsipi_request;
    443  1.6.8.1  nathanw 	sc->sc_adapter.adapt_minphys = minphys;
    444  1.6.8.1  nathanw 
    445  1.6.8.1  nathanw 	/*
    446  1.6.8.1  nathanw 	 * Fill in our portion of the scsipi_channel.
    447  1.6.8.1  nathanw 	 */
    448  1.6.8.1  nathanw 
    449  1.6.8.1  nathanw 	sc->sc_channel.chan_id = 7;
    450      1.1  mycroft 
    451      1.1  mycroft 	/*
    452      1.1  mycroft 	 *  Initialize nca board itself.
    453      1.1  mycroft 	 */
    454      1.3  mycroft 	ncr5380_attach(sc);
    455      1.1  mycroft }
    456