1 /* $NetBSD: epwdog.c,v 1.2 2006/03/26 04:38:52 thorpej Exp $ */
4 * Copyright (c) 2005 HAMAJIMA Katsuomi. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 #include <sys/cdefs.h>
29 __KERNEL_RCSID(0, "$NetBSD: epwdog.c,v 1.2 2006/03/26 04:38:52 thorpej Exp $");
31 #include <sys/param.h>
32 #include <sys/systm.h>
33 #include <sys/kernel.h>
34 #include <sys/device.h>
35 #include <machine/bus.h>
36 #include <arm/ep93xx/ep93xxvar.h>
37 #include <arm/ep93xx/epsocvar.h>
38 #include <arm/ep93xx/epwdogreg.h>
39 #include <arm/ep93xx/epwdogvar.h>
43 bus_space_tag_t sc_iot
;
44 bus_space_handle_t sc_ioh
;
47 static int epwdog_match(struct device
*, struct cfdata
*, void *);
48 static void epwdog_attach(struct device
*, struct device
*, void *);
50 CFATTACH_DECL(epwdog
, sizeof(struct epwdog_softc
),
51 epwdog_match
, epwdog_attach
, NULL
, NULL
);
53 static struct epwdog_softc
*the_epwdog_sc
= 0;
56 epwdog_match(struct device
*parent
, struct cfdata
*match
, void *aux
)
62 epwdog_attach(struct device
*parent
, struct device
*self
, void *aux
)
64 struct epwdog_softc
*sc
= (struct epwdog_softc
*)self
;
65 struct epsoc_attach_args
*sa
= aux
;
68 sc
->sc_iot
= sa
->sa_iot
;
70 if (bus_space_map(sa
->sa_iot
, sa
->sa_addr
,
71 sa
->sa_size
, 0, &sc
->sc_ioh
)){
72 printf("%s: Cannot map registers", self
->dv_xname
);
80 printf("%s is already configured\n", sc
->sc_dev
.dv_xname
);
87 struct epwdog_softc
*sc
= the_epwdog_sc
;
91 printf("epwdog not configured\n");
96 bus_space_write_2(sc
->sc_iot
, sc
->sc_ioh
,
97 EP93XX_WDOG_Ctrl
, EP93XX_WDOG_DISABLE
);
99 bus_space_write_2(sc
->sc_iot
, sc
->sc_ioh
,
100 EP93XX_WDOG_Ctrl
, EP93XX_WDOG_ENABLE
);
103 return 0; /* not reached */