Home | History | Annotate | Line # | Download | only in tc
mcclock_ioasic.c revision 1.22.6.1
      1  1.22.6.1    jruoho /*	$NetBSD: mcclock_ioasic.c,v 1.22.6.1 2011/06/06 09:06:25 jruoho 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.13        ad #include <sys/cdefs.h>
     31  1.22.6.1    jruoho __KERNEL_RCSID(0, "$NetBSD: mcclock_ioasic.c,v 1.22.6.1 2011/06/06 09:06:25 jruoho Exp $");
     32       1.1  jonathan 
     33       1.1  jonathan #include <sys/param.h>
     34       1.1  jonathan #include <sys/device.h>
     35      1.15       chs #include <sys/systm.h>
     36      1.19     joerg #include <dev/clock_subr.h>
     37       1.1  jonathan 
     38       1.3  jonathan #include <dev/dec/mcclockvar.h>
     39      1.12    simonb #include <dev/dec/mcclock_pad32.h>
     40       1.6  jonathan 
     41       1.9  nisimura #include <dev/tc/tcvar.h>
     42       1.9  nisimura #include <dev/tc/ioasicvar.h>
     43       1.1  jonathan 
     44  1.22.6.1    jruoho static int	mcclock_ioasic_match(device_t, cfdata_t, void *);
     45  1.22.6.1    jruoho static void	mcclock_ioasic_attach(device_t, device_t, void *);
     46       1.1  jonathan 
     47  1.22.6.1    jruoho CFATTACH_DECL_NEW(mcclock_ioasic, sizeof (struct mcclock_pad32_softc),
     48      1.18   thorpej     mcclock_ioasic_match, mcclock_ioasic_attach, NULL, NULL);
     49       1.1  jonathan 
     50      1.11    simonb static int
     51  1.22.6.1    jruoho mcclock_ioasic_match(device_t parent, cfdata_t cf, void *aux)
     52       1.1  jonathan {
     53       1.6  jonathan 	struct ioasicdev_attach_args *d = aux;
     54       1.6  jonathan 
     55       1.6  jonathan 	if (strcmp("mc146818", d->iada_modname) != 0)
     56       1.1  jonathan 		return (0);
     57       1.6  jonathan 
     58       1.6  jonathan 	if (tc_badaddr(d->iada_addr))
     59       1.6  jonathan 		return (0);
     60       1.6  jonathan 
     61       1.1  jonathan 	return (1);
     62       1.1  jonathan }
     63       1.1  jonathan 
     64      1.11    simonb static void
     65  1.22.6.1    jruoho mcclock_ioasic_attach(device_t parent, device_t self, void *aux)
     66       1.1  jonathan {
     67       1.1  jonathan 	struct ioasicdev_attach_args *ioasicdev = aux;
     68  1.22.6.1    jruoho 	struct mcclock_pad32_softc *sc = device_private(self);
     69       1.1  jonathan 
     70  1.22.6.1    jruoho 	sc->sc_mcclock.sc_dev = self;
     71       1.7  jonathan 	sc->sc_dp = (struct mcclock_pad32_clockdatum *)ioasicdev->iada_addr;
     72       1.1  jonathan 
     73       1.6  jonathan 	/* Attach MI driver, using busfns with TC-style register padding */
     74       1.7  jonathan 	mcclock_attach(&sc->sc_mcclock, &mcclock_pad32_busfns);
     75       1.1  jonathan }
     76