Home | History | Annotate | Line # | Download | only in tc
mcclock_ioasic.c revision 1.6
      1  1.6  jonathan /* $NetBSD: mcclock_ioasic.c,v 1.6 1998/04/19 07:50:26 jonathan Exp $ */
      2  1.1  jonathan 
      3  1.1  jonathan /*
      4  1.1  jonathan  * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
      5  1.1  jonathan  * All rights reserved.
      6  1.1  jonathan  *
      7  1.1  jonathan  * Author: Chris G. Demetriou
      8  1.1  jonathan  *
      9  1.1  jonathan  * Permission to use, copy, modify and distribute this software and
     10  1.1  jonathan  * its documentation is hereby granted, provided that both the copyright
     11  1.1  jonathan  * notice and this permission notice appear in all copies of the
     12  1.1  jonathan  * software, derivative works or modified versions, and any portions
     13  1.1  jonathan  * thereof, and that both notices appear in supporting documentation.
     14  1.1  jonathan  *
     15  1.1  jonathan  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     16  1.1  jonathan  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     17  1.1  jonathan  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     18  1.1  jonathan  *
     19  1.1  jonathan  * Carnegie Mellon requests users of this software to return to
     20  1.1  jonathan  *
     21  1.1  jonathan  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     22  1.1  jonathan  *  School of Computer Science
     23  1.1  jonathan  *  Carnegie Mellon University
     24  1.1  jonathan  *  Pittsburgh PA 15213-3890
     25  1.1  jonathan  *
     26  1.1  jonathan  * any improvements or extensions that they make and grant Carnegie the
     27  1.1  jonathan  * rights to redistribute these changes.
     28  1.1  jonathan  */
     29  1.1  jonathan 
     30  1.1  jonathan #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
     31  1.1  jonathan 
     32  1.6  jonathan __KERNEL_RCSID(0, "$NetBSD: mcclock_ioasic.c,v 1.6 1998/04/19 07:50:26 jonathan Exp $");
     33  1.1  jonathan 
     34  1.1  jonathan #include <sys/param.h>
     35  1.1  jonathan #include <sys/kernel.h>
     36  1.1  jonathan #include <sys/systm.h>
     37  1.1  jonathan #include <sys/device.h>
     38  1.1  jonathan 
     39  1.1  jonathan #include <machine/autoconf.h>
     40  1.2  jonathan #include <dev/dec/clockvar.h>
     41  1.3  jonathan #include <dev/dec/mcclockvar.h>
     42  1.1  jonathan #include <dev/ic/mc146818reg.h>
     43  1.6  jonathan 
     44  1.6  jonathan 
     45  1.1  jonathan #include <dev/tc/tcreg.h>
     46  1.1  jonathan #include <dev/tc/tcvar.h>
     47  1.1  jonathan #include <dev/tc/ioasicvar.h>                   /* XXX */
     48  1.1  jonathan 
     49  1.6  jonathan #include  <pmax/dev/mcclock_decvar.h>
     50  1.1  jonathan 
     51  1.1  jonathan int	mcclock_ioasic_match __P((struct device *, struct cfdata *, void *));
     52  1.1  jonathan void	mcclock_ioasic_attach __P((struct device *, struct device *, void *));
     53  1.1  jonathan 
     54  1.1  jonathan struct cfattach mcclock_ioasic_ca = {
     55  1.6  jonathan 	sizeof (struct mcclock_dec_softc),
     56  1.6  jonathan 	     (void *)mcclock_ioasic_match, mcclock_ioasic_attach,
     57  1.1  jonathan };
     58  1.1  jonathan 
     59  1.1  jonathan int
     60  1.1  jonathan mcclock_ioasic_match(parent, match, aux)
     61  1.1  jonathan 	struct device *parent;
     62  1.1  jonathan 	struct cfdata *match;
     63  1.1  jonathan 	void *aux;
     64  1.1  jonathan {
     65  1.6  jonathan 	struct ioasicdev_attach_args *d = aux;
     66  1.6  jonathan 
     67  1.6  jonathan #define	CFNAME(cf) ((cf)->dv_cfdata->cf_driver->cd_name)
     68  1.6  jonathan 	if (strcmp(CFNAME(parent), "ioasic") != 0)
     69  1.6  jonathan 		return 0;
     70  1.6  jonathan 
     71  1.6  jonathan 	if (strcmp("mc146818", d->iada_modname) != 0)
     72  1.1  jonathan 		return (0);
     73  1.6  jonathan 
     74  1.6  jonathan 	if (tc_badaddr(d->iada_addr))
     75  1.6  jonathan 		return (0);
     76  1.6  jonathan 
     77  1.1  jonathan 	return (1);
     78  1.1  jonathan }
     79  1.1  jonathan 
     80  1.1  jonathan void
     81  1.1  jonathan mcclock_ioasic_attach(parent, self, aux)
     82  1.1  jonathan 	struct device *parent, *self;
     83  1.1  jonathan 	void *aux;
     84  1.1  jonathan {
     85  1.1  jonathan 	struct ioasicdev_attach_args *ioasicdev = aux;
     86  1.6  jonathan 	struct mcclock_dec_softc *sc = (struct mcclock_dec_softc *)self;
     87  1.1  jonathan 
     88  1.6  jonathan 	sc->sc_dp = (struct mcclock_dec_clockdatum *)ioasicdev->iada_addr;
     89  1.1  jonathan 
     90  1.6  jonathan 	/* Attach MI driver, using busfns with TC-style register padding */
     91  1.6  jonathan 	mcclock_attach(&sc->sc_mcclock, &mcclock_dec_busfns);
     92  1.1  jonathan }
     93