1*95fee2b1Smatt /* $NetBSD: mcclock_ioasic.c,v 1.24 2015/06/09 20:23:53 matt Exp $ */
289868a5fSjonathan
389868a5fSjonathan /*
489868a5fSjonathan * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
589868a5fSjonathan * All rights reserved.
689868a5fSjonathan *
789868a5fSjonathan * Author: Chris G. Demetriou
889868a5fSjonathan *
989868a5fSjonathan * Permission to use, copy, modify and distribute this software and
1089868a5fSjonathan * its documentation is hereby granted, provided that both the copyright
1189868a5fSjonathan * notice and this permission notice appear in all copies of the
1289868a5fSjonathan * software, derivative works or modified versions, and any portions
1389868a5fSjonathan * thereof, and that both notices appear in supporting documentation.
1489868a5fSjonathan *
1589868a5fSjonathan * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
1689868a5fSjonathan * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
1789868a5fSjonathan * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
1889868a5fSjonathan *
1989868a5fSjonathan * Carnegie Mellon requests users of this software to return to
2089868a5fSjonathan *
2189868a5fSjonathan * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
2289868a5fSjonathan * School of Computer Science
2389868a5fSjonathan * Carnegie Mellon University
2489868a5fSjonathan * Pittsburgh PA 15213-3890
2589868a5fSjonathan *
2689868a5fSjonathan * any improvements or extensions that they make and grant Carnegie the
2789868a5fSjonathan * rights to redistribute these changes.
2889868a5fSjonathan */
2989868a5fSjonathan
300ab58494Sad #include <sys/cdefs.h>
31*95fee2b1Smatt __KERNEL_RCSID(0, "$NetBSD: mcclock_ioasic.c,v 1.24 2015/06/09 20:23:53 matt Exp $");
3289868a5fSjonathan
3389868a5fSjonathan #include <sys/param.h>
34*95fee2b1Smatt #include <sys/cpu.h>
3589868a5fSjonathan #include <sys/device.h>
36a6f2a36eSchs #include <sys/systm.h>
3728b31e73Sjoerg #include <dev/clock_subr.h>
3889868a5fSjonathan
39787738a4Sjonathan #include <dev/dec/mcclockvar.h>
4024ddcc31Ssimonb #include <dev/dec/mcclock_pad32.h>
41c84f4e94Sjonathan
4289868a5fSjonathan #include <dev/tc/tcvar.h>
430310fa65Snisimura #include <dev/tc/ioasicvar.h>
4489868a5fSjonathan
45eaf783aeStsutsui static int mcclock_ioasic_match(device_t, cfdata_t, void *);
46eaf783aeStsutsui static void mcclock_ioasic_attach(device_t, device_t, void *);
4789868a5fSjonathan
48eaf783aeStsutsui CFATTACH_DECL_NEW(mcclock_ioasic, sizeof (struct mcclock_pad32_softc),
49b96bc0d7Sthorpej mcclock_ioasic_match, mcclock_ioasic_attach, NULL, NULL);
5089868a5fSjonathan
51636b65beSsimonb static int
mcclock_ioasic_match(device_t parent,cfdata_t cf,void * aux)52eaf783aeStsutsui mcclock_ioasic_match(device_t parent, cfdata_t cf, void *aux)
5389868a5fSjonathan {
5489868a5fSjonathan struct ioasicdev_attach_args *d = aux;
55c84f4e94Sjonathan
56c84f4e94Sjonathan if (strcmp("mc146818", d->iada_modname) != 0)
5789868a5fSjonathan return (0);
58c84f4e94Sjonathan
59c84f4e94Sjonathan if (tc_badaddr(d->iada_addr))
6089868a5fSjonathan return (0);
61c84f4e94Sjonathan
6289868a5fSjonathan return (1);
6389868a5fSjonathan }
6489868a5fSjonathan
65636b65beSsimonb static void
mcclock_ioasic_attach(device_t parent,device_t self,void * aux)66eaf783aeStsutsui mcclock_ioasic_attach(device_t parent, device_t self, void *aux)
6789868a5fSjonathan {
6889868a5fSjonathan struct ioasicdev_attach_args *ioasicdev = aux;
69eaf783aeStsutsui struct mcclock_pad32_softc *sc = device_private(self);
7089868a5fSjonathan
71eaf783aeStsutsui sc->sc_mcclock.sc_dev = self;
72e4874836Sjonathan sc->sc_dp = (struct mcclock_pad32_clockdatum *)ioasicdev->iada_addr;
7389868a5fSjonathan
74c84f4e94Sjonathan /* Attach MI driver, using busfns with TC-style register padding */
75e4874836Sjonathan mcclock_attach(&sc->sc_mcclock, &mcclock_pad32_busfns);
7689868a5fSjonathan }
77