1 /* $NetBSD: ofwgencfg_clock.c,v 1.9 2009/03/14 15:36:02 dsl Exp $ */
5 * Digital Equipment Corporation. All rights reserved.
7 * This software is furnished under license and may be used and
8 * copied only in accordance with the following terms and conditions.
9 * Subject to these conditions, you may download, copy, install,
10 * use, modify and distribute this software in source and/or binary
11 * form. No title or ownership is transferred hereby.
13 * 1) Any source code used, modified or distributed must reproduce
14 * and retain this copyright notice and list of conditions as
15 * they appear in the source file.
17 * 2) No right is granted to use any trade name, trademark, or logo of
18 * Digital Equipment Corporation. Neither the "Digital Equipment
19 * Corporation" name nor any trademark or logo of Digital Equipment
20 * Corporation may be used to endorse or promote products derived
21 * from this software without the prior written permission of
22 * Digital Equipment Corporation.
24 * 3) This software is provided "AS-IS" and any express or implied
25 * warranties, including but not limited to, any implied warranties
26 * of merchantability, fitness for a particular purpose, or
27 * non-infringement are disclaimed. In no event shall DIGITAL be
28 * liable for any damages whatsoever, and in particular, DIGITAL
29 * shall not be liable for special, indirect, consequential, or
30 * incidental damages or damages for lost profits, loss of
31 * revenue or loss of use, whether such damages arise in contract,
32 * negligence, tort, under statute, in equity, at law or otherwise,
33 * even if advised of the possibility of such damage.
36 /* Include header files */
38 #include <sys/cdefs.h>
39 __KERNEL_RCSID(0, "$NetBSD: ofwgencfg_clock.c,v 1.9 2009/03/14 15:36:02 dsl Exp $");
41 #include <sys/types.h>
42 #include <sys/param.h>
43 #include <sys/systm.h>
44 #include <sys/kernel.h>
47 #include <machine/intr.h>
48 #include <machine/irqhandler.h>
49 #include <arm/cpufunc.h>
50 #include <machine/cpu.h>
51 #include <machine/ofw.h>
53 static void *clockirq
;
57 * int clockhandler(struct clockframe *frame)
59 * Function called by timer 0 interrupts. This just calls
60 * hardclock(). Eventually the irqhandler can call hardclock() directly
61 * but for now we use this function so that we can debug IRQ's
65 clockhandler(struct clockframe
*frame
)
69 return(0); /* Pass the interrupt on down the chain */
74 * int statclockhandler(struct clockframe *frame)
76 * Function called by timer 1 interrupts. This just calls
77 * statclock(). Eventually the irqhandler can call statclock() directly
78 * but for now we use this function so that we can debug IRQ's
82 statclockhandler(struct clockframe
*frame
)
86 return(0); /* Pass the interrupt on down the chain */
91 * void setstatclockrate(int hz)
93 * Set the stat clock rate. The stat clock uses timer1
97 setstatclockrate(int arg
)
100 printf("Not setting statclock: OFW generic has only one clock.\n");
106 * void cpu_initclocks(void)
108 * Initialise the clocks.
109 * This sets up the two timers in the IOMD and installs the IRQ handlers
111 * NOTE: Currently only timer 0 is setup and the IRQ handler is not installed
118 * Load timer 0 with count down value
119 * This timer generates 100Hz interrupts for the system clock
122 printf("clock: hz=%d stathz = %d profhz = %d\n", hz
, stathz
, profhz
);
124 clockirq
= intr_claim(IRQ_TIMER0
, IPL_CLOCK
,
125 (int (*)(void *))clockhandler
, 0, "clock", "hard intr");
126 if (clockirq
== NULL
)
127 panic("Cannot installer timer 0 IRQ handler");
129 /* Notify callback handler that it can start processing ticks. */
133 printf("Not installing statclock: OFW generic has only one clock.\n");
138 * Estimated loop for n microseconds
141 /* Need to re-write this to use the timers */
143 /* One day soon I will actually do this */
154 if (cputype
== CPU_ID_SA110
) /* XXX - Seriously gross hack */
155 for (i
= delaycount
; --i
;);