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

Annotation of sys/arch/sparc64/dev/bbc.c, Revision 1.1

1.1     ! nbrk        1: /*     $OpenBSD: bbc.c,v 1.1 2007/04/10 19:05:52 kettenis Exp $        */
        !             2:
        !             3: /*
        !             4:  * Copyright (c) 2007 Mark Kettenis
        !             5:  *
        !             6:  * Permission to use, copy, modify, and distribute this software for any
        !             7:  * purpose with or without fee is hereby granted, provided that the above
        !             8:  * copyright notice and this permission notice appear in all copies.
        !             9:  *
        !            10:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
        !            11:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
        !            12:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
        !            13:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
        !            14:  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
        !            15:  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
        !            16:  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
        !            17:  */
        !            18:
        !            19: #include <sys/param.h>
        !            20: #include <sys/kernel.h>
        !            21: #include <sys/device.h>
        !            22: #include <sys/malloc.h>
        !            23: #include <sys/systm.h>
        !            24:
        !            25: #include <machine/bus.h>
        !            26: #include <machine/autoconf.h>
        !            27:
        !            28: #include <sparc64/dev/ebusreg.h>
        !            29: #include <sparc64/dev/ebusvar.h>
        !            30:
        !            31: /* Watchdog Action */
        !            32: #define BBC_WATCHDOG_ACTION    0x00004
        !            33:
        !            34: /* Perform system reset when watchdog timer expires. */
        !            35: #define        BBC_WATCHDOG_RESET      0x01
        !            36:
        !            37: struct bbc_softc {
        !            38:        struct device           sc_dv;
        !            39:        bus_space_tag_t         sc_iot;
        !            40:        bus_space_handle_t      sc_ioh;
        !            41: };
        !            42:
        !            43: int    bbc_match(struct device *, void *, void *);
        !            44: void   bbc_attach(struct device *, struct device *, void *);
        !            45:
        !            46: struct cfattach bbc_ca = {
        !            47:        sizeof(struct bbc_softc), bbc_match, bbc_attach
        !            48: };
        !            49:
        !            50: struct cfdriver bbc_cd = {
        !            51:        NULL, "bbc", DV_DULL
        !            52: };
        !            53:
        !            54: int
        !            55: bbc_match(struct device *parent, void *cf, void *aux)
        !            56: {
        !            57:        struct ebus_attach_args *ea = aux;
        !            58:
        !            59:        if (strcmp("bbc", ea->ea_name) == 0)
        !            60:                return (1);
        !            61:        return (0);
        !            62: }
        !            63:
        !            64: void
        !            65: bbc_attach(struct device *parent, struct device *self, void *aux)
        !            66: {
        !            67:        struct bbc_softc *sc = (void *)self;
        !            68:        struct ebus_attach_args *ea = aux;
        !            69:
        !            70:        /* Use prom address if available, otherwise map it. */
        !            71:        if (ea->ea_nvaddrs) {
        !            72:                if (bus_space_map(ea->ea_memtag, ea->ea_vaddrs[0], 0,
        !            73:                    BUS_SPACE_MAP_PROMADDRESS, &sc->sc_ioh)) {
        !            74:                        printf(": can't map PROM register space\n");
        !            75:                        return;
        !            76:                }
        !            77:                sc->sc_iot = ea->ea_memtag;
        !            78:        } else if (ebus_bus_map(ea->ea_iotag, 0,
        !            79:            EBUS_PADDR_FROM_REG(&ea->ea_regs[0]),
        !            80:            ea->ea_regs[0].size, 0, 0, &sc->sc_ioh) == 0) {
        !            81:                sc->sc_iot = ea->ea_iotag;
        !            82:        } else if (ebus_bus_map(ea->ea_memtag, 0,
        !            83:            EBUS_PADDR_FROM_REG(&ea->ea_regs[0]),
        !            84:            ea->ea_regs[0].size, 0, 0, &sc->sc_ioh) == 0) {
        !            85:                sc->sc_iot = ea->ea_memtag;
        !            86:        } else {
        !            87:                printf("%s: can't map register space\n", self->dv_xname);
        !            88:                return;
        !            89:        }
        !            90:
        !            91:        printf("\n");
        !            92:
        !            93:        /*
        !            94:         * Make sure we actually reset the system when the watchdog
        !            95:         * timer expires.
        !            96:         */
        !            97:        bus_space_write_1(sc->sc_iot, sc->sc_ioh,
        !            98:            BBC_WATCHDOG_ACTION, BBC_WATCHDOG_RESET);
        !            99: }

CVSweb