3 * Josh Huber <huber@mclx.com>, Mission Critical Linux, Inc.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 * interrupts.c - just enough support for the decrementer/timer
30 #include <mpc8xx_irq.h>
31 #include <asm/processor.h>
35 /****************************************************************************/
37 unsigned decrementer_count; /* count value for 1e6/HZ microseconds */
39 /****************************************************************************/
41 static __inline__ unsigned long
46 asm volatile("mfmsr %0" : "=r" (msr) :);
50 static __inline__ void
51 set_msr(unsigned long msr)
53 asm volatile("mtmsr %0" : : "r" (msr));
56 static __inline__ unsigned long
61 asm volatile("mfdec %0" : "=r" (val) :);
66 static __inline__ void
67 set_dec(unsigned long val)
69 asm volatile("mtdec %0" : : "r" (val));
74 enable_interrupts(void)
76 set_msr (get_msr() | MSR_EE);
79 /* returns flag if MSR_EE was set before */
81 disable_interrupts(void)
83 ulong msr = get_msr();
84 set_msr (msr & ~MSR_EE);
85 return ((msr & MSR_EE) != 0);
88 /****************************************************************************/
90 int interrupt_init(void)
92 #if defined(DEBUG) && !defined(CONFIG_AMIGAONEG3SE)
93 printf("interrupt_init: GT main cause reg: %08x:%08x\n",
94 GTREGREAD(LOW_INTERRUPT_CAUSE_REGISTER),
95 GTREGREAD(HIGH_INTERRUPT_CAUSE_REGISTER));
96 printf("interrupt_init: ethernet cause regs: %08x %08x %08x\n",
97 GTREGREAD(ETHERNET0_INTERRUPT_CAUSE_REGISTER),
98 GTREGREAD(ETHERNET1_INTERRUPT_CAUSE_REGISTER),
99 GTREGREAD(ETHERNET2_INTERRUPT_CAUSE_REGISTER));
100 printf("interrupt_init: ethernet mask regs: %08x %08x %08x\n",
101 GTREGREAD(ETHERNET0_INTERRUPT_MASK_REGISTER),
102 GTREGREAD(ETHERNET1_INTERRUPT_MASK_REGISTER),
103 GTREGREAD(ETHERNET2_INTERRUPT_MASK_REGISTER));
104 puts("interrupt_init: setting decrementer_count\n");
106 decrementer_count = get_tbclk() / CFG_HZ;
109 puts("interrupt_init: setting actual decremter\n");
111 set_dec (get_tbclk() / CFG_HZ);
114 printf("interrupt_init: enabling interrupts (msr = %08lx)\n",
117 set_msr (get_msr() | MSR_EE);
120 printf("interrupt_init: done. (msr = %08lx)\n", get_msr());
125 /****************************************************************************/
128 * Handle external interrupts
131 external_interrupt(struct pt_regs *regs)
133 puts("external_interrupt (oops!)\n");
136 volatile ulong timestamp = 0;
139 * timer_interrupt - gets called when the decrementer overflows,
140 * with interrupts disabled.
141 * Trivial implementation - no need to be really accurate.
144 timer_interrupt(struct pt_regs *regs)
146 set_dec(decrementer_count);
149 #if defined(CONFIG_WATCHDOG)
150 if ((timestamp % (CFG_HZ / 2)) == 0) {
151 #if defined(CONFIG_PCIPPC2)
152 extern void pcippc2_wdt_reset (void);
157 #endif /* CONFIG_WATCHDOG */
160 /****************************************************************************/
169 get_timer(ulong base)
171 return (timestamp - base);
180 /****************************************************************************/
183 * Install and free a interrupt handler.
187 irq_install_handler(int vec, interrupt_handler_t *handler, void *arg)
193 irq_free_handler(int vec)
198 /****************************************************************************/
201 do_irqinfo(cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
203 puts("IRQ related functions are unimplemented currently.\n");