No empty .Rs/.Re
[netbsd-mini2440.git] / sys / arch / mvme68k / dev / timekeeper.c
blob799a24d2301969751eb83624b3e26f8427654db7
1 /* $NetBSD: timekeeper.c,v 1.12 2008/03/29 05:47:53 tsutsui Exp $ */
3 /*-
4 * Copyright (c) 2001 The NetBSD Foundation, Inc.
5 * All rights reserved.
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
12 * are met:
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>
45 #include <sys/conf.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>
57 #include "ioconf.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);
65 int
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))
71 return (0);
73 return (1);
76 void
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;
81 bus_size_t size;
83 sc->sc_dev = self;
84 sc->sc_bst = ma->ma_bust;
86 if (machineid == MVME_147) {
87 size = MK48T02_CLKSZ;
88 sc->sc_model = "mk48t02";
89 } else {
90 size = MK48T08_CLKSZ;
91 sc->sc_model = "mk48t08";
94 bus_space_map(sc->sc_bst, ma->ma_offset, size, 0, &sc->sc_bsh);
96 sc->sc_year0 = YEAR0;
97 mk48txx_attach(sc);
99 aprint_normal(" Time-Keeper RAM\n");
100 aprint_normal_dev(self, "%ld bytes NVRAM plus Realtime Clock\n",
101 sc->sc_nvramsz);