2 * (C) Copyright 2000-2002
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 * Rob Taylor, Flying Pig Systems. robt@flyingpig.com
6 * See file CREDITS for list of people who contributed to this
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 #include <asm/processor.h>
28 #include <asm/pci_io.h>
30 #include "drivers/epic.h"
32 /****************************************************************************/
34 unsigned decrementer_count; /* count val 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)
62 asm volatile ("mtdec %0"::"r" (val));
66 void enable_interrupts (void)
68 set_msr (get_msr () | MSR_EE);
71 /* returns flag if MSR_EE was set before */
72 int disable_interrupts (void)
74 ulong msr = get_msr ();
76 set_msr (msr & ~MSR_EE);
77 return ((msr & MSR_EE) != 0);
80 /****************************************************************************/
82 int interrupt_init (void)
84 decrementer_count = (get_bus_freq (0) / 4) / CFG_HZ;
87 * It's all broken at the moment and I currently don't need
88 * interrupts. If you want to fix it, have a look at the epic
89 * drivers in dink32 v12. They do everthing and Motorola said
90 * I could use the dink source in this project as long as
91 * copyright notices remain intact.
94 epicInit (EPIC_DIRECT_IRQ, 0);
96 set_dec (decrementer_count);
98 set_msr (get_msr () | MSR_EE);
103 /****************************************************************************/
106 * Handle external interrupts
108 void external_interrupt (struct pt_regs *regs)
110 register unsigned long temp;
112 pci_readl (CFG_EUMB_ADDR + EPIC_PROC_INT_ACK_REG, temp);
113 sync (); /* i'm not convinced this is needed, but dink source has it */
114 temp &= 0xff; /*get vector */
116 /*TODO: handle them -... */
120 /****************************************************************************/
123 * blank int handlers.
127 irq_install_handler (int vec, interrupt_handler_t * handler, void *arg)
131 void irq_free_handler (int vec)
136 /*TODO: some handlers for winbond and 87308 interrupts
137 and what about generic pci inteerupts?
141 volatile ulong timestamp = 0;
143 void timer_interrupt (struct pt_regs *regs)
145 /* Restore Decrementer Count */
146 set_dec (decrementer_count);
150 #if defined(CONFIG_WATCHDOG)
151 if ((timestamp % (CFG_HZ / 2)) == 0) {
152 #if defined(CONFIG_OXC)
154 extern void oxc_wdt_reset (void);
160 #endif /* CONFIG_WATCHDOG */
161 #if defined(CONFIG_SHOW_ACTIVITY) && defined(CONFIG_OXC)
162 if ((timestamp % (CFG_HZ / 10)) == 0) {
164 extern void oxc_toggle_activeled (void);
166 oxc_toggle_activeled ();
172 void reset_timer (void)
177 ulong get_timer (ulong base)
179 return (timestamp - base);
182 void set_timer (ulong t)