aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/irqchip/irq-mips-gic.c
diff options
context:
space:
mode:
authorAndrew Bresticker <abrestic@chromium.org>2014-10-20 15:03:52 -0400
committerRalf Baechle <ralf@linux-mips.org>2014-11-24 01:44:58 -0500
commit5f68fea09ef1bc36e16d1059a84cf8b833cfb789 (patch)
tree30062cbcdde7aa9a1f8def192fdcdc685d52f5d1 /drivers/irqchip/irq-mips-gic.c
parent609ead041b4c607163e7240a8674b608df31d2a8 (diff)
irqchip: mips-gic: Use proper iomem accessors
Get rid of the ugly GICREAD/GICWRITE/GICBIS macros and use proper iomem accessors instead. Since the GIC registers are not directly accessed outside of the GIC driver any more, make gic_base static and move all the GIC register manipulation macros out of gic.h, converting them to static inline functions. Signed-off-by: Andrew Bresticker <abrestic@chromium.org> Cc: Daniel Lezcano <daniel.lezcano@linaro.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Jason Cooper <jason@lakedaemon.net> Cc: Paul Burton <paul.burton@imgtec.com> Cc: Qais Yousef <qais.yousef@imgtec.com> Cc: John Crispin <blogic@openwrt.org> Cc: linux-mips@linux-mips.org Cc: linux-kernel@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/8127/ Patchwork: https://patchwork.linux-mips.org/patch/8229/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'drivers/irqchip/irq-mips-gic.c')
-rw-r--r--drivers/irqchip/irq-mips-gic.c206
1 files changed, 135 insertions, 71 deletions
diff --git a/drivers/irqchip/irq-mips-gic.c b/drivers/irqchip/irq-mips-gic.c
index b5fad6377736..88086d7e7c51 100644
--- a/drivers/irqchip/irq-mips-gic.c
+++ b/drivers/irqchip/irq-mips-gic.c
@@ -23,7 +23,6 @@
23 23
24unsigned int gic_frequency; 24unsigned int gic_frequency;
25unsigned int gic_present; 25unsigned int gic_present;
26unsigned long _gic_base;
27 26
28struct gic_pcpu_mask { 27struct gic_pcpu_mask {
29 DECLARE_BITMAP(pcpu_mask, GIC_MAX_INTRS); 28 DECLARE_BITMAP(pcpu_mask, GIC_MAX_INTRS);
@@ -37,6 +36,7 @@ struct gic_intrmask_regs {
37 DECLARE_BITMAP(intrmask, GIC_MAX_INTRS); 36 DECLARE_BITMAP(intrmask, GIC_MAX_INTRS);
38}; 37};
39 38
39static void __iomem *gic_base;
40static struct gic_pcpu_mask pcpu_masks[NR_CPUS]; 40static struct gic_pcpu_mask pcpu_masks[NR_CPUS];
41static struct gic_pending_regs pending_regs[NR_CPUS]; 41static struct gic_pending_regs pending_regs[NR_CPUS];
42static struct gic_intrmask_regs intrmask_regs[NR_CPUS]; 42static struct gic_intrmask_regs intrmask_regs[NR_CPUS];
@@ -49,15 +49,82 @@ static struct irq_chip gic_level_irq_controller, gic_edge_irq_controller;
49 49
50static void __gic_irq_dispatch(void); 50static void __gic_irq_dispatch(void);
51 51
52static inline unsigned int gic_read(unsigned int reg)
53{
54 return __raw_readl(gic_base + reg);
55}
56
57static inline void gic_write(unsigned int reg, unsigned int val)
58{
59 __raw_writel(val, gic_base + reg);
60}
61
62static inline void gic_update_bits(unsigned int reg, unsigned int mask,
63 unsigned int val)
64{
65 unsigned int regval;
66
67 regval = gic_read(reg);
68 regval &= ~mask;
69 regval |= val;
70 gic_write(reg, regval);
71}
72
73static inline void gic_reset_mask(unsigned int intr)
74{
75 gic_write(GIC_REG(SHARED, GIC_SH_RMASK) + GIC_INTR_OFS(intr),
76 1 << GIC_INTR_BIT(intr));
77}
78
79static inline void gic_set_mask(unsigned int intr)
80{
81 gic_write(GIC_REG(SHARED, GIC_SH_SMASK) + GIC_INTR_OFS(intr),
82 1 << GIC_INTR_BIT(intr));
83}
84
85static inline void gic_set_polarity(unsigned int intr, unsigned int pol)
86{
87 gic_update_bits(GIC_REG(SHARED, GIC_SH_SET_POLARITY) +
88 GIC_INTR_OFS(intr), 1 << GIC_INTR_BIT(intr),
89 pol << GIC_INTR_BIT(intr));
90}
91
92static inline void gic_set_trigger(unsigned int intr, unsigned int trig)
93{
94 gic_update_bits(GIC_REG(SHARED, GIC_SH_SET_TRIGGER) +
95 GIC_INTR_OFS(intr), 1 << GIC_INTR_BIT(intr),
96 trig << GIC_INTR_BIT(intr));
97}
98
99static inline void gic_set_dual_edge(unsigned int intr, unsigned int dual)
100{
101 gic_update_bits(GIC_REG(SHARED, GIC_SH_SET_DUAL) + GIC_INTR_OFS(intr),
102 1 << GIC_INTR_BIT(intr),
103 dual << GIC_INTR_BIT(intr));
104}
105
106static inline void gic_map_to_pin(unsigned int intr, unsigned int pin)
107{
108 gic_write(GIC_REG(SHARED, GIC_SH_INTR_MAP_TO_PIN_BASE) +
109 GIC_SH_MAP_TO_PIN(intr), GIC_MAP_TO_PIN_MSK | pin);
110}
111
112static inline void gic_map_to_vpe(unsigned int intr, unsigned int vpe)
113{
114 gic_write(GIC_REG(SHARED, GIC_SH_INTR_MAP_TO_VPE_BASE) +
115 GIC_SH_MAP_TO_VPE_REG_OFF(intr, vpe),
116 GIC_SH_MAP_TO_VPE_REG_BIT(vpe));
117}
118
52#if defined(CONFIG_CSRC_GIC) || defined(CONFIG_CEVT_GIC) 119#if defined(CONFIG_CSRC_GIC) || defined(CONFIG_CEVT_GIC)
53cycle_t gic_read_count(void) 120cycle_t gic_read_count(void)
54{ 121{
55 unsigned int hi, hi2, lo; 122 unsigned int hi, hi2, lo;
56 123
57 do { 124 do {
58 GICREAD(GIC_REG(SHARED, GIC_SH_COUNTER_63_32), hi); 125 hi = gic_read(GIC_REG(SHARED, GIC_SH_COUNTER_63_32));
59 GICREAD(GIC_REG(SHARED, GIC_SH_COUNTER_31_00), lo); 126 lo = gic_read(GIC_REG(SHARED, GIC_SH_COUNTER_31_00));
60 GICREAD(GIC_REG(SHARED, GIC_SH_COUNTER_63_32), hi2); 127 hi2 = gic_read(GIC_REG(SHARED, GIC_SH_COUNTER_63_32));
61 } while (hi2 != hi); 128 } while (hi2 != hi);
62 129
63 return (((cycle_t) hi) << 32) + lo; 130 return (((cycle_t) hi) << 32) + lo;
@@ -67,7 +134,7 @@ unsigned int gic_get_count_width(void)
67{ 134{
68 unsigned int bits, config; 135 unsigned int bits, config;
69 136
70 GICREAD(GIC_REG(SHARED, GIC_SH_CONFIG), config); 137 config = gic_read(GIC_REG(SHARED, GIC_SH_CONFIG));
71 bits = 32 + 4 * ((config & GIC_SH_CONFIG_COUNTBITS_MSK) >> 138 bits = 32 + 4 * ((config & GIC_SH_CONFIG_COUNTBITS_MSK) >>
72 GIC_SH_CONFIG_COUNTBITS_SHF); 139 GIC_SH_CONFIG_COUNTBITS_SHF);
73 140
@@ -76,9 +143,9 @@ unsigned int gic_get_count_width(void)
76 143
77void gic_write_compare(cycle_t cnt) 144void gic_write_compare(cycle_t cnt)
78{ 145{
79 GICWRITE(GIC_REG(VPE_LOCAL, GIC_VPE_COMPARE_HI), 146 gic_write(GIC_REG(VPE_LOCAL, GIC_VPE_COMPARE_HI),
80 (int)(cnt >> 32)); 147 (int)(cnt >> 32));
81 GICWRITE(GIC_REG(VPE_LOCAL, GIC_VPE_COMPARE_LO), 148 gic_write(GIC_REG(VPE_LOCAL, GIC_VPE_COMPARE_LO),
82 (int)(cnt & 0xffffffff)); 149 (int)(cnt & 0xffffffff));
83} 150}
84 151
@@ -88,10 +155,10 @@ void gic_write_cpu_compare(cycle_t cnt, int cpu)
88 155
89 local_irq_save(flags); 156 local_irq_save(flags);
90 157
91 GICWRITE(GIC_REG(VPE_LOCAL, GIC_VPE_OTHER_ADDR), cpu); 158 gic_write(GIC_REG(VPE_LOCAL, GIC_VPE_OTHER_ADDR), cpu);
92 GICWRITE(GIC_REG(VPE_OTHER, GIC_VPE_COMPARE_HI), 159 gic_write(GIC_REG(VPE_OTHER, GIC_VPE_COMPARE_HI),
93 (int)(cnt >> 32)); 160 (int)(cnt >> 32));
94 GICWRITE(GIC_REG(VPE_OTHER, GIC_VPE_COMPARE_LO), 161 gic_write(GIC_REG(VPE_OTHER, GIC_VPE_COMPARE_LO),
95 (int)(cnt & 0xffffffff)); 162 (int)(cnt & 0xffffffff));
96 163
97 local_irq_restore(flags); 164 local_irq_restore(flags);
@@ -101,8 +168,8 @@ cycle_t gic_read_compare(void)
101{ 168{
102 unsigned int hi, lo; 169 unsigned int hi, lo;
103 170
104 GICREAD(GIC_REG(VPE_LOCAL, GIC_VPE_COMPARE_HI), hi); 171 hi = gic_read(GIC_REG(VPE_LOCAL, GIC_VPE_COMPARE_HI));
105 GICREAD(GIC_REG(VPE_LOCAL, GIC_VPE_COMPARE_LO), lo); 172 lo = gic_read(GIC_REG(VPE_LOCAL, GIC_VPE_COMPARE_LO));
106 173
107 return (((cycle_t) hi) << 32) + lo; 174 return (((cycle_t) hi) << 32) + lo;
108} 175}
@@ -116,7 +183,7 @@ static bool gic_local_irq_is_routable(int intr)
116 if (cpu_has_veic) 183 if (cpu_has_veic)
117 return true; 184 return true;
118 185
119 GICREAD(GIC_REG(VPE_LOCAL, GIC_VPE_CTL), vpe_ctl); 186 vpe_ctl = gic_read(GIC_REG(VPE_LOCAL, GIC_VPE_CTL));
120 switch (intr) { 187 switch (intr) {
121 case GIC_LOCAL_INT_TIMER: 188 case GIC_LOCAL_INT_TIMER:
122 return vpe_ctl & GIC_VPE_CTL_TIMER_RTBL_MSK; 189 return vpe_ctl & GIC_VPE_CTL_TIMER_RTBL_MSK;
@@ -136,7 +203,7 @@ unsigned int gic_get_timer_pending(void)
136{ 203{
137 unsigned int vpe_pending; 204 unsigned int vpe_pending;
138 205
139 GICREAD(GIC_REG(VPE_LOCAL, GIC_VPE_PEND), vpe_pending); 206 vpe_pending = gic_read(GIC_REG(VPE_LOCAL, GIC_VPE_PEND));
140 return vpe_pending & GIC_VPE_PEND_TIMER_MSK; 207 return vpe_pending & GIC_VPE_PEND_TIMER_MSK;
141} 208}
142 209
@@ -146,12 +213,13 @@ static void gic_bind_eic_interrupt(int irq, int set)
146 irq -= GIC_PIN_TO_VEC_OFFSET; 213 irq -= GIC_PIN_TO_VEC_OFFSET;
147 214
148 /* Set irq to use shadow set */ 215 /* Set irq to use shadow set */
149 GICWRITE(GIC_REG_ADDR(VPE_LOCAL, GIC_VPE_EIC_SS(irq)), set); 216 gic_write(GIC_REG(VPE_LOCAL, GIC_VPE_EIC_SHADOW_SET_BASE) +
217 GIC_VPE_EIC_SS(irq), set);
150} 218}
151 219
152void gic_send_ipi(unsigned int intr) 220void gic_send_ipi(unsigned int intr)
153{ 221{
154 GICWRITE(GIC_REG(SHARED, GIC_SH_WEDGE), 0x80000000 | intr); 222 gic_write(GIC_REG(SHARED, GIC_SH_WEDGE), 0x80000000 | intr);
155} 223}
156 224
157int gic_get_c0_compare_int(void) 225int gic_get_c0_compare_int(void)
@@ -178,23 +246,21 @@ static unsigned int gic_get_int(void)
178{ 246{
179 unsigned int i; 247 unsigned int i;
180 unsigned long *pending, *intrmask, *pcpu_mask; 248 unsigned long *pending, *intrmask, *pcpu_mask;
181 unsigned long *pending_abs, *intrmask_abs; 249 unsigned long pending_reg, intrmask_reg;
182 250
183 /* Get per-cpu bitmaps */ 251 /* Get per-cpu bitmaps */
184 pending = pending_regs[smp_processor_id()].pending; 252 pending = pending_regs[smp_processor_id()].pending;
185 intrmask = intrmask_regs[smp_processor_id()].intrmask; 253 intrmask = intrmask_regs[smp_processor_id()].intrmask;
186 pcpu_mask = pcpu_masks[smp_processor_id()].pcpu_mask; 254 pcpu_mask = pcpu_masks[smp_processor_id()].pcpu_mask;
187 255
188 pending_abs = (unsigned long *) GIC_REG_ABS_ADDR(SHARED, 256 pending_reg = GIC_REG(SHARED, GIC_SH_PEND_31_0);
189 GIC_SH_PEND_31_0_OFS); 257 intrmask_reg = GIC_REG(SHARED, GIC_SH_MASK_31_0);
190 intrmask_abs = (unsigned long *) GIC_REG_ABS_ADDR(SHARED,
191 GIC_SH_MASK_31_0_OFS);
192 258
193 for (i = 0; i < BITS_TO_LONGS(gic_shared_intrs); i++) { 259 for (i = 0; i < BITS_TO_LONGS(gic_shared_intrs); i++) {
194 GICREAD(*pending_abs, pending[i]); 260 pending[i] = gic_read(pending_reg);
195 GICREAD(*intrmask_abs, intrmask[i]); 261 intrmask[i] = gic_read(intrmask_reg);
196 pending_abs++; 262 pending_reg += 0x4;
197 intrmask_abs++; 263 intrmask_reg += 0x4;
198 } 264 }
199 265
200 bitmap_and(pending, pending, intrmask, gic_shared_intrs); 266 bitmap_and(pending, pending, intrmask, gic_shared_intrs);
@@ -205,19 +271,19 @@ static unsigned int gic_get_int(void)
205 271
206static void gic_mask_irq(struct irq_data *d) 272static void gic_mask_irq(struct irq_data *d)
207{ 273{
208 GIC_CLR_INTR_MASK(GIC_HWIRQ_TO_SHARED(d->hwirq)); 274 gic_reset_mask(GIC_HWIRQ_TO_SHARED(d->hwirq));
209} 275}
210 276
211static void gic_unmask_irq(struct irq_data *d) 277static void gic_unmask_irq(struct irq_data *d)
212{ 278{
213 GIC_SET_INTR_MASK(GIC_HWIRQ_TO_SHARED(d->hwirq)); 279 gic_set_mask(GIC_HWIRQ_TO_SHARED(d->hwirq));
214} 280}
215 281
216static void gic_ack_irq(struct irq_data *d) 282static void gic_ack_irq(struct irq_data *d)
217{ 283{
218 unsigned int irq = GIC_HWIRQ_TO_SHARED(d->hwirq); 284 unsigned int irq = GIC_HWIRQ_TO_SHARED(d->hwirq);
219 285
220 GICWRITE(GIC_REG(SHARED, GIC_SH_WEDGE), irq); 286 gic_write(GIC_REG(SHARED, GIC_SH_WEDGE), irq);
221} 287}
222 288
223static int gic_set_type(struct irq_data *d, unsigned int type) 289static int gic_set_type(struct irq_data *d, unsigned int type)
@@ -229,34 +295,34 @@ static int gic_set_type(struct irq_data *d, unsigned int type)
229 spin_lock_irqsave(&gic_lock, flags); 295 spin_lock_irqsave(&gic_lock, flags);
230 switch (type & IRQ_TYPE_SENSE_MASK) { 296 switch (type & IRQ_TYPE_SENSE_MASK) {
231 case IRQ_TYPE_EDGE_FALLING: 297 case IRQ_TYPE_EDGE_FALLING:
232 GIC_SET_POLARITY(irq, GIC_POL_NEG); 298 gic_set_polarity(irq, GIC_POL_NEG);
233 GIC_SET_TRIGGER(irq, GIC_TRIG_EDGE); 299 gic_set_trigger(irq, GIC_TRIG_EDGE);
234 GIC_SET_DUAL(irq, GIC_TRIG_DUAL_DISABLE); 300 gic_set_dual_edge(irq, GIC_TRIG_DUAL_DISABLE);
235 is_edge = true; 301 is_edge = true;
236 break; 302 break;
237 case IRQ_TYPE_EDGE_RISING: 303 case IRQ_TYPE_EDGE_RISING:
238 GIC_SET_POLARITY(irq, GIC_POL_POS); 304 gic_set_polarity(irq, GIC_POL_POS);
239 GIC_SET_TRIGGER(irq, GIC_TRIG_EDGE); 305 gic_set_trigger(irq, GIC_TRIG_EDGE);
240 GIC_SET_DUAL(irq, GIC_TRIG_DUAL_DISABLE); 306 gic_set_dual_edge(irq, GIC_TRIG_DUAL_DISABLE);
241 is_edge = true; 307 is_edge = true;
242 break; 308 break;
243 case IRQ_TYPE_EDGE_BOTH: 309 case IRQ_TYPE_EDGE_BOTH:
244 /* polarity is irrelevant in this case */ 310 /* polarity is irrelevant in this case */
245 GIC_SET_TRIGGER(irq, GIC_TRIG_EDGE); 311 gic_set_trigger(irq, GIC_TRIG_EDGE);
246 GIC_SET_DUAL(irq, GIC_TRIG_DUAL_ENABLE); 312 gic_set_dual_edge(irq, GIC_TRIG_DUAL_ENABLE);
247 is_edge = true; 313 is_edge = true;
248 break; 314 break;
249 case IRQ_TYPE_LEVEL_LOW: 315 case IRQ_TYPE_LEVEL_LOW:
250 GIC_SET_POLARITY(irq, GIC_POL_NEG); 316 gic_set_polarity(irq, GIC_POL_NEG);
251 GIC_SET_TRIGGER(irq, GIC_TRIG_LEVEL); 317 gic_set_trigger(irq, GIC_TRIG_LEVEL);
252 GIC_SET_DUAL(irq, GIC_TRIG_DUAL_DISABLE); 318 gic_set_dual_edge(irq, GIC_TRIG_DUAL_DISABLE);
253 is_edge = false; 319 is_edge = false;
254 break; 320 break;
255 case IRQ_TYPE_LEVEL_HIGH: 321 case IRQ_TYPE_LEVEL_HIGH:
256 default: 322 default:
257 GIC_SET_POLARITY(irq, GIC_POL_POS); 323 gic_set_polarity(irq, GIC_POL_POS);
258 GIC_SET_TRIGGER(irq, GIC_TRIG_LEVEL); 324 gic_set_trigger(irq, GIC_TRIG_LEVEL);
259 GIC_SET_DUAL(irq, GIC_TRIG_DUAL_DISABLE); 325 gic_set_dual_edge(irq, GIC_TRIG_DUAL_DISABLE);
260 is_edge = false; 326 is_edge = false;
261 break; 327 break;
262 } 328 }
@@ -292,7 +358,7 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *cpumask,
292 spin_lock_irqsave(&gic_lock, flags); 358 spin_lock_irqsave(&gic_lock, flags);
293 359
294 /* Re-route this IRQ */ 360 /* Re-route this IRQ */
295 GIC_SH_MAP_TO_VPE_SMASK(irq, first_cpu(tmp)); 361 gic_map_to_vpe(irq, first_cpu(tmp));
296 362
297 /* Update the pcpu_masks */ 363 /* Update the pcpu_masks */
298 for (i = 0; i < NR_CPUS; i++) 364 for (i = 0; i < NR_CPUS; i++)
@@ -331,8 +397,8 @@ static unsigned int gic_get_local_int(void)
331{ 397{
332 unsigned long pending, masked; 398 unsigned long pending, masked;
333 399
334 GICREAD(GIC_REG(VPE_LOCAL, GIC_VPE_PEND), pending); 400 pending = gic_read(GIC_REG(VPE_LOCAL, GIC_VPE_PEND));
335 GICREAD(GIC_REG(VPE_LOCAL, GIC_VPE_MASK), masked); 401 masked = gic_read(GIC_REG(VPE_LOCAL, GIC_VPE_MASK));
336 402
337 bitmap_and(&pending, &pending, &masked, GIC_NUM_LOCAL_INTRS); 403 bitmap_and(&pending, &pending, &masked, GIC_NUM_LOCAL_INTRS);
338 404
@@ -343,14 +409,14 @@ static void gic_mask_local_irq(struct irq_data *d)
343{ 409{
344 int intr = GIC_HWIRQ_TO_LOCAL(d->hwirq); 410 int intr = GIC_HWIRQ_TO_LOCAL(d->hwirq);
345 411
346 GICWRITE(GIC_REG(VPE_LOCAL, GIC_VPE_RMASK), 1 << intr); 412 gic_write(GIC_REG(VPE_LOCAL, GIC_VPE_RMASK), 1 << intr);
347} 413}
348 414
349static void gic_unmask_local_irq(struct irq_data *d) 415static void gic_unmask_local_irq(struct irq_data *d)
350{ 416{
351 int intr = GIC_HWIRQ_TO_LOCAL(d->hwirq); 417 int intr = GIC_HWIRQ_TO_LOCAL(d->hwirq);
352 418
353 GICWRITE(GIC_REG(VPE_LOCAL, GIC_VPE_SMASK), 1 << intr); 419 gic_write(GIC_REG(VPE_LOCAL, GIC_VPE_SMASK), 1 << intr);
354} 420}
355 421
356static struct irq_chip gic_local_irq_controller = { 422static struct irq_chip gic_local_irq_controller = {
@@ -367,8 +433,8 @@ static void gic_mask_local_irq_all_vpes(struct irq_data *d)
367 433
368 spin_lock_irqsave(&gic_lock, flags); 434 spin_lock_irqsave(&gic_lock, flags);
369 for (i = 0; i < gic_vpes; i++) { 435 for (i = 0; i < gic_vpes; i++) {
370 GICWRITE(GIC_REG(VPE_LOCAL, GIC_VPE_OTHER_ADDR), i); 436 gic_write(GIC_REG(VPE_LOCAL, GIC_VPE_OTHER_ADDR), i);
371 GICWRITE(GIC_REG(VPE_OTHER, GIC_VPE_RMASK), 1 << intr); 437 gic_write(GIC_REG(VPE_OTHER, GIC_VPE_RMASK), 1 << intr);
372 } 438 }
373 spin_unlock_irqrestore(&gic_lock, flags); 439 spin_unlock_irqrestore(&gic_lock, flags);
374} 440}
@@ -381,8 +447,8 @@ static void gic_unmask_local_irq_all_vpes(struct irq_data *d)
381 447
382 spin_lock_irqsave(&gic_lock, flags); 448 spin_lock_irqsave(&gic_lock, flags);
383 for (i = 0; i < gic_vpes; i++) { 449 for (i = 0; i < gic_vpes; i++) {
384 GICWRITE(GIC_REG(VPE_LOCAL, GIC_VPE_OTHER_ADDR), i); 450 gic_write(GIC_REG(VPE_LOCAL, GIC_VPE_OTHER_ADDR), i);
385 GICWRITE(GIC_REG(VPE_OTHER, GIC_VPE_SMASK), 1 << intr); 451 gic_write(GIC_REG(VPE_OTHER, GIC_VPE_SMASK), 1 << intr);
386 } 452 }
387 spin_unlock_irqrestore(&gic_lock, flags); 453 spin_unlock_irqrestore(&gic_lock, flags);
388} 454}
@@ -462,7 +528,7 @@ static __init void gic_ipi_init_one(unsigned int intr, int cpu,
462 GIC_SHARED_TO_HWIRQ(intr)); 528 GIC_SHARED_TO_HWIRQ(intr));
463 int i; 529 int i;
464 530
465 GIC_SH_MAP_TO_VPE_SMASK(intr, cpu); 531 gic_map_to_vpe(intr, cpu);
466 for (i = 0; i < NR_CPUS; i++) 532 for (i = 0; i < NR_CPUS; i++)
467 clear_bit(intr, pcpu_masks[i].pcpu_mask); 533 clear_bit(intr, pcpu_masks[i].pcpu_mask);
468 set_bit(intr, pcpu_masks[cpu].pcpu_mask); 534 set_bit(intr, pcpu_masks[cpu].pcpu_mask);
@@ -500,19 +566,19 @@ static void __init gic_basic_init(void)
500 566
501 /* Setup defaults */ 567 /* Setup defaults */
502 for (i = 0; i < gic_shared_intrs; i++) { 568 for (i = 0; i < gic_shared_intrs; i++) {
503 GIC_SET_POLARITY(i, GIC_POL_POS); 569 gic_set_polarity(i, GIC_POL_POS);
504 GIC_SET_TRIGGER(i, GIC_TRIG_LEVEL); 570 gic_set_trigger(i, GIC_TRIG_LEVEL);
505 GIC_CLR_INTR_MASK(i); 571 gic_reset_mask(i);
506 } 572 }
507 573
508 for (i = 0; i < gic_vpes; i++) { 574 for (i = 0; i < gic_vpes; i++) {
509 unsigned int j; 575 unsigned int j;
510 576
511 GICWRITE(GIC_REG(VPE_LOCAL, GIC_VPE_OTHER_ADDR), i); 577 gic_write(GIC_REG(VPE_LOCAL, GIC_VPE_OTHER_ADDR), i);
512 for (j = 0; j < GIC_NUM_LOCAL_INTRS; j++) { 578 for (j = 0; j < GIC_NUM_LOCAL_INTRS; j++) {
513 if (!gic_local_irq_is_routable(j)) 579 if (!gic_local_irq_is_routable(j))
514 continue; 580 continue;
515 GICWRITE(GIC_REG(VPE_OTHER, GIC_VPE_RMASK), 1 << j); 581 gic_write(GIC_REG(VPE_OTHER, GIC_VPE_RMASK), 1 << j);
516 } 582 }
517 } 583 }
518} 584}
@@ -548,29 +614,29 @@ static int gic_local_irq_domain_map(struct irq_domain *d, unsigned int virq,
548 for (i = 0; i < gic_vpes; i++) { 614 for (i = 0; i < gic_vpes; i++) {
549 u32 val = GIC_MAP_TO_PIN_MSK | gic_cpu_pin; 615 u32 val = GIC_MAP_TO_PIN_MSK | gic_cpu_pin;
550 616
551 GICWRITE(GIC_REG(VPE_LOCAL, GIC_VPE_OTHER_ADDR), i); 617 gic_write(GIC_REG(VPE_LOCAL, GIC_VPE_OTHER_ADDR), i);
552 618
553 switch (intr) { 619 switch (intr) {
554 case GIC_LOCAL_INT_WD: 620 case GIC_LOCAL_INT_WD:
555 GICWRITE(GIC_REG(VPE_OTHER, GIC_VPE_WD_MAP), val); 621 gic_write(GIC_REG(VPE_OTHER, GIC_VPE_WD_MAP), val);
556 break; 622 break;
557 case GIC_LOCAL_INT_COMPARE: 623 case GIC_LOCAL_INT_COMPARE:
558 GICWRITE(GIC_REG(VPE_OTHER, GIC_VPE_COMPARE_MAP), val); 624 gic_write(GIC_REG(VPE_OTHER, GIC_VPE_COMPARE_MAP), val);
559 break; 625 break;
560 case GIC_LOCAL_INT_TIMER: 626 case GIC_LOCAL_INT_TIMER:
561 GICWRITE(GIC_REG(VPE_OTHER, GIC_VPE_TIMER_MAP), val); 627 gic_write(GIC_REG(VPE_OTHER, GIC_VPE_TIMER_MAP), val);
562 break; 628 break;
563 case GIC_LOCAL_INT_PERFCTR: 629 case GIC_LOCAL_INT_PERFCTR:
564 GICWRITE(GIC_REG(VPE_OTHER, GIC_VPE_PERFCTR_MAP), val); 630 gic_write(GIC_REG(VPE_OTHER, GIC_VPE_PERFCTR_MAP), val);
565 break; 631 break;
566 case GIC_LOCAL_INT_SWINT0: 632 case GIC_LOCAL_INT_SWINT0:
567 GICWRITE(GIC_REG(VPE_OTHER, GIC_VPE_SWINT0_MAP), val); 633 gic_write(GIC_REG(VPE_OTHER, GIC_VPE_SWINT0_MAP), val);
568 break; 634 break;
569 case GIC_LOCAL_INT_SWINT1: 635 case GIC_LOCAL_INT_SWINT1:
570 GICWRITE(GIC_REG(VPE_OTHER, GIC_VPE_SWINT1_MAP), val); 636 gic_write(GIC_REG(VPE_OTHER, GIC_VPE_SWINT1_MAP), val);
571 break; 637 break;
572 case GIC_LOCAL_INT_FDC: 638 case GIC_LOCAL_INT_FDC:
573 GICWRITE(GIC_REG(VPE_OTHER, GIC_VPE_FDC_MAP), val); 639 gic_write(GIC_REG(VPE_OTHER, GIC_VPE_FDC_MAP), val);
574 break; 640 break;
575 default: 641 default:
576 pr_err("Invalid local IRQ %d\n", intr); 642 pr_err("Invalid local IRQ %d\n", intr);
@@ -593,10 +659,9 @@ static int gic_shared_irq_domain_map(struct irq_domain *d, unsigned int virq,
593 handle_level_irq); 659 handle_level_irq);
594 660
595 spin_lock_irqsave(&gic_lock, flags); 661 spin_lock_irqsave(&gic_lock, flags);
596 GICWRITE(GIC_REG_ADDR(SHARED, GIC_SH_MAP_TO_PIN(intr)), 662 gic_map_to_pin(intr, gic_cpu_pin);
597 GIC_MAP_TO_PIN_MSK | gic_cpu_pin);
598 /* Map to VPE 0 by default */ 663 /* Map to VPE 0 by default */
599 GIC_SH_MAP_TO_VPE_SMASK(intr, 0); 664 gic_map_to_vpe(intr, 0);
600 set_bit(intr, pcpu_masks[0].pcpu_mask); 665 set_bit(intr, pcpu_masks[0].pcpu_mask);
601 spin_unlock_irqrestore(&gic_lock, flags); 666 spin_unlock_irqrestore(&gic_lock, flags);
602 667
@@ -622,10 +687,9 @@ void __init gic_init(unsigned long gic_base_addr,
622{ 687{
623 unsigned int gicconfig; 688 unsigned int gicconfig;
624 689
625 _gic_base = (unsigned long) ioremap_nocache(gic_base_addr, 690 gic_base = ioremap_nocache(gic_base_addr, gic_addrspace_size);
626 gic_addrspace_size);
627 691
628 GICREAD(GIC_REG(SHARED, GIC_SH_CONFIG), gicconfig); 692 gicconfig = gic_read(GIC_REG(SHARED, GIC_SH_CONFIG));
629 gic_shared_intrs = (gicconfig & GIC_SH_CONFIG_NUMINTRS_MSK) >> 693 gic_shared_intrs = (gicconfig & GIC_SH_CONFIG_NUMINTRS_MSK) >>
630 GIC_SH_CONFIG_NUMINTRS_SHF; 694 GIC_SH_CONFIG_NUMINTRS_SHF;
631 gic_shared_intrs = ((gic_shared_intrs + 1) * 8); 695 gic_shared_intrs = ((gic_shared_intrs + 1) * 8);