1818#include <linux/interrupt.h>
1919#include <linux/irq.h>
2020#include <linux/kernel_stat.h>
21+ #include <linux/irqchip.h>
22+ #include <linux/irqchip/xtensa-pic.h>
2123#include <linux/irqdomain.h>
2224#include <linux/of.h>
2325
2426#include <asm/uaccess.h>
2527#include <asm/platform.h>
2628
27- static unsigned int cached_irq_mask ;
28-
2929atomic_t irq_err_count ;
3030
31- static struct irq_domain * root_domain ;
32-
33- /*
34- * do_IRQ handles all normal device IRQ's (the special
35- * SMP cross-CPU interrupts have their own specific
36- * handlers).
37- */
38-
3931asmlinkage void do_IRQ (int hwirq , struct pt_regs * regs )
4032{
4133 struct pt_regs * old_regs = set_irq_regs (regs );
42- int irq = irq_find_mapping (root_domain , hwirq );
34+ int irq = irq_find_mapping (NULL , hwirq );
4335
4436 if (hwirq >= NR_IRQS ) {
4537 printk (KERN_EMERG "%s: cannot handle IRQ %d\n" ,
@@ -74,83 +66,57 @@ int arch_show_interrupts(struct seq_file *p, int prec)
7466 return 0 ;
7567}
7668
77- static void xtensa_irq_mask (struct irq_data * d )
78- {
79- cached_irq_mask &= ~(1 << d -> hwirq );
80- set_sr (cached_irq_mask , intenable );
81- }
82-
83- static void xtensa_irq_unmask (struct irq_data * d )
84- {
85- cached_irq_mask |= 1 << d -> hwirq ;
86- set_sr (cached_irq_mask , intenable );
87- }
88-
89- static void xtensa_irq_enable (struct irq_data * d )
90- {
91- variant_irq_enable (d -> hwirq );
92- xtensa_irq_unmask (d );
93- }
94-
95- static void xtensa_irq_disable (struct irq_data * d )
96- {
97- xtensa_irq_mask (d );
98- variant_irq_disable (d -> hwirq );
99- }
100-
101- static void xtensa_irq_ack (struct irq_data * d )
102- {
103- set_sr (1 << d -> hwirq , intclear );
104- }
105-
106- static int xtensa_irq_retrigger (struct irq_data * d )
69+ int xtensa_irq_domain_xlate (const u32 * intspec , unsigned int intsize ,
70+ unsigned long int_irq , unsigned long ext_irq ,
71+ unsigned long * out_hwirq , unsigned int * out_type )
10772{
108- set_sr (1 << d -> hwirq , intset );
109- return 1 ;
73+ if (WARN_ON (intsize < 1 || intsize > 2 ))
74+ return - EINVAL ;
75+ if (intsize == 2 && intspec [1 ] == 1 ) {
76+ int_irq = xtensa_map_ext_irq (ext_irq );
77+ if (int_irq < XCHAL_NUM_INTERRUPTS )
78+ * out_hwirq = int_irq ;
79+ else
80+ return - EINVAL ;
81+ } else {
82+ * out_hwirq = int_irq ;
83+ }
84+ * out_type = IRQ_TYPE_NONE ;
85+ return 0 ;
11086}
11187
112- static struct irq_chip xtensa_irq_chip = {
113- .name = "xtensa" ,
114- .irq_enable = xtensa_irq_enable ,
115- .irq_disable = xtensa_irq_disable ,
116- .irq_mask = xtensa_irq_mask ,
117- .irq_unmask = xtensa_irq_unmask ,
118- .irq_ack = xtensa_irq_ack ,
119- .irq_retrigger = xtensa_irq_retrigger ,
120- };
121-
122- static int xtensa_irq_map (struct irq_domain * d , unsigned int irq ,
88+ int xtensa_irq_map (struct irq_domain * d , unsigned int irq ,
12389 irq_hw_number_t hw )
12490{
91+ struct irq_chip * irq_chip = d -> host_data ;
12592 u32 mask = 1 << hw ;
12693
12794 if (mask & XCHAL_INTTYPE_MASK_SOFTWARE ) {
128- irq_set_chip_and_handler_name (irq , & xtensa_irq_chip ,
95+ irq_set_chip_and_handler_name (irq , irq_chip ,
12996 handle_simple_irq , "level" );
13097 irq_set_status_flags (irq , IRQ_LEVEL );
13198 } else if (mask & XCHAL_INTTYPE_MASK_EXTERN_EDGE ) {
132- irq_set_chip_and_handler_name (irq , & xtensa_irq_chip ,
99+ irq_set_chip_and_handler_name (irq , irq_chip ,
133100 handle_edge_irq , "edge" );
134101 irq_clear_status_flags (irq , IRQ_LEVEL );
135102 } else if (mask & XCHAL_INTTYPE_MASK_EXTERN_LEVEL ) {
136- irq_set_chip_and_handler_name (irq , & xtensa_irq_chip ,
103+ irq_set_chip_and_handler_name (irq , irq_chip ,
137104 handle_level_irq , "level" );
138105 irq_set_status_flags (irq , IRQ_LEVEL );
139106 } else if (mask & XCHAL_INTTYPE_MASK_TIMER ) {
140- irq_set_chip_and_handler_name (irq , & xtensa_irq_chip ,
141- handle_edge_irq , "edge " );
107+ irq_set_chip_and_handler_name (irq , irq_chip ,
108+ handle_percpu_irq , "timer " );
142109 irq_clear_status_flags (irq , IRQ_LEVEL );
143110 } else {/* XCHAL_INTTYPE_MASK_WRITE_ERROR */
144111 /* XCHAL_INTTYPE_MASK_NMI */
145-
146- irq_set_chip_and_handler_name (irq , & xtensa_irq_chip ,
112+ irq_set_chip_and_handler_name (irq , irq_chip ,
147113 handle_level_irq , "level" );
148114 irq_set_status_flags (irq , IRQ_LEVEL );
149115 }
150116 return 0 ;
151117}
152118
153- static unsigned map_ext_irq (unsigned ext_irq )
119+ unsigned xtensa_map_ext_irq (unsigned ext_irq )
154120{
155121 unsigned mask = XCHAL_INTTYPE_MASK_EXTERN_EDGE |
156122 XCHAL_INTTYPE_MASK_EXTERN_LEVEL ;
@@ -163,55 +129,12 @@ static unsigned map_ext_irq(unsigned ext_irq)
163129 return XCHAL_NUM_INTERRUPTS ;
164130}
165131
166- /*
167- * Device Tree IRQ specifier translation function which works with one or
168- * two cell bindings. First cell value maps directly to the hwirq number.
169- * Second cell if present specifies whether hwirq number is external (1) or
170- * internal (0).
171- */
172- int xtensa_irq_domain_xlate (struct irq_domain * d , struct device_node * ctrlr ,
173- const u32 * intspec , unsigned int intsize ,
174- unsigned long * out_hwirq , unsigned int * out_type )
175- {
176- if (WARN_ON (intsize < 1 || intsize > 2 ))
177- return - EINVAL ;
178- if (intsize == 2 && intspec [1 ] == 1 ) {
179- unsigned int_irq = map_ext_irq (intspec [0 ]);
180- if (int_irq < XCHAL_NUM_INTERRUPTS )
181- * out_hwirq = int_irq ;
182- else
183- return - EINVAL ;
184- } else {
185- * out_hwirq = intspec [0 ];
186- }
187- * out_type = IRQ_TYPE_NONE ;
188- return 0 ;
189- }
190-
191- static const struct irq_domain_ops xtensa_irq_domain_ops = {
192- .xlate = xtensa_irq_domain_xlate ,
193- .map = xtensa_irq_map ,
194- };
195-
196132void __init init_IRQ (void )
197133{
198- struct device_node * intc = NULL ;
199-
200- cached_irq_mask = 0 ;
201- set_sr (~0 , intclear );
202-
203134#ifdef CONFIG_OF
204- /* The interrupt controller device node is mandatory */
205- intc = of_find_compatible_node (NULL , NULL , "xtensa,pic" );
206- BUG_ON (!intc );
207-
208- root_domain = irq_domain_add_linear (intc , NR_IRQS ,
209- & xtensa_irq_domain_ops , NULL );
135+ irqchip_init ();
210136#else
211- root_domain = irq_domain_add_legacy (intc , NR_IRQS , 0 , 0 ,
212- & xtensa_irq_domain_ops , NULL );
137+ xtensa_pic_init_legacy (NULL );
213138#endif
214- irq_set_default_host (root_domain );
215-
216139 variant_init_irq ();
217140}
0 commit comments