2 * Copyright 2004, 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.
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>
29 /* Global SB handle */
30 extern void *bcm947xx_sbh
;
31 extern spinlock_t bcm947xx_sbh_lock
;
34 #define sbh bcm947xx_sbh
35 #define sbh_lock bcm947xx_sbh_lock
37 extern int panic_timeout
;
38 static int watchdog
= 0;
39 static u8
*mcr
= NULL
;
42 bcm947xx_time_init(void)
48 * Use deterministic values for initial counter interrupt
49 * so that calibrate delay avoids encountering a counter wrap.
52 write_c0_compare(0xffff);
54 if (!(hz
= sb_mips_clock(sbh
)))
57 printk("CPU: BCM%04x rev %d at %d MHz\n", sb_chip(sbh
), sb_chiprev(sbh
),
58 (hz
+ 500000) / 1000000);
60 /* Set MIPS counter frequency for fixed_rate_gettimeoffset() */
61 mips_hpt_frequency
= hz
/ 2;
63 /* Set watchdog interval in ms */
64 watchdog
= simple_strtoul(nvram_safe_get("watchdog"), NULL
, 0);
66 /* 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;
77 if ((eir
= sb_setcore(sbh
, SB_EXTIF
, 0))) {
78 sbconfig_t
*sb
= (sbconfig_t
*)((unsigned int) eir
+ SBCONFIGOFF
);
79 unsigned long base
= EXTIF_CFGIF_BASE(sb_base(readl(&sb
->sbadmatch1
)));
80 mcr
= (u8
*) ioremap_nocache(base
+ UART_MCR
, 1);
85 bcm947xx_timer_interrupt(int irq
, void *dev_id
, struct pt_regs
*regs
)
87 /* Generic MIPS timer code */
88 timer_interrupt(irq
, dev_id
, regs
);
90 /* Set the watchdog timer to reset after the specified number of ms */
92 sb_watchdog(sbh
, WATCHDOG_CLOCK
/ 1000 * watchdog
);
95 (*((int *)0xa0000f1c))++;
97 /* Blink one of the LEDs in the external UART */
98 if (mcr
&& !(jiffies
% (HZ
/2)))
99 writeb(readb(mcr
) ^ UART_MCR_OUT2
, mcr
);
103 static struct irqaction bcm947xx_timer_irqaction
= {
104 bcm947xx_timer_interrupt
,
113 bcm947xx_timer_setup(struct irqaction
*irq
)
115 /* Enable the timer interrupt */
116 setup_irq(7, &bcm947xx_timer_irqaction
);