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.
11 #include <linux/config.h>
12 #include <linux/init.h>
13 #include <linux/kernel.h>
14 #include <linux/sched.h>
15 #include <linux/serial_reg.h>
16 #include <linux/interrupt.h>
17 #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;
44 bcm947xx_time_init(void)
49 * Use deterministic values for initial counter interrupt
50 * so that calibrate delay avoids encountering a counter wrap.
53 write_c0_compare(0xffff);
55 if (!(hz
= sb_cpu_clock(sbh
)))
58 printk("CPU: BCM%04x rev %d at %d MHz\n", sb_chip(sbh
), sb_chiprev(sbh
),
59 (hz
+ 500000) / 1000000);
61 /* Set MIPS counter frequency for fixed_rate_gettimeoffset() */
62 mips_hpt_frequency
= hz
/ 2;
64 /* Set watchdog interval in ms */
65 watchdog
= simple_strtoul(nvram_safe_get("watchdog"), NULL
, 0);
67 /* Please set the watchdog to 3 sec if it is less than 3 but not equal to 0 */
73 /* Set panic timeout in seconds */
74 panic_timeout
= watchdog
/ 1000;
78 bcm947xx_timer_interrupt(int irq
, void *dev_id
, struct pt_regs
*regs
)
80 /* Generic MIPS timer code */
81 timer_interrupt(irq
, dev_id
, regs
);
83 /* Set the watchdog timer to reset after the specified number of ms */
85 if (sb_chip(sbh
) == BCM5354_CHIP_ID
)
86 sb_watchdog(sbh
, WATCHDOG_CLOCK_5354
/ 1000 * watchdog
);
88 sb_watchdog(sbh
, WATCHDOG_CLOCK
/ 1000 * watchdog
);
93 static struct irqaction bcm947xx_timer_irqaction
= {
94 bcm947xx_timer_interrupt
,
103 bcm947xx_timer_setup(struct irqaction
*irq
)
107 /* Enable the timer interrupt */
108 setup_irq(7, &bcm947xx_timer_irqaction
);
112 for (x
=0; x
<5; x
++) {
115 while (ticks
== jiffies
)