/*1* Carsten Langgaard, [email protected]2* Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.3*4* This program is free software; you can distribute it and/or modify it5* under the terms of the GNU General Public License (Version 2) as6* published by the Free Software Foundation.7*8* This program is distributed in the hope it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* for more details.12*13* You should have received a copy of the GNU General Public License along14* with this program; if not, write to the Free Software Foundation, Inc.,15* 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.16*17* Setting up the clock on the MIPS boards.18*/1920#include <linux/init.h>21#include <linux/kernel_stat.h>22#include <linux/ptrace.h>23#include <linux/sched.h>24#include <linux/spinlock.h>25#include <linux/mc146818rtc.h>26#include <linux/irq.h>27#include <linux/timex.h>2829#include <asm/mipsregs.h>30#include <asm/time.h>31#include <asm/mach-rc32434/rc32434.h>3233extern unsigned int idt_cpu_freq;3435/*36* Figure out the r4k offset, the amount to increment the compare37* register for each time tick. There is no RTC available.38*39* The RC32434 counts at half the CPU *core* speed.40*/41static unsigned long __init cal_r4koff(void)42{43mips_hpt_frequency = idt_cpu_freq * IDT_CLOCK_MULT / 2;4445return mips_hpt_frequency / HZ;46}4748void __init plat_time_init(void)49{50unsigned int est_freq;51unsigned long flags, r4k_offset;5253local_irq_save(flags);5455printk(KERN_INFO "calculating r4koff... ");56r4k_offset = cal_r4koff();57printk("%08lx(%d)\n", r4k_offset, (int) r4k_offset);5859est_freq = 2 * r4k_offset * HZ;60est_freq += 5000; /* round */61est_freq -= est_freq % 10000;62printk(KERN_INFO "CPU frequency %d.%02d MHz\n", est_freq / 1000000,63(est_freq % 1000000) * 100 / 1000000);64local_irq_restore(flags);65}666768