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_STATUS_LED
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
extern int interrupt_init_cpu (unsigned *);
32
extern void timer_interrupt_cpu (struct pt_regs *);
34
static unsigned decrementer_count; /* count value for 1e6/HZ microseconds */
36
static __inline__ unsigned long get_msr (void)
40
asm volatile ("mfmsr %0":"=r" (msr):);
45
static __inline__ void set_msr (unsigned long msr)
47
asm volatile ("mtmsr %0"::"r" (msr));
50
static __inline__ unsigned long get_dec (void)
54
asm volatile ("mfdec %0":"=r" (val):);
60
static __inline__ void set_dec (unsigned long val)
63
asm volatile ("mtdec %0"::"r" (val));
67
void enable_interrupts (void)
69
set_msr (get_msr () | MSR_EE);
72
/* returns flag if MSR_EE was set before */
73
int disable_interrupts (void)
75
ulong msr = get_msr ();
77
set_msr (msr & ~MSR_EE);
78
return ((msr & MSR_EE) != 0);
81
int interrupt_init (void)
85
/* call cpu specific function from $(CPU)/interrupts.c */
86
ret = interrupt_init_cpu (&decrementer_count);
91
set_dec (decrementer_count);
93
set_msr (get_msr () | MSR_EE);
98
static volatile ulong timestamp = 0;
100
void timer_interrupt (struct pt_regs *regs)
102
/* call cpu specific function from $(CPU)/interrupts.c */
103
timer_interrupt_cpu (regs);
105
/* Restore Decrementer Count */
106
set_dec (decrementer_count);
110
#if defined(CONFIG_WATCHDOG) || defined (CONFIG_HW_WATCHDOG)
111
if ((timestamp % (CONFIG_SYS_WATCHDOG_FREQ)) == 0)
113
#endif /* CONFIG_WATCHDOG || CONFIG_HW_WATCHDOG */
115
#ifdef CONFIG_STATUS_LED
116
status_led_tick (timestamp);
117
#endif /* CONFIG_STATUS_LED */
119
#ifdef CONFIG_SHOW_ACTIVITY
120
board_show_activity (timestamp);
121
#endif /* CONFIG_SHOW_ACTIVITY */
124
ulong get_timer (ulong base)
126
return (timestamp - base);