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

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

1.1     ! nbrk        1: /*     $OpenBSD: sti_sgc.c,v 1.35 2007/01/11 21:58:05 miod Exp $       */
        !             2:
        !             3: /*
        !             4:  * Copyright (c) 2000-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:  * These cards has to be known to work so far:
        !            30:  *     - HPA1991AGrayscale rev 0.02    (705/35) (byte-wide)
        !            31:  *     - HPA1991AC19       rev 0.02    (715/33) (byte-wide)
        !            32:  *     - HPA208LC1280      rev 8.04    (712/80) just works
        !            33:  */
        !            34:
        !            35: #include <sys/param.h>
        !            36: #include <sys/systm.h>
        !            37: #include <sys/device.h>
        !            38:
        !            39: #include <uvm/uvm.h>
        !            40:
        !            41: #include <machine/bus.h>
        !            42: #include <machine/cpu.h>
        !            43: #include <machine/iomod.h>
        !            44: #include <machine/autoconf.h>
        !            45:
        !            46: #include <dev/wscons/wsdisplayvar.h>
        !            47: #include <dev/wscons/wsconsio.h>
        !            48:
        !            49: #include <dev/ic/stireg.h>
        !            50: #include <dev/ic/stivar.h>
        !            51:
        !            52: #include <hppa/dev/cpudevs.h>
        !            53:
        !            54: #define        STI_ROMSIZE     (sizeof(struct sti_dd) * 4)
        !            55: #define        STI_ID_FDDI     0x280b31af      /* Medusa FDDI ROM id */
        !            56:
        !            57: /* gecko optional graphics (these share the onboard's prom) */
        !            58: char sti_sgc_opt[] = { 0x17, 0x20, 0x30, 0x40, 0x70, 0xc0, 0xd0 };
        !            59:
        !            60: /* internal EG */
        !            61: #define        STI_INEG_REV    0x60
        !            62: #define        STI_INEG_PROM   0xf0011000
        !            63:
        !            64: extern struct cfdriver sti_cd;
        !            65:
        !            66: int    sti_sgc_probe(struct device *, void *, void *);
        !            67: void   sti_sgc_attach(struct device *, struct device *, void *);
        !            68: paddr_t        sti_sgc_getrom(int, struct confargs *);
        !            69:
        !            70: struct cfattach sti_gedoens_ca = {
        !            71:        sizeof(struct sti_softc), sti_sgc_probe, sti_sgc_attach
        !            72: };
        !            73:
        !            74: /*
        !            75:  * Locate STI ROM.
        !            76:  * On some machines it may not be part of the HPA space.
        !            77:  */
        !            78: paddr_t
        !            79: sti_sgc_getrom(int unit, struct confargs *ca)
        !            80: {
        !            81:        paddr_t rom = PAGE0->pd_resv2[1];
        !            82:        int i;
        !            83:
        !            84:        if (unit) {
        !            85:                i = -1;
        !            86:                if (ca->ca_type.iodc_sv_model == HPPA_FIO_GSGC)
        !            87:                        for (i = sizeof(sti_sgc_opt); i-- &&
        !            88:                            sti_sgc_opt[i] != ca->ca_type.iodc_revision; )
        !            89:                                ;
        !            90:                if (i < 0)
        !            91:                        rom = 0;
        !            92:        }
        !            93:
        !            94:        if (rom < HPPA_IOBEGIN) {
        !            95:                if (unit == 0 &&
        !            96:                    ca->ca_type.iodc_sv_model == HPPA_FIO_GSGC &&
        !            97:                    ca->ca_type.iodc_revision == STI_INEG_REV)
        !            98:                        rom = STI_INEG_PROM;
        !            99:                else
        !           100:                        rom = ca->ca_hpa;
        !           101:        }
        !           102:
        !           103:        return (rom);
        !           104: }
        !           105:
        !           106: int
        !           107: sti_sgc_probe(parent, match, aux)
        !           108:        struct device *parent;
        !           109:        void *match, *aux;
        !           110: {
        !           111:        struct cfdata *cf = match;
        !           112:        struct confargs *ca = aux;
        !           113:        bus_space_handle_t romh;
        !           114:        paddr_t rom;
        !           115:        u_int32_t id;
        !           116:        u_char devtype;
        !           117:        int rv = 0, romunmapped = 0;
        !           118:
        !           119:        /* due to the graphic nature of this program do probe only one */
        !           120:        if (cf->cf_unit > sti_cd.cd_ndevs)
        !           121:                return (0);
        !           122:
        !           123:        if (ca->ca_type.iodc_type != HPPA_TYPE_FIO)
        !           124:                return (0);
        !           125:
        !           126:        /* these need futher checking for the graphics id */
        !           127:        if (ca->ca_type.iodc_sv_model != HPPA_FIO_GSGC &&
        !           128:            ca->ca_type.iodc_sv_model != HPPA_FIO_SGC)
        !           129:                return 0;
        !           130:
        !           131:        rom = sti_sgc_getrom(cf->cf_unit, ca);
        !           132: #ifdef STIDEBUG
        !           133:        printf ("sti: hpa=%x, rom=%x\n", ca->ca_hpa, rom);
        !           134: #endif
        !           135:
        !           136:        /* if it does not map, probably part of the lasi space */
        !           137:        if ((rv = bus_space_map(ca->ca_iot, rom, STI_ROMSIZE, 0, &romh))) {
        !           138: #ifdef STIDEBUG
        !           139:                printf ("sti: cannot map rom space (%d)\n", rv);
        !           140: #endif
        !           141:                if ((rom & HPPA_IOBEGIN) == HPPA_IOBEGIN) {
        !           142:                        romh = rom;
        !           143:                        romunmapped++;
        !           144:                } else {
        !           145:                        /* in this case nobody has no freaking idea */
        !           146:                        return 0;
        !           147:                }
        !           148:        }
        !           149:
        !           150:        devtype = bus_space_read_1(ca->ca_iot, romh, 3);
        !           151:
        !           152: #ifdef STIDEBUG
        !           153:        printf("sti: devtype=%d\n", devtype);
        !           154: #endif
        !           155:        rv = 1;
        !           156:        switch (devtype) {
        !           157:        case STI_DEVTYPE4:
        !           158:                id = bus_space_read_4(ca->ca_iot, romh, 0x8);
        !           159:                break;
        !           160:        case STI_DEVTYPE1:
        !           161:                id = (bus_space_read_1(ca->ca_iot, romh, 0x10 +  3) << 24) |
        !           162:                     (bus_space_read_1(ca->ca_iot, romh, 0x10 +  7) << 16) |
        !           163:                     (bus_space_read_1(ca->ca_iot, romh, 0x10 + 11) <<  8) |
        !           164:                     (bus_space_read_1(ca->ca_iot, romh, 0x10 + 15));
        !           165:                break;
        !           166:        default:
        !           167: #ifdef STIDEBUG
        !           168:                printf("sti: unknown type (%x)\n", devtype);
        !           169: #endif
        !           170:                rv = 0;
        !           171:        }
        !           172:
        !           173:        if (rv &&
        !           174:            ca->ca_type.iodc_sv_model == HPPA_FIO_SGC && id == STI_ID_FDDI) {
        !           175: #ifdef STIDEBUG
        !           176:                printf("sti: not a graphics device\n");
        !           177: #endif
        !           178:                rv = 0;
        !           179:        }
        !           180:
        !           181:        if (ca->ca_naddrs >= sizeof(ca->ca_addrs)/sizeof(ca->ca_addrs[0])) {
        !           182:                printf("sti: address list overflow\n");
        !           183:                return (0);
        !           184:        }
        !           185:
        !           186:        ca->ca_addrs[ca->ca_naddrs].addr = rom;
        !           187:        ca->ca_addrs[ca->ca_naddrs].size = sti_rom_size(ca->ca_iot, romh);
        !           188:        ca->ca_naddrs++;
        !           189:
        !           190:        if (!romunmapped)
        !           191:                bus_space_unmap(ca->ca_iot, romh, STI_ROMSIZE);
        !           192:        return (rv);
        !           193: }
        !           194:
        !           195: void
        !           196: sti_sgc_attach(parent, self, aux)
        !           197:        struct device *parent, *self;
        !           198:        void *aux;
        !           199: {
        !           200:        struct sti_softc *sc = (void *)self;
        !           201:        struct confargs *ca = aux;
        !           202:        paddr_t rom;
        !           203:        u_int32_t romlen;
        !           204:        int rv;
        !           205:        int i;
        !           206:
        !           207:        sc->memt = sc->iot = ca->ca_iot;
        !           208:
        !           209:        /* we stashed rom addr/len into the last slot during probe */
        !           210:        rom = ca->ca_addrs[ca->ca_naddrs - 1].addr;
        !           211:        romlen = ca->ca_addrs[ca->ca_naddrs - 1].size;
        !           212:        if ((rv = bus_space_map(ca->ca_iot, rom, romlen, 0, &sc->romh))) {
        !           213:                if ((rom & HPPA_IOBEGIN) == HPPA_IOBEGIN)
        !           214:                        sc->romh = rom;
        !           215:                else {
        !           216:                        printf (": cannot map rom space (%d)\n", rv);
        !           217:                        return;
        !           218:                }
        !           219:        }
        !           220:
        !           221:        sc->bases[0] = sc->romh;
        !           222:        for (i = 1; i < STI_REGION_MAX; i++)
        !           223:                sc->bases[i] = ca->ca_hpa;
        !           224:
        !           225: #ifdef HP7300LC_CPU
        !           226:        /* PCXL2: enable accel i/o for this space */
        !           227:        if (cpu_type == hpcxl2)
        !           228:                eaio_l2(0x8 >> (((ca->ca_hpa >> 25) & 3) - 2));
        !           229: #endif
        !           230:
        !           231:        if (ca->ca_hpa == (hppa_hpa_t)PAGE0->mem_cons.pz_hpa)
        !           232:                sc->sc_flags |= STI_CONSOLE;
        !           233:        if (sti_attach_common(sc, STI_CODEBASE_PA) == 0)
        !           234:                startuphook_establish(sti_end_attach, sc);
        !           235: }

CVSweb