Drop CONFIG_SHOW_ACTIVITY
[oweals/u-boot.git] / arch / powerpc / lib / interrupts.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2000-2002
4  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5  *
6  * (C) Copyright 2003
7  * Gleb Natapov <gnatapov@mrv.com>
8  */
9
10 #include <common.h>
11 #include <asm/processor.h>
12 #include <watchdog.h>
13 #ifdef CONFIG_LED_STATUS
14 #include <status_led.h>
15 #endif
16
17 #ifndef CONFIG_MPC83XX_TIMER
18 #ifndef CONFIG_SYS_WATCHDOG_FREQ
19 #define CONFIG_SYS_WATCHDOG_FREQ (CONFIG_SYS_HZ / 2)
20 #endif
21
22 static unsigned decrementer_count; /* count value for 1e6/HZ microseconds */
23
24 static __inline__ unsigned long get_dec (void)
25 {
26         unsigned long val;
27
28         asm volatile ("mfdec %0":"=r" (val):);
29
30         return val;
31 }
32
33
34 static __inline__ void set_dec (unsigned long val)
35 {
36         if (val)
37                 asm volatile ("mtdec %0"::"r" (val));
38 }
39 #endif /* !CONFIG_MPC83XX_TIMER */
40
41 void enable_interrupts (void)
42 {
43         set_msr (get_msr () | MSR_EE);
44 }
45
46 /* returns flag if MSR_EE was set before */
47 int disable_interrupts (void)
48 {
49         ulong msr = get_msr ();
50
51         set_msr (msr & ~MSR_EE);
52         return ((msr & MSR_EE) != 0);
53 }
54
55 #ifndef CONFIG_MPC83XX_TIMER
56 int interrupt_init (void)
57 {
58         /* call cpu specific function from $(CPU)/interrupts.c */
59         interrupt_init_cpu (&decrementer_count);
60
61         set_dec (decrementer_count);
62
63         set_msr (get_msr () | MSR_EE);
64
65         return (0);
66 }
67
68 static volatile ulong timestamp = 0;
69
70 void timer_interrupt (struct pt_regs *regs)
71 {
72         /* call cpu specific function from $(CPU)/interrupts.c */
73         timer_interrupt_cpu (regs);
74
75         /* Restore Decrementer Count */
76         set_dec (decrementer_count);
77
78         timestamp++;
79
80 #if defined(CONFIG_WATCHDOG) || defined (CONFIG_HW_WATCHDOG)
81         if ((timestamp % (CONFIG_SYS_WATCHDOG_FREQ)) == 0)
82                 WATCHDOG_RESET ();
83 #endif    /* CONFIG_WATCHDOG || CONFIG_HW_WATCHDOG */
84
85 #ifdef CONFIG_LED_STATUS
86         status_led_tick (timestamp);
87 #endif /* CONFIG_LED_STATUS */
88 }
89
90 ulong get_timer (ulong base)
91 {
92         return (timestamp - base);
93 }
94 #endif /* !CONFIG_MPC83XX_TIMER */