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);
95 /* EPIC won't generate INT unless Current Task Pri < 15 */
96 epicCurTaskPrioSet(0);
98 set_dec (decrementer_count);
100 set_msr (get_msr () | MSR_EE);
105 /****************************************************************************/
108 * Handle external interrupts
110 void external_interrupt (struct pt_regs *regs)
112 register unsigned long temp;
114 pci_readl (CFG_EUMB_ADDR + EPIC_PROC_INT_ACK_REG, temp);
115 sync (); /* i'm not convinced this is needed, but dink source has it */
116 temp &= 0xff; /*get vector */
118 /*TODO: handle them -... */
122 /****************************************************************************/
125 * blank int handlers.
129 irq_install_handler (int vec, interrupt_handler_t * handler, void *arg)
133 void irq_free_handler (int vec)
138 /*TODO: some handlers for winbond and 87308 interrupts
139 and what about generic pci inteerupts?
143 volatile ulong timestamp = 0;
145 void timer_interrupt (struct pt_regs *regs)
147 /* Restore Decrementer Count */
148 set_dec (decrementer_count);
152 #if defined(CONFIG_WATCHDOG)
153 if ((timestamp % (CFG_HZ / 2)) == 0) {
154 #if defined(CONFIG_OXC)
156 extern void oxc_wdt_reset (void);
162 #endif /* CONFIG_WATCHDOG */
163 #if defined(CONFIG_SHOW_ACTIVITY) && defined(CONFIG_OXC)
164 if ((timestamp % (CFG_HZ / 10)) == 0) {
166 extern void oxc_toggle_activeled (void);
168 oxc_toggle_activeled ();
174 void reset_timer (void)
179 ulong get_timer (ulong base)
181 return (timestamp - base);
184 void set_timer (ulong t)