Path: blob/master/arch/mips/pmc-sierra/msp71xx/msp_time.c
15118 views
/*1* Setting up the clock on MSP SOCs. No RTC typically.2*3* Carsten Langgaard, [email protected]4* Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.5*6* ########################################################################7*8* This program is free software; you can distribute it and/or modify it9* under the terms of the GNU General Public License (Version 2) as10* published by the Free Software Foundation.11*12* This program is distributed in the hope it will be useful, but WITHOUT13* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or14* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License15* for more details.16*17* You should have received a copy of the GNU General Public License along18* with this program; if not, write to the Free Software Foundation, Inc.,19* 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.20*21* ########################################################################22*/2324#include <linux/init.h>25#include <linux/kernel_stat.h>26#include <linux/sched.h>27#include <linux/spinlock.h>28#include <linux/module.h>29#include <linux/ptrace.h>3031#include <asm/cevt-r4k.h>32#include <asm/mipsregs.h>33#include <asm/time.h>3435#include <msp_prom.h>36#include <msp_int.h>37#include <msp_regs.h>3839#define get_current_vpe() \40((read_c0_tcbind() >> TCBIND_CURVPE_SHIFT) & TCBIND_CURVPE)4142static struct irqaction timer_vpe1;43static int tim_installed;4445void __init plat_time_init(void)46{47char *endp, *s;48unsigned long cpu_rate = 0;4950if (cpu_rate == 0) {51s = prom_getenv("clkfreqhz");52cpu_rate = simple_strtoul(s, &endp, 10);53if (endp != NULL && *endp != 0) {54printk(KERN_ERR55"Clock rate in Hz parse error: %s\n", s);56cpu_rate = 0;57}58}5960if (cpu_rate == 0) {61s = prom_getenv("clkfreq");62cpu_rate = 1000 * simple_strtoul(s, &endp, 10);63if (endp != NULL && *endp != 0) {64printk(KERN_ERR65"Clock rate in MHz parse error: %s\n", s);66cpu_rate = 0;67}68}6970if (cpu_rate == 0) {71#if defined(CONFIG_PMC_MSP7120_EVAL) \72|| defined(CONFIG_PMC_MSP7120_GW)73cpu_rate = 400000000;74#elif defined(CONFIG_PMC_MSP7120_FPGA)75cpu_rate = 25000000;76#else77cpu_rate = 150000000;78#endif79printk(KERN_ERR80"Failed to determine CPU clock rate, "81"assuming %ld hz ...\n", cpu_rate);82}8384printk(KERN_WARNING "Clock rate set to %ld\n", cpu_rate);8586/* timer frequency is 1/2 clock rate */87mips_hpt_frequency = cpu_rate/2;88}8990unsigned int __cpuinit get_c0_compare_int(void)91{92/* MIPS_MT modes may want timer for second VPE */93if ((get_current_vpe()) && !tim_installed) {94memcpy(&timer_vpe1, &c0_compare_irqaction, sizeof(timer_vpe1));95setup_irq(MSP_INT_VPE1_TIMER, &timer_vpe1);96tim_installed++;97}9899return get_current_vpe() ? MSP_INT_VPE1_TIMER : MSP_INT_VPE0_TIMER;100}101102103