2 * (C) Copyright 2000-2002
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6 * Gleb Natapov <gnatapov@mrv.com>
8 * SPDX-License-Identifier: GPL-2.0+
12 #include <asm/processor.h>
14 #ifdef CONFIG_LED_STATUS
15 #include <status_led.h>
18 #ifdef CONFIG_SHOW_ACTIVITY
19 void board_show_activity (ulong) __attribute__((weak, alias("__board_show_activity")));
21 void __board_show_activity (ulong dummy)
25 #endif /* CONFIG_SHOW_ACTIVITY */
27 #ifndef CONFIG_SYS_WATCHDOG_FREQ
28 #define CONFIG_SYS_WATCHDOG_FREQ (CONFIG_SYS_HZ / 2)
31 static unsigned decrementer_count; /* count value for 1e6/HZ microseconds */
33 static __inline__ unsigned long get_dec (void)
37 asm volatile ("mfdec %0":"=r" (val):);
43 static __inline__ void set_dec (unsigned long val)
46 asm volatile ("mtdec %0"::"r" (val));
50 void enable_interrupts (void)
52 set_msr (get_msr () | MSR_EE);
55 /* returns flag if MSR_EE was set before */
56 int disable_interrupts (void)
58 ulong msr = get_msr ();
60 set_msr (msr & ~MSR_EE);
61 return ((msr & MSR_EE) != 0);
64 int interrupt_init (void)
66 /* call cpu specific function from $(CPU)/interrupts.c */
67 interrupt_init_cpu (&decrementer_count);
69 set_dec (decrementer_count);
71 set_msr (get_msr () | MSR_EE);
76 static volatile ulong timestamp = 0;
78 void timer_interrupt (struct pt_regs *regs)
80 /* call cpu specific function from $(CPU)/interrupts.c */
81 timer_interrupt_cpu (regs);
83 /* Restore Decrementer Count */
84 set_dec (decrementer_count);
88 #if defined(CONFIG_WATCHDOG) || defined (CONFIG_HW_WATCHDOG)
89 if ((timestamp % (CONFIG_SYS_WATCHDOG_FREQ)) == 0)
91 #endif /* CONFIG_WATCHDOG || CONFIG_HW_WATCHDOG */
93 #ifdef CONFIG_LED_STATUS
94 status_led_tick (timestamp);
95 #endif /* CONFIG_LED_STATUS */
97 #ifdef CONFIG_SHOW_ACTIVITY
98 board_show_activity (timestamp);
99 #endif /* CONFIG_SHOW_ACTIVITY */
102 ulong get_timer (ulong base)
104 return (timestamp - base);