blob: 5b440859bcee6bd9b9f32ab2605463c2b89bf854 [file] [log] [blame]
Mark.Zhana240a462006-05-06 17:04:20 +08001/*
2 * time.c: MIPS CPU Count/Compare timer hookup
3 *
4 * Author: Mark.Zhan, <rongkai.zhan@windriver.com>
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 *
10 * Copyright (C) 1996, 1997, 2004 by Ralf Baechle (ralf@linux-mips.org)
11 * Copyright (C) 2006, Wind River System Inc.
12 */
Mark.Zhana240a462006-05-06 17:04:20 +080013#include <linux/init.h>
14#include <linux/string.h>
15#include <linux/kernel.h>
16#include <linux/param.h> /* for HZ */
17#include <linux/irq.h>
18#include <linux/timex.h>
19#include <linux/interrupt.h>
20
21#include <asm/reboot.h>
22#include <asm/time.h>
23#include <asm/io.h>
24#include <asm/bootinfo.h>
25#include <asm/gt64120.h>
26
27#define WRPPMC_CPU_CLK_FREQ 40000000 /* 40MHZ */
28
Ralf Baechle54d0a212006-07-09 21:38:56 +010029void __init plat_timer_setup(struct irqaction *irq)
Mark.Zhana240a462006-05-06 17:04:20 +080030{
31 /* Install ISR for timer interrupt */
32 setup_irq(WRPPMC_MIPS_TIMER_IRQ, irq);
Mark.Zhana240a462006-05-06 17:04:20 +080033}
34
35/*
36 * Estimate CPU frequency. Sets mips_hpt_frequency as a side-effect
37 *
38 * NOTE: We disable all GT64120 timers, and use MIPS processor internal
39 * timer as the source of kernel clock tick.
40 */
41void __init wrppmc_time_init(void)
42{
43 /* Disable GT64120 timers */
44 GT_WRITE(GT_TC_CONTROL_OFS, 0x00);
45 GT_WRITE(GT_TC0_OFS, 0x00);
46 GT_WRITE(GT_TC1_OFS, 0x00);
47 GT_WRITE(GT_TC2_OFS, 0x00);
48 GT_WRITE(GT_TC3_OFS, 0x00);
49
50 /* Use MIPS compare/count internal timer */
51 mips_hpt_frequency = WRPPMC_CPU_CLK_FREQ;
52}