2 ****************************************************************************
3 * Carsten Langgaard, carstenl@mips.com
4 * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.
6 ***************************************************************************
8 * This program is free software; you can distribute it and/or modify it
9 * under the terms of the GNU General Public License (Version 2) as
10 * published by the Free Software Foundation.
12 * This program is distributed in the hope it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
21 ****************************************************************************
23 * Setting up the clock on the MIPS boards.
25 ****************************************************************************
26 * P. Sadik Oct 10, 2003
29 * mips_counter_frequency is now calculated at run time, based on idt_cpu_freq.
31 ****************************************************************************
34 #include <linux/autoconf.h>
35 #include <linux/init.h>
36 #include <linux/kernel_stat.h>
37 #include <linux/sched.h>
38 #include <linux/spinlock.h>
39 #include <linux/mc146818rtc.h>
40 #include <linux/irq.h>
41 #include <linux/timex.h>
43 #include <asm/irq_cpu.h>
44 #include <asm/mipsregs.h>
45 #include <asm/ptrace.h>
46 #include <asm/debug.h>
47 #include <asm/rc32434/rc32434.h>
49 static unsigned long r4k_offset
; /* Amount to incr compare reg each time */
50 static unsigned long r4k_cur
; /* What counter should be at next timer irq */
51 extern unsigned int mips_hpt_frequency
;
52 extern unsigned int idt_cpu_freq
;
55 * Figure out the r4k offset, the amount to increment the compare
56 * register for each time tick. There is no RTC available.
58 * The RC32434 counts at half the CPU *core* speed.
60 static unsigned long __init
cal_r4koff(void)
62 mips_hpt_frequency
= idt_cpu_freq
* IDT_CLOCK_MULT
/ 2;
63 return (mips_hpt_frequency
/ HZ
);
67 void __init
rc32434_time_init(void)
69 unsigned int est_freq
, flags
;
71 local_irq_save(flags
);
73 printk("calculating r4koff... ");
74 r4k_offset
= cal_r4koff();
75 printk("%08lx(%d)\n", r4k_offset
, (int) r4k_offset
);
77 est_freq
= 2*r4k_offset
*HZ
;
78 est_freq
+= 5000; /* round */
79 est_freq
-= est_freq
%10000;
80 printk("CPU frequency %d.%02d MHz\n", est_freq
/1000000,
81 (est_freq
%1000000)*100/1000000);
82 local_irq_restore(flags
);
85 void __init
plat_timer_setup(struct irqaction
*irq
)
87 /* we are using the cpu counter for timer interrupts */
88 setup_irq(MIPS_CPU_TIMER_IRQ
, irq
);
90 /* to generate the first timer interrupt */
91 r4k_cur
= (read_c0_count() + r4k_offset
);
92 write_c0_compare(r4k_cur
);
This page took 0.053435 seconds and 5 git commands to generate.