2 * (C) Copyright 2003 Josef Baumgartner <josef.baumgartner@telex.de>
4 * (C) Copyright 2000-2004
5 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
7 * See file CREDITS for list of people who contributed to this
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28 #include <asm/processor.h>
31 #include <asm/m5271.h>
32 #include <asm/immap_5271.h>
36 #include <asm/m5272.h>
37 #include <asm/immap_5272.h>
41 #include <asm/m5282.h>
42 #include <asm/immap_5282.h>
46 #include <asm/m5249.h>
53 * Interrupt vector functions.
55 struct interrupt_action {
56 interrupt_handler_t *handler;
60 static struct interrupt_action irq_vecs[NR_IRQS];
62 static __inline__ unsigned short get_sr (void)
66 asm volatile ("move.w %%sr,%0":"=r" (sr):);
71 static __inline__ void set_sr (unsigned short sr)
73 asm volatile ("move.w %0,%%sr"::"r" (sr));
76 /************************************************************************/
78 * Install and free an interrupt handler
80 void irq_install_handler (int vec, interrupt_handler_t * handler, void *arg)
83 volatile intctrl_t *intp = (intctrl_t *) (CFG_MBAR + MCFSIM_ICR1);
88 vec_base = intp->int_pivr & 0xe0;
91 if ((vec < vec_base) || (vec > vec_base + NR_IRQS)) {
92 printf ("irq_install_handler: wrong interrupt vector %d\n",
97 irq_vecs[vec - vec_base].handler = handler;
98 irq_vecs[vec - vec_base].arg = arg;
101 void irq_free_handler (int vec)
104 volatile intctrl_t *intp = (intctrl_t *) (CFG_MBAR + MCFSIM_ICR1);
109 vec_base = intp->int_pivr & 0xe0;
112 if ((vec < vec_base) || (vec > vec_base + NR_IRQS)) {
116 irq_vecs[vec - vec_base].handler = NULL;
117 irq_vecs[vec - vec_base].arg = NULL;
120 void enable_interrupts (void)
125 set_sr (sr & ~0x0700);
128 int disable_interrupts (void)
133 set_sr (sr | 0x0700);
135 return ((sr & 0x0700) == 0); /* return TRUE, if interrupts were enabled before */
138 void int_handler (struct pt_regs *fp)
141 volatile intctrl_t *intp = (intctrl_t *) (CFG_MBAR + MCFSIM_ICR1);
143 int vec, vec_base = 0;
145 vec = (fp->vector >> 2) & 0xff;
147 vec_base = intp->int_pivr & 0xe0;
150 if (irq_vecs[vec - vec_base].handler != NULL) {
152 vec_base].handler (irq_vecs[vec - vec_base].arg);
154 printf ("\nBogus External Interrupt Vector %d\n", vec);
160 int interrupt_init (void)
162 volatile intctrl_t *intp = (intctrl_t *) (CFG_MBAR + MCFSIM_ICR1);
164 /* disable all external interrupts */
165 intp->int_icr1 = 0x88888888;
166 intp->int_icr2 = 0x88888888;
167 intp->int_icr3 = 0x88888888;
168 intp->int_icr4 = 0x88888888;
169 intp->int_pitr = 0x00000000;
170 /* initialize vector register */
171 intp->int_pivr = 0x40;
173 enable_interrupts ();
179 #if defined(CONFIG_M5282) || defined(CONFIG_M5271)
180 int interrupt_init (void)
187 int interrupt_init (void)
189 enable_interrupts ();