1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2000-2002
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
7 * Gleb Natapov <gnatapov@mrv.com>
12 #include <asm/processor.h>
14 #ifdef CONFIG_LED_STATUS
15 #include <status_led.h>
17 #include <asm/ptrace.h>
19 #ifndef CONFIG_MPC83XX_TIMER
20 #ifndef CONFIG_SYS_WATCHDOG_FREQ
21 #define CONFIG_SYS_WATCHDOG_FREQ (CONFIG_SYS_HZ / 2)
24 static unsigned decrementer_count; /* count value for 1e6/HZ microseconds */
26 static __inline__ unsigned long get_dec (void)
30 asm volatile ("mfdec %0":"=r" (val):);
36 static __inline__ void set_dec (unsigned long val)
39 asm volatile ("mtdec %0"::"r" (val));
41 #endif /* !CONFIG_MPC83XX_TIMER */
43 void enable_interrupts(void)
45 set_msr (get_msr () | MSR_EE);
48 /* returns flag if MSR_EE was set before */
49 int disable_interrupts(void)
51 ulong msr = get_msr ();
53 set_msr (msr & ~MSR_EE);
54 return ((msr & MSR_EE) != 0);
57 #ifndef CONFIG_MPC83XX_TIMER
58 int interrupt_init(void)
60 /* call cpu specific function from $(CPU)/interrupts.c */
61 interrupt_init_cpu (&decrementer_count);
63 set_dec (decrementer_count);
65 set_msr (get_msr () | MSR_EE);
70 static volatile ulong timestamp = 0;
72 void timer_interrupt(struct pt_regs *regs)
74 /* call cpu specific function from $(CPU)/interrupts.c */
75 timer_interrupt_cpu (regs);
77 /* Restore Decrementer Count */
78 set_dec (decrementer_count);
82 #if defined(CONFIG_WATCHDOG) || defined (CONFIG_HW_WATCHDOG)
83 if ((timestamp % (CONFIG_SYS_WATCHDOG_FREQ)) == 0)
85 #endif /* CONFIG_WATCHDOG || CONFIG_HW_WATCHDOG */
87 #ifdef CONFIG_LED_STATUS
88 status_led_tick(timestamp);
89 #endif /* CONFIG_LED_STATUS */
92 ulong get_timer (ulong base)
94 return (timestamp - base);
96 #endif /* !CONFIG_MPC83XX_TIMER */