2 * linux/arch/xtensa/kernel/irq.c
4 * Xtensa built-in interrupt controller and some generic functions copied
7 * Copyright (C) 2002 - 2006 Tensilica, Inc.
8 * Copyright (C) 1992, 1998 Linus Torvalds, Ingo Molnar
11 * Chris Zankel <chris@zankel.net>
16 #include <linux/module.h>
17 #include <linux/seq_file.h>
18 #include <linux/interrupt.h>
19 #include <linux/irq.h>
20 #include <linux/kernel_stat.h>
22 #include <asm/uaccess.h>
23 #include <asm/platform.h>
25 static unsigned int cached_irq_mask
;
27 atomic_t irq_err_count
;
30 * do_IRQ handles all normal device IRQ's (the special
31 * SMP cross-CPU interrupts have their own specific
35 asmlinkage
void do_IRQ(int irq
, struct pt_regs
*regs
)
37 struct pt_regs
*old_regs
= set_irq_regs(regs
);
40 printk(KERN_EMERG
"%s: cannot handle IRQ %d\n",
46 #ifdef CONFIG_DEBUG_STACKOVERFLOW
47 /* Debugging check for stack overflow: is there less than 1KB free? */
51 __asm__
__volatile__ ("mov %0, a1\n" : "=a" (sp
));
52 sp
&= THREAD_SIZE
- 1;
54 if (unlikely(sp
< (sizeof(thread_info
) + 1024)))
55 printk("Stack overflow in do_IRQ: %ld\n",
56 sp
- sizeof(struct thread_info
));
59 generic_handle_irq(irq
);
62 set_irq_regs(old_regs
);
65 int arch_show_interrupts(struct seq_file
*p
, int prec
)
67 seq_printf(p
, "%*s: ", prec
, "ERR");
68 seq_printf(p
, "%10u\n", atomic_read(&irq_err_count
));
72 static void xtensa_irq_mask(struct irq_data
*d
)
74 cached_irq_mask
&= ~(1 << d
->irq
);
75 set_sr (cached_irq_mask
, INTENABLE
);
78 static void xtensa_irq_unmask(struct irq_data
*d
)
80 cached_irq_mask
|= 1 << d
->irq
;
81 set_sr (cached_irq_mask
, INTENABLE
);
84 static void xtensa_irq_enable(struct irq_data
*d
)
86 variant_irq_enable(d
->irq
);
87 xtensa_irq_unmask(d
->irq
);
90 static void xtensa_irq_disable(struct irq_data
*d
)
92 xtensa_irq_mask(d
->irq
);
93 variant_irq_disable(d
->irq
);
96 static void xtensa_irq_ack(struct irq_data
*d
)
98 set_sr(1 << d
->irq
, INTCLEAR
);
101 static int xtensa_irq_retrigger(struct irq_data
*d
)
103 set_sr (1 << d
->irq
, INTSET
);
108 static struct irq_chip xtensa_irq_chip
= {
110 .irq_enable
= xtensa_irq_enable
,
111 .irq_disable
= xtensa_irq_disable
,
112 .irq_mask
= xtensa_irq_mask
,
113 .irq_unmask
= xtensa_irq_unmask
,
114 .irq_ack
= xtensa_irq_ack
,
115 .irq_retrigger
= xtensa_irq_retrigger
,
118 void __init
init_IRQ(void)
122 for (index
= 0; index
< XTENSA_NR_IRQS
; index
++) {
123 int mask
= 1 << index
;
125 if (mask
& XCHAL_INTTYPE_MASK_SOFTWARE
)
126 irq_set_chip_and_handler(index
, &xtensa_irq_chip
,
129 else if (mask
& XCHAL_INTTYPE_MASK_EXTERN_EDGE
)
130 irq_set_chip_and_handler(index
, &xtensa_irq_chip
,
133 else if (mask
& XCHAL_INTTYPE_MASK_EXTERN_LEVEL
)
134 irq_set_chip_and_handler(index
, &xtensa_irq_chip
,
137 else if (mask
& XCHAL_INTTYPE_MASK_TIMER
)
138 irq_set_chip_and_handler(index
, &xtensa_irq_chip
,
141 else /* XCHAL_INTTYPE_MASK_WRITE_ERROR */
142 /* XCHAL_INTTYPE_MASK_NMI */
144 irq_set_chip_and_handler(index
, &xtensa_irq_chip
,