No empty .Rs/.Re
[netbsd-mini2440.git] / sys / arch / arm / omap / obio_wdt.c
blobd066feb6f074f3a1dcbf6303d1f40fbc88f2a93b
1 /*
2 * Copyright (c) 2007 Microsoft
3 * All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by Microsoft
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTERS BE LIABLE FOR ANY DIRECT,
21 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
31 * obio attachment for OMAP watchdog timers
33 #include "opt_omap.h"
35 #include <sys/cdefs.h>
36 __KERNEL_RCSID(0, "$NetBSD: obio_wdt.c,v 1.3 2008/08/27 11:03:10 matt Exp $");
38 #include <sys/param.h>
39 #include <sys/callout.h>
40 #include <sys/cdefs.h>
41 #include <sys/device.h>
42 #include <sys/kernel.h>
43 #include <sys/systm.h>
44 #include <sys/wdog.h>
46 #include <machine/param.h>
47 #include <machine/bus.h>
48 #include <dev/sysmon/sysmonvar.h>
50 #include <arm/omap/omap2_obiovar.h>
52 #include <arm/omap/omap_wdtvar.h>
53 #include <arm/omap/omap_wdtreg.h>
55 static int obiowdt32k_match(device_t, cfdata_t, void *);
56 static void obiowdt32k_attach(device_t, device_t, void *);
58 CFATTACH_DECL_NEW(obiowdt32k, sizeof(struct omapwdt32k_softc),
59 obiowdt32k_match, obiowdt32k_attach, NULL, NULL);
61 static int
62 obiowdt32k_match(device_t parent, cfdata_t cf, void *aux)
64 return (1);
67 static void
68 obiowdt32k_attach(device_t parent, device_t self, void *aux)
70 struct omapwdt32k_softc *sc = device_private(self);
71 struct obio_attach_args *obio = aux;
72 unsigned int val;
74 sc->sc_dev = self;
75 sc->sc_smw.smw_name = device_xname(sc->sc_dev);
76 sc->sc_smw.smw_cookie = sc;
77 sc->sc_smw.smw_setmode = omapwdt32k_setmode;
78 sc->sc_smw.smw_tickle = omapwdt32k_tickle;
79 sc->sc_smw.smw_period = OMAPWDT32K_DEFAULT_PERIOD;
80 sc->sc_iot = obio->obio_iot;
82 if (bus_space_map(sc->sc_iot, obio->obio_addr, obio->obio_size,
83 0, &sc->sc_ioh))
84 panic("%s: Cannot map registers", device_xname(self));
86 val = bus_space_read_4(sc->sc_iot, sc->sc_ioh, WIDR);
87 aprint_normal(": rev %d.%d\n", (val & WD_REV) >> 4,
88 (val & WD_REV & 0xf));
90 if (sysmon_wdog_register(&sc->sc_smw) != 0)
91 aprint_error("%s: unable to register with sysmon\n",
92 device_xname(sc->sc_dev));
94 omapwdt32k_sc = sc;
96 /* Turn on autoidle. */
98 omapwdt_sysconfig =
99 bus_space_read_4(omapwdt32k_sc->sc_iot,
100 omapwdt32k_sc->sc_ioh, WD_SYSCONFIG) |
101 (1 << WD_SYSCONFIG_AUTOIDLE);
102 bus_space_write_4(omapwdt32k_sc->sc_iot, omapwdt32k_sc->sc_ioh,
103 WD_SYSCONFIG, omapwdt_sysconfig);