1 /* $NetBSD: timekeeper.c,v 1.12 2008/03/29 05:47:53 tsutsui Exp $ */
4 * Copyright (c) 2001 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Steve C. Woodford.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
33 * Attachment interface for the Time-Keeper RAMs on mvme boards.
35 * XXXSCW: Needs to be extended to allow read/write to NVRAM by
36 * userland application.
39 #include <sys/cdefs.h>
40 __KERNEL_RCSID(0, "$NetBSD: timekeeper.c,v 1.12 2008/03/29 05:47:53 tsutsui Exp $");
42 #include <sys/param.h>
43 #include <sys/systm.h>
44 #include <sys/device.h>
47 #include <machine/cpu.h>
48 #include <machine/bus.h>
50 #include <dev/mvme/clockvar.h>
52 #include <dev/ic/mk48txxreg.h>
53 #include <dev/ic/mk48txxvar.h>
55 #include <mvme68k/dev/mainbus.h>
59 int timekeeper_match(device_t
, cfdata_t
, void *);
60 void timekeeper_attach(device_t
, device_t
, void *);
62 CFATTACH_DECL_NEW(timekeeper
, sizeof(struct mk48txx_softc
),
63 timekeeper_match
, timekeeper_attach
, NULL
, NULL
);
66 timekeeper_match(device_t parent
, cfdata_t cf
, void *aux
)
68 struct mainbus_attach_args
*ma
= aux
;
70 if (strcmp(ma
->ma_name
, timekeeper_cd
.cd_name
))
77 timekeeper_attach(device_t parent
, device_t self
, void *aux
)
79 struct mk48txx_softc
*sc
= device_private(self
);
80 struct mainbus_attach_args
*ma
= aux
;
84 sc
->sc_bst
= ma
->ma_bust
;
86 if (machineid
== MVME_147
) {
88 sc
->sc_model
= "mk48t02";
91 sc
->sc_model
= "mk48t08";
94 bus_space_map(sc
->sc_bst
, ma
->ma_offset
, size
, 0, &sc
->sc_bsh
);
99 aprint_normal(" Time-Keeper RAM\n");
100 aprint_normal_dev(self
, "%ld bytes NVRAM plus Realtime Clock\n",