2 * Copyright 2006, Broadcom Corporation
5 * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6 * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7 * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8 * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
10 * $Id: time.c,v 1.1.1.10 2006/02/27 03:42:55 honor Exp $
12 #include <linux/config.h>
13 #include <linux/init.h>
14 #include <linux/kernel.h>
15 #include <linux/sched.h>
16 #include <linux/serial_reg.h>
17 #include <linux/interrupt.h>
18 #include <asm/addrspace.h>
32 /* Global SB handle */
33 extern void *bcm947xx_sbh
;
34 extern spinlock_t bcm947xx_sbh_lock
;
37 #define sbh bcm947xx_sbh
38 #define sbh_lock bcm947xx_sbh_lock
40 extern int panic_timeout
;
41 static int watchdog
= 0;
42 static u8
*mcr
= NULL
;
45 bcm947xx_time_init(void)
51 * Use deterministic values for initial counter interrupt
52 * so that calibrate delay avoids encountering a counter wrap.
55 write_c0_compare(0xffff);
57 if (!(hz
= sb_cpu_clock(sbh
)))
60 printk("CPU: BCM%04x rev %d at %d MHz\n", sb_chip(sbh
), sb_chiprev(sbh
),
61 (hz
+ 500000) / 1000000);
63 /* Set MIPS counter frequency for fixed_rate_gettimeoffset() */
64 mips_hpt_frequency
= hz
/ 2;
66 /* Set watchdog interval in ms */
67 watchdog
= simple_strtoul(nvram_safe_get("watchdog"), NULL
, 0);
69 /* Please set the watchdog to 3 sec if it is less than 3 but not equal to 0 */
75 /* Set panic timeout in seconds */
76 panic_timeout
= watchdog
/ 1000;
80 bcm947xx_timer_interrupt(int irq
, void *dev_id
, struct pt_regs
*regs
)
82 /* Generic MIPS timer code */
83 timer_interrupt(irq
, dev_id
, regs
);
85 /* Set the watchdog timer to reset after the specified number of ms */
87 sb_watchdog(sbh
, WATCHDOG_CLOCK
/ 1000 * watchdog
);
90 static struct irqaction bcm947xx_timer_irqaction
= {
91 bcm947xx_timer_interrupt
,
100 bcm947xx_timer_setup(struct irqaction
*irq
)
104 /* Enable the timer interrupt */
105 setup_irq(7, &bcm947xx_timer_irqaction
);
109 for (x
=0; x
<5; x
++) {
112 while (ticks
== jiffies
)