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

Annotation of sys/arch/sparc/dev/stp_sbus.c, Revision 1.1

1.1     ! nbrk        1: /*     $OpenBSD: stp_sbus.c,v 1.6 2007/05/29 09:54:19 sobrado Exp $    */
        !             2: /*     $NetBSD: stp4020.c,v 1.23 2002/06/01 23:51:03 lukem Exp $       */
        !             3:
        !             4: /*-
        !             5:  * Copyright (c) 1998 The NetBSD Foundation, Inc.
        !             6:  * All rights reserved.
        !             7:  *
        !             8:  * This code is derived from software contributed to The NetBSD Foundation
        !             9:  * by Paul Kranenburg.
        !            10:  *
        !            11:  * Redistribution and use in source and binary forms, with or without
        !            12:  * modification, are permitted provided that the following conditions
        !            13:  * are met:
        !            14:  * 1. Redistributions of source code must retain the above copyright
        !            15:  *    notice, this list of conditions and the following disclaimer.
        !            16:  * 2. Redistributions in binary form must reproduce the above copyright
        !            17:  *    notice, this list of conditions and the following disclaimer in the
        !            18:  *    documentation and/or other materials provided with the distribution.
        !            19:  * 3. All advertising materials mentioning features or use of this software
        !            20:  *    must display the following acknowledgement:
        !            21:  *        This product includes software developed by the NetBSD
        !            22:  *        Foundation, Inc. and its contributors.
        !            23:  * 4. Neither the name of The NetBSD Foundation nor the names of its
        !            24:  *    contributors may be used to endorse or promote products derived
        !            25:  *    from this software without specific prior written permission.
        !            26:  *
        !            27:  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
        !            28:  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
        !            29:  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
        !            30:  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
        !            31:  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
        !            32:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
        !            33:  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
        !            34:  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
        !            35:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
        !            36:  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
        !            37:  * POSSIBILITY OF SUCH DAMAGE.
        !            38:  */
        !            39:
        !            40: /*
        !            41:  * STP4020: SBus/PCMCIA bridge supporting one Type-3 PCMCIA card, or up to
        !            42:  * two Type-1 and Type-2 PCMCIA cards..
        !            43:  */
        !            44:
        !            45: #include <sys/param.h>
        !            46: #include <sys/systm.h>
        !            47: #include <sys/errno.h>
        !            48: #include <sys/malloc.h>
        !            49: #include <sys/extent.h>
        !            50: #include <sys/proc.h>
        !            51: #include <sys/kernel.h>
        !            52: #include <sys/kthread.h>
        !            53: #include <sys/device.h>
        !            54:
        !            55: #include <dev/pcmcia/pcmciareg.h>
        !            56: #include <dev/pcmcia/pcmciavar.h>
        !            57: #include <dev/pcmcia/pcmciachip.h>
        !            58:
        !            59: #include <machine/bus.h>
        !            60: #include <sparc/dev/sbusvar.h>
        !            61:
        !            62: #include <dev/sbus/stp4020reg.h>
        !            63: #include <dev/sbus/stp4020var.h>
        !            64:
        !            65: struct stp4020_sbus_softc {
        !            66:        struct stp4020_softc stp;
        !            67:        struct rom_reg  sc_reg;
        !            68:        struct rom_reg  sc_reg_le;  /* rev. copy for pcmcia bus_space access */
        !            69:        struct intrhand sc_ih[2];
        !            70: };
        !            71:
        !            72: int    stpmatch(struct device *, void *, void *);
        !            73: void   stpattach(struct device *, struct device *, void *);
        !            74:
        !            75: struct cfattach stp_sbus_ca = {
        !            76:        sizeof(struct stp4020_sbus_softc), stpmatch, stpattach
        !            77: };
        !            78:
        !            79: int
        !            80: stpmatch(parent, match, aux)
        !            81:        struct device *parent;
        !            82:        void *match;
        !            83:        void *aux;
        !            84: {
        !            85:        struct confargs *ca = aux;
        !            86:
        !            87:        return (strcmp("SUNW,pcmcia", ca->ca_ra.ra_name) == 0);
        !            88: }
        !            89:
        !            90: /*
        !            91:  * Attach all the sub-devices we can find
        !            92:  */
        !            93: void
        !            94: stpattach(parent, self, aux)
        !            95:        struct device *parent, *self;
        !            96:        void *aux;
        !            97: {
        !            98:        struct confargs *ca = aux;
        !            99:        struct stp4020_sbus_softc *ssc = (void *)self;
        !           100:        struct stp4020_softc *sc = (void *)self;
        !           101:        int node;
        !           102:        int i;
        !           103:        bus_space_handle_t bh;
        !           104:
        !           105:        node = ca->ca_ra.ra_node;
        !           106:
        !           107:        /* Transfer bus tags */
        !           108:        ssc->sc_reg = ca->ca_ra.ra_reg[0];
        !           109:        ssc->sc_reg_le = ca->ca_ra.ra_reg[0];
        !           110:        SET_TAG_LITTLE_ENDIAN(&ssc->sc_reg_le);
        !           111:        sc->sc_bustag = &ssc->sc_reg;
        !           112:
        !           113:        /* Set up per-socket static initialization */
        !           114:        sc->sc_socks[0].sc = sc->sc_socks[1].sc = sc;
        !           115:        sc->sc_socks[0].tag = sc->sc_socks[1].tag = sc->sc_bustag;
        !           116:
        !           117:        if (ca->ca_ra.ra_nreg < 8) {
        !           118:                printf(": only %d register sets\n", ca->ca_ra.ra_nreg);
        !           119:                return;
        !           120:        }
        !           121:
        !           122:        if (ca->ca_ra.ra_nintr != 2) {
        !           123:                printf(": expect 2 interrupt SBus levels; got %d\n",
        !           124:                    ca->ca_ra.ra_nintr);
        !           125:                return;
        !           126:        }
        !           127:
        !           128: #define STP4020_BANK_PROM      0
        !           129: #define STP4020_BANK_CTRL      4
        !           130:        for (i = 0; i < 8; i++) {
        !           131:
        !           132:                /*
        !           133:                 * STP4020 Register address map:
        !           134:                 *      bank  0:   Forth PROM
        !           135:                 *      banks 1-3: socket 0, windows 0-2
        !           136:                 *      bank  4:   control registers
        !           137:                 *      banks 5-7: socket 1, windows 0-2
        !           138:                 */
        !           139:
        !           140:                if (i == STP4020_BANK_PROM)
        !           141:                        /* Skip the PROM */
        !           142:                        continue;
        !           143:
        !           144:                if (bus_space_map(&ca->ca_ra.ra_reg[i], 0,
        !           145:                    ca->ca_ra.ra_reg[i].rr_len, 0, &bh) != 0) {
        !           146:                        printf(": attach: cannot map registers\n");
        !           147:                        return;
        !           148:                }
        !           149:
        !           150:                if (i == STP4020_BANK_CTRL) {
        !           151:                        /*
        !           152:                         * Copy tag and handle to both socket structures
        !           153:                         * for easy access in control/status IO functions.
        !           154:                         */
        !           155:                        sc->sc_socks[0].regs = sc->sc_socks[1].regs = bh;
        !           156:                } else if (i < STP4020_BANK_CTRL) {
        !           157:                        /* banks 1-3 */
        !           158:                        sc->sc_socks[0].windows[i-1].winaddr = bh;
        !           159:                        sc->sc_socks[0].wintag = &ssc->sc_reg_le;
        !           160:                } else {
        !           161:                        /* banks 5-7 */
        !           162:                        sc->sc_socks[1].windows[i-5].winaddr = bh;
        !           163:                        sc->sc_socks[1].wintag = &ssc->sc_reg_le;
        !           164:                }
        !           165:        }
        !           166:
        !           167:        /*
        !           168:         * We get to use two SBus interrupt levels.
        !           169:         * The higher level we use for status change interrupts;
        !           170:         * the lower level for PC card I/O.
        !           171:         */
        !           172:        ssc->sc_ih[1].ih_fun = stp4020_statintr;
        !           173:        ssc->sc_ih[1].ih_arg = sc;
        !           174:        intr_establish(ca->ca_ra.ra_intr[1].int_pri,
        !           175:            &ssc->sc_ih[1], -1, self->dv_xname);
        !           176:        printf(" pri %d", ca->ca_ra.ra_intr[1].int_pri);
        !           177:
        !           178:        ssc->sc_ih[0].ih_fun = stp4020_iointr;
        !           179:        ssc->sc_ih[0].ih_arg = sc;
        !           180:        intr_establish(ca->ca_ra.ra_intr[0].int_pri,
        !           181:            &ssc->sc_ih[0], -1, self->dv_xname);
        !           182:        printf(" and %d", ca->ca_ra.ra_intr[0].int_pri);
        !           183:
        !           184:        stpattach_common(sc, ((struct sbus_softc *)parent)->sc_clockfreq);
        !           185: }

CVSweb