diff options
author | Lee Jones <lee.jones@linaro.org> | 2012-09-07 07:14:56 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2012-09-17 09:03:38 -0400 |
commit | 15e27b1088245a2de3b7d09d39cd209212eb16af (patch) | |
tree | 8986de2dd41b21b590ffe5a4910fb4e22be0364e /drivers/mfd/tc3589x.c | |
parent | 8d2493781ad910019e9dc63dbf99f6dd2a8a2083 (diff) |
mfd: Provide the tc3589x with its own IRQ domain
In preparation for Device Tree enablement all IRQ controllers
should control their own IRQ domain. This patch provides just
that.
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd/tc3589x.c')
-rw-r--r-- | drivers/mfd/tc3589x.c | 73 |
1 files changed, 47 insertions, 26 deletions
diff --git a/drivers/mfd/tc3589x.c b/drivers/mfd/tc3589x.c index b56ba6b43294..2df44acaf907 100644 --- a/drivers/mfd/tc3589x.c +++ b/drivers/mfd/tc3589x.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/module.h> | 9 | #include <linux/module.h> |
10 | #include <linux/interrupt.h> | 10 | #include <linux/interrupt.h> |
11 | #include <linux/irq.h> | 11 | #include <linux/irq.h> |
12 | #include <linux/irqdomain.h> | ||
12 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
13 | #include <linux/i2c.h> | 14 | #include <linux/i2c.h> |
14 | #include <linux/mfd/core.h> | 15 | #include <linux/mfd/core.h> |
@@ -168,8 +169,9 @@ again: | |||
168 | 169 | ||
169 | while (status) { | 170 | while (status) { |
170 | int bit = __ffs(status); | 171 | int bit = __ffs(status); |
172 | int virq = irq_create_mapping(tc3589x->domain, bit); | ||
171 | 173 | ||
172 | handle_nested_irq(tc3589x->irq_base + bit); | 174 | handle_nested_irq(virq); |
173 | status &= ~(1 << bit); | 175 | status &= ~(1 << bit); |
174 | } | 176 | } |
175 | 177 | ||
@@ -186,38 +188,60 @@ again: | |||
186 | return IRQ_HANDLED; | 188 | return IRQ_HANDLED; |
187 | } | 189 | } |
188 | 190 | ||
189 | static int tc3589x_irq_init(struct tc3589x *tc3589x) | 191 | static int tc3589x_irq_map(struct irq_domain *d, unsigned int virq, |
192 | irq_hw_number_t hwirq) | ||
190 | { | 193 | { |
191 | int base = tc3589x->irq_base; | 194 | struct tc3589x *tc3589x = d->host_data; |
192 | int irq; | ||
193 | 195 | ||
194 | for (irq = base; irq < base + TC3589x_NR_INTERNAL_IRQS; irq++) { | 196 | irq_set_chip_data(virq, tc3589x); |
195 | irq_set_chip_data(irq, tc3589x); | 197 | irq_set_chip_and_handler(virq, &dummy_irq_chip, |
196 | irq_set_chip_and_handler(irq, &dummy_irq_chip, | 198 | handle_edge_irq); |
197 | handle_edge_irq); | 199 | irq_set_nested_thread(virq, 1); |
198 | irq_set_nested_thread(irq, 1); | ||
199 | #ifdef CONFIG_ARM | 200 | #ifdef CONFIG_ARM |
200 | set_irq_flags(irq, IRQF_VALID); | 201 | set_irq_flags(virq, IRQF_VALID); |
201 | #else | 202 | #else |
202 | irq_set_noprobe(irq); | 203 | irq_set_noprobe(virq); |
203 | #endif | 204 | #endif |
204 | } | ||
205 | 205 | ||
206 | return 0; | 206 | return 0; |
207 | } | 207 | } |
208 | 208 | ||
209 | static void tc3589x_irq_remove(struct tc3589x *tc3589x) | 209 | static void tc3589x_irq_unmap(struct irq_domain *d, unsigned int virq) |
210 | { | 210 | { |
211 | int base = tc3589x->irq_base; | ||
212 | int irq; | ||
213 | |||
214 | for (irq = base; irq < base + TC3589x_NR_INTERNAL_IRQS; irq++) { | ||
215 | #ifdef CONFIG_ARM | 211 | #ifdef CONFIG_ARM |
216 | set_irq_flags(irq, 0); | 212 | set_irq_flags(virq, 0); |
217 | #endif | 213 | #endif |
218 | irq_set_chip_and_handler(irq, NULL, NULL); | 214 | irq_set_chip_and_handler(virq, NULL, NULL); |
219 | irq_set_chip_data(irq, NULL); | 215 | irq_set_chip_data(virq, NULL); |
216 | } | ||
217 | |||
218 | static struct irq_domain_ops tc3589x_irq_ops = { | ||
219 | .map = tc3589x_irq_map, | ||
220 | .unmap = tc3589x_irq_unmap, | ||
221 | .xlate = irq_domain_xlate_twocell, | ||
222 | }; | ||
223 | |||
224 | static int tc3589x_irq_init(struct tc3589x *tc3589x) | ||
225 | { | ||
226 | int base = tc3589x->irq_base; | ||
227 | |||
228 | if (base) { | ||
229 | tc3589x->domain = irq_domain_add_legacy( | ||
230 | NULL, TC3589x_NR_INTERNAL_IRQS, base, | ||
231 | 0, &tc3589x_irq_ops, tc3589x); | ||
220 | } | 232 | } |
233 | else { | ||
234 | tc3589x->domain = irq_domain_add_linear( | ||
235 | NULL, TC3589x_NR_INTERNAL_IRQS, | ||
236 | &tc3589x_irq_ops, tc3589x); | ||
237 | } | ||
238 | |||
239 | if (!tc3589x->domain) { | ||
240 | dev_err(tc3589x->dev, "Failed to create irqdomain\n"); | ||
241 | return -ENOSYS; | ||
242 | } | ||
243 | |||
244 | return 0; | ||
221 | } | 245 | } |
222 | 246 | ||
223 | static int tc3589x_chip_init(struct tc3589x *tc3589x) | 247 | static int tc3589x_chip_init(struct tc3589x *tc3589x) |
@@ -263,7 +287,7 @@ static int __devinit tc3589x_device_init(struct tc3589x *tc3589x) | |||
263 | if (blocks & TC3589x_BLOCK_GPIO) { | 287 | if (blocks & TC3589x_BLOCK_GPIO) { |
264 | ret = mfd_add_devices(tc3589x->dev, -1, tc3589x_dev_gpio, | 288 | ret = mfd_add_devices(tc3589x->dev, -1, tc3589x_dev_gpio, |
265 | ARRAY_SIZE(tc3589x_dev_gpio), NULL, | 289 | ARRAY_SIZE(tc3589x_dev_gpio), NULL, |
266 | tc3589x->irq_base, NULL); | 290 | tc3589x->irq_base, tc3589x->domain); |
267 | if (ret) { | 291 | if (ret) { |
268 | dev_err(tc3589x->dev, "failed to add gpio child\n"); | 292 | dev_err(tc3589x->dev, "failed to add gpio child\n"); |
269 | return ret; | 293 | return ret; |
@@ -274,7 +298,7 @@ static int __devinit tc3589x_device_init(struct tc3589x *tc3589x) | |||
274 | if (blocks & TC3589x_BLOCK_KEYPAD) { | 298 | if (blocks & TC3589x_BLOCK_KEYPAD) { |
275 | ret = mfd_add_devices(tc3589x->dev, -1, tc3589x_dev_keypad, | 299 | ret = mfd_add_devices(tc3589x->dev, -1, tc3589x_dev_keypad, |
276 | ARRAY_SIZE(tc3589x_dev_keypad), NULL, | 300 | ARRAY_SIZE(tc3589x_dev_keypad), NULL, |
277 | tc3589x->irq_base, NULL); | 301 | tc3589x->irq_base, tc3589x->domain); |
278 | if (ret) { | 302 | if (ret) { |
279 | dev_err(tc3589x->dev, "failed to keypad child\n"); | 303 | dev_err(tc3589x->dev, "failed to keypad child\n"); |
280 | return ret; | 304 | return ret; |
@@ -323,7 +347,7 @@ static int __devinit tc3589x_probe(struct i2c_client *i2c, | |||
323 | "tc3589x", tc3589x); | 347 | "tc3589x", tc3589x); |
324 | if (ret) { | 348 | if (ret) { |
325 | dev_err(tc3589x->dev, "failed to request IRQ: %d\n", ret); | 349 | dev_err(tc3589x->dev, "failed to request IRQ: %d\n", ret); |
326 | goto out_removeirq; | 350 | goto out_free; |
327 | } | 351 | } |
328 | 352 | ||
329 | ret = tc3589x_device_init(tc3589x); | 353 | ret = tc3589x_device_init(tc3589x); |
@@ -336,8 +360,6 @@ static int __devinit tc3589x_probe(struct i2c_client *i2c, | |||
336 | 360 | ||
337 | out_freeirq: | 361 | out_freeirq: |
338 | free_irq(tc3589x->i2c->irq, tc3589x); | 362 | free_irq(tc3589x->i2c->irq, tc3589x); |
339 | out_removeirq: | ||
340 | tc3589x_irq_remove(tc3589x); | ||
341 | out_free: | 363 | out_free: |
342 | kfree(tc3589x); | 364 | kfree(tc3589x); |
343 | return ret; | 365 | return ret; |
@@ -350,7 +372,6 @@ static int __devexit tc3589x_remove(struct i2c_client *client) | |||
350 | mfd_remove_devices(tc3589x->dev); | 372 | mfd_remove_devices(tc3589x->dev); |
351 | 373 | ||
352 | free_irq(tc3589x->i2c->irq, tc3589x); | 374 | free_irq(tc3589x->i2c->irq, tc3589x); |
353 | tc3589x_irq_remove(tc3589x); | ||
354 | 375 | ||
355 | kfree(tc3589x); | 376 | kfree(tc3589x); |
356 | 377 | ||