aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/common/gic.c
diff options
context:
space:
mode:
authorSantosh Shilimkar <santosh.shilimkar@ti.com>2011-03-02 02:03:22 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2011-03-08 19:18:47 -0500
commitd7ed36a4ea84e3a850f9932e2058ceef987d1acd (patch)
treeb4e8daf31024698e1b6be9ff6f8810be776f4c5c /arch/arm/common/gic.c
parent4bdb157749a0da065e532f2f46040c178075b06f (diff)
ARM: 6777/1: gic: Add hooks for architecture specific extensions
Few architectures combine the GIC with an external interrupt controller. On such systems it may be necessary to update both the GIC registers and the external controller's registers to control IRQ behavior. This can be addressed in couple of possible methods. 1. Export common GIC routines along with 'struct irq_chip gic_chip' and allow architectures to have custom function by override. 2. Provide architecture specific function pointer hooks within GIC library and leave platforms to add the necessary code as part of these hooks. First one might be non-intrusive but have few shortcomings like arch needs to have there own custom gic library. Locks used should be common since it caters to same IRQs etc. Maintenance point of view also it leads to multiple file fixes. The second probably is cleaner and portable. It ensures that all the common GIC infrastructure is not touched and also provides archs to address their specific issue. Cc: Russell King <rmk+kernel@arm.linux.org.uk> Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com> Acked-by: Colin Cross <ccross@android.com> Tested-by: Colin Cross <ccross@android.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/common/gic.c')
-rw-r--r--arch/arm/common/gic.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/arch/arm/common/gic.c b/arch/arm/common/gic.c
index e21c1f4218d3..cb6b041c39d2 100644
--- a/arch/arm/common/gic.c
+++ b/arch/arm/common/gic.c
@@ -44,6 +44,19 @@ struct gic_chip_data {
44 void __iomem *cpu_base; 44 void __iomem *cpu_base;
45}; 45};
46 46
47/*
48 * Supported arch specific GIC irq extension.
49 * Default make them NULL.
50 */
51struct irq_chip gic_arch_extn = {
52 .irq_ack = NULL,
53 .irq_mask = NULL,
54 .irq_unmask = NULL,
55 .irq_retrigger = NULL,
56 .irq_set_type = NULL,
57 .irq_set_wake = NULL,
58};
59
47#ifndef MAX_GIC_NR 60#ifndef MAX_GIC_NR
48#define MAX_GIC_NR 1 61#define MAX_GIC_NR 1
49#endif 62#endif
@@ -74,6 +87,8 @@ static inline unsigned int gic_irq(struct irq_data *d)
74static void gic_ack_irq(struct irq_data *d) 87static void gic_ack_irq(struct irq_data *d)
75{ 88{
76 spin_lock(&irq_controller_lock); 89 spin_lock(&irq_controller_lock);
90 if (gic_arch_extn.irq_ack)
91 gic_arch_extn.irq_ack(d);
77 writel(gic_irq(d), gic_cpu_base(d) + GIC_CPU_EOI); 92 writel(gic_irq(d), gic_cpu_base(d) + GIC_CPU_EOI);
78 spin_unlock(&irq_controller_lock); 93 spin_unlock(&irq_controller_lock);
79} 94}
@@ -84,6 +99,8 @@ static void gic_mask_irq(struct irq_data *d)
84 99
85 spin_lock(&irq_controller_lock); 100 spin_lock(&irq_controller_lock);
86 writel(mask, gic_dist_base(d) + GIC_DIST_ENABLE_CLEAR + (gic_irq(d) / 32) * 4); 101 writel(mask, gic_dist_base(d) + GIC_DIST_ENABLE_CLEAR + (gic_irq(d) / 32) * 4);
102 if (gic_arch_extn.irq_mask)
103 gic_arch_extn.irq_mask(d);
87 spin_unlock(&irq_controller_lock); 104 spin_unlock(&irq_controller_lock);
88} 105}
89 106
@@ -92,6 +109,8 @@ static void gic_unmask_irq(struct irq_data *d)
92 u32 mask = 1 << (d->irq % 32); 109 u32 mask = 1 << (d->irq % 32);
93 110
94 spin_lock(&irq_controller_lock); 111 spin_lock(&irq_controller_lock);
112 if (gic_arch_extn.irq_unmask)
113 gic_arch_extn.irq_unmask(d);
95 writel(mask, gic_dist_base(d) + GIC_DIST_ENABLE_SET + (gic_irq(d) / 32) * 4); 114 writel(mask, gic_dist_base(d) + GIC_DIST_ENABLE_SET + (gic_irq(d) / 32) * 4);
96 spin_unlock(&irq_controller_lock); 115 spin_unlock(&irq_controller_lock);
97} 116}
@@ -116,6 +135,9 @@ static int gic_set_type(struct irq_data *d, unsigned int type)
116 135
117 spin_lock(&irq_controller_lock); 136 spin_lock(&irq_controller_lock);
118 137
138 if (gic_arch_extn.irq_set_type)
139 gic_arch_extn.irq_set_type(d, type);
140
119 val = readl(base + GIC_DIST_CONFIG + confoff); 141 val = readl(base + GIC_DIST_CONFIG + confoff);
120 if (type == IRQ_TYPE_LEVEL_HIGH) 142 if (type == IRQ_TYPE_LEVEL_HIGH)
121 val &= ~confmask; 143 val &= ~confmask;
@@ -141,6 +163,14 @@ static int gic_set_type(struct irq_data *d, unsigned int type)
141 return 0; 163 return 0;
142} 164}
143 165
166static int gic_retrigger(struct irq_data *d)
167{
168 if (gic_arch_extn.irq_retrigger)
169 return gic_arch_extn.irq_retrigger(d);
170
171 return -ENXIO;
172}
173
144#ifdef CONFIG_SMP 174#ifdef CONFIG_SMP
145static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val, 175static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val,
146 bool force) 176 bool force)
@@ -166,6 +196,21 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val,
166} 196}
167#endif 197#endif
168 198
199#ifdef CONFIG_PM
200static int gic_set_wake(struct irq_data *d, unsigned int on)
201{
202 int ret = -ENXIO;
203
204 if (gic_arch_extn.irq_set_wake)
205 ret = gic_arch_extn.irq_set_wake(d, on);
206
207 return ret;
208}
209
210#else
211#define gic_set_wake NULL
212#endif
213
169static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc) 214static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
170{ 215{
171 struct gic_chip_data *chip_data = get_irq_data(irq); 216 struct gic_chip_data *chip_data = get_irq_data(irq);
@@ -201,9 +246,11 @@ static struct irq_chip gic_chip = {
201 .irq_mask = gic_mask_irq, 246 .irq_mask = gic_mask_irq,
202 .irq_unmask = gic_unmask_irq, 247 .irq_unmask = gic_unmask_irq,
203 .irq_set_type = gic_set_type, 248 .irq_set_type = gic_set_type,
249 .irq_retrigger = gic_retrigger,
204#ifdef CONFIG_SMP 250#ifdef CONFIG_SMP
205 .irq_set_affinity = gic_set_affinity, 251 .irq_set_affinity = gic_set_affinity,
206#endif 252#endif
253 .irq_set_wake = gic_set_wake,
207}; 254};
208 255
209void __init gic_cascade_irq(unsigned int gic_nr, unsigned int irq) 256void __init gic_cascade_irq(unsigned int gic_nr, unsigned int irq)