2001-03-17 23:34:43 +03:00
|
|
|
/* $NetBSD: oak.c,v 1.20 2001/03/17 20:34:44 bjh21 Exp $ */
|
1996-03-08 19:22:38 +03:00
|
|
|
|
1996-02-01 02:24:54 +03:00
|
|
|
/*
|
1998-03-14 20:06:17 +03:00
|
|
|
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
1996-02-01 02:24:54 +03:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
1998-03-14 20:06:17 +03:00
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Mark Brinicombe of Causality Limited.
|
|
|
|
*
|
1996-02-01 02:24:54 +03:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
1998-03-14 20:06:17 +03:00
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
1996-02-01 02:24:54 +03:00
|
|
|
*
|
1998-03-14 20:06:17 +03:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
1996-10-15 03:42:17 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
1998-03-14 20:06:17 +03:00
|
|
|
* Oak SCSI 1 driver using the generic NCR5380 driver
|
1996-02-01 02:24:54 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
1998-03-14 20:06:17 +03:00
|
|
|
#include <sys/systm.h>
|
1996-02-01 02:24:54 +03:00
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/buf.h>
|
1997-08-27 15:22:52 +04:00
|
|
|
#include <dev/scsipi/scsi_all.h>
|
|
|
|
#include <dev/scsipi/scsipi_all.h>
|
|
|
|
#include <dev/scsipi/scsiconf.h>
|
1996-02-01 02:24:54 +03:00
|
|
|
|
1998-03-14 20:06:17 +03:00
|
|
|
#include <dev/ic/ncr5380reg.h>
|
|
|
|
#include <dev/ic/ncr5380var.h>
|
1996-02-01 02:24:54 +03:00
|
|
|
|
|
|
|
#include <machine/io.h>
|
1998-03-14 20:06:17 +03:00
|
|
|
#include <machine/bootconfig.h>
|
|
|
|
|
1996-02-01 02:24:54 +03:00
|
|
|
#include <arm32/podulebus/podulebus.h>
|
2001-03-17 23:34:43 +03:00
|
|
|
#include <dev/podulebus/podules.h>
|
1996-02-01 02:24:54 +03:00
|
|
|
|
1998-03-14 20:06:17 +03:00
|
|
|
void oak_attach __P((struct device *, struct device *, void *));
|
|
|
|
int oak_match __P((struct device *, struct cfdata *, void *));
|
1996-02-01 02:24:54 +03:00
|
|
|
|
1998-03-14 20:06:17 +03:00
|
|
|
/*
|
|
|
|
* Oak SCSI 1 softc structure.
|
|
|
|
*
|
|
|
|
* Contains the generic ncr5380 device node, podule information and global information
|
|
|
|
* required by the driver.
|
|
|
|
*/
|
1996-02-01 02:24:54 +03:00
|
|
|
|
1998-03-14 20:06:17 +03:00
|
|
|
struct oak_softc {
|
|
|
|
struct ncr5380_softc sc_ncr5380;
|
|
|
|
int sc_podule_number;
|
|
|
|
podule_t *sc_podule;
|
1996-02-01 02:24:54 +03:00
|
|
|
};
|
|
|
|
|
1998-03-14 20:06:17 +03:00
|
|
|
struct cfattach oak_ca = {
|
|
|
|
sizeof(struct oak_softc), oak_match, oak_attach
|
1996-02-01 02:24:54 +03:00
|
|
|
};
|
|
|
|
|
1998-03-14 20:06:17 +03:00
|
|
|
/*
|
|
|
|
* Card probe function
|
|
|
|
*
|
|
|
|
* Just match the manufacturer and podule ID's
|
|
|
|
*/
|
|
|
|
|
1996-02-01 02:24:54 +03:00
|
|
|
int
|
1998-03-14 20:06:17 +03:00
|
|
|
oak_match(parent, cf, aux)
|
|
|
|
struct device *parent;
|
|
|
|
struct cfdata *cf;
|
|
|
|
void *aux;
|
1996-02-01 02:24:54 +03:00
|
|
|
{
|
1998-03-14 20:06:17 +03:00
|
|
|
struct podule_attach_args *pa = aux;
|
1996-02-01 02:24:54 +03:00
|
|
|
|
1996-10-15 03:42:17 +04:00
|
|
|
if (matchpodule(pa, MANUFACTURER_OAK, PODULE_OAK_SCSI, -1) == 0)
|
1996-04-27 02:38:11 +04:00
|
|
|
return(0);
|
1996-02-01 02:24:54 +03:00
|
|
|
|
1998-03-14 20:06:17 +03:00
|
|
|
return(1);
|
1996-02-01 02:24:54 +03:00
|
|
|
}
|
|
|
|
|
1998-03-14 20:06:17 +03:00
|
|
|
/*
|
|
|
|
* Card attach function
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
1996-02-01 02:24:54 +03:00
|
|
|
void
|
1998-03-14 20:06:17 +03:00
|
|
|
oak_attach(parent, self, aux)
|
|
|
|
struct device *parent, *self;
|
|
|
|
void *aux;
|
1996-02-01 02:24:54 +03:00
|
|
|
{
|
1998-03-14 20:06:17 +03:00
|
|
|
struct oak_softc *sc = (struct oak_softc *)self;
|
|
|
|
struct podule_attach_args *pa = aux;
|
|
|
|
u_char *iobase;
|
1998-09-18 07:23:19 +04:00
|
|
|
char hi_option[sizeof(sc->sc_ncr5380.sc_dev.dv_xname) + 8];
|
1998-03-14 20:06:17 +03:00
|
|
|
|
|
|
|
/* Note the podule number and validate */
|
1996-03-08 19:22:38 +03:00
|
|
|
|
1996-04-27 02:38:11 +04:00
|
|
|
if (pa->pa_podule_number == -1)
|
|
|
|
panic("Podule has disappeared !");
|
|
|
|
|
|
|
|
sc->sc_podule_number = pa->pa_podule_number;
|
|
|
|
sc->sc_podule = pa->pa_podule;
|
|
|
|
podules[sc->sc_podule_number].attached = 1;
|
1996-02-01 02:24:54 +03:00
|
|
|
|
1998-03-14 20:06:17 +03:00
|
|
|
sc->sc_ncr5380.sc_flags |= NCR5380_FORCE_POLLING;
|
|
|
|
sc->sc_ncr5380.sc_min_dma_len = 0;
|
|
|
|
sc->sc_ncr5380.sc_no_disconnect = 0xff;
|
|
|
|
sc->sc_ncr5380.sc_parity_disable = 0xff;
|
|
|
|
|
|
|
|
sc->sc_ncr5380.sc_dma_alloc = NULL;
|
|
|
|
sc->sc_ncr5380.sc_dma_free = NULL;
|
|
|
|
sc->sc_ncr5380.sc_dma_poll = NULL;
|
|
|
|
sc->sc_ncr5380.sc_dma_setup = NULL;
|
|
|
|
sc->sc_ncr5380.sc_dma_start = NULL;
|
|
|
|
sc->sc_ncr5380.sc_dma_eop = NULL;
|
|
|
|
sc->sc_ncr5380.sc_dma_stop = NULL;
|
|
|
|
sc->sc_ncr5380.sc_intr_on = NULL;
|
|
|
|
sc->sc_ncr5380.sc_intr_off = NULL;
|
|
|
|
|
|
|
|
iobase = (u_char *)pa->pa_podule->mod_base;
|
|
|
|
sc->sc_ncr5380.sci_r0 = iobase + 0;
|
|
|
|
sc->sc_ncr5380.sci_r1 = iobase + 4;
|
|
|
|
sc->sc_ncr5380.sci_r2 = iobase + 8;
|
|
|
|
sc->sc_ncr5380.sci_r3 = iobase + 12;
|
|
|
|
sc->sc_ncr5380.sci_r4 = iobase + 16;
|
|
|
|
sc->sc_ncr5380.sci_r5 = iobase + 20;
|
|
|
|
sc->sc_ncr5380.sci_r6 = iobase + 24;
|
|
|
|
sc->sc_ncr5380.sci_r7 = iobase + 28;
|
2000-03-25 18:27:54 +03:00
|
|
|
|
|
|
|
sc->sc_ncr5380.sc_rev = NCR_VARIANT_NCR5380;
|
|
|
|
|
1998-03-14 20:06:17 +03:00
|
|
|
sc->sc_ncr5380.sc_pio_in = ncr5380_pio_in;
|
|
|
|
sc->sc_ncr5380.sc_pio_out = ncr5380_pio_out;
|
1998-11-20 00:43:00 +03:00
|
|
|
|
1998-03-14 20:06:17 +03:00
|
|
|
/* Provide an override for the host id */
|
2000-03-18 19:13:22 +03:00
|
|
|
sc->sc_ncr5380.sc_link.scsipi_scsi.adapter_target = 7;
|
1998-09-18 07:23:19 +04:00
|
|
|
sprintf(hi_option, "%s.hostid", sc->sc_ncr5380.sc_dev.dv_xname);
|
|
|
|
(void)get_bootconf_option(boot_args, hi_option,
|
1998-03-14 20:06:17 +03:00
|
|
|
BOOTOPT_TYPE_INT, &sc->sc_ncr5380.sc_link.scsipi_scsi.adapter_target);
|
2000-03-18 19:13:22 +03:00
|
|
|
sc->sc_ncr5380.sc_adapter.scsipi_minphys = minphys;
|
1998-03-14 20:06:17 +03:00
|
|
|
|
2001-03-17 21:46:25 +03:00
|
|
|
printf(": host=%d, using 8 bit PIO\n",
|
1998-03-14 20:06:17 +03:00
|
|
|
sc->sc_ncr5380.sc_link.scsipi_scsi.adapter_target);
|
|
|
|
|
2000-03-18 19:13:22 +03:00
|
|
|
ncr5380_attach(&sc->sc_ncr5380);
|
1996-02-01 02:24:54 +03:00
|
|
|
}
|