Sync usage with man page.
[netbsd-mini2440.git] / sys / arch / alpha / tc / mcclock_ioasic.c
blobfb865805a5d0798adaed50e260f0b0ad1de0bb05
1 /* $NetBSD: mcclock_ioasic.c,v 1.14 2008/03/28 19:05:49 tsutsui Exp $ */
3 /*
4 * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
5 * All rights reserved.
7 * Author: Chris G. Demetriou
9 * Permission to use, copy, modify and distribute this software and
10 * its documentation is hereby granted, provided that both the copyright
11 * notice and this permission notice appear in all copies of the
12 * software, derivative works or modified versions, and any portions
13 * thereof, and that both notices appear in supporting documentation.
15 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
19 * Carnegie Mellon requests users of this software to return to
21 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
22 * School of Computer Science
23 * Carnegie Mellon University
24 * Pittsburgh PA 15213-3890
26 * any improvements or extensions that they make and grant Carnegie the
27 * rights to redistribute these changes.
30 #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
32 __KERNEL_RCSID(0, "$NetBSD: mcclock_ioasic.c,v 1.14 2008/03/28 19:05:49 tsutsui Exp $");
34 #include <sys/param.h>
35 #include <sys/kernel.h>
36 #include <sys/systm.h>
37 #include <sys/device.h>
39 #include <machine/bus.h>
41 #include <dev/clock_subr.h>
43 #include <dev/ic/mc146818reg.h>
44 #include <dev/ic/mc146818var.h>
45 #include <dev/tc/tcvar.h>
46 #include <dev/tc/ioasicvar.h> /* XXX */
48 #include <alpha/alpha/mcclockvar.h>
50 struct mcclock_ioasic_clockdatum {
51 u_char datum;
52 char pad[3];
55 struct mcclock_ioasic_softc {
56 struct mc146818_softc sc_mc146818;
58 struct mcclock_ioasic_clockdatum *sc_dp;
61 int mcclock_ioasic_match(device_t, cfdata_t, void *);
62 void mcclock_ioasic_attach(device_t, device_t, void *);
64 CFATTACH_DECL_NEW(mcclock_ioasic, sizeof(struct mcclock_ioasic_softc),
65 mcclock_ioasic_match, mcclock_ioasic_attach, NULL, NULL);
67 void mcclock_ioasic_write(struct mc146818_softc *, u_int, u_int);
68 u_int mcclock_ioasic_read(struct mc146818_softc *, u_int);
70 int
71 mcclock_ioasic_match(device_t parent, cfdata_t cf, void *aux)
73 struct ioasicdev_attach_args *d = aux;
75 if (strncmp("TOY_RTC ", d->iada_modname, TC_ROM_LLEN))
76 return (0);
78 return (1);
81 void
82 mcclock_ioasic_attach(device_t parent, device_t self, void *aux)
84 struct mcclock_ioasic_softc *isc = device_private(self);
85 struct ioasicdev_attach_args *ioasicdev = aux;
86 struct mc146818_softc *sc = &isc->sc_mc146818;
88 /* XXX no bus_space(9) for TURBOchannel yet */
89 isc->sc_dp = (void *)ioasicdev->iada_addr;
91 sc->sc_dev = self;
92 sc->sc_mcread = mcclock_ioasic_read;
93 sc->sc_mcwrite = mcclock_ioasic_write;
95 /* call alpha common mcclock attachment */
96 mcclock_attach(sc);
99 void
100 mcclock_ioasic_write(struct mc146818_softc *sc, u_int reg, u_int datum)
102 struct mcclock_ioasic_softc *isc = (void *)sc;
104 isc->sc_dp[reg].datum = datum;
107 u_int
108 mcclock_ioasic_read(struct mc146818_softc *sc, u_int reg)
110 struct mcclock_ioasic_softc *isc = (void *)sc;
112 return isc->sc_dp[reg].datum;