Annotation of sys/arch/hppa/gsc/mongoose_gsc.c, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: mongoose_gsc.c,v 1.1 2004/10/30 10:26:32 miod Exp $ */
! 2:
! 3: /*
! 4: * Copyright (c) 2004, Miodrag Vallat.
! 5: *
! 6: * Redistribution and use in source and binary forms, with or without
! 7: * modification, are permitted provided that the following conditions
! 8: * are met:
! 9: * 1. Redistributions of source code must retain the above copyright
! 10: * notice, this list of conditions and the following disclaimer.
! 11: * 2. Redistributions in binary form must reproduce the above copyright
! 12: * notice, this list of conditions and the following disclaimer in the
! 13: * documentation and/or other materials provided with the distribution.
! 14: *
! 15: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
! 16: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
! 17: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
! 18: * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
! 19: * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
! 20: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
! 21: * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
! 22: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
! 23: * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
! 24: * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
! 25: * POSSIBILITY OF SUCH DAMAGE.
! 26: */
! 27:
! 28: #include <sys/param.h>
! 29: #include <sys/systm.h>
! 30: #include <sys/device.h>
! 31:
! 32: #include <machine/bus.h>
! 33: #include <machine/autoconf.h>
! 34:
! 35: #include <hppa/dev/cpudevs.h>
! 36:
! 37: #include <dev/eisa/eisavar.h>
! 38: #include <dev/isa/isavar.h>
! 39:
! 40: #include <hppa/dev/mongoosereg.h>
! 41: #include <hppa/dev/mongoosevar.h>
! 42:
! 43: #include <hppa/gsc/gscbusvar.h>
! 44:
! 45: void mgattach_gsc(struct device *, struct device *, void *);
! 46: int mgmatch_gsc(struct device *, void *, void *);
! 47:
! 48: struct cfattach mg_gsc_ca = {
! 49: sizeof(struct mongoose_softc), mgmatch_gsc, mgattach_gsc
! 50: };
! 51:
! 52: int
! 53: mgmatch_gsc(struct device *parent, void *cfdata, void *aux)
! 54: {
! 55: struct gsc_attach_args *ga = aux;
! 56:
! 57: if (ga->ga_type.iodc_type != HPPA_TYPE_BHA ||
! 58: ga->ga_type.iodc_sv_model != HPPA_BHA_WEISA)
! 59: return (0);
! 60:
! 61: return (1);
! 62: }
! 63:
! 64: void
! 65: mgattach_gsc(struct device *parent, struct device *self, void *aux)
! 66: {
! 67: struct mongoose_softc *sc = (struct mongoose_softc *)self;
! 68: struct gsc_attach_args *ga = aux;
! 69: bus_space_handle_t ioh;
! 70:
! 71: sc->sc_bt = ga->ga_iot;
! 72: sc->sc_iomap = ga->ga_hpa;
! 73:
! 74: if (bus_space_map(ga->ga_iot, ga->ga_hpa + MONGOOSE_MONGOOSE,
! 75: sizeof(struct mongoose_regs), 0, &ioh) != 0) {
! 76: printf(": can't map IO space\n");
! 77: return;
! 78: }
! 79: sc->sc_regs = (struct mongoose_regs *)ioh;
! 80:
! 81: if (bus_space_map(ga->ga_iot, ga->ga_hpa + MONGOOSE_CTRL,
! 82: sizeof(struct mongoose_ctrl), 0, &ioh) != 0) {
! 83: printf(": can't map control registers\n");
! 84: bus_space_unmap(ga->ga_iot, (bus_space_handle_t)sc->sc_regs,
! 85: sizeof(struct mongoose_regs));
! 86: return;
! 87: }
! 88: sc->sc_ctrl = (struct mongoose_ctrl *)ioh;
! 89:
! 90: if (mgattach_common(sc) != 0)
! 91: return;
! 92:
! 93: sc->sc_ih = gsc_intr_establish((struct gsc_softc *)parent,
! 94: ga->ga_irq, IPL_HIGH, mg_intr, sc, sc->sc_dev.dv_xname);
! 95: }
CVSweb