2005-06-24 07:01:16 +02:00
|
|
|
/*
|
|
|
|
* linux/arch/xtensa/kernel/irq.c
|
|
|
|
*
|
|
|
|
* Xtensa built-in interrupt controller and some generic functions copied
|
|
|
|
* from i386.
|
|
|
|
*
|
2006-12-10 11:18:47 +01:00
|
|
|
* Copyright (C) 2002 - 2006 Tensilica, Inc.
|
2005-06-24 07:01:16 +02:00
|
|
|
* Copyright (C) 1992, 1998 Linus Torvalds, Ingo Molnar
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Chris Zankel <chris@zankel.net>
|
|
|
|
* Kevin Chea
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/seq_file.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/irq.h>
|
|
|
|
#include <linux/kernel_stat.h>
|
|
|
|
|
|
|
|
#include <asm/uaccess.h>
|
|
|
|
#include <asm/platform.h>
|
|
|
|
|
|
|
|
static unsigned int cached_irq_mask;
|
|
|
|
|
|
|
|
atomic_t irq_err_count;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* do_IRQ handles all normal device IRQ's (the special
|
|
|
|
* SMP cross-CPU interrupts have their own specific
|
|
|
|
* handlers).
|
|
|
|
*/
|
|
|
|
|
2006-12-10 11:18:47 +01:00
|
|
|
asmlinkage void do_IRQ(int irq, struct pt_regs *regs)
|
2005-06-24 07:01:16 +02:00
|
|
|
{
|
2006-12-10 11:18:47 +01:00
|
|
|
struct pt_regs *old_regs = set_irq_regs(regs);
|
|
|
|
|
|
|
|
if (irq >= NR_IRQS) {
|
|
|
|
printk(KERN_EMERG "%s: cannot handle IRQ %d\n",
|
2008-07-30 21:48:54 +02:00
|
|
|
__func__, irq);
|
2006-12-10 11:18:47 +01:00
|
|
|
}
|
|
|
|
|
2005-06-24 07:01:16 +02:00
|
|
|
irq_enter();
|
|
|
|
|
|
|
|
#ifdef CONFIG_DEBUG_STACKOVERFLOW
|
|
|
|
/* Debugging check for stack overflow: is there less than 1KB free? */
|
|
|
|
{
|
|
|
|
unsigned long sp;
|
|
|
|
|
|
|
|
__asm__ __volatile__ ("mov %0, a1\n" : "=a" (sp));
|
|
|
|
sp &= THREAD_SIZE - 1;
|
|
|
|
|
|
|
|
if (unlikely(sp < (sizeof(thread_info) + 1024)))
|
|
|
|
printk("Stack overflow in do_IRQ: %ld\n",
|
|
|
|
sp - sizeof(struct thread_info));
|
|
|
|
}
|
|
|
|
#endif
|
2011-02-06 22:10:52 +01:00
|
|
|
generic_handle_irq(irq);
|
2005-06-24 07:01:16 +02:00
|
|
|
|
|
|
|
irq_exit();
|
2006-12-10 11:18:47 +01:00
|
|
|
set_irq_regs(old_regs);
|
2005-06-24 07:01:16 +02:00
|
|
|
}
|
|
|
|
|
2011-03-24 18:28:40 +01:00
|
|
|
int arch_show_interrupts(struct seq_file *p, int prec)
|
2005-06-24 07:01:16 +02:00
|
|
|
{
|
2011-03-24 18:28:40 +01:00
|
|
|
int j;
|
|
|
|
|
|
|
|
seq_printf(p, "%*s: ", prec, "NMI");
|
|
|
|
for_each_online_cpu(j)
|
|
|
|
seq_printf(p, "%10u ", nmi_count(j));
|
|
|
|
seq_putc(p, '\n');
|
|
|
|
seq_printf(p, "%*s: ", prec, "ERR");
|
|
|
|
seq_printf(p, "%10u\n", atomic_read(&irq_err_count));
|
2005-06-24 07:01:16 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-02-06 22:10:52 +01:00
|
|
|
static void xtensa_irq_mask(struct irq_chip *d)
|
2005-06-24 07:01:16 +02:00
|
|
|
{
|
2011-02-06 22:10:52 +01:00
|
|
|
cached_irq_mask &= ~(1 << d->irq);
|
2005-06-24 07:01:16 +02:00
|
|
|
set_sr (cached_irq_mask, INTENABLE);
|
|
|
|
}
|
|
|
|
|
2011-02-06 22:10:52 +01:00
|
|
|
static void xtensa_irq_unmask(struct irq_chip *d)
|
2005-06-24 07:01:16 +02:00
|
|
|
{
|
2011-02-06 22:10:52 +01:00
|
|
|
cached_irq_mask |= 1 << d->irq;
|
2005-06-24 07:01:16 +02:00
|
|
|
set_sr (cached_irq_mask, INTENABLE);
|
|
|
|
}
|
|
|
|
|
2011-02-06 22:10:52 +01:00
|
|
|
static void xtensa_irq_enable(struct irq_chip *d)
|
2009-03-04 16:21:31 +01:00
|
|
|
{
|
2011-02-06 22:10:52 +01:00
|
|
|
variant_irq_enable(d->irq);
|
|
|
|
xtensa_irq_unmask(d->irq);
|
2009-03-04 16:21:31 +01:00
|
|
|
}
|
|
|
|
|
2011-02-06 22:10:52 +01:00
|
|
|
static void xtensa_irq_disable(struct irq_chip *d)
|
2009-03-04 16:21:31 +01:00
|
|
|
{
|
2011-02-06 22:10:52 +01:00
|
|
|
xtensa_irq_mask(d->irq);
|
|
|
|
variant_irq_disable(d->irq);
|
2009-03-04 16:21:31 +01:00
|
|
|
}
|
|
|
|
|
2011-02-06 22:10:52 +01:00
|
|
|
static void xtensa_irq_ack(struct irq_chip *d)
|
2005-06-24 07:01:16 +02:00
|
|
|
{
|
2011-02-06 22:10:52 +01:00
|
|
|
set_sr(1 << d->irq, INTCLEAR);
|
2005-06-24 07:01:16 +02:00
|
|
|
}
|
|
|
|
|
2011-02-06 22:10:52 +01:00
|
|
|
static int xtensa_irq_retrigger(struct irq_chip *d)
|
2005-06-24 07:01:16 +02:00
|
|
|
{
|
2011-02-06 22:10:52 +01:00
|
|
|
set_sr (1 << d->irq, INTSET);
|
2006-12-10 11:18:47 +01:00
|
|
|
return 1;
|
2005-06-24 07:01:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-12-10 11:18:47 +01:00
|
|
|
static struct irq_chip xtensa_irq_chip = {
|
|
|
|
.name = "xtensa",
|
2011-02-06 22:10:52 +01:00
|
|
|
.irq_enable = xtensa_irq_enable,
|
|
|
|
.irq_disable = xtensa_irq_disable,
|
|
|
|
.irq_mask = xtensa_irq_mask,
|
|
|
|
.irq_unmask = xtensa_irq_unmask,
|
|
|
|
.irq_ack = xtensa_irq_ack,
|
|
|
|
.irq_retrigger = xtensa_irq_retrigger,
|
2006-12-10 11:18:47 +01:00
|
|
|
};
|
2005-06-24 07:01:16 +02:00
|
|
|
|
|
|
|
void __init init_IRQ(void)
|
|
|
|
{
|
2006-12-10 11:18:47 +01:00
|
|
|
int index;
|
2005-06-24 07:01:16 +02:00
|
|
|
|
2006-12-10 11:18:47 +01:00
|
|
|
for (index = 0; index < XTENSA_NR_IRQS; index++) {
|
|
|
|
int mask = 1 << index;
|
2005-06-24 07:01:16 +02:00
|
|
|
|
2006-12-10 11:18:47 +01:00
|
|
|
if (mask & XCHAL_INTTYPE_MASK_SOFTWARE)
|
2011-03-24 14:58:43 +01:00
|
|
|
irq_set_chip_and_handler(index, &xtensa_irq_chip,
|
2006-12-10 11:18:47 +01:00
|
|
|
handle_simple_irq);
|
2005-06-24 07:01:16 +02:00
|
|
|
|
2006-12-10 11:18:47 +01:00
|
|
|
else if (mask & XCHAL_INTTYPE_MASK_EXTERN_EDGE)
|
2011-03-24 14:58:43 +01:00
|
|
|
irq_set_chip_and_handler(index, &xtensa_irq_chip,
|
2006-12-10 11:18:47 +01:00
|
|
|
handle_edge_irq);
|
|
|
|
|
|
|
|
else if (mask & XCHAL_INTTYPE_MASK_EXTERN_LEVEL)
|
2011-03-24 14:58:43 +01:00
|
|
|
irq_set_chip_and_handler(index, &xtensa_irq_chip,
|
2006-12-10 11:18:47 +01:00
|
|
|
handle_level_irq);
|
|
|
|
|
|
|
|
else if (mask & XCHAL_INTTYPE_MASK_TIMER)
|
2011-03-24 14:58:43 +01:00
|
|
|
irq_set_chip_and_handler(index, &xtensa_irq_chip,
|
2006-12-10 11:18:47 +01:00
|
|
|
handle_edge_irq);
|
|
|
|
|
|
|
|
else /* XCHAL_INTTYPE_MASK_WRITE_ERROR */
|
|
|
|
/* XCHAL_INTTYPE_MASK_NMI */
|
|
|
|
|
2011-03-24 14:58:43 +01:00
|
|
|
irq_set_chip_and_handler(index, &xtensa_irq_chip,
|
2006-12-10 11:18:47 +01:00
|
|
|
handle_level_irq);
|
|
|
|
}
|
|
|
|
|
|
|
|
cached_irq_mask = 0;
|
2009-05-05 17:03:21 +02:00
|
|
|
|
|
|
|
variant_init_irq();
|
2005-06-24 07:01:16 +02:00
|
|
|
}
|