1 /**************************************************************************
3 * BRIEF MODULE DESCRIPTION
4 * timer routines for IDT EB434 boards
6 * Copyright 2004 IDT Inc. (rischelp@idt.com)
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
14 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
15 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
16 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
19 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 675 Mass Ave, Cambridge, MA 02139, USA.
29 **************************************************************************
36 **************************************************************************
39 #include <linux/autoconf.h>
40 #include <linux/init.h>
41 #include <linux/kernel_stat.h>
42 #include <linux/sched.h>
43 #include <linux/spinlock.h>
44 #include <linux/mc146818rtc.h>
45 #include <linux/irq.h>
46 #include <linux/timex.h>
48 #include <linux/param.h>
49 #include <asm/mipsregs.h>
50 #include <asm/ptrace.h>
52 #include <asm/hardirq.h>
54 #include <asm/mipsregs.h>
55 #include <asm/ptrace.h>
56 #include <asm/debug.h>
59 #include <asm/idt-boards/rc32434/rc32434.h>
61 static unsigned long r4k_offset
; /* Amount to incr compare reg each time */
62 static unsigned long r4k_cur
; /* What counter should be at next timer irq */
64 extern unsigned int idt_cpu_freq
;
66 static unsigned long __init
cal_r4koff(void)
68 mips_hpt_frequency
= idt_cpu_freq
* IDT_CLOCK_MULT
/ 2;
69 return (mips_hpt_frequency
/ HZ
);
72 void __init
aruba_time_init(void)
74 unsigned int est_freq
, flags
;
75 local_irq_save(flags
);
77 printk("calculating r4koff... ");
78 r4k_offset
= cal_r4koff();
79 printk("%08lx(%d)\n", r4k_offset
, (int)r4k_offset
);
81 est_freq
= 2 * r4k_offset
* HZ
;
82 est_freq
+= 5000; /* round */
83 est_freq
-= est_freq
% 10000;
84 printk("CPU frequency %d.%02d MHz\n", est_freq
/ 1000000,
85 (est_freq
% 1000000) * 100 / 1000000);
86 local_irq_restore(flags
);
90 void __init
plat_timer_setup(struct irqaction
*irq
)
92 /* we are using the cpu counter for timer interrupts */
93 setup_irq(MIPS_CPU_TIMER_IRQ
, irq
);
95 /* to generate the first timer interrupt */
96 r4k_cur
= (read_c0_count() + r4k_offset
);
97 write_c0_compare(r4k_cur
);
101 asmlinkage
void aruba_timer_interrupt(struct pt_regs
*regs
)
103 int irq
= MIPS_CPU_TIMER_IRQ
;
106 kstat_this_cpu
.irqs
[irq
]++;
108 timer_interrupt(irq
, NULL
);
This page took 0.050297 seconds and 5 git commands to generate.