[BACK]Return to wax.c CVS log [TXT][DIR] Up to [local] / sys / arch / hppa / dev

Annotation of sys/arch/hppa/dev/wax.c, Revision 1.1

1.1     ! nbrk        1: /*     $OpenBSD: wax.c,v 1.10 2004/11/08 20:53:25 miod Exp $   */
        !             2:
        !             3: /*
        !             4:  * Copyright (c) 1998-2003 Michael Shalayeff
        !             5:  * All rights reserved.
        !             6:  *
        !             7:  * Redistribution and use in source and binary forms, with or without
        !             8:  * modification, are permitted provided that the following conditions
        !             9:  * are met:
        !            10:  * 1. Redistributions of source code must retain the above copyright
        !            11:  *    notice, this list of conditions and the following disclaimer.
        !            12:  * 2. Redistributions in binary form must reproduce the above copyright
        !            13:  *    notice, this list of conditions and the following disclaimer in the
        !            14:  *    documentation and/or other materials provided with the distribution.
        !            15:  *
        !            16:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
        !            17:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
        !            18:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
        !            19:  * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
        !            20:  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
        !            21:  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        !            22:  * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            23:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
        !            24:  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
        !            25:  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
        !            26:  * THE POSSIBILITY OF SUCH DAMAGE.
        !            27:  */
        !            28:
        !            29: #include <sys/param.h>
        !            30: #include <sys/systm.h>
        !            31: #include <sys/device.h>
        !            32: #include <sys/reboot.h>
        !            33:
        !            34: #include <machine/iomod.h>
        !            35: #include <machine/autoconf.h>
        !            36:
        !            37: #include <hppa/dev/cpudevs.h>
        !            38:
        !            39: #include <hppa/gsc/gscbusvar.h>
        !            40:
        !            41: #define        WAX_IOMASK      0xfff00000
        !            42:
        !            43: struct wax_regs {
        !            44:        u_int32_t wax_irr;      /* int request register */
        !            45:        u_int32_t wax_imr;      /* int mask register */
        !            46:        u_int32_t wax_ipr;      /* int pending register */
        !            47:        u_int32_t wax_icr;      /* int command? register */
        !            48:        u_int32_t wax_iar;      /* int acquire? register */
        !            49: };
        !            50:
        !            51: struct wax_softc {
        !            52:        struct device sc_dv;
        !            53:        struct gscbus_ic sc_ic;
        !            54:
        !            55:        struct wax_regs volatile *sc_regs;
        !            56: };
        !            57:
        !            58: int    waxmatch(struct device *, void *, void *);
        !            59: void   waxattach(struct device *, struct device *, void *);
        !            60: void   wax_gsc_attach(struct device *);
        !            61:
        !            62: struct cfattach wax_ca = {
        !            63:        sizeof(struct wax_softc), waxmatch, waxattach
        !            64: };
        !            65:
        !            66: struct cfdriver wax_cd = {
        !            67:        NULL, "wax", DV_DULL
        !            68: };
        !            69:
        !            70: int
        !            71: waxmatch(parent, cfdata, aux)
        !            72:        struct device *parent;
        !            73:        void *cfdata;
        !            74:        void *aux;
        !            75: {
        !            76:        struct confargs *ca = aux;
        !            77:        struct cfdata *cf = cfdata;
        !            78:
        !            79:        /* there will be only one */
        !            80:        if (cf->cf_unit > 0 ||
        !            81:            ca->ca_type.iodc_type != HPPA_TYPE_BHA ||
        !            82:            ca->ca_type.iodc_sv_model != HPPA_BHA_WAX)
        !            83:                return 0;
        !            84:
        !            85:        return 1;
        !            86: }
        !            87:
        !            88: void
        !            89: waxattach(parent, self, aux)
        !            90:        struct device *parent;
        !            91:        struct device *self;
        !            92:        void *aux;
        !            93: {
        !            94:        struct wax_softc *sc = (struct wax_softc *)self;
        !            95:        struct confargs *ca = aux;
        !            96:        struct gsc_attach_args ga;
        !            97:        bus_space_handle_t ioh;
        !            98:        int s, in;
        !            99:
        !           100:        if (bus_space_map(ca->ca_iot, ca->ca_hpa, IOMOD_HPASIZE, 0, &ioh)) {
        !           101:                printf(": can't map IO space\n");
        !           102:                return;
        !           103:        }
        !           104:
        !           105:        sc->sc_regs = (struct wax_regs *)ca->ca_hpa;
        !           106:
        !           107:        printf("\n");
        !           108:
        !           109:        /* interrupts guts */
        !           110:        s = splhigh();
        !           111:        sc->sc_regs->wax_iar = cpu_gethpa(0) | (31 - ca->ca_irq);
        !           112:        sc->sc_regs->wax_icr = 0;
        !           113:        sc->sc_regs->wax_imr = ~0U;
        !           114:        in = sc->sc_regs->wax_irr;
        !           115:        sc->sc_regs->wax_imr = 0;
        !           116:        splx(s);
        !           117:
        !           118:        sc->sc_ic.gsc_type = gsc_wax;
        !           119:        sc->sc_ic.gsc_dv = sc;
        !           120:        sc->sc_ic.gsc_base = sc->sc_regs;
        !           121:
        !           122:        ga.ga_ca = *ca; /* clone from us */
        !           123:        if (!strcmp(parent->dv_xname, "mainbus0")) {
        !           124:                ga.ga_dp.dp_bc[0] = ga.ga_dp.dp_bc[1];
        !           125:                ga.ga_dp.dp_bc[1] = ga.ga_dp.dp_bc[2];
        !           126:                ga.ga_dp.dp_bc[2] = ga.ga_dp.dp_bc[3];
        !           127:                ga.ga_dp.dp_bc[3] = ga.ga_dp.dp_bc[4];
        !           128:                ga.ga_dp.dp_bc[4] = ga.ga_dp.dp_bc[5];
        !           129:                ga.ga_dp.dp_bc[5] = ga.ga_dp.dp_mod;
        !           130:                ga.ga_dp.dp_mod = 0;
        !           131:        }
        !           132:
        !           133:        ga.ga_name = "gsc";
        !           134:        ga.ga_hpamask = WAX_IOMASK;
        !           135:        ga.ga_ic = &sc->sc_ic;
        !           136:        config_found(self, &ga, gscprint);
        !           137: }

CVSweb