2005-06-24 05:01:16 +00:00
|
|
|
/*
|
|
|
|
* linux/arch/xtensa/kernel/irq.c
|
|
|
|
*
|
|
|
|
* Xtensa built-in interrupt controller and some generic functions copied
|
|
|
|
* from i386.
|
|
|
|
*
|
2006-12-10 10:18:47 +00:00
|
|
|
* Copyright (C) 2002 - 2006 Tensilica, Inc.
|
2005-06-24 05:01:16 +00: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 10:18:47 +00:00
|
|
|
asmlinkage void do_IRQ(int irq, struct pt_regs *regs)
|
2005-06-24 05:01:16 +00:00
|
|
|
{
|
2006-12-10 10:18:47 +00: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 19:48:54 +00:00
|
|
|
__func__, irq);
|
2006-12-10 10:18:47 +00:00
|
|
|
}
|
|
|
|
|
2005-06-24 05:01:16 +00: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 21:10:52 +00:00
|
|
|
generic_handle_irq(irq);
|
2005-06-24 05:01:16 +00:00
|
|
|
|
|
|
|
irq_exit();
|
2006-12-10 10:18:47 +00:00
|
|
|
set_irq_regs(old_regs);
|
2005-06-24 05:01:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Generic, controller-independent functions:
|
|
|
|
*/
|
|
|
|
|
|
|
|
int show_interrupts(struct seq_file *p, void *v)
|
|
|
|
{
|
|
|
|
int i = *(loff_t *) v, j;
|
|
|
|
struct irqaction * action;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
if (i == 0) {
|
|
|
|
seq_printf(p, " ");
|
2006-03-23 11:01:05 +00:00
|
|
|
for_each_online_cpu(j)
|
|
|
|
seq_printf(p, "CPU%d ",j);
|
2005-06-24 05:01:16 +00:00
|
|
|
seq_putc(p, '\n');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i < NR_IRQS) {
|
2009-11-17 15:46:45 +00:00
|
|
|
raw_spin_lock_irqsave(&irq_desc[i].lock, flags);
|
2005-06-24 05:01:16 +00:00
|
|
|
action = irq_desc[i].action;
|
|
|
|
if (!action)
|
|
|
|
goto skip;
|
|
|
|
seq_printf(p, "%3d: ",i);
|
|
|
|
#ifndef CONFIG_SMP
|
|
|
|
seq_printf(p, "%10u ", kstat_irqs(i));
|
|
|
|
#else
|
2006-03-23 11:01:05 +00:00
|
|
|
for_each_online_cpu(j)
|
2009-01-11 08:29:15 +00:00
|
|
|
seq_printf(p, "%10u ", kstat_irqs_cpu(i, j));
|
2005-06-24 05:01:16 +00:00
|
|
|
#endif
|
2010-09-23 16:40:07 +00:00
|
|
|
seq_printf(p, " %14s", irq_desc[i].chip->name);
|
2005-06-24 05:01:16 +00:00
|
|
|
seq_printf(p, " %s", action->name);
|
|
|
|
|
|
|
|
for (action=action->next; action; action = action->next)
|
|
|
|
seq_printf(p, ", %s", action->name);
|
|
|
|
|
|
|
|
seq_putc(p, '\n');
|
|
|
|
skip:
|
2009-11-17 15:46:45 +00:00
|
|
|
raw_spin_unlock_irqrestore(&irq_desc[i].lock, flags);
|
2005-06-24 05:01:16 +00:00
|
|
|
} else if (i == NR_IRQS) {
|
|
|
|
seq_printf(p, "NMI: ");
|
2006-03-23 11:01:05 +00:00
|
|
|
for_each_online_cpu(j)
|
|
|
|
seq_printf(p, "%10u ", nmi_count(j));
|
2005-06-24 05:01:16 +00:00
|
|
|
seq_putc(p, '\n');
|
|
|
|
seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count));
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-02-06 21:10:52 +00:00
|
|
|
static void xtensa_irq_mask(struct irq_chip *d)
|
2005-06-24 05:01:16 +00:00
|
|
|
{
|
2011-02-06 21:10:52 +00:00
|
|
|
cached_irq_mask &= ~(1 << d->irq);
|
2005-06-24 05:01:16 +00:00
|
|
|
set_sr (cached_irq_mask, INTENABLE);
|
|
|
|
}
|
|
|
|
|
2011-02-06 21:10:52 +00:00
|
|
|
static void xtensa_irq_unmask(struct irq_chip *d)
|
2005-06-24 05:01:16 +00:00
|
|
|
{
|
2011-02-06 21:10:52 +00:00
|
|
|
cached_irq_mask |= 1 << d->irq;
|
2005-06-24 05:01:16 +00:00
|
|
|
set_sr (cached_irq_mask, INTENABLE);
|
|
|
|
}
|
|
|
|
|
2011-02-06 21:10:52 +00:00
|
|
|
static void xtensa_irq_enable(struct irq_chip *d)
|
2009-03-04 15:21:31 +00:00
|
|
|
{
|
2011-02-06 21:10:52 +00:00
|
|
|
variant_irq_enable(d->irq);
|
|
|
|
xtensa_irq_unmask(d->irq);
|
2009-03-04 15:21:31 +00:00
|
|
|
}
|
|
|
|
|
2011-02-06 21:10:52 +00:00
|
|
|
static void xtensa_irq_disable(struct irq_chip *d)
|
2009-03-04 15:21:31 +00:00
|
|
|
{
|
2011-02-06 21:10:52 +00:00
|
|
|
xtensa_irq_mask(d->irq);
|
|
|
|
variant_irq_disable(d->irq);
|
2009-03-04 15:21:31 +00:00
|
|
|
}
|
|
|
|
|
2011-02-06 21:10:52 +00:00
|
|
|
static void xtensa_irq_ack(struct irq_chip *d)
|
2005-06-24 05:01:16 +00:00
|
|
|
{
|
2011-02-06 21:10:52 +00:00
|
|
|
set_sr(1 << d->irq, INTCLEAR);
|
2005-06-24 05:01:16 +00:00
|
|
|
}
|
|
|
|
|
2011-02-06 21:10:52 +00:00
|
|
|
static int xtensa_irq_retrigger(struct irq_chip *d)
|
2005-06-24 05:01:16 +00:00
|
|
|
{
|
2011-02-06 21:10:52 +00:00
|
|
|
set_sr (1 << d->irq, INTSET);
|
2006-12-10 10:18:47 +00:00
|
|
|
return 1;
|
2005-06-24 05:01:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-12-10 10:18:47 +00:00
|
|
|
static struct irq_chip xtensa_irq_chip = {
|
|
|
|
.name = "xtensa",
|
2011-02-06 21:10:52 +00: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 10:18:47 +00:00
|
|
|
};
|
2005-06-24 05:01:16 +00:00
|
|
|
|
|
|
|
void __init init_IRQ(void)
|
|
|
|
{
|
2006-12-10 10:18:47 +00:00
|
|
|
int index;
|
2005-06-24 05:01:16 +00:00
|
|
|
|
2006-12-10 10:18:47 +00:00
|
|
|
for (index = 0; index < XTENSA_NR_IRQS; index++) {
|
|
|
|
int mask = 1 << index;
|
2005-06-24 05:01:16 +00:00
|
|
|
|
2006-12-10 10:18:47 +00:00
|
|
|
if (mask & XCHAL_INTTYPE_MASK_SOFTWARE)
|
|
|
|
set_irq_chip_and_handler(index, &xtensa_irq_chip,
|
|
|
|
handle_simple_irq);
|
2005-06-24 05:01:16 +00:00
|
|
|
|
2006-12-10 10:18:47 +00:00
|
|
|
else if (mask & XCHAL_INTTYPE_MASK_EXTERN_EDGE)
|
|
|
|
set_irq_chip_and_handler(index, &xtensa_irq_chip,
|
|
|
|
handle_edge_irq);
|
|
|
|
|
|
|
|
else if (mask & XCHAL_INTTYPE_MASK_EXTERN_LEVEL)
|
|
|
|
set_irq_chip_and_handler(index, &xtensa_irq_chip,
|
|
|
|
handle_level_irq);
|
|
|
|
|
|
|
|
else if (mask & XCHAL_INTTYPE_MASK_TIMER)
|
|
|
|
set_irq_chip_and_handler(index, &xtensa_irq_chip,
|
|
|
|
handle_edge_irq);
|
|
|
|
|
|
|
|
else /* XCHAL_INTTYPE_MASK_WRITE_ERROR */
|
|
|
|
/* XCHAL_INTTYPE_MASK_NMI */
|
|
|
|
|
|
|
|
set_irq_chip_and_handler(index, &xtensa_irq_chip,
|
|
|
|
handle_level_irq);
|
|
|
|
}
|
|
|
|
|
|
|
|
cached_irq_mask = 0;
|
2009-05-05 15:03:21 +00:00
|
|
|
|
|
|
|
variant_init_irq();
|
2005-06-24 05:01:16 +00:00
|
|
|
}
|