mcclock_pad32.c revision 1.1 1 /* XXX */
2
3 #include <sys/param.h>
4 #include <sys/kernel.h>
5 #include <sys/systm.h>
6 #include <sys/device.h>
7
8 #include <alpha/alpha/clockvar.h>
9 #include <alpha/alpha/mcclockvar.h>
10 #include <dev/ic/mc146818reg.h>
11 #include <dev/tc/tcreg.h>
12 #include <dev/tc/tcvar.h>
13 #include <dev/tc/ioasicvar.h> /* XXX */
14
15 struct mcclock_ioasic_clockdatum {
16 u_char datum;
17 char pad[3];
18 };
19
20 struct mcclock_ioasic_softc {
21 struct mcclock_softc sc_mcclock;
22
23 struct mcclock_ioasic_clockdatum *sc_dp;
24 };
25
26 int mcclock_ioasic_match __P((struct device *, void *, void *));
27 void mcclock_ioasic_attach __P((struct device *, struct device *, void *));
28
29 struct cfattach mcclock_ioasic_ca = {
30 sizeof (struct mcclock_ioasic_softc), mcclock_ioasic_match,
31 mcclock_ioasic_attach,
32 };
33
34 void mcclock_ioasic_write __P((struct mcclock_softc *, u_int, u_int));
35 u_int mcclock_ioasic_read __P((struct mcclock_softc *, u_int));
36
37 const struct mcclock_busfns mcclock_ioasic_busfns = {
38 mcclock_ioasic_write, mcclock_ioasic_read,
39 };
40
41 int
42 mcclock_ioasic_match(parent, match, aux)
43 struct device *parent;
44 void *match, *aux;
45 {
46 struct ioasicdev_attach_args *d = aux;
47
48 if (strncmp("TOY_RTC ", d->iada_modname, TC_ROM_LLEN))
49 return (0);
50
51 return (1);
52 }
53
54 void
55 mcclock_ioasic_attach(parent, self, aux)
56 struct device *parent, *self;
57 void *aux;
58 {
59 struct ioasicdev_attach_args *ioasicdev = aux;
60 struct mcclock_ioasic_softc *sc = (struct mcclock_ioasic_softc *)self;
61
62 sc->sc_dp = (struct mcclock_ioasic_clockdatum *)ioasicdev->iada_addr;
63
64 mcclock_attach(&sc->sc_mcclock, &mcclock_ioasic_busfns);
65 }
66
67 void
68 mcclock_ioasic_write(dev, reg, datum)
69 struct mcclock_softc *dev;
70 u_int reg, datum;
71 {
72 struct mcclock_ioasic_softc *sc = (struct mcclock_ioasic_softc *)dev;
73
74 sc->sc_dp[reg].datum = datum;
75 }
76
77 u_int
78 mcclock_ioasic_read(dev, reg)
79 struct mcclock_softc *dev;
80 u_int reg;
81 {
82 struct mcclock_ioasic_softc *sc = (struct mcclock_ioasic_softc *)dev;
83
84 return (sc->sc_dp[reg].datum);
85 }
86