]>
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 * SPDX-License-Identifier: GPL-2.0+
17 #include <asm/stack.h>
20 #include <asm/processor.h>
26 /* 15 normal irqs and a non maskable interrupt */
30 interrupt_handler_t
*handler
;
35 static struct irq_action irq_handlers
[NR_IRQS
] = { {0}, };
36 static int spurious_irq_cnt
= 0;
37 static int spurious_irq
= 0;
39 static inline unsigned int leon2_get_irqmask(unsigned int irq
)
41 if ((irq
< 0) || (irq
>= NR_IRQS
)) {
48 static void leon2_ic_disable(unsigned int irq
)
50 unsigned int mask
, pil
;
51 LEON2_regs
*leon2
= (LEON2_regs
*) LEON2_PREGS
;
55 /* get mask of interrupt */
56 mask
= leon2_get_irqmask(irq
);
59 leon2
->Interrupt_Mask
=
60 SPARC_NOCACHE_READ(&leon2
->Interrupt_Mask
) & (~mask
);
65 static void leon2_ic_enable(unsigned int irq
)
67 unsigned int mask
, pil
;
68 LEON2_regs
*leon2
= (LEON2_regs
*) LEON2_PREGS
;
72 /* get mask of interrupt */
73 mask
= leon2_get_irqmask(irq
);
76 leon2
->Interrupt_Mask
=
77 SPARC_NOCACHE_READ(&leon2
->Interrupt_Mask
) | mask
;
82 void handler_irq(int irq
, struct pt_regs
*regs
)
84 if (irq_handlers
[irq
].handler
) {
85 if (((unsigned int)irq_handlers
[irq
].handler
> CONFIG_SYS_RAM_END
) ||
86 ((unsigned int)irq_handlers
[irq
].handler
< CONFIG_SYS_RAM_BASE
)
88 printf("handler_irq: bad handler: %x, irq number %d\n",
89 (unsigned int)irq_handlers
[irq
].handler
, irq
);
92 irq_handlers
[irq
].handler(irq_handlers
[irq
].arg
);
93 irq_handlers
[irq
].count
++;
100 void leon2_force_int(int irq
)
102 LEON2_regs
*leon2
= (LEON2_regs
*) LEON2_PREGS
;
104 if ((irq
>= NR_IRQS
) || (irq
< 0))
106 printf("Forcing interrupt %d\n", irq
);
108 leon2
->Interrupt_Force
=
109 SPARC_NOCACHE_READ(&leon2
->Interrupt_Force
) | (1 << irq
);
112 /****************************************************************************/
114 int interrupt_init_cpu(void)
119 /****************************************************************************/
121 /* Handle Timer 0 IRQ */
122 void timer_interrupt_cpu(void *arg
)
124 LEON2_regs
*leon2
= (LEON2_regs
*) LEON2_PREGS
;
126 leon2
->Timer_Control_1
=
127 (LEON2_TIMER_CTRL_EN
| LEON2_TIMER_CTRL_RS
| LEON2_TIMER_CTRL_LD
);
129 /* nothing to do here */
133 /****************************************************************************/
136 * Install and free a interrupt handler.
139 void irq_install_handler(int irq
, interrupt_handler_t
* handler
, void *arg
)
141 if (irq
< 0 || irq
>= NR_IRQS
) {
142 printf("irq_install_handler: bad irq number %d\n", irq
);
146 if (irq_handlers
[irq
].handler
!= NULL
)
147 printf("irq_install_handler: 0x%08lx replacing 0x%08lx\n",
148 (ulong
) handler
, (ulong
) irq_handlers
[irq
].handler
);
150 if (((unsigned int)handler
> CONFIG_SYS_RAM_END
) ||
151 ((unsigned int)handler
< CONFIG_SYS_RAM_BASE
)
153 printf("irq_install_handler: bad handler: %x, irq number %d\n",
154 (unsigned int)handler
, irq
);
157 irq_handlers
[irq
].handler
= handler
;
158 irq_handlers
[irq
].arg
= arg
;
160 /* enable irq on LEON2 hardware */
161 leon2_ic_enable(irq
);
165 void irq_free_handler(int irq
)
167 if (irq
< 0 || irq
>= NR_IRQS
) {
168 printf("irq_free_handler: bad irq number %d\n", irq
);
172 /* disable irq on LEON2 hardware */
173 leon2_ic_disable(irq
);
175 irq_handlers
[irq
].handler
= NULL
;
176 irq_handlers
[irq
].arg
= NULL
;
179 /****************************************************************************/
181 #if defined(CONFIG_CMD_IRQ)
182 void do_irqinfo(cmd_tbl_t
* cmdtp
, bd_t
* bd
, int flag
, int argc
, char * const argv
[])
185 unsigned int pil
= get_pil();
186 printf("PIL level: %u\n\r", pil
);
187 printf("Spurious IRQ: %u, last unknown IRQ: %d\n",
188 spurious_irq_cnt
, spurious_irq
);
190 puts("\nInterrupt-Information:\n" "Nr Routine Arg Count\n");
192 for (irq
= 0; irq
< NR_IRQS
; irq
++) {
193 if (irq_handlers
[irq
].handler
!= NULL
) {
194 printf("%02d %p %p %d\n", irq
,
195 irq_handlers
[irq
].handler
,
196 irq_handlers
[irq
].arg
,
197 irq_handlers
[irq
].count
);