[BACK]Return to cgsix_sbus.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / dev / sbus

Annotation of src/sys/dev/sbus/cgsix_sbus.c, Revision 1.3.2.5

1.3.2.4   nathanw     1: /*     $NetBSD$ */
1.1       pk          2:
                      3: /*-
                      4:  * Copyright (c) 1998 The NetBSD Foundation, Inc.
                      5:  * All rights reserved.
                      6:  *
                      7:  * This code is derived from software contributed to The NetBSD Foundation
                      8:  * by Paul Kranenburg.
                      9:  *
                     10:  * Redistribution and use in source and binary forms, with or without
                     11:  * modification, are permitted provided that the following conditions
                     12:  * are met:
                     13:  * 1. Redistributions of source code must retain the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer.
                     15:  * 2. Redistributions in binary form must reproduce the above copyright
                     16:  *    notice, this list of conditions and the following disclaimer in the
                     17:  *    documentation and/or other materials provided with the distribution.
                     18:  * 3. All advertising materials mentioning features or use of this software
                     19:  *    must display the following acknowledgement:
                     20:  *        This product includes software developed by the NetBSD
                     21:  *        Foundation, Inc. and its contributors.
                     22:  * 4. Neither the name of The NetBSD Foundation nor the names of its
                     23:  *    contributors may be used to endorse or promote products derived
                     24:  *    from this software without specific prior written permission.
                     25:  *
                     26:  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
                     27:  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
                     28:  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
                     29:  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
                     30:  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
                     31:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
                     32:  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
                     33:  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
                     34:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
                     35:  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
                     36:  * POSSIBILITY OF SUCH DAMAGE.
                     37:  */
                     38:
                     39: /*
                     40:  * color display (cgsix) driver; Sbus bus front-end.
                     41:  */
1.3.2.3   nathanw    42:
                     43: #include <sys/cdefs.h>
                     44: __KERNEL_RCSID(0, "$NetBSD$");
1.1       pk         45:
                     46: #include <sys/param.h>
                     47: #include <sys/systm.h>
                     48: #include <sys/buf.h>
                     49: #include <sys/device.h>
                     50: #include <sys/ioctl.h>
                     51: #include <sys/malloc.h>
                     52: #include <sys/mman.h>
                     53: #include <sys/tty.h>
                     54: #include <sys/conf.h>
                     55:
                     56: #ifdef DEBUG
                     57: #include <sys/proc.h>
                     58: #include <sys/syslog.h>
                     59: #endif
                     60:
                     61: #include <machine/bus.h>
                     62: #include <machine/autoconf.h>
                     63:
                     64: #include <dev/sbus/sbusvar.h>
                     65:
                     66: #include <dev/sun/fbio.h>
                     67: #include <dev/sun/fbvar.h>
                     68: #include <dev/sun/btreg.h>
                     69: #include <dev/sun/btvar.h>
                     70: #include <dev/sun/cgsixreg.h>
                     71: #include <dev/sun/cgsixvar.h>
                     72:
                     73: /* autoconfiguration driver */
                     74: static int     cgsixmatch __P((struct device *, struct cfdata *, void *));
                     75: static void    cgsixattach __P((struct device *, struct device *, void *));
                     76:
1.2       pk         77: /* Allocate an `sbusdev' in addition to the cgsix softc */
1.1       pk         78: struct cgsix_sbus_softc {
                     79:        struct cgsix_softc bss_softc;
                     80:        struct sbusdev bss_sd;
                     81: };
                     82:
1.3.2.5 ! nathanw    83: CFATTACH_DECL(cgsix_sbus, sizeof(struct cgsix_sbus_softc),
        !            84:     cgsixmatch, cgsixattach, NULL, NULL);
