Staging: Merge staging-next into Linus's tree
[sfrench/cifs-2.6.git] / arch / microblaze / kernel / irq.c
1 /*
2  * Copyright (C) 2007-2009 Michal Simek <monstr@monstr.eu>
3  * Copyright (C) 2007-2009 PetaLogix
4  * Copyright (C) 2006 Atmark Techno, Inc.
5  *
6  * This file is subject to the terms and conditions of the GNU General Public
7  * License. See the file "COPYING" in the main directory of this archive
8  * for more details.
9  */
10
11 #include <linux/init.h>
12 #include <linux/ftrace.h>
13 #include <linux/kernel.h>
14 #include <linux/hardirq.h>
15 #include <linux/interrupt.h>
16 #include <linux/irqflags.h>
17 #include <linux/seq_file.h>
18 #include <linux/kernel_stat.h>
19 #include <linux/irq.h>
20
21 #include <asm/prom.h>
22
23 unsigned int irq_of_parse_and_map(struct device_node *dev, int index)
24 {
25         struct of_irq oirq;
26
27         if (of_irq_map_one(dev, index, &oirq))
28                 return NO_IRQ;
29
30         return oirq.specifier[0];
31 }
32 EXPORT_SYMBOL_GPL(irq_of_parse_and_map);
33
34 static u32 concurrent_irq;
35
36 void __irq_entry do_IRQ(struct pt_regs *regs)
37 {
38         unsigned int irq;
39         struct pt_regs *old_regs = set_irq_regs(regs);
40         trace_hardirqs_off();
41
42         irq_enter();
43         irq = get_irq(regs);
44 next_irq:
45         BUG_ON(irq == -1U);
46         generic_handle_irq(irq);
47
48         irq = get_irq(regs);
49         if (irq != -1U) {
50                 pr_debug("next irq: %d\n", irq);
51                 ++concurrent_irq;
52                 goto next_irq;
53         }
54
55         irq_exit();
56         set_irq_regs(old_regs);
57         trace_hardirqs_on();
58 }
59
60 int show_interrupts(struct seq_file *p, void *v)
61 {
62         int i = *(loff_t *) v, j;
63         struct irqaction *action;
64         unsigned long flags;
65
66         if (i == 0) {
67                 seq_printf(p, "         ");
68                 for_each_online_cpu(j)
69                         seq_printf(p, "CPU%-8d", j);
70                 seq_putc(p, '\n');
71         }
72
73         if (i < nr_irq) {
74                 raw_spin_lock_irqsave(&irq_desc[i].lock, flags);
75                 action = irq_desc[i].action;
76                 if (!action)
77                         goto skip;
78                 seq_printf(p, "%3d: ", i);
79 #ifndef CONFIG_SMP
80                 seq_printf(p, "%10u ", kstat_irqs(i));
81 #else
82                 for_each_online_cpu(j)
83                         seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
84 #endif
85                 seq_printf(p, " %8s", irq_desc[i].status &
86                                         IRQ_LEVEL ? "level" : "edge");
87                 seq_printf(p, " %8s", irq_desc[i].chip->name);
88                 seq_printf(p, "  %s", action->name);
89
90                 for (action = action->next; action; action = action->next)
91                         seq_printf(p, ", %s", action->name);
92
93                 seq_putc(p, '\n');
94 skip:
95                 raw_spin_unlock_irqrestore(&irq_desc[i].lock, flags);
96         }
97         return 0;
98 }
99
100 /* MS: There is no any advance mapping mechanism. We are using simple 32bit
101   intc without any cascades or any connection that's why mapping is 1:1 */
102 unsigned int irq_create_mapping(struct irq_host *host, irq_hw_number_t hwirq)
103 {
104         return hwirq;
105 }
106 EXPORT_SYMBOL_GPL(irq_create_mapping);
107
108 unsigned int irq_create_of_mapping(struct device_node *controller,
109                                         u32 *intspec, unsigned int intsize)
110 {
111         return intspec[0];
112 }
113 EXPORT_SYMBOL_GPL(irq_create_of_mapping);