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

Annotation of sys/arch/mvme88k/dev/syscon.c, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: syscon.c,v 1.27 2006/11/18 12:04:57 miod Exp $ */
                      2: /*
                      3:  * Copyright (c) 1999 Steve Murphree, Jr.
                      4:  * All rights reserved.
                      5:  *
                      6:  * Redistribution and use in source and binary forms, with or without
                      7:  * modification, are permitted provided that the following conditions
                      8:  * are met:
                      9:  * 1. Redistributions of source code must retain the above copyright
                     10:  *    notice, this list of conditions and the following disclaimer.
                     11:  * 2. Redistributions in binary form must reproduce the above copyright
                     12:  *    notice, this list of conditions and the following disclaimer in the
                     13:  *    documentation and/or other materials provided with the distribution.
                     14:  *
                     15:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
                     16:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
                     17:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
                     18:  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
                     19:  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
                     20:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
                     21:  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
                     22:  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
                     23:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
                     24:  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                     25:  */
                     26:
                     27: /*
                     28:  * VME188 SYSCON
                     29:  */
                     30:
                     31: #include <sys/param.h>
                     32: #include <sys/conf.h>
                     33: #include <sys/systm.h>
                     34: #include <sys/kernel.h>
                     35: #include <sys/device.h>
                     36:
                     37: #include <machine/autoconf.h>
                     38: #include <machine/cpu.h>
                     39:
                     40: #include <machine/mvme188.h>
                     41: #include <mvme88k/dev/sysconreg.h>
                     42:
                     43: struct sysconsoftc {
                     44:        struct device   sc_dev;
                     45:
                     46:        struct intrhand sc_abih;        /* `abort' switch */
                     47:        struct intrhand sc_acih;        /* `ac fail' */
                     48:        struct intrhand sc_sfih;        /* `sys fail' */
                     49: #if 0
                     50:        struct intrhand sc_m188ih;      /* `m188 interrupt' */
                     51: #endif
                     52: };
                     53:
                     54: void   sysconattach(struct device *, struct device *, void *);
                     55: int    sysconmatch(struct device *, void *, void *);
                     56:
                     57: int    syscon_print(void *, const char *);
                     58: int    syscon_scan(struct device *, void *, void *);
                     59: int    sysconabort(void *);
                     60: int    sysconacfail(void *);
                     61: int    sysconsysfail(void *);
                     62: int    sysconm188(void *);
                     63:
                     64: struct cfattach syscon_ca = {
                     65:        sizeof(struct sysconsoftc), sysconmatch, sysconattach
                     66: };
                     67:
                     68: struct cfdriver syscon_cd = {
                     69:        NULL, "syscon", DV_DULL
                     70: };
                     71:
                     72: int
                     73: sysconmatch(parent, vcf, args)
                     74:        struct device *parent;
                     75:        void *vcf, *args;
                     76: {
                     77:        /* Don't match if wrong cpu */
                     78:        if (brdtyp != BRD_188)
                     79:                return (0);
                     80:
                     81:        return (1);
                     82: }
                     83:
                     84: int
                     85: syscon_print(args, bus)
                     86:        void *args;
                     87:        const char *bus;
                     88: {
                     89:        struct confargs *ca = args;
                     90:
                     91:        if (ca->ca_offset != -1)
                     92:                printf(" offset 0x%x", ca->ca_offset);
                     93:        if (ca->ca_ipl > 0)
                     94:                printf(" ipl %d", ca->ca_ipl);
                     95:        return (UNCONF);
                     96: }
                     97:
                     98: int
                     99: syscon_scan(parent, child, args)
                    100:        struct device *parent;
                    101:        void *child, *args;
                    102: {
                    103:        struct cfdata *cf = child;
                    104:        struct confargs oca, *ca = args;
                    105:
                    106:        bzero(&oca, sizeof oca);
                    107:        oca.ca_iot = ca->ca_iot;
                    108:        oca.ca_dmat = ca->ca_dmat;
                    109:        oca.ca_offset = cf->cf_loc[0];
                    110:        oca.ca_ipl = cf->cf_loc[1];
                    111:        if (oca.ca_offset != -1) {
                    112:                oca.ca_paddr = ca->ca_paddr + oca.ca_offset;
                    113:        } else {
                    114:                oca.ca_paddr = -1;
                    115:        }
                    116:        oca.ca_bustype = BUS_SYSCON;
                    117:        oca.ca_name = cf->cf_driver->cd_name;
                    118:        if ((*cf->cf_attach->ca_match)(parent, cf, &oca) == 0)
                    119:                return (0);
                    120:        config_attach(parent, cf, &oca, syscon_print);
                    121:        return (1);
                    122: }
                    123:
                    124: void
                    125: sysconattach(parent, self, args)
                    126:        struct device *parent, *self;
                    127:        void *args;
                    128: {
                    129:        struct sysconsoftc *sc = (struct sysconsoftc *)self;
                    130:
                    131:        printf("\n");
                    132:
                    133:        /*
                    134:         * Clear SYSFAIL if lit.
                    135:         */
                    136:        *(volatile u_int32_t *)MVME188_UCSR |= UCSR_DRVSFBIT;
                    137:
                    138:        /*
                    139:         * pseudo driver, abort interrupt handler
                    140:         */
                    141:        sc->sc_abih.ih_fn = sysconabort;
                    142:        sc->sc_abih.ih_arg = 0;
                    143:        sc->sc_abih.ih_wantframe = 1;
                    144:        sc->sc_abih.ih_ipl = IPL_ABORT;
                    145:
                    146:        sc->sc_acih.ih_fn = sysconacfail;
                    147:        sc->sc_acih.ih_arg = 0;
                    148:        sc->sc_acih.ih_wantframe = 1;
                    149:        sc->sc_acih.ih_ipl = IPL_ABORT;
                    150:
                    151:        sc->sc_sfih.ih_fn = sysconsysfail;
                    152:        sc->sc_sfih.ih_arg = 0;
                    153:        sc->sc_sfih.ih_wantframe = 1;
                    154:        sc->sc_sfih.ih_ipl = IPL_ABORT;
                    155:
                    156: #if 0
                    157:        sc->sc_m188ih.ih_fn = sysconm188;
                    158:        sc->sc_m188ih.ih_arg = 0;
                    159:        sc->sc_m188ih.ih_wantframe = 1;
                    160:        sc->sc_m188ih.ih_ipl = IPL_ABORT;
                    161: #endif
                    162:
                    163:        sysconintr_establish(SYSCV_ABRT, &sc->sc_abih, "abort");
                    164:        sysconintr_establish(SYSCV_ACF, &sc->sc_acih, "acfail");
                    165:        sysconintr_establish(SYSCV_SYSF, &sc->sc_sfih, "sysfail");
                    166: #if 0
                    167:        intr_establish(M188_IVEC, &sc->sc_m188ih, self->dv_xname);
                    168: #endif
                    169:
                    170:        config_search(syscon_scan, self, args);
                    171: }
                    172:
                    173: int
                    174: sysconintr_establish(int vec, struct intrhand *ih, const char *name)
                    175: {
                    176: #ifdef DIAGNOSTIC
                    177:        if (vec < 0 || vec >= SYSCON_NVEC)
                    178:                panic("sysconintr_establish: illegal vector 0x%x", vec);
                    179: #endif
                    180:
                    181:        return intr_establish(SYSCON_VECT + vec, ih, name);
                    182: }
                    183:
                    184: int
                    185: sysconabort(eframe)
                    186:        void *eframe;
                    187: {
                    188:        *(volatile u_int32_t *)MVME188_CLRINT = ISTATE_ABORT;
                    189:        nmihand(eframe);
                    190:        return (1);
                    191: }
                    192:
                    193: int
                    194: sysconsysfail(eframe)
                    195:        void *eframe;
                    196: {
                    197:        *(volatile u_int32_t *)MVME188_CLRINT = ISTATE_SYSFAIL;
                    198:        printf("WARNING: SYSFAIL* ASSERTED\n");
                    199:        return (1);
                    200: }
                    201:
                    202: int
                    203: sysconacfail(eframe)
                    204:        void *eframe;
                    205: {
                    206:        *(volatile u_int32_t *)MVME188_CLRINT = ISTATE_ACFAIL;
                    207:        printf("WARNING: ACFAIL* ASSERTED\n");
                    208:        return (1);
                    209: }
                    210:
                    211: #if 0
                    212: int
                    213: sysconm188(eframe)
                    214:        void *eframe;
                    215: {
                    216:        /* shouldn't happen! */
                    217:        printf("MVME188: self-inflicted interrupt\n");
                    218:        return (1);
                    219: }
                    220: #endif

CVSweb