Annotation of sys/arch/mvme88k/mvme88k/clock.c, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: clock.c,v 1.3 2006/04/19 22:09:40 miod Exp $ */
2: /*
3: * Copyright (c) 1999 Steve Murphree, Jr.
4: * Copyright (c) 1995 Theo de Raadt
5: *
6: * Redistribution and use in source and binary forms, with or without
7: * modification, are permitted provided that the following conditions
8: * are met:
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.
14: *
15: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
16: * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18: * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
19: * 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
25: * SUCH DAMAGE.
26: *
27: * Copyright (c) 1992, 1993
28: * The Regents of the University of California. All rights reserved.
29: * Copyright (c) 1995 Nivas Madhur
30: * Copyright (c) 1994 Gordon W. Ross
31: * Copyright (c) 1993 Adam Glass
32: *
33: * This software was developed by the Computer Systems Engineering group
34: * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
35: * contributed to Berkeley.
36: *
37: * All advertising materials mentioning features or use of this software
38: * must display the following acknowledgement:
39: * This product includes software developed by the University of
40: * California, Lawrence Berkeley Laboratory.
41: *
42: * Redistribution and use in source and binary forms, with or without
43: * modification, are permitted provided that the following conditions
44: * are met:
45: * 1. Redistributions of source code must retain the above copyright
46: * notice, this list of conditions and the following disclaimer.
47: * 2. Redistributions in binary form must reproduce the above copyright
48: * notice, this list of conditions and the following disclaimer in the
49: * documentation and/or other materials provided with the distribution.
50: * 3. Neither the name of the University nor the names of its contributors
51: * may be used to endorse or promote products derived from this software
52: * without specific prior written permission.
53: *
54: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
55: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
56: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
57: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
58: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
59: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
60: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
61: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
62: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
63: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64: * SUCH DAMAGE.
65: *
66: * @(#)clock.c 8.1 (Berkeley) 6/11/93
67: */
68:
69: /*
70: * Interval and statistic clocks driver.
71: */
72:
73: #include <sys/param.h>
74: #include <sys/kernel.h>
75: #include <sys/device.h>
76: #include <sys/systm.h>
77:
78: #include <machine/autoconf.h>
79: #include <machine/bus.h>
80:
81: #include <mvme88k/mvme88k/clockvar.h>
82: #include <mvme88k/dev/vme.h>
83:
84: struct intrhand clock_ih;
85: struct intrhand statclock_ih;
86:
87: /*
88: * Statistics clock interval and variance, in usec. Variance must be a
89: * power of two. Since this gives us an even number, not an odd number,
90: * we discard one case and compensate. That is, a variance of 4096 would
91: * give us offsets in [0..4095]. Instead, we take offsets in [1..4095].
92: * This is symmetric about the point 2048, or statvar/2, and thus averages
93: * to that value (assuming uniform random numbers).
94: */
95: int statvar = 8192;
96: int statmin; /* statclock interval - 1/2*variance */
97:
98: void
99: delay(int us)
100: {
101: if (brdtyp == BRD_188) {
102: extern void m188_delay(int);
103:
104: m188_delay(us);
105: } else {
106: /*
107: * On MVME187 and MVME197, use the VMEchip for the
108: * delay clock.
109: */
110: *(volatile u_int32_t *)(VME2_BASE + VME2_T1CMP) = 0xffffffff;
111: *(volatile u_int32_t *)(VME2_BASE + VME2_T1COUNT) = 0;
112: *(volatile u_int32_t *)(VME2_BASE + VME2_TCTL) |=
113: VME2_TCTL1_CEN;
114:
115: while ((*(volatile u_int32_t *)(VME2_BASE + VME2_T1COUNT)) <
116: (u_int32_t)us)
117: ;
118: *(volatile u_int32_t *)(VME2_BASE + VME2_TCTL) &=
119: ~VME2_TCTL1_CEN;
120: }
121: }
CVSweb