No empty .Rs/.Re
[netbsd-mini2440.git] / sys / arch / arc / jazz / timer_jazzio.c
blob28d829f66648951f23b1ec0ebca1c9ef45ca5930
1 /* $NetBSD: timer_jazzio.c,v 1.9 2006/06/24 03:50:38 tsutsui Exp $ */
2 /* $OpenBSD: clock.c,v 1.6 1998/10/15 21:30:15 imp Exp $ */
4 /*
5 * Copyright (c) 1992, 1993
6 * The Regents of the University of California. All rights reserved.
8 * This code is derived from software contributed to Berkeley by
9 * the Systems Programming Group of the University of Utah Computer
10 * Science Department and Ralph Campbell.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
36 * from: Utah Hdr: clock.c 1.18 91/01/21
38 * from: @(#)clock.c 8.1 (Berkeley) 6/10/93
42 * Copyright (c) 1997 Per Fogelstrom.
43 * Copyright (c) 1988 University of Utah.
45 * This code is derived from software contributed to Berkeley by
46 * the Systems Programming Group of the University of Utah Computer
47 * Science Department and Ralph Campbell.
49 * Redistribution and use in source and binary forms, with or without
50 * modification, are permitted provided that the following conditions
51 * are met:
52 * 1. Redistributions of source code must retain the above copyright
53 * notice, this list of conditions and the following disclaimer.
54 * 2. Redistributions in binary form must reproduce the above copyright
55 * notice, this list of conditions and the following disclaimer in the
56 * documentation and/or other materials provided with the distribution.
57 * 3. All advertising materials mentioning features or use of this software
58 * must display the following acknowledgement:
59 * This product includes software developed by the University of
60 * California, Berkeley and its contributors.
61 * 4. Neither the name of the University nor the names of its contributors
62 * may be used to endorse or promote products derived from this software
63 * without specific prior written permission.
65 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
66 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
67 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
68 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
69 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
70 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
71 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
72 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
73 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
74 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
75 * SUCH DAMAGE.
77 * from: Utah Hdr: clock.c 1.18 91/01/21
79 * from: @(#)clock.c 8.1 (Berkeley) 6/10/93
82 #include <sys/cdefs.h>
83 __KERNEL_RCSID(0, "$NetBSD: timer_jazzio.c,v 1.9 2006/06/24 03:50:38 tsutsui Exp $");
85 #include <sys/param.h>
86 #include <sys/kernel.h>
87 #include <sys/systm.h>
88 #include <sys/device.h>
90 #include <machine/autoconf.h>
91 #include <machine/platform.h>
93 #include <dev/isa/isavar.h>
95 #include <arc/arc/timervar.h>
96 #include <arc/jazz/jazziovar.h>
97 #include <arc/jazz/timer_jazziovar.h>
99 /* Definition of the driver for autoconfig. */
100 static int timer_jazzio_match(device_t , cfdata_t, void *);
101 static void timer_jazzio_attach(device_t , device_t , void *);
103 CFATTACH_DECL_NEW(timer_jazzio, 0,
104 timer_jazzio_match, timer_jazzio_attach, NULL, NULL);
106 /* Jazz timer access code */
107 static void timer_jazzio_init(device_t);
109 struct timerfns timerfns_jazzio = {
110 timer_jazzio_init,
113 struct timer_jazzio_config *timer_jazzio_conf = NULL;
114 struct evcnt timer_jazzio_ev =
115 EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "jazzio", "timer");
117 static int timer_jazzio_found = 0;
119 static int
120 timer_jazzio_match(device_t parent, cfdata_t cf, void *aux)
122 struct jazzio_attach_args *ja = aux;
124 /* make sure that we're looking for this type of device. */
125 if (strcmp(ja->ja_name, "timer") != 0)
126 return 0;
128 if (timer_jazzio_found)
129 return 0;
131 return 1;
134 static void
135 timer_jazzio_attach(device_t parent, device_t self, void *aux)
138 if (timer_jazzio_conf == NULL)
139 panic("timer_jazzio_conf isn't initialized");
141 aprint_normal("\n");
143 evcnt_attach_static(&timer_jazzio_ev);
144 (*platform->set_intr)(timer_jazzio_conf->tjc_intr_mask,
145 timer_jazzio_conf->tjc_intr, ARC_INTPRI_TIMER_INT);
147 timerattach(self, &timerfns_jazzio);
149 timer_jazzio_found = 1;
152 void
153 timer_jazzio_init(struct device *sc)
156 (*timer_jazzio_conf->tjc_init)(1000 / hz);