[BACK]Return to mcclock_isa.c CVS log [TXT][DIR] Up to [local] / sys / arch / alpha / isa

Annotation of sys/arch/alpha/isa/mcclock_isa.c, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: mcclock_isa.c,v 1.8 2006/01/02 05:21:24 brad Exp $    */
                      2: /*     $NetBSD: mcclock_isa.c,v 1.5 1996/12/05 01:39:29 cgd Exp $      */
                      3:
                      4: /*
                      5:  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
                      6:  * All rights reserved.
                      7:  *
                      8:  * Author: Chris G. Demetriou
                      9:  *
                     10:  * Permission to use, copy, modify and distribute this software and
                     11:  * its documentation is hereby granted, provided that both the copyright
                     12:  * notice and this permission notice appear in all copies of the
                     13:  * software, derivative works or modified versions, and any portions
                     14:  * thereof, and that both notices appear in supporting documentation.
                     15:  *
                     16:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
                     17:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
                     18:  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
                     19:  *
                     20:  * Carnegie Mellon requests users of this software to return to
                     21:  *
                     22:  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
                     23:  *  School of Computer Science
                     24:  *  Carnegie Mellon University
                     25:  *  Pittsburgh PA 15213-3890
                     26:  *
                     27:  * any improvements or extensions that they make and grant Carnegie the
                     28:  * rights to redistribute these changes.
                     29:  */
                     30:
                     31: #include <sys/param.h>
                     32: #include <sys/kernel.h>
                     33: #include <sys/systm.h>
                     34: #include <sys/device.h>
                     35:
                     36: #include <machine/bus.h>
                     37:
                     38: #include <alpha/alpha/clockvar.h>
                     39: #include <alpha/alpha/mcclockvar.h>
                     40: #include <dev/ic/mc146818reg.h>
                     41: #include <dev/isa/isavar.h>
                     42:
                     43: struct mcclock_isa_softc {
                     44:        struct mcclock_softc    sc_mcclock;
                     45:
                     46:        bus_space_tag_t         sc_iot;
                     47:        bus_space_handle_t      sc_ioh;
                     48: };
                     49:
                     50: int    mcclock_isa_match(struct device *, void *, void *);
                     51: void   mcclock_isa_attach(struct device *, struct device *, void *);
                     52:
                     53: struct cfattach mcclock_isa_ca = {
                     54:        sizeof (struct mcclock_isa_softc), mcclock_isa_match,
                     55:            mcclock_isa_attach,
                     56: };
                     57:
                     58: void   mcclock_isa_write(struct mcclock_softc *, u_int, u_int);
                     59: u_int  mcclock_isa_read(struct mcclock_softc *, u_int);
                     60:
                     61: const struct mcclock_busfns mcclock_isa_busfns = {
                     62:        mcclock_isa_write, mcclock_isa_read,
                     63: };
                     64:
                     65: int
                     66: mcclock_isa_match(parent, match, aux)
                     67:        struct device *parent;
                     68:        void *match;
                     69:        void *aux;
                     70: {
                     71:        struct isa_attach_args *ia = aux;
                     72:        bus_space_handle_t ioh;
                     73:
                     74:         if ((ia->ia_iobase != IOBASEUNK && ia->ia_iobase != 0x70) ||
                     75:             /* (ia->ia_iosize != 0 && ia->ia_iosize != 0x2) || XXX isa.c */
                     76:             ia->ia_maddr != MADDRUNK || ia->ia_msize != 0 ||
                     77:             ia->ia_irq != IRQUNK || ia->ia_drq != DRQUNK)
                     78:                 return (0);
                     79:
                     80:        if (bus_space_map(ia->ia_iot, 0x70, 0x2, 0, &ioh))
                     81:                return (0);
                     82:
                     83:        bus_space_unmap(ia->ia_iot, ioh, 0x2);
                     84:
                     85:        ia->ia_iobase = 0x70;
                     86:        ia->ia_iosize = 0x2;
                     87:
                     88:        return (1);
                     89: }
                     90:
                     91: void
                     92: mcclock_isa_attach(parent, self, aux)
                     93:        struct device *parent, *self;
                     94:        void *aux;
                     95: {
                     96:        struct isa_attach_args *ia = aux;
                     97:        struct mcclock_isa_softc *sc = (struct mcclock_isa_softc *)self;
                     98:
                     99:        sc->sc_iot = ia->ia_iot;
                    100:        if (bus_space_map(sc->sc_iot, ia->ia_iobase, ia->ia_iosize, 0,
                    101:            &sc->sc_ioh))
                    102:                panic("mcclock_isa_attach: couldn't map clock I/O space");
                    103:
                    104:        mcclock_attach(&sc->sc_mcclock, &mcclock_isa_busfns);
                    105: }
                    106:
                    107: void
                    108: mcclock_isa_write(mcsc, reg, datum)
                    109:        struct mcclock_softc *mcsc;
                    110:        u_int reg, datum;
                    111: {
                    112:        struct mcclock_isa_softc *sc = (struct mcclock_isa_softc *)mcsc;
                    113:        bus_space_tag_t iot = sc->sc_iot;
                    114:        bus_space_handle_t ioh = sc->sc_ioh;
                    115:
                    116:        bus_space_write_1(iot, ioh, 0, reg);
                    117:        bus_space_write_1(iot, ioh, 1, datum);
                    118: }
                    119:
                    120: u_int
                    121: mcclock_isa_read(mcsc, reg)
                    122:        struct mcclock_softc *mcsc;
                    123:        u_int reg;
                    124: {
                    125:        struct mcclock_isa_softc *sc = (struct mcclock_isa_softc *)mcsc;
                    126:        bus_space_tag_t iot = sc->sc_iot;
                    127:        bus_space_handle_t ioh = sc->sc_ioh;
                    128:
                    129:        bus_space_write_1(iot, ioh, 0, reg);
                    130:        return bus_space_read_1(iot, ioh, 1);
                    131: }

CVSweb