2 * (C) Copyright 2007 Michal Simek
3 * (C) Copyright 2004 Atmark Techno, Inc.
5 * Michal SIMEK <monstr@monstr.eu>
6 * Yasushi SHOJI <yashi@atmark-techno.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/microblaze_intc.h>
33 extern void microblaze_disable_interrupts (void);
34 extern void microblaze_enable_interrupts (void);
36 void enable_interrupts (void)
38 microblaze_enable_interrupts ();
41 int disable_interrupts (void)
43 microblaze_disable_interrupts ();
49 extern void timer_init (void);
52 static struct irq_action vecs[CFG_INTC_0_NUM];
54 /* mapping structure to interrupt controller */
55 microblaze_intc_t *intc = (microblaze_intc_t *) (CFG_INTC_0_ADDR);
63 void enable_one_interrupt (int irq)
69 intc->ier = (mask | offset);
71 printf ("Enable one interrupt irq %x - mask %x,ier %x\n", offset, mask,
73 printf ("INTC isr %x, ier %x, iar %x, mer %x\n", intc->isr, intc->ier,
74 intc->iar, intc->mer);
78 void disable_one_interrupt (int irq)
84 intc->ier = (mask & ~offset);
86 printf ("Disable one interrupt irq %x - mask %x,ier %x\n", irq, mask,
88 printf ("INTC isr %x, ier %x, iar %x, mer %x\n", intc->isr, intc->ier,
89 intc->iar, intc->mer);
93 /* adding new handler for interrupt */
94 void install_interrupt_handler (int irq, interrupt_handler_t * hdlr, void *arg)
96 struct irq_action *act;
97 /* irq out of range */
98 if ((irq < 0) || (irq > CFG_INTC_0_NUM)) {
99 puts ("IRQ out of range\n");
103 if (hdlr) { /* enable */
107 enable_one_interrupt (irq);
108 } else { /* disable */
110 act->handler = (interrupt_handler_t *) def_hdlr;
111 act->arg = (void *)irq;
112 disable_one_interrupt (irq);
116 /* initialization interrupt controller - hardware */
117 void intc_init (void)
121 intc->iar = 0xFFFFFFFF;
122 /* XIntc_Start - hw_interrupt enable and all interrupt enable */
125 printf ("INTC isr %x, ier %x, iar %x, mer %x\n", intc->isr, intc->ier,
126 intc->iar, intc->mer);
130 int interrupts_init (void)
133 /* initialize irq list */
134 for (i = 0; i < CFG_INTC_0_NUM; i++) {
135 vecs[i].handler = (interrupt_handler_t *) def_hdlr;
136 vecs[i].arg = (void *)i;
139 /* initialize intc controller */
144 enable_interrupts ();
148 void interrupt_handler (void)
151 irqs = (intc->isr & intc->ier); /* find active interrupt */
154 printf ("INTC isr %x, ier %x, iar %x, mer %x\n", intc->isr, intc->ier,
155 intc->iar, intc->mer);
156 printf ("Interrupt handler on %x line, r14 %x\n", irqs, value);
158 struct irq_action *act = vecs;
163 ("Jumping to interrupt handler rutine addr %x,count %x,arg %x\n",
164 act->handler, act->count, act->arg);
166 act->handler (act->arg);
172 intc->iar = 0xFFFFFFFF; /* erase all events */
174 printf ("Dump INTC reg, isr %x, ier %x, iar %x, mer %x\n", intc->isr,
175 intc->ier, intc->iar, intc->mer);
176 printf ("Interrupt handler on %x line, r14\n", irqs);
181 #if (CONFIG_COMMANDS & CFG_CMD_IRQ)
183 int do_irqinfo (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
186 struct irq_action *act = vecs;
188 puts ("\nInterrupt-Information:\n\n"
189 "Nr Routine Arg Count\n"
190 "-----------------------------\n");
192 for (i = 0; i < CFG_INTC_0_NUM; i++) {
193 if (act->handler != (interrupt_handler_t*) def_hdlr) {
194 printf ("%02d %08lx %08lx %d\n", i,
195 (int)act->handler, (int)act->arg, act->count);
203 int do_irqinfo (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
205 puts ("Undefined interrupt controller\n");
208 #endif /* CONFIG_COMMANDS & CFG_CMD_IRQ */