1
2
3
4
5
6
7
8
9
10#include <linux/interrupt.h>
11#include <linux/module.h>
12#include <linux/of.h>
13#include <linux/irqdomain.h>
14#include <linux/irqchip.h>
15#include "../../drivers/irqchip/irqchip.h"
16#include <asm/sections.h>
17#include <asm/irq.h>
18#include <asm/mach_desc.h>
19
20
21
22
23
24
25
26
27
28void arc_init_IRQ(void)
29{
30 int level_mask = 0;
31
32
33 level_mask |= IS_ENABLED(CONFIG_ARC_IRQ3_LV2) << 3;
34 level_mask |= IS_ENABLED(CONFIG_ARC_IRQ5_LV2) << 5;
35 level_mask |= IS_ENABLED(CONFIG_ARC_IRQ6_LV2) << 6;
36
37
38
39
40
41 write_aux_reg(AUX_IRQ_LEV, level_mask);
42
43 if (level_mask)
44 pr_info("Level-2 interrupts bitset %x\n", level_mask);
45}
46
47
48
49
50
51
52
53
54
55
56
57
58static void arc_irq_mask(struct irq_data *data)
59{
60 unsigned int ienb;
61
62 ienb = read_aux_reg(AUX_IENABLE);
63 ienb &= ~(1 << data->irq);
64 write_aux_reg(AUX_IENABLE, ienb);
65}
66
67static void arc_irq_unmask(struct irq_data *data)
68{
69 unsigned int ienb;
70
71 ienb = read_aux_reg(AUX_IENABLE);
72 ienb |= (1 << data->irq);
73 write_aux_reg(AUX_IENABLE, ienb);
74}
75
76static struct irq_chip onchip_intc = {
77 .name = "ARC In-core Intc",
78 .irq_mask = arc_irq_mask,
79 .irq_unmask = arc_irq_unmask,
80};
81
82static int arc_intc_domain_map(struct irq_domain *d, unsigned int irq,
83 irq_hw_number_t hw)
84{
85 if (irq == TIMER0_IRQ)
86 irq_set_chip_and_handler(irq, &onchip_intc, handle_percpu_irq);
87 else
88 irq_set_chip_and_handler(irq, &onchip_intc, handle_level_irq);
89
90 return 0;
91}
92
93static const struct irq_domain_ops arc_intc_domain_ops = {
94 .xlate = irq_domain_xlate_onecell,
95 .map = arc_intc_domain_map,
96};
97
98static struct irq_domain *root_domain;
99
100static int __init
101init_onchip_IRQ(struct device_node *intc, struct device_node *parent)
102{
103 if (parent)
104 panic("DeviceTree incore intc not a root irq controller\n");
105
106 root_domain = irq_domain_add_legacy(intc, NR_CPU_IRQS, 0, 0,
107 &arc_intc_domain_ops, NULL);
108
109 if (!root_domain)
110 panic("root irq domain not avail\n");
111
112
113 irq_set_default_host(root_domain);
114
115 return 0;
116}
117
118IRQCHIP_DECLARE(arc_intc, "snps,arc700-intc", init_onchip_IRQ);
119
120
121
122
123
124
125
126void __init init_IRQ(void)
127{
128
129 if (machine_desc->init_irq)
130 machine_desc->init_irq();
131
132
133 irqchip_init();
134
135#ifdef CONFIG_SMP
136
137 if (machine_desc->init_smp)
138 machine_desc->init_smp(smp_processor_id());
139#endif
140}
141
142
143
144
145
146void arch_do_IRQ(unsigned int irq, struct pt_regs *regs)
147{
148 struct pt_regs *old_regs = set_irq_regs(regs);
149
150 irq_enter();
151 generic_handle_irq(irq);
152 irq_exit();
153 set_irq_regs(old_regs);
154}
155
156void arc_request_percpu_irq(int irq, int cpu,
157 irqreturn_t (*isr)(int irq, void *dev),
158 const char *irq_nm,
159 void *percpu_dev)
160{
161
162 if (!cpu) {
163 int rc;
164
165
166
167
168
169
170
171 irq_set_percpu_devid(irq);
172 irq_modify_status(irq, IRQ_NOAUTOEN, 0);
173
174 rc = request_percpu_irq(irq, isr, irq_nm, percpu_dev);
175 if (rc)
176 panic("Percpu IRQ request failed for %d\n", irq);
177 }
178
179 enable_percpu_irq(irq, 0);
180}
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206#ifdef CONFIG_ARC_COMPACT_IRQ_LEVELS
207
208void arch_local_irq_enable(void)
209{
210
211 unsigned long flags;
212 flags = arch_local_save_flags();
213
214
215 flags |= (STATUS_E1_MASK | STATUS_E2_MASK);
216
217
218 if (in_irq()) {
219
220
221
222
223
224
225 if (flags & STATUS_A2_MASK)
226 flags &= ~(STATUS_E1_MASK | STATUS_E2_MASK);
227
228
229 else if (flags & STATUS_A1_MASK)
230 flags &= ~(STATUS_E1_MASK);
231 }
232
233
234
235 else if (in_softirq()) {
236
237
238
239
240
241
242
243
244
245
246
247
248
249 struct pt_regs *pt = get_irq_regs();
250 if ((flags & STATUS_A2_MASK) && pt &&
251 (pt->status32 & STATUS_A1_MASK)) {
252
253 flags &= ~(STATUS_E1_MASK);
254 }
255 }
256
257 arch_local_irq_restore(flags);
258}
259
260#else
261
262
263
264
265
266void arch_local_irq_enable(void)
267{
268 unsigned long flags;
269
270
271
272
273
274 if (in_irq()) {
275 WARN_ONCE(1, "IRQ enabled from hard-isr");
276 return;
277 }
278
279 flags = arch_local_save_flags();
280 flags |= (STATUS_E1_MASK | STATUS_E2_MASK);
281 arch_local_irq_restore(flags);
282}
283#endif
284EXPORT_SYMBOL(arch_local_irq_enable);
285