]>
git.ipfire.org Git - people/ms/u-boot.git/blob - arch/sparc/cpu/leon3/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 #include <grlib/irqmp.h>
27 #include <grlib/gptimer.h>
29 /* 15 normal irqs and a non maskable interrupt */
33 interrupt_handler_t
*handler
;
38 extern ambapp_dev_irqmp
*irqmp
;
39 extern ambapp_dev_gptimer
*gptimer
;
41 static struct irq_action irq_handlers
[NR_IRQS
] = { {0}, };
42 static int spurious_irq_cnt
= 0;
43 static int spurious_irq
= 0;
45 static inline unsigned int irqmp_get_irqmask(unsigned int irq
)
47 if ((irq
< 0) || (irq
>= NR_IRQS
)) {
55 static void leon3_ic_disable(unsigned int irq
)
57 unsigned int mask
, pil
;
63 /* get mask of interrupt */
64 mask
= irqmp_get_irqmask(irq
);
67 irqmp
->cpu_mask
[0] = SPARC_NOCACHE_READ(&irqmp
->cpu_mask
[0]) & (~mask
);
72 static void leon3_ic_enable(unsigned int irq
)
74 unsigned int mask
, pil
;
80 /* get mask of interrupt */
81 mask
= irqmp_get_irqmask(irq
);
84 irqmp
->cpu_mask
[0] = SPARC_NOCACHE_READ(&irqmp
->cpu_mask
[0]) | mask
;
90 void handler_irq(int irq
, struct pt_regs
*regs
)
92 if (irq_handlers
[irq
].handler
) {
93 if (((unsigned int)irq_handlers
[irq
].handler
> CONFIG_SYS_RAM_END
) ||
94 ((unsigned int)irq_handlers
[irq
].handler
< CONFIG_SYS_RAM_BASE
)
96 printf("handler_irq: bad handler: %x, irq number %d\n",
97 (unsigned int)irq_handlers
[irq
].handler
, irq
);
100 irq_handlers
[irq
].handler(irq_handlers
[irq
].arg
);
101 irq_handlers
[irq
].count
++;
108 void leon3_force_int(int irq
)
110 if (!irqmp
|| (irq
>= NR_IRQS
) || (irq
< 0))
112 printf("Forcing interrupt %d\n", irq
);
114 irqmp
->iforce
= SPARC_NOCACHE_READ(&irqmp
->iforce
) | (1 << irq
);
117 /****************************************************************************/
119 int interrupt_init_cpu(void)
125 /****************************************************************************/
128 * Install and free a interrupt handler.
131 void irq_install_handler(int irq
, interrupt_handler_t
* handler
, void *arg
)
133 if (irq
< 0 || irq
>= NR_IRQS
) {
134 printf("irq_install_handler: bad irq number %d\n", irq
);
138 if (irq_handlers
[irq
].handler
!= NULL
)
139 printf("irq_install_handler: 0x%08lx replacing 0x%08lx\n",
140 (ulong
) handler
, (ulong
) irq_handlers
[irq
].handler
);
142 if (((unsigned int)handler
> CONFIG_SYS_RAM_END
) ||
143 ((unsigned int)handler
< CONFIG_SYS_RAM_BASE
)
145 printf("irq_install_handler: bad handler: %x, irq number %d\n",
146 (unsigned int)handler
, irq
);
149 irq_handlers
[irq
].handler
= handler
;
150 irq_handlers
[irq
].arg
= arg
;
152 /* enable irq on IRQMP hardware */
153 leon3_ic_enable(irq
);
157 void irq_free_handler(int irq
)
159 if (irq
< 0 || irq
>= NR_IRQS
) {
160 printf("irq_free_handler: bad irq number %d\n", irq
);
164 /* disable irq on IRQMP hardware */
165 leon3_ic_disable(irq
);
167 irq_handlers
[irq
].handler
= NULL
;
168 irq_handlers
[irq
].arg
= NULL
;
171 /****************************************************************************/
173 #if defined(CONFIG_CMD_IRQ)
174 void do_irqinfo(cmd_tbl_t
* cmdtp
, bd_t
* bd
, int flag
, int argc
, char * const argv
[])
177 unsigned int pil
= get_pil();
178 printf("PIL level: %u\n\r", pil
);
179 printf("Spurious IRQ: %u, last unknown IRQ: %d\n",
180 spurious_irq_cnt
, spurious_irq
);
182 puts("\nInterrupt-Information:\n" "Nr Routine Arg Count\n");
184 for (irq
= 0; irq
< NR_IRQS
; irq
++) {
185 if (irq_handlers
[irq
].handler
!= NULL
) {
186 printf("%02d %p %p %d\n", irq
,
187 irq_handlers
[irq
].handler
,
188 irq_handlers
[irq
].arg
,
189 irq_handlers
[irq
].count
);