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

Annotation of sys/arch/sparc64/dev/stp_sbus.c, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: stp_sbus.c,v 1.8 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 <machine/intr.h>
                     61:
                     62: #include <dev/sbus/sbusvar.h>
                     63: #include <dev/sbus/stp4020reg.h>
                     64: #include <dev/sbus/stp4020var.h>
                     65:
                     66: struct stp4020_sbus_softc {
                     67:        struct stp4020_softc stp;
                     68: };
                     69:
                     70: int    stpmatch(struct device *, void *, void *);
                     71: void   stpattach(struct device *, struct device *, void *);
                     72:
                     73: struct cfattach stp_sbus_ca = {
                     74:        sizeof(struct stp4020_sbus_softc), stpmatch, stpattach
                     75: };
                     76:
                     77: int
                     78: stpmatch(parent, match, aux)
                     79:        struct device *parent;
                     80:        void *match;
                     81:        void *aux;
                     82: {
                     83:        struct sbus_attach_args *sa = aux;
                     84:
                     85:        return (strcmp("SUNW,pcmcia", sa->sa_name) == 0);
                     86: }
                     87:
                     88: /*
                     89:  * Attach all the sub-devices we can find
                     90:  */
                     91: void
                     92: stpattach(parent, self, aux)
                     93:        struct device *parent, *self;
                     94:        void *aux;
                     95: {
                     96:        struct sbus_attach_args *sa = aux;
                     97:        struct stp4020_softc *sc = (void *)self;
                     98:        int node;
                     99:        int i;
                    100:        bus_space_handle_t bh;
                    101:
                    102:        node = sa->sa_node;
                    103:
                    104:        /* Transfer bus tags */
                    105:        sc->sc_bustag = sa->sa_bustag;
                    106:
                    107:        /* Set up per-socket static initialization */
                    108:        sc->sc_socks[0].sc = sc->sc_socks[1].sc = sc;
                    109:        sc->sc_socks[0].tag = sc->sc_socks[1].tag = sa->sa_bustag;
                    110:
                    111:        if (sa->sa_nreg < 8) {
                    112:                printf(": only %d register sets\n", sa->sa_nreg);
                    113:                return;
                    114:        }
                    115:
                    116:        if (sa->sa_nintr != 2) {
                    117:                printf(": expect 2 interrupt SBus levels; got %d\n",
                    118:                    sa->sa_nintr);
                    119:                return;
                    120:        }
                    121:
                    122: #define STP4020_BANK_PROM      0
                    123: #define STP4020_BANK_CTRL      4
                    124:        for (i = 0; i < 8; i++) {
                    125:
                    126:                /*
                    127:                 * STP4020 Register address map:
                    128:                 *      bank  0:   Forth PROM
                    129:                 *      banks 1-3: socket 0, windows 0-2
                    130:                 *      bank  4:   control registers
                    131:                 *      banks 5-7: socket 1, windows 0-2
                    132:                 */
                    133:
                    134:                if (i == STP4020_BANK_PROM)
                    135:                        /* Skip the PROM */
                    136:                        continue;
                    137:
                    138:                if (sbus_bus_map(sa->sa_bustag, sa->sa_reg[i].sbr_slot,
                    139:                    sa->sa_reg[i].sbr_offset, sa->sa_reg[i].sbr_size, 0, 0,
                    140:                    &bh) != 0) {
                    141:                        printf(": attach: cannot map registers\n");
                    142:                        return;
                    143:                }
                    144:
                    145:                if (i == STP4020_BANK_CTRL) {
                    146:                        /*
                    147:                         * Copy tag and handle to both socket structures
                    148:                         * for easy access in control/status IO functions.
                    149:                         */
                    150:                        sc->sc_socks[0].regs = sc->sc_socks[1].regs = bh;
                    151:                } else if (i < STP4020_BANK_CTRL) {
                    152:                        /* banks 1-3 */
                    153:                        sc->sc_socks[0].windows[i-1].winaddr = bh;
                    154:                        sc->sc_socks[0].wintag = sc->sc_bustag;
                    155:                } else {
                    156:                        /* banks 5-7 */
                    157:                        sc->sc_socks[1].windows[i-5].winaddr = bh;
                    158:                        sc->sc_socks[1].wintag = sc->sc_bustag;
                    159:                }
                    160:        }
                    161:
                    162:        /*
                    163:         * We get to use two SBus interrupt levels.
                    164:         * The higher level we use for status change interrupts;
                    165:         * the lower level for PC card I/O.
                    166:         */
                    167:        bus_intr_establish(sa->sa_bustag, sa->sa_intr[1].sbi_pri,
                    168:            IPL_NONE, 0, stp4020_statintr, sc, self->dv_xname);
                    169:
                    170:        bus_intr_establish(sa->sa_bustag, sa->sa_intr[0].sbi_pri,
                    171:            IPL_NONE, 0, stp4020_iointr, sc, self->dv_xname);
                    172:
                    173:        stpattach_common(sc, sa->sa_frequency);
                    174: }

CVSweb