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>
34 extern void microblaze_disable_interrupts (void);
35 extern void microblaze_enable_interrupts (void);
37 void enable_interrupts (void)
42 int disable_interrupts (void)
48 #ifdef CONFIG_SYS_INTC_0
50 static struct irq_action vecs[CONFIG_SYS_INTC_0_NUM];
52 /* mapping structure to interrupt controller */
53 microblaze_intc_t *intc = (microblaze_intc_t *) (CONFIG_SYS_INTC_0_ADDR);
61 void enable_one_interrupt (int irq)
67 intc->ier = (mask | offset);
69 printf ("Enable one interrupt irq %x - mask %x,ier %x\n", offset, mask,
71 printf ("INTC isr %x, ier %x, iar %x, mer %x\n", intc->isr, intc->ier,
72 intc->iar, intc->mer);
76 void disable_one_interrupt (int irq)
82 intc->ier = (mask & ~offset);
84 printf ("Disable one interrupt irq %x - mask %x,ier %x\n", irq, mask,
86 printf ("INTC isr %x, ier %x, iar %x, mer %x\n", intc->isr, intc->ier,
87 intc->iar, intc->mer);
91 /* adding new handler for interrupt */
92 void install_interrupt_handler (int irq, interrupt_handler_t * hdlr, void *arg)
94 struct irq_action *act;
95 /* irq out of range */
96 if ((irq < 0) || (irq > CONFIG_SYS_INTC_0_NUM)) {
97 puts ("IRQ out of range\n");
101 if (hdlr) { /* enable */
105 enable_one_interrupt (irq);
106 } else { /* disable */
107 act->handler = (interrupt_handler_t *) def_hdlr;
108 act->arg = (void *)irq;
109 disable_one_interrupt (irq);
113 /* initialization interrupt controller - hardware */
114 void intc_init (void)
118 intc->iar = 0xFFFFFFFF;
119 /* XIntc_Start - hw_interrupt enable and all interrupt enable */
122 printf ("INTC isr %x, ier %x, iar %x, mer %x\n", intc->isr, intc->ier,
123 intc->iar, intc->mer);
127 int interrupts_init (void)
130 /* initialize irq list */
131 for (i = 0; i < CONFIG_SYS_INTC_0_NUM; i++) {
132 vecs[i].handler = (interrupt_handler_t *) def_hdlr;
133 vecs[i].arg = (void *)i;
136 /* initialize intc controller */
138 enable_interrupts ();
142 void interrupt_handler (void)
144 int irqs = (intc->isr & intc->ier); /* find active interrupt */
148 printf ("INTC isr %x, ier %x, iar %x, mer %x\n", intc->isr, intc->ier,
149 intc->iar, intc->mer);
151 printf ("Interrupt handler on %x line, r14 %x\n", irqs, value);
153 struct irq_action *act = vecs;
158 ("Jumping to interrupt handler rutine addr %x,count %x,arg %x\n",
159 act->handler, act->count, act->arg);
161 act->handler (act->arg);
172 printf ("Dump INTC reg, isr %x, ier %x, iar %x, mer %x\n", intc->isr,
173 intc->ier, intc->iar, intc->mer);
175 printf ("Interrupt handler on %x line, r14 %x\n", irqs, value);
180 #if defined(CONFIG_CMD_IRQ)
181 #ifdef CONFIG_SYS_INTC_0
182 int do_irqinfo (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
185 struct irq_action *act = vecs;
187 puts ("\nInterrupt-Information:\n\n"
188 "Nr Routine Arg Count\n"
189 "-----------------------------\n");
191 for (i = 0; i < CONFIG_SYS_INTC_0_NUM; i++) {
192 if (act->handler != (interrupt_handler_t*) def_hdlr) {
193 printf ("%02d %08x %08x %d\n", i,
194 (int)act->handler, (int)act->arg, act->count);
202 int do_irqinfo (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
204 puts ("Undefined interrupt controller\n");