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

Annotation of sys/arch/mvme68k/dev/pcctwo.c, Revision 1.1

1.1     ! nbrk        1:
        !             2: /*     $OpenBSD: pcctwo.c,v 1.15 2005/11/24 22:43:16 miod Exp $ */
        !             3:
        !             4: /*
        !             5:  * Copyright (c) 1995 Theo de Raadt
        !             6:  * All rights reserved.
        !             7:  *
        !             8:  * Redistribution and use in source and binary forms, with or without
        !             9:  * modification, are permitted provided that the following conditions
        !            10:  * are met:
        !            11:  * 1. Redistributions of source code must retain the above copyright
        !            12:  *    notice, this list of conditions and the following disclaimer.
        !            13:  * 2. Redistributions in binary form must reproduce the above copyright
        !            14:  *    notice, this list of conditions and the following disclaimer in the
        !            15:  *    documentation and/or other materials provided with the distribution.
        !            16:  *
        !            17:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
        !            18:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
        !            19:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
        !            20:  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
        !            21:  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
        !            22:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
        !            23:  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
        !            24:  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
        !            25:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
        !            26:  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        !            27:  */
        !            28:
        !            29: /*
        !            30:  * VME16x PCC2 chip
        !            31:  */
        !            32: #include <sys/param.h>
        !            33: #include <sys/conf.h>
        !            34: #include <sys/ioctl.h>
        !            35: #include <sys/proc.h>
        !            36: #include <sys/user.h>
        !            37: #include <sys/tty.h>
        !            38: #include <sys/uio.h>
        !            39: #include <sys/systm.h>
        !            40: #include <sys/kernel.h>
        !            41: #include <sys/syslog.h>
        !            42: #include <sys/fcntl.h>
        !            43: #include <sys/device.h>
        !            44: #include <machine/cpu.h>
        !            45: #include <machine/autoconf.h>
        !            46: #include <dev/cons.h>
        !            47:
        !            48: #include <mvme68k/dev/pcctworeg.h>
        !            49:
        !            50: struct pcctwosoftc {
        !            51:        struct device   sc_dev;
        !            52:        vaddr_t         sc_vaddr;       /* PCC2 space */
        !            53:        paddr_t         sc_paddr;
        !            54:        struct pcctworeg *sc_pcc2;      /* the actual registers */
        !            55: };
        !            56:
        !            57: void pcctwoattach(struct device *, struct device *, void *);
        !            58: int  pcctwomatch(struct device *, void *, void *);
        !            59: int  pcctwo_print(void *, const char *);
        !            60: int  pcctwo_scan(struct device *, void *, void *);
        !            61:
        !            62: struct cfattach pcctwo_ca = {
        !            63:        sizeof(struct pcctwosoftc), pcctwomatch, pcctwoattach
        !            64: };
        !            65:
        !            66: struct cfdriver pcctwo_cd = {
        !            67:        NULL, "pcctwo", DV_DULL
        !            68: };
        !            69:
        !            70: struct pcctworeg *sys_pcc2 = NULL;
        !            71:
        !            72: int
        !            73: pcctwomatch(parent, vcf, args)
        !            74:        struct device *parent;
        !            75:        void *vcf, *args;
        !            76: {
        !            77:        struct confargs *ca = args;
        !            78:        struct pcctworeg *pcc2;
        !            79:
        !            80:        /* the PCC2 only exists on MVME16x's except the 162, right? */
        !            81:        if (cputyp == CPU_162 || cputyp == CPU_147 || cputyp == CPU_172)
        !            82:                return (0);
        !            83:        pcc2 = (struct pcctworeg *)(IIOV(ca->ca_paddr) + PCC2_PCC2CHIP_OFF);
        !            84:        if (badvaddr((vaddr_t)pcc2, 1) || pcc2->pcc2_chipid != PCC2_CHIPID)
        !            85:                return (0);
        !            86:        return (1);
        !            87: }
        !            88:
        !            89: int
        !            90: pcctwo_print(args, bus)
        !            91:        void *args;
        !            92:        const char *bus;
        !            93: {
        !            94:        struct confargs *ca = args;
        !            95:
        !            96:        if (ca->ca_offset != -1)
        !            97:                printf(" offset 0x%x", ca->ca_offset);
        !            98:        if (ca->ca_ipl > 0)
        !            99:                printf(" ipl %d", ca->ca_ipl);
        !           100:        return (UNCONF);
        !           101: }
        !           102:
        !           103: int
        !           104: pcctwo_scan(parent, child, args)
        !           105:        struct device *parent;
        !           106:        void *child, *args;
        !           107: {
        !           108:        struct cfdata *cf = child;
        !           109:        struct pcctwosoftc *sc = (struct pcctwosoftc *)parent;
        !           110:        struct confargs oca;
        !           111:
        !           112:        bzero(&oca, sizeof oca);
        !           113:        oca.ca_offset = cf->cf_loc[0];
        !           114:        oca.ca_ipl = cf->cf_loc[1];
        !           115:        if (oca.ca_offset != -1 && ISIIOVA(sc->sc_vaddr + oca.ca_offset)) {
        !           116:                oca.ca_vaddr = sc->sc_vaddr + oca.ca_offset;
        !           117:                oca.ca_paddr = sc->sc_paddr + oca.ca_offset;
        !           118:        } else {
        !           119:                oca.ca_vaddr = (vaddr_t)-1;
        !           120:                oca.ca_paddr = (paddr_t)-1;
        !           121:        }
        !           122:        oca.ca_bustype = BUS_PCCTWO;
        !           123:        oca.ca_name = cf->cf_driver->cd_name;
        !           124:        if ((*cf->cf_attach->ca_match)(parent, cf, &oca) == 0)
        !           125:                return (0);
        !           126:        config_attach(parent, cf, &oca, pcctwo_print);
        !           127:        return (1);
        !           128: }
        !           129:
        !           130: void
        !           131: pcctwoattach(parent, self, args)
        !           132:        struct device *parent, *self;
        !           133:        void *args;
        !           134: {
        !           135:        struct confargs *ca = args;
        !           136:        struct pcctwosoftc *sc = (struct pcctwosoftc *)self;
        !           137:
        !           138:        if (sys_pcc2)
        !           139:                panic("pcc2 already attached!");
        !           140:
        !           141:        /*
        !           142:         * since we know ourself to land in intiobase land,
        !           143:         * we must adjust our address
        !           144:         */
        !           145:        sc->sc_paddr = ca->ca_paddr;
        !           146:        sc->sc_vaddr = IIOV(sc->sc_paddr);
        !           147:        sc->sc_pcc2 = (struct pcctworeg *)(sc->sc_vaddr + PCC2_PCC2CHIP_OFF);
        !           148:        sys_pcc2 = sc->sc_pcc2;
        !           149:
        !           150:        printf(": rev %d\n", sc->sc_pcc2->pcc2_chiprev);
        !           151:
        !           152:        sc->sc_pcc2->pcc2_vecbase = PCC2_VECBASE;
        !           153:        sc->sc_pcc2->pcc2_genctl |= PCC2_GENCTL_IEN;    /* global irq enable */
        !           154:
        !           155:        config_search(pcctwo_scan, self, args);
        !           156: }
        !           157:
        !           158: /*
        !           159:  * PCC2 interrupts land in a PCC2_NVEC sized hole starting at PCC2_VECBASE
        !           160:  */
        !           161: int
        !           162: pcctwointr_establish(vec, ih, name)
        !           163:        int vec;
        !           164:        struct intrhand *ih;
        !           165:        const char *name;
        !           166: {
        !           167: #ifdef DIAGNOSTIC
        !           168:        if (vec < 0 || vec >= PCC2_NVEC)
        !           169:                panic("pcctwointr_establish: illegal vector for %s: 0x%x",
        !           170:                    name, vec);
        !           171: #endif
        !           172:
        !           173:        return intr_establish(PCC2_VECBASE + vec, ih, name);
        !           174: }

CVSweb