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>
31 #include "drivers/epic.h"
33 /****************************************************************************/
35 unsigned decrementer_count; /* count val for 1e6/HZ microseconds */
37 static __inline__ unsigned long get_msr (void)
41 asm volatile ("mfmsr %0":"=r" (msr):);
46 static __inline__ void set_msr (unsigned long msr)
48 asm volatile ("mtmsr %0"::"r" (msr));
51 static __inline__ unsigned long get_dec (void)
55 asm volatile ("mfdec %0":"=r" (val):);
61 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 /****************************************************************************/
83 int interrupt_init (void)
85 decrementer_count = (get_bus_freq (0) / 4) / CFG_HZ;
88 * It's all broken at the moment and I currently don't need
89 * interrupts. If you want to fix it, have a look at the epic
90 * drivers in dink32 v12. They do everthing and Motorola said
91 * I could use the dink source in this project as long as
92 * copyright notices remain intact.
95 epicInit (EPIC_DIRECT_IRQ, 0);
96 /* EPIC won't generate INT unless Current Task Pri < 15 */
97 epicCurTaskPrioSet(0);
99 set_dec (decrementer_count);
101 set_msr (get_msr () | MSR_EE);
106 /****************************************************************************/
109 * Handle external interrupts
111 void external_interrupt (struct pt_regs *regs)
113 register unsigned long temp;
115 pci_readl (CFG_EUMB_ADDR + EPIC_PROC_INT_ACK_REG, temp);
116 sync (); /* i'm not convinced this is needed, but dink source has it */
117 temp &= 0xff; /*get vector */
119 /*TODO: handle them -... */
123 /****************************************************************************/
126 * blank int handlers.
130 irq_install_handler (int vec, interrupt_handler_t * handler, void *arg)
134 void irq_free_handler (int vec)
139 /*TODO: some handlers for winbond and 87308 interrupts
140 and what about generic pci inteerupts?
144 volatile ulong timestamp = 0;
146 void timer_interrupt (struct pt_regs *regs)
148 /* Restore Decrementer Count */
149 set_dec (decrementer_count);
153 #if defined(CONFIG_WATCHDOG) || defined (CONFIG_HW_WATCHDOG)
154 if ((timestamp % (CFG_HZ / 2)) == 0) {
157 #endif /* CONFIG_WATCHDOG */
158 #if defined(CONFIG_SHOW_ACTIVITY) && defined(CONFIG_OXC)
159 if ((timestamp % (CFG_HZ / 10)) == 0) {
161 extern void oxc_toggle_activeled (void);
163 oxc_toggle_activeled ();
169 void reset_timer (void)
174 ulong get_timer (ulong base)
176 return (timestamp - base);
179 void set_timer (ulong t)