Annotation of sys/arch/hppa/gsc/oosiop_gsc.c, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: oosiop_gsc.c,v 1.2 2005/12/13 23:13:45 mickey Exp $ */
! 2: /* $NetBSD: oosiop_gsc.c,v 1.2 2003/07/15 02:29:25 lukem Exp $ */
! 3:
! 4: /*
! 5: * Copyright (c) 2001 Matt Fredette. All rights reserved.
! 6: * Copyright (c) 2001,2002 Izumi Tsutsui. All rights reserved.
! 7: *
! 8: * Redistribution and use in source and binary forms, with or without
! 9: * modification, are permitted provided that the following conditions
! 10: * are met:
! 11: * 1. Redistributions of source code must retain the above copyright
! 12: * notice, this list of conditions and the following disclaimer.
! 13: * 2. Redistributions in binary form must reproduce the above copyright
! 14: * notice, this list of conditions and the following disclaimer in the
! 15: * documentation and/or other materials provided with the distribution.
! 16: * 3. 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 AUTHORS ``AS IS'' AND ANY EXPRESS OR
! 20: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
! 21: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
! 22: * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
! 23: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
! 24: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
! 25: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
! 26: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
! 27: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
! 28: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
! 29: */
! 30: /*
! 31: * Copyright (c) 1998 Michael Shalayeff
! 32: * All rights reserved.
! 33: *
! 34: * Redistribution and use in source and binary forms, with or without
! 35: * modification, are permitted provided that the following conditions
! 36: * are met:
! 37: * 1. Redistributions of source code must retain the above copyright
! 38: * notice, this list of conditions and the following disclaimer.
! 39: * 2. Redistributions in binary form must reproduce the above copyright
! 40: * notice, this list of conditions and the following disclaimer in the
! 41: * documentation and/or other materials provided with the distribution.
! 42: * 3. The name of the author may not be used to endorse or promote products
! 43: * derived from this software without specific prior written permission.
! 44: *
! 45: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
! 46: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
! 47: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
! 48: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
! 49: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
! 50: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
! 51: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
! 52: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
! 53: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
! 54: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
! 55: */
! 56:
! 57: #include <sys/param.h>
! 58: #include <sys/systm.h>
! 59: #include <sys/device.h>
! 60: #include <sys/buf.h>
! 61: #include <sys/malloc.h>
! 62:
! 63: #include <scsi/scsi_all.h>
! 64: #include <scsi/scsiconf.h>
! 65:
! 66: #include <machine/cpu.h>
! 67: #include <machine/intr.h>
! 68: #include <machine/iomod.h>
! 69: #include <machine/autoconf.h>
! 70: #include <machine/bus.h>
! 71:
! 72: #include <dev/ic/oosiopreg.h>
! 73: #include <dev/ic/oosiopvar.h>
! 74:
! 75: #include <hppa/dev/cpudevs.h>
! 76: #include <hppa/gsc/gscbusvar.h>
! 77:
! 78: #define OOSIOP_GSC_RESET 0x0000
! 79: #define OOSIOP_GSC_OFFSET 0x0100
! 80:
! 81: int oosiop_gsc_match(struct device *, void *, void *);
! 82: void oosiop_gsc_attach(struct device *, struct device *, void *);
! 83: int oosiop_gsc_intr(void *);
! 84:
! 85: struct cfattach oosiop_gsc_ca = {
! 86: sizeof(struct oosiop_softc), oosiop_gsc_match, oosiop_gsc_attach
! 87: };
! 88:
! 89: int
! 90: oosiop_gsc_match(parent, match, aux)
! 91: struct device *parent;
! 92: void *match, *aux;
! 93: {
! 94: struct gsc_attach_args *ga = aux;
! 95:
! 96: if (ga->ga_type.iodc_type != HPPA_TYPE_FIO ||
! 97: ga->ga_type.iodc_sv_model != HPPA_FIO_SCSI)
! 98: return 0;
! 99:
! 100: return 1;
! 101: }
! 102:
! 103: void
! 104: oosiop_gsc_attach(parent, self, aux)
! 105: struct device *parent, *self;
! 106: void *aux;
! 107: {
! 108: struct oosiop_softc *sc = (void *)self;
! 109: struct gsc_attach_args *ga = aux;
! 110: bus_space_handle_t ioh;
! 111:
! 112: sc->sc_bst = ga->ga_iot;
! 113: sc->sc_dmat = ga->ga_dmatag;
! 114: if (bus_space_map(sc->sc_bst, ga->ga_hpa,
! 115: OOSIOP_GSC_OFFSET + OOSIOP_NREGS, 0, &ioh))
! 116: panic("oosiop_gsc_attach: couldn't map I/O ports");
! 117: if (bus_space_subregion(sc->sc_bst, ioh,
! 118: OOSIOP_GSC_OFFSET, OOSIOP_NREGS, &sc->sc_bsh))
! 119: panic("oosiop_gsc_attach: couldn't get chip ports");
! 120:
! 121: sc->sc_freq = ga->ga_ca.ca_pdc_iodc_read->filler2[14];
! 122: if (!sc->sc_freq)
! 123: sc->sc_freq = 50 * 1000000;
! 124:
! 125: sc->sc_chip = OOSIOP_700;
! 126: sc->sc_id = 7; /* XXX */
! 127:
! 128: /*
! 129: * Reset the SCSI subsystem.
! 130: */
! 131: bus_space_write_1(sc->sc_bst, ioh, OOSIOP_GSC_RESET, 0);
! 132: DELAY(1000);
! 133:
! 134: /*
! 135: * Call common attachment
! 136: */
! 137: #ifdef OOSIOP_DEBUG
! 138: {
! 139: extern int oosiop_debug;
! 140: oosiop_debug = -1;
! 141: }
! 142: #endif /* OOSIOP_DEBUG */
! 143: oosiop_attach(sc);
! 144:
! 145: (void)gsc_intr_establish((struct gsc_softc *)parent,
! 146: ga->ga_irq, IPL_BIO, oosiop_gsc_intr, sc, sc->sc_dev.dv_xname);
! 147: }
! 148:
! 149: /*
! 150: * interrupt handler
! 151: */
! 152: int
! 153: oosiop_gsc_intr(arg)
! 154: void *arg;
! 155: {
! 156: struct oosiop_softc *sc = arg;
! 157: int rv;
! 158:
! 159: rv = oosiop_intr(sc);
! 160:
! 161: #ifdef USELEDS
! 162: ledctl(PALED_DISK, 0, 0);
! 163: #endif
! 164:
! 165: return (rv);
! 166: }
CVSweb