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)
39 __asm__ __volatile__ ("msrset r0, 0x2");
40 //microblaze_enable_interrupts ();
43 int disable_interrupts (void)
45 __asm__ __volatile__ ("msrclr r0, 0x2");
46 //microblaze_disable_interrupts ();
52 extern void timer_init (void);
55 extern void fsl_init2 (void);
59 static struct irq_action vecs[CFG_INTC_0_NUM];
61 /* mapping structure to interrupt controller */
62 microblaze_intc_t *intc = (microblaze_intc_t *) (CFG_INTC_0_ADDR);
70 void enable_one_interrupt (int irq)
76 intc->ier = (mask | offset);
78 printf ("Enable one interrupt irq %x - mask %x,ier %x\n", offset, mask,
80 printf ("INTC isr %x, ier %x, iar %x, mer %x\n", intc->isr, intc->ier,
81 intc->iar, intc->mer);
85 void disable_one_interrupt (int irq)
91 intc->ier = (mask & ~offset);
93 printf ("Disable one interrupt irq %x - mask %x,ier %x\n", irq, mask,
95 printf ("INTC isr %x, ier %x, iar %x, mer %x\n", intc->isr, intc->ier,
96 intc->iar, intc->mer);
100 /* adding new handler for interrupt */
101 void install_interrupt_handler (int irq, interrupt_handler_t * hdlr, void *arg)
103 struct irq_action *act;
104 /* irq out of range */
105 if ((irq < 0) || (irq > CFG_INTC_0_NUM)) {
106 puts ("IRQ out of range\n");
110 if (hdlr) { /* enable */
114 enable_one_interrupt (irq);
115 } else { /* disable */
116 act->handler = (interrupt_handler_t *) def_hdlr;
117 act->arg = (void *)irq;
118 disable_one_interrupt (irq);
122 /* initialization interrupt controller - hardware */
123 void intc_init (void)
127 intc->iar = 0xFFFFFFFF;
128 /* XIntc_Start - hw_interrupt enable and all interrupt enable */
131 printf ("INTC isr %x, ier %x, iar %x, mer %x\n", intc->isr, intc->ier,
132 intc->iar, intc->mer);
136 int interrupts_init (void)
139 /* initialize irq list */
140 for (i = 0; i < CFG_INTC_0_NUM; i++) {
141 vecs[i].handler = (interrupt_handler_t *) def_hdlr;
142 vecs[i].arg = (void *)i;
145 /* initialize intc controller */
153 enable_interrupts ();
157 void interrupt_handler (void)
159 int irqs = (intc->isr & intc->ier); /* find active interrupt */
163 printf ("INTC isr %x, ier %x, iar %x, mer %x\n", intc->isr, intc->ier,
164 intc->iar, intc->mer);
166 printf ("Interrupt handler on %x line, r14 %x\n", irqs, value);
168 struct irq_action *act = vecs;
173 ("Jumping to interrupt handler rutine addr %x,count %x,arg %x\n",
174 act->handler, act->count, act->arg);
176 act->handler (act->arg);
187 printf ("Dump INTC reg, isr %x, ier %x, iar %x, mer %x\n", intc->isr,
188 intc->ier, intc->iar, intc->mer);
190 printf ("Interrupt handler on %x line, r14 %x\n", irqs, value);
195 #if (CONFIG_COMMANDS & CFG_CMD_IRQ)
197 int do_irqinfo (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
200 struct irq_action *act = vecs;
202 puts ("\nInterrupt-Information:\n\n"
203 "Nr Routine Arg Count\n"
204 "-----------------------------\n");
206 for (i = 0; i < CFG_INTC_0_NUM; i++) {
207 if (act->handler != (interrupt_handler_t*) def_hdlr) {
208 printf ("%02d %08lx %08lx %d\n", i,
209 (int)act->handler, (int)act->arg, act->count);
217 int do_irqinfo (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
219 puts ("Undefined interrupt controller\n");
222 #endif /* CONFIG_COMMANDS & CFG_CMD_IRQ */