]>
git.ipfire.org Git - people/ms/u-boot.git/blob - arch/sparc/cpu/leon2/interrupts.c
3 * Daniel Hellstrom, Gaisler Research, daniel@gaisler.com
6 * Detlev Zundel, DENX Software Engineering, dzu@denx.de
9 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
12 * Josh Huber <huber@mclx.com>, Mission Critical Linux, Inc.
14 * See file CREDITS for list of people who contributed to this
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License as
19 * published by the Free Software Foundation; either version 2 of
20 * the License, or (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
33 #include <asm/stack.h>
36 #include <asm/processor.h>
42 /* 15 normal irqs and a non maskable interrupt */
46 interrupt_handler_t
*handler
;
51 static struct irq_action irq_handlers
[NR_IRQS
] = { {0}, };
52 static int spurious_irq_cnt
= 0;
53 static int spurious_irq
= 0;
55 static inline unsigned int leon2_get_irqmask(unsigned int irq
)
57 if ((irq
< 0) || (irq
>= NR_IRQS
)) {
64 static void leon2_ic_disable(unsigned int irq
)
66 unsigned int mask
, pil
;
67 LEON2_regs
*leon2
= (LEON2_regs
*) LEON2_PREGS
;
71 /* get mask of interrupt */
72 mask
= leon2_get_irqmask(irq
);
75 leon2
->Interrupt_Mask
=
76 SPARC_NOCACHE_READ(&leon2
->Interrupt_Mask
) & (~mask
);
81 static void leon2_ic_enable(unsigned int irq
)
83 unsigned int mask
, pil
;
84 LEON2_regs
*leon2
= (LEON2_regs
*) LEON2_PREGS
;
88 /* get mask of interrupt */
89 mask
= leon2_get_irqmask(irq
);
92 leon2
->Interrupt_Mask
=
93 SPARC_NOCACHE_READ(&leon2
->Interrupt_Mask
) | mask
;
98 void handler_irq(int irq
, struct pt_regs
*regs
)
100 if (irq_handlers
[irq
].handler
) {
101 if (((unsigned int)irq_handlers
[irq
].handler
> CONFIG_SYS_RAM_END
) ||
102 ((unsigned int)irq_handlers
[irq
].handler
< CONFIG_SYS_RAM_BASE
)
104 printf("handler_irq: bad handler: %x, irq number %d\n",
105 (unsigned int)irq_handlers
[irq
].handler
, irq
);
108 irq_handlers
[irq
].handler(irq_handlers
[irq
].arg
);
109 irq_handlers
[irq
].count
++;
116 void leon2_force_int(int irq
)
118 LEON2_regs
*leon2
= (LEON2_regs
*) LEON2_PREGS
;
120 if ((irq
>= NR_IRQS
) || (irq
< 0))
122 printf("Forcing interrupt %d\n", irq
);
124 leon2
->Interrupt_Force
=
125 SPARC_NOCACHE_READ(&leon2
->Interrupt_Force
) | (1 << irq
);
128 /****************************************************************************/
130 int interrupt_init_cpu(void)
135 /****************************************************************************/
137 /* Handle Timer 0 IRQ */
138 void timer_interrupt_cpu(void *arg
)
140 LEON2_regs
*leon2
= (LEON2_regs
*) LEON2_PREGS
;
142 leon2
->Timer_Control_1
=
143 (LEON2_TIMER_CTRL_EN
| LEON2_TIMER_CTRL_RS
| LEON2_TIMER_CTRL_LD
);
145 /* nothing to do here */
149 /****************************************************************************/
152 * Install and free a interrupt handler.
155 void irq_install_handler(int irq
, interrupt_handler_t
* handler
, void *arg
)
157 if (irq
< 0 || irq
>= NR_IRQS
) {
158 printf("irq_install_handler: bad irq number %d\n", irq
);
162 if (irq_handlers
[irq
].handler
!= NULL
)
163 printf("irq_install_handler: 0x%08lx replacing 0x%08lx\n",
164 (ulong
) handler
, (ulong
) irq_handlers
[irq
].handler
);
166 if (((unsigned int)handler
> CONFIG_SYS_RAM_END
) ||
167 ((unsigned int)handler
< CONFIG_SYS_RAM_BASE
)
169 printf("irq_install_handler: bad handler: %x, irq number %d\n",
170 (unsigned int)handler
, irq
);
173 irq_handlers
[irq
].handler
= handler
;
174 irq_handlers
[irq
].arg
= arg
;
176 /* enable irq on LEON2 hardware */
177 leon2_ic_enable(irq
);
181 void irq_free_handler(int irq
)
183 if (irq
< 0 || irq
>= NR_IRQS
) {
184 printf("irq_free_handler: bad irq number %d\n", irq
);
188 /* disable irq on LEON2 hardware */
189 leon2_ic_disable(irq
);
191 irq_handlers
[irq
].handler
= NULL
;
192 irq_handlers
[irq
].arg
= NULL
;
195 /****************************************************************************/
197 #if defined(CONFIG_CMD_IRQ)
198 void do_irqinfo(cmd_tbl_t
* cmdtp
, bd_t
* bd
, int flag
, int argc
, char *argv
[])
201 unsigned int pil
= get_pil();
202 printf("PIL level: %u\n\r", pil
);
203 printf("Spurious IRQ: %u, last unknown IRQ: %d\n",
204 spurious_irq_cnt
, spurious_irq
);
206 puts("\nInterrupt-Information:\n" "Nr Routine Arg Count\n");
208 for (irq
= 0; irq
< NR_IRQS
; irq
++) {
209 if (irq_handlers
[irq
].handler
!= NULL
) {
210 printf("%02d %08lx %08lx %ld\n", irq
,
211 (unsigned int)irq_handlers
[irq
].handler
,
212 (unsigned int)irq_handlers
[irq
].arg
,
213 irq_handlers
[irq
].count
);