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>
11 #include <asm/processor.h>
13 #ifdef CONFIG_LED_STATUS
14 #include <status_led.h>
17 #ifndef CONFIG_MPC83XX_TIMER
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));
48 #endif /* !CONFIG_MPC83XX_TIMER */
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 #ifndef CONFIG_MPC83XX_TIMER
65 int interrupt_init (void)
67 /* call cpu specific function from $(CPU)/interrupts.c */
68 interrupt_init_cpu (&decrementer_count);
70 set_dec (decrementer_count);
72 set_msr (get_msr () | MSR_EE);
77 static volatile ulong timestamp = 0;
79 void timer_interrupt (struct pt_regs *regs)
81 /* call cpu specific function from $(CPU)/interrupts.c */
82 timer_interrupt_cpu (regs);
84 /* Restore Decrementer Count */
85 set_dec (decrementer_count);
89 #if defined(CONFIG_WATCHDOG) || defined (CONFIG_HW_WATCHDOG)
90 if ((timestamp % (CONFIG_SYS_WATCHDOG_FREQ)) == 0)
92 #endif /* CONFIG_WATCHDOG || CONFIG_HW_WATCHDOG */
94 #ifdef CONFIG_LED_STATUS
95 status_led_tick (timestamp);
96 #endif /* CONFIG_LED_STATUS */
98 #ifdef CONFIG_SHOW_ACTIVITY
99 board_show_activity (timestamp);
100 #endif /* CONFIG_SHOW_ACTIVITY */
103 ulong get_timer (ulong base)
105 return (timestamp - base);
107 #endif /* !CONFIG_MPC83XX_TIMER */