microblaze: intc: Clear interrupt code

Clear and prepare for device-tree driven configuration.
Remove CONFIG_SYS_INTC_0 definition
Use dynamic allocation instead of static.

Signed-off-by: Michal Simek <monstr@monstr.eu>
Acked-by: Simon Glass <sjg@chromium.org>
master
Michal Simek 13 years ago
parent e0bb305df8
commit 575a3d21f6
  1. 88
      arch/microblaze/cpu/interrupts.c
  2. 2
      arch/microblaze/cpu/start.S
  3. 2
      arch/microblaze/cpu/timer.c
  4. 3
      arch/microblaze/include/asm/microblaze_intc.h
  5. 6
      arch/microblaze/lib/board.c
  6. 1
      include/configs/microblaze-generic.h

@ -26,6 +26,7 @@
#include <common.h> #include <common.h>
#include <command.h> #include <command.h>
#include <malloc.h>
#include <asm/microblaze_intc.h> #include <asm/microblaze_intc.h>
#include <asm/asm.h> #include <asm/asm.h>
@ -48,20 +49,19 @@ int disable_interrupts (void)
return (msr & 0x2) != 0; return (msr & 0x2) != 0;
} }
#ifdef CONFIG_SYS_INTC_0 static struct irq_action *vecs;
static u32 irq_no;
static struct irq_action vecs[CONFIG_SYS_INTC_0_NUM];
/* mapping structure to interrupt controller */ /* mapping structure to interrupt controller */
microblaze_intc_t *intc = (microblaze_intc_t *) (CONFIG_SYS_INTC_0_ADDR); microblaze_intc_t *intc;
/* default handler */ /* default handler */
void def_hdlr (void) static void def_hdlr(void)
{ {
puts ("def_hdlr\n"); puts ("def_hdlr\n");
} }
void enable_one_interrupt (int irq) static void enable_one_interrupt(int irq)
{ {
int mask; int mask;
int offset = 1; int offset = 1;
@ -76,7 +76,7 @@ void enable_one_interrupt (int irq)
#endif #endif
} }
void disable_one_interrupt (int irq) static void disable_one_interrupt(int irq)
{ {
int mask; int mask;
int offset = 1; int offset = 1;
@ -96,7 +96,7 @@ void install_interrupt_handler (int irq, interrupt_handler_t * hdlr, void *arg)
{ {
struct irq_action *act; struct irq_action *act;
/* irq out of range */ /* irq out of range */
if ((irq < 0) || (irq > CONFIG_SYS_INTC_0_NUM)) { if ((irq < 0) || (irq > irq_no)) {
puts ("IRQ out of range\n"); puts ("IRQ out of range\n");
return; return;
} }
@ -114,7 +114,7 @@ void install_interrupt_handler (int irq, interrupt_handler_t * hdlr, void *arg)
} }
/* initialization interrupt controller - hardware */ /* initialization interrupt controller - hardware */
void intc_init (void) static void intc_init(void)
{ {
intc->mer = 0; intc->mer = 0;
intc->ier = 0; intc->ier = 0;
@ -127,18 +127,33 @@ void intc_init (void)
#endif #endif
} }
int interrupts_init (void) int interrupts_init(void)
{ {
int i; int i;
/* initialize irq list */
for (i = 0; i < CONFIG_SYS_INTC_0_NUM; i++) { #if defined(CONFIG_SYS_INTC_0_ADDR) && defined(CONFIG_SYS_INTC_0_NUM)
vecs[i].handler = (interrupt_handler_t *) def_hdlr; intc = (microblaze_intc_t *) (CONFIG_SYS_INTC_0_ADDR);
vecs[i].arg = (void *)i; irq_no = CONFIG_SYS_INTC_0_NUM;
vecs[i].count = 0; #endif
if (irq_no) {
vecs = calloc(1, sizeof(struct irq_action) * irq_no);
if (vecs == NULL) {
puts("Interrupt vector allocation failed\n");
return -1;
}
/* initialize irq list */
for (i = 0; i < irq_no; i++) {
vecs[i].handler = (interrupt_handler_t *) def_hdlr;
vecs[i].arg = (void *)i;
vecs[i].count = 0;
}
/* initialize intc controller */
intc_init();
enable_interrupts();
} else {
puts("Undefined interrupt controller\n");
} }
/* initialize intc controller */
intc_init ();
enable_interrupts ();
return 0; return 0;
} }
@ -172,33 +187,30 @@ void interrupt_handler (void)
printf ("Interrupt handler on %x line, r14 %x\n", irqs, value); printf ("Interrupt handler on %x line, r14 %x\n", irqs, value);
#endif #endif
} }
#endif
#if defined(CONFIG_CMD_IRQ) #if defined(CONFIG_CMD_IRQ)
#ifdef CONFIG_SYS_INTC_0 int do_irqinfo(cmd_tbl_t *cmdtp, int flag, int argc, const char *argv[])
int do_irqinfo (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
{ {
int i; int i;
struct irq_action *act = vecs; struct irq_action *act = vecs;
puts ("\nInterrupt-Information:\n\n" if (irq_no) {
"Nr Routine Arg Count\n" puts("\nInterrupt-Information:\n\n"
"-----------------------------\n"); "Nr Routine Arg Count\n"
"-----------------------------\n");
for (i = 0; i < CONFIG_SYS_INTC_0_NUM; i++) {
if (act->handler != (interrupt_handler_t*) def_hdlr) { for (i = 0; i < irq_no; i++) {
printf ("%02d %08x %08x %d\n", i, if (act->handler != (interrupt_handler_t *) def_hdlr) {
(int)act->handler, (int)act->arg, act->count); printf("%02d %08x %08x %d\n", i,
(int)act->handler, (int)act->arg,
act->count);
}
act++;
} }
act++; puts("\n");
} else {
puts("Undefined interrupt controller\n");
} }
puts ("\n"); return 0;
return (0);
}
#else
int do_irqinfo (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
{
puts ("Undefined interrupt controller\n");
} }
#endif #endif
#endif

@ -108,7 +108,6 @@ _start:
sh r6, r0, r8 sh r6, r0, r8
#endif #endif
#ifdef CONFIG_SYS_INTC_0
/* interrupt_handler */ /* interrupt_handler */
swi r2, r0, 0x10 /* interrupt - imm opcode */ swi r2, r0, 0x10 /* interrupt - imm opcode */
swi r3, r0, 0x14 /* interrupt - brai opcode */ swi r3, r0, 0x14 /* interrupt - brai opcode */
@ -120,7 +119,6 @@ _start:
sh r7, r0, r8 sh r7, r0, r8
rsubi r8, r10, 0x16 rsubi r8, r10, 0x16
sh r6, r0, r8 sh r6, r0, r8
#endif
/* hardware exception */ /* hardware exception */
swi r2, r0, 0x20 /* hardware exception - imm opcode */ swi r2, r0, 0x20 /* hardware exception - imm opcode */

@ -40,7 +40,6 @@ ulong get_timer (ulong base)
} }
#endif #endif
#ifdef CONFIG_SYS_INTC_0
#ifdef CONFIG_SYS_TIMER_0 #ifdef CONFIG_SYS_TIMER_0
void __udelay(unsigned long usec) void __udelay(unsigned long usec)
{ {
@ -80,7 +79,6 @@ int timer_init (void)
return 0; return 0;
} }
#endif #endif
#endif
/* /*
* This function is derived from PowerPC code (read timebase as long long). * This function is derived from PowerPC code (read timebase as long long).

@ -41,3 +41,6 @@ struct irq_action {
void install_interrupt_handler (int irq, interrupt_handler_t * hdlr, void install_interrupt_handler (int irq, interrupt_handler_t * hdlr,
void *arg); void *arg);
int interrupts_init(void);

@ -33,15 +33,13 @@
#include <serial.h> #include <serial.h>
#include <net.h> #include <net.h>
#include <asm/processor.h> #include <asm/processor.h>
#include <asm/microblaze_intc.h>
DECLARE_GLOBAL_DATA_PTR; DECLARE_GLOBAL_DATA_PTR;
#ifdef CONFIG_SYS_GPIO_0 #ifdef CONFIG_SYS_GPIO_0
extern int gpio_init (void); extern int gpio_init (void);
#endif #endif
#ifdef CONFIG_SYS_INTC_0
extern int interrupts_init (void);
#endif
#ifdef CONFIG_SYS_TIMER_0 #ifdef CONFIG_SYS_TIMER_0
extern int timer_init (void); extern int timer_init (void);
#endif #endif
@ -70,9 +68,7 @@ init_fnc_t *init_sequence[] = {
#ifdef CONFIG_SYS_GPIO_0 #ifdef CONFIG_SYS_GPIO_0
gpio_init, gpio_init,
#endif #endif
#ifdef CONFIG_SYS_INTC_0
interrupts_init, interrupts_init,
#endif
#ifdef CONFIG_SYS_TIMER_0 #ifdef CONFIG_SYS_TIMER_0
timer_init, timer_init,
#endif #endif

@ -102,7 +102,6 @@
/* interrupt controller */ /* interrupt controller */
#ifdef XILINX_INTC_BASEADDR #ifdef XILINX_INTC_BASEADDR
# define CONFIG_SYS_INTC_0 1
# define CONFIG_SYS_INTC_0_ADDR XILINX_INTC_BASEADDR # define CONFIG_SYS_INTC_0_ADDR XILINX_INTC_BASEADDR
# define CONFIG_SYS_INTC_0_NUM XILINX_INTC_NUM_INTR_INPUTS # define CONFIG_SYS_INTC_0_NUM XILINX_INTC_NUM_INTR_INPUTS
#endif #endif

Loading…
Cancel
Save