2
* (C) Copyright 2000-2004
3
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5
* (C) Copyright 2007 Freescale Semiconductor Inc
6
* TsiChung Liew (Tsi-Chung.Liew@freescale.com)
8
* See file CREDITS for list of people who contributed to this
11
* This program is free software; you can redistribute it and/or
12
* modify it under the terms of the GNU General Public License as
13
* published by the Free Software Foundation; either version 2 of
14
* the License, or (at your option) any later version.
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU General Public License for more details.
21
* You should have received a copy of the GNU General Public License
22
* along with this program; if not, write to the Free Software
23
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29
#include <asm/processor.h>
30
#include <asm/immap.h>
32
#define NR_IRQS (CONFIG_SYS_NUM_IRQS)
35
* Interrupt vector functions.
37
struct interrupt_action {
38
interrupt_handler_t *handler;
42
static struct interrupt_action irq_vecs[NR_IRQS];
44
static __inline__ unsigned short get_sr (void)
48
asm volatile ("move.w %%sr,%0":"=r" (sr):);
53
static __inline__ void set_sr (unsigned short sr)
55
asm volatile ("move.w %0,%%sr"::"r" (sr));
58
/************************************************************************/
60
* Install and free an interrupt handler
62
void irq_install_handler (int vec, interrupt_handler_t * handler, void *arg)
64
if ((vec < 0) || (vec >= NR_IRQS)) {
65
printf ("irq_install_handler: wrong interrupt vector %d\n",
70
irq_vecs[vec].handler = handler;
71
irq_vecs[vec].arg = arg;
74
void irq_free_handler (int vec)
76
if ((vec < 0) || (vec >= NR_IRQS)) {
80
irq_vecs[vec].handler = NULL;
81
irq_vecs[vec].arg = NULL;
84
void enable_interrupts (void)
89
set_sr (sr & ~0x0700);
92
int disable_interrupts (void)
99
return ((sr & 0x0700) == 0); /* return TRUE, if interrupts were enabled before */
102
void int_handler (struct pt_regs *fp)
106
vec = (fp->vector >> 2) & 0xff;
110
if (irq_vecs[vec].handler != NULL) {
111
irq_vecs[vec].handler (irq_vecs[vec].arg);
113
printf ("\nBogus External Interrupt Vector %d\n", vec);