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 return (msr & 0x2) != 0;
51 #ifdef CONFIG_SYS_INTC_0
53 static struct irq_action vecs[CONFIG_SYS_INTC_0_NUM];
55 /* mapping structure to interrupt controller */
56 microblaze_intc_t *intc = (microblaze_intc_t *) (CONFIG_SYS_INTC_0_ADDR);
64 void enable_one_interrupt (int irq)
70 intc->ier = (mask | offset);
72 printf ("Enable one interrupt irq %x - mask %x,ier %x\n", offset, mask,
74 printf ("INTC isr %x, ier %x, iar %x, mer %x\n", intc->isr, intc->ier,
75 intc->iar, intc->mer);
79 void disable_one_interrupt (int irq)
85 intc->ier = (mask & ~offset);
87 printf ("Disable one interrupt irq %x - mask %x,ier %x\n", irq, mask,
89 printf ("INTC isr %x, ier %x, iar %x, mer %x\n", intc->isr, intc->ier,
90 intc->iar, intc->mer);
94 /* adding new handler for interrupt */
95 void install_interrupt_handler (int irq, interrupt_handler_t * hdlr, void *arg)
97 struct irq_action *act;
98 /* irq out of range */
99 if ((irq < 0) || (irq > CONFIG_SYS_INTC_0_NUM)) {
100 puts ("IRQ out of range\n");
104 if (hdlr) { /* enable */
108 enable_one_interrupt (irq);
109 } 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 < CONFIG_SYS_INTC_0_NUM; i++) {
135 vecs[i].handler = (interrupt_handler_t *) def_hdlr;
136 vecs[i].arg = (void *)i;
139 /* initialize intc controller */
141 enable_interrupts ();
145 void interrupt_handler (void)
147 int irqs = intc->ivr; /* find active interrupt */
151 printf ("INTC isr %x, ier %x, iar %x, mer %x\n", intc->isr, intc->ier,
152 intc->iar, intc->mer);
154 printf ("Interrupt handler on %x line, r14 %x\n", irqs, value);
156 struct irq_action *act = vecs + irqs;
160 ("Jumping to interrupt handler rutine addr %x,count %x,arg %x\n",
161 act->handler, act->count, act->arg);
163 act->handler (act->arg);
166 intc->iar = mask << irqs;
169 printf ("Dump INTC reg, isr %x, ier %x, iar %x, mer %x\n", intc->isr,
170 intc->ier, intc->iar, intc->mer);
172 printf ("Interrupt handler on %x line, r14 %x\n", irqs, value);
177 #if defined(CONFIG_CMD_IRQ)
178 #ifdef CONFIG_SYS_INTC_0
179 int do_irqinfo (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
182 struct irq_action *act = vecs;
184 puts ("\nInterrupt-Information:\n\n"
185 "Nr Routine Arg Count\n"
186 "-----------------------------\n");
188 for (i = 0; i < CONFIG_SYS_INTC_0_NUM; i++) {
189 if (act->handler != (interrupt_handler_t*) def_hdlr) {
190 printf ("%02d %08x %08x %d\n", i,
191 (int)act->handler, (int)act->arg, act->count);
199 int do_irqinfo (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
201 puts ("Undefined interrupt controller\n");