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 <asm/irq.h>
16
17
18
19
20
21
22
23
24
25void arc_init_IRQ(void)
26{
27 int level_mask = 0;
28
29
30 level_mask |= IS_ENABLED(CONFIG_ARC_IRQ3_LV2) << 3;
31 level_mask |= IS_ENABLED(CONFIG_ARC_IRQ5_LV2) << 5;
32 level_mask |= IS_ENABLED(CONFIG_ARC_IRQ6_LV2) << 6;
33
34
35
36
37
38 write_aux_reg(AUX_IRQ_LEV, level_mask);
39
40 if (level_mask)
41 pr_info("Level-2 interrupts bitset %x\n", level_mask);
42}
43
44
45
46
47
48
49
50
51
52
53
54
55static void arc_irq_mask(struct irq_data *data)
56{
57 unsigned int ienb;
58
59 ienb = read_aux_reg(AUX_IENABLE);
60 ienb &= ~(1 << data->irq);
61 write_aux_reg(AUX_IENABLE, ienb);
62}
63
64static void arc_irq_unmask(struct irq_data *data)
65{
66 unsigned int ienb;
67
68 ienb = read_aux_reg(AUX_IENABLE);
69 ienb |= (1 << data->irq);
70 write_aux_reg(AUX_IENABLE, ienb);
71}
72
73static struct irq_chip onchip_intc = {
74 .name = "ARC In-core Intc",
75 .irq_mask = arc_irq_mask,
76 .irq_unmask = arc_irq_unmask,
77};
78
79static int arc_intc_domain_map(struct irq_domain *d, unsigned int irq,
80 irq_hw_number_t hw)
81{
82 switch (irq) {
83 case TIMER0_IRQ:
84 irq_set_chip_and_handler(irq, &onchip_intc, handle_percpu_irq);
85 break;
86 default:
87 irq_set_chip_and_handler(irq, &onchip_intc, handle_level_irq);
88 }
89 return 0;
90}
91
92static const struct irq_domain_ops arc_intc_domain_ops = {
93 .xlate = irq_domain_xlate_onecell,
94 .map = arc_intc_domain_map,
95};
96
97static struct irq_domain *root_domain;
98
99static int __init
100init_onchip_IRQ(struct device_node *intc, struct device_node *parent)
101{
102 if (parent)
103 panic("DeviceTree incore intc not a root irq controller\n");
104
105 root_domain = irq_domain_add_legacy(intc, NR_CPU_IRQS, 0, 0,
106 &arc_intc_domain_ops, NULL);
107
108 if (!root_domain)
109 panic("root irq domain not avail\n");
110
111
112 irq_set_default_host(root_domain);
113
114 return 0;
115}
116
117IRQCHIP_DECLARE(arc_intc, "snps,arc700-intc", init_onchip_IRQ);
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143#ifdef CONFIG_ARC_COMPACT_IRQ_LEVELS
144
145void arch_local_irq_enable(void)
146{
147 unsigned long flags = arch_local_save_flags();
148
149 if (flags & STATUS_A2_MASK)
150 flags |= STATUS_E2_MASK;
151 else if (flags & STATUS_A1_MASK)
152 flags |= STATUS_E1_MASK;
153
154 arch_local_irq_restore(flags);
155}
156
157EXPORT_SYMBOL(arch_local_irq_enable);
158#endif
159