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>
33 /* Global SB handle */
34 extern void *bcm947xx_sbh
;
35 extern spinlock_t bcm947xx_sbh_lock
;
38 #define sbh bcm947xx_sbh
39 #define sbh_lock bcm947xx_sbh_lock
41 extern int panic_timeout
;
42 static int watchdog
= 0;
45 bcm947xx_time_init(void)
50 * Use deterministic values for initial counter interrupt
51 * so that calibrate delay avoids encountering a counter wrap.
54 write_c0_compare(0xffff);
56 if (!(hz
= sb_cpu_clock(sbh
)))
59 printk("CPU: BCM%04x rev %d at %d MHz\n", sb_chip(sbh
), sb_chiprev(sbh
),
60 (hz
+ 500000) / 1000000);
62 /* Set MIPS counter frequency for fixed_rate_gettimeoffset() */
63 mips_hpt_frequency
= hz
/ 2;
65 /* Set watchdog interval in ms */
66 watchdog
= simple_strtoul(nvram_safe_get("watchdog"), NULL
, 0);
68 /* Please set the watchdog to 3 sec if it is less than 3 but not equal to 0 */
74 /* Set panic timeout in seconds */
75 panic_timeout
= watchdog
/ 1000;
79 bcm947xx_timer_interrupt(int irq
, void *dev_id
, struct pt_regs
*regs
)
81 /* Generic MIPS timer code */
82 timer_interrupt(irq
, dev_id
, regs
);
84 /* Set the watchdog timer to reset after the specified number of ms */
86 if (sb_chip(sbh
) == BCM5354_CHIP_ID
)
87 sb_watchdog(sbh
, WATCHDOG_CLOCK_5354
/ 1000 * watchdog
);
89 sb_watchdog(sbh
, WATCHDOG_CLOCK
/ 1000 * watchdog
);
94 static struct irqaction bcm947xx_timer_irqaction
= {
95 bcm947xx_timer_interrupt
,
104 bcm947xx_timer_setup(struct irqaction
*irq
)
108 /* Enable the timer interrupt */
109 setup_irq(7, &bcm947xx_timer_irqaction
);
113 for (x
=0; x
<5; x
++) {
116 while (ticks
== jiffies
)