1.1       pk         85:
                     86: /*
                     87:  * Match a cgsix.
                     88:  */
                     89: int
                     90: cgsixmatch(parent, cf, aux)
                     91:        struct device *parent;
                     92:        struct cfdata *cf;
                     93:        void *aux;
                     94: {
                     95:        struct sbus_attach_args *sa = aux;
                     96:
1.3.2.5 ! nathanw    97:        return (strcmp(cf->cf_name, sa->sa_name) == 0);
1.1       pk         98: }
                     99:
                    100:
                    101: /*
                    102:  * Attach a cgsix.
                    103:  */
                    104: void
                    105: cgsixattach(parent, self, aux)
                    106:        struct device *parent, *self;
                    107:        void *aux;
                    108: {
                    109:        struct cgsix_softc *sc = (struct cgsix_softc *)self;
                    110:        struct sbusdev *sd = &((struct cgsix_sbus_softc *)self)->bss_sd;
                    111:        struct sbus_attach_args *sa = aux;
                    112:        struct fbdevice *fb = &sc->sc_fb;
                    113:        int node, isconsole;
                    114:        char *name;
                    115:        bus_space_handle_t bh;
                    116:
                    117:        /* Remember cookies for cgsix_mmap() */
                    118:        sc->sc_bustag = sa->sa_bustag;
1.3.2.1   nathanw   119:        sc->sc_paddr = sbus_bus_addr(sa->sa_bustag, sa->sa_slot, sa->sa_offset);
1.1       pk        120:
                    121:        node = sa->sa_node;
                    122:
                    123:        fb->fb_device = &sc->sc_dev;
                    124:        fb->fb_type.fb_type = FBTYPE_SUNFAST_COLOR;
                    125:        fb->fb_flags = sc->sc_dev.dv_cfdata->cf_flags & FB_USERMASK;
                    126:        fb->fb_type.fb_depth = 8;
                    127:
                    128:        fb_setsize_obp(fb, fb->fb_type.fb_depth, 1152, 900, node);
                    129:
                    130:        /*
                    131:         * Dunno what the PROM has mapped, though obviously it must have
                    132:         * the video RAM mapped.  Just map what we care about for ourselves
                    133:         * (the FHC, THC, and Brooktree registers).
                    134:         */
1.3.2.4   nathanw   135:        if (sbus_bus_map(sa->sa_bustag,
                    136:                         sa->sa_slot,
1.1       pk        137:                         sa->sa_offset + CGSIX_BT_OFFSET,
                    138:                         sizeof(*sc->sc_bt),
1.3.2.4   nathanw   139:                         BUS_SPACE_MAP_LINEAR, &bh) != 0) {
1.1       pk        140:                printf("%s: cannot map brooktree registers\n", self->dv_xname);
                    141:                return;
                    142:        }
1.3.2.4   nathanw   143:        sc->sc_bt = (struct bt_regs *)bus_space_vaddr(sa->sa_bustag, bh);
1.1       pk        144:
1.3.2.4   nathanw   145:        if (sbus_bus_map(sa->sa_bustag,
                    146:                         sa->sa_slot,
1.1       pk        147:                         sa->sa_offset + CGSIX_FHC_OFFSET,
                    148:                         sizeof(*sc->sc_fhc),
1.3.2.4   nathanw   149:                         BUS_SPACE_MAP_LINEAR, &bh) != 0) {
1.1       pk        150:                printf("%s: cannot map FHC registers\n", self->dv_xname);
                    151:                return;
                    152:        }
1.3.2.4   nathanw   153:        sc->sc_fhc = (int *)bus_space_vaddr(sa->sa_bustag, bh);
1.1       pk        154:
1.3.2.4   nathanw   155:        if (sbus_bus_map(sa->sa_bustag,
                    156:                         sa->sa_slot,
1.1       pk        157:                         sa->sa_offset + CGSIX_THC_OFFSET,
                    158:                         sizeof(*sc->sc_thc),
1.3.2.4   nathanw   159:                         BUS_SPACE_MAP_LINEAR, &bh) != 0) {
1.1       pk        160:                printf("%s: cannot map THC registers\n", self->dv_xname);
                    161:                return;
                    162:        }
1.3.2.4   nathanw   163:        sc->sc_thc = (struct cg6_thc *)bus_space_vaddr(sa->sa_bustag, bh);
1.1       pk        164:
1.3.2.4   nathanw   165:        if (sbus_bus_map(sa->sa_bustag,
                    166:                         sa->sa_slot,
1.1       pk        167:                         sa->sa_offset + CGSIX_TEC_OFFSET,
                    168:                         sizeof(*sc->sc_tec),
1.3.2.4   nathanw   169:                         BUS_SPACE_MAP_LINEAR, &bh) != 0) {
1.1       pk        170:                printf("%s: cannot map TEC registers\n", self->dv_xname);
                    171:                return;
                    172:        }
1.3.2.4   nathanw   173:        sc->sc_tec = (struct cg6_tec_xxx *)bus_space_vaddr(sa->sa_bustag, bh);
1.1       pk        174:
1.3.2.4   nathanw   175:        if (sbus_bus_map(sa->sa_bustag,
                    176:                         sa->sa_slot,
1.1       pk        177:                         sa->sa_offset + CGSIX_FBC_OFFSET,
                    178:                         sizeof(*sc->sc_fbc),
1.3.2.4   nathanw   179:                         BUS_SPACE_MAP_LINEAR, &bh) != 0) {
1.1       pk        180:                printf("%s: cannot map FBC registers\n", self->dv_xname);
                    181:                return;
                    182:        }
1.3.2.4   nathanw   183:        sc->sc_fbc = (struct cg6_fbc *)bus_space_vaddr(sa->sa_bustag, bh);
1.1       pk        184:
                    185:        sbus_establish(sd, &sc->sc_dev);
1.3.2.2   nathanw   186:        name = PROM_getpropstring(node, "model");
1.1       pk        187:
                    188:        isconsole = fb_is_console(node);
                    189:        if (isconsole && cgsix_use_rasterconsole) {
                    190:                int ramsize = fb->fb_type.fb_height * fb->fb_linebytes;
1.3.2.4   nathanw   191:                if (sbus_bus_map(sa->sa_bustag,
                    192:                                 sa->sa_slot,
1.1       pk        193:                                 sa->sa_offset + CGSIX_RAM_OFFSET,
                    194:                                 ramsize,
1.3.2.4   nathanw   195:                                 BUS_SPACE_MAP_LINEAR, &bh) != 0) {
1.1       pk        196:                        printf("%s: cannot map pixels\n", self->dv_xname);
                    197:                        return;
                    198:                }
1.3.2.4   nathanw   199:                sc->sc_fb.fb_pixels = (caddr_t)bus_space_vaddr(sa->sa_bustag,
                    200:                        bh);
1.1       pk        201:        }
                    202:
                    203:        cg6attach(sc, name, isconsole);
                    204: }

CVSweb <webmaster@jp.NetBSD.org>