Home | History | Annotate | Line # | Download | only in ibus
mcclock_ibus.c revision 1.13.24.1
      1  1.13.24.1       jym /*	$NetBSD: mcclock_ibus.c,v 1.13.24.1 2009/05/13 17:18:12 jym 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.13.24.1       jym __KERNEL_RCSID(0, "$NetBSD: mcclock_ibus.c,v 1.13.24.1 2009/05/13 17:18:12 jym Exp $");
     32        1.1  jonathan 
     33        1.1  jonathan #include <sys/param.h>
     34        1.1  jonathan #include <sys/kernel.h>
     35        1.1  jonathan #include <sys/device.h>
     36        1.8       chs #include <sys/systm.h>
     37       1.13     joerg #include <dev/clock_subr.h>
     38        1.1  jonathan 
     39        1.1  jonathan #include <dev/dec/mcclockvar.h>
     40        1.6    simonb #include <dev/dec/mcclock_pad32.h>
     41        1.1  jonathan 
     42        1.1  jonathan #include <pmax/ibus/ibusvar.h>
     43        1.1  jonathan 
     44  1.13.24.1       jym static int	mcclock_ibus_match(struct device *, struct cfdata *,
     45  1.13.24.1       jym 		    void *);
     46  1.13.24.1       jym static void	mcclock_ibus_attach(struct device *, struct device *,
     47  1.13.24.1       jym 		    void *);
     48        1.1  jonathan 
     49       1.12   thorpej CFATTACH_DECL(mcclock_ibus, sizeof (struct mcclock_pad32_softc),
     50       1.12   thorpej     mcclock_ibus_match, mcclock_ibus_attach, NULL, NULL);
     51        1.1  jonathan 
     52        1.5    simonb static int
     53  1.13.24.1       jym mcclock_ibus_match(struct device *parent, struct cfdata *match, void *aux)
     54        1.1  jonathan {
     55        1.1  jonathan 	struct ibus_attach_args *ia = aux;
     56        1.1  jonathan 
     57        1.1  jonathan 	if (strcmp("mc146818", ia->ia_name) != 0)
     58        1.1  jonathan 		return (0);
     59        1.1  jonathan 
     60        1.4  nisimura 	if (badaddr((void *)ia->ia_addr, sizeof(u_int32_t)))
     61        1.1  jonathan 		return (0);
     62        1.1  jonathan 
     63        1.1  jonathan 	return (1);
     64        1.1  jonathan }
     65        1.1  jonathan 
     66        1.5    simonb static void
     67  1.13.24.1       jym mcclock_ibus_attach(struct device *parent, struct device *self, void *aux)
     68        1.1  jonathan {
     69        1.1  jonathan 	struct ibus_attach_args *ia =aux;
     70        1.2  jonathan 	struct mcclock_pad32_softc *sc = (struct mcclock_pad32_softc *)self;
     71        1.1  jonathan 
     72        1.2  jonathan 	sc->sc_dp = (struct mcclock_pad32_clockdatum*)ia->ia_addr;
     73        1.1  jonathan 
     74        1.1  jonathan 	/* Attach MI driver, using busfns with TC-style register padding */
     75        1.2  jonathan 	mcclock_attach(&sc->sc_mcclock, &mcclock_pad32_busfns);
     76        1.1  jonathan }
     77