aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd
diff options
context:
space:
mode:
authorPeter Ujfalusi <peter.ujfalusi@ti.com>2012-05-16 07:11:56 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2012-05-20 11:27:12 -0400
commit6712419d697851c4472cdfd2111c844d777472e8 (patch)
treeb2725bdab830ceb9cd2712357e4a36aace81dd45 /drivers/mfd
parent68029c6cf9750ff0d4ed5c812a3755cbd855862a (diff)
mfd: Allocate twl6040 IRQ numbers dynamically
Use irq_alloc_descs() to get the IRQ number range dynamically instead of the hardwired use if pdata->irq_base. The twl6040 only provides interrupts for it's internal components which means that it is not working as an IRQ expander type of device. The client drivers will receive their interrupt numbers as resource which is configured based on the received IRQ range we got from irq_alloc_descs() Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd')
-rw-r--r--drivers/mfd/twl6040-core.c3
-rw-r--r--drivers/mfd/twl6040-irq.c13
2 files changed, 12 insertions, 4 deletions
diff --git a/drivers/mfd/twl6040-core.c b/drivers/mfd/twl6040-core.c
index 7a92d95bfb60..c50fba7be778 100644
--- a/drivers/mfd/twl6040-core.c
+++ b/drivers/mfd/twl6040-core.c
@@ -515,7 +515,7 @@ static int __devinit twl6040_probe(struct i2c_client *client,
515 } 515 }
516 516
517 /* In order to operate correctly we need valid interrupt config */ 517 /* In order to operate correctly we need valid interrupt config */
518 if (!client->irq || !pdata->irq_base) { 518 if (!client->irq) {
519 dev_err(&client->dev, "Invalid IRQ configuration\n"); 519 dev_err(&client->dev, "Invalid IRQ configuration\n");
520 return -EINVAL; 520 return -EINVAL;
521 } 521 }
@@ -552,7 +552,6 @@ static int __devinit twl6040_probe(struct i2c_client *client,
552 552
553 twl6040->dev = &client->dev; 553 twl6040->dev = &client->dev;
554 twl6040->irq = client->irq; 554 twl6040->irq = client->irq;
555 twl6040->irq_base = pdata->irq_base;
556 555
557 mutex_init(&twl6040->mutex); 556 mutex_init(&twl6040->mutex);
558 mutex_init(&twl6040->io_mutex); 557 mutex_init(&twl6040->io_mutex);
diff --git a/drivers/mfd/twl6040-irq.c b/drivers/mfd/twl6040-irq.c
index 008022cdb06d..914978e1b62e 100644
--- a/drivers/mfd/twl6040-irq.c
+++ b/drivers/mfd/twl6040-irq.c
@@ -23,6 +23,7 @@
23 23
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/err.h>
26#include <linux/irq.h> 27#include <linux/irq.h>
27#include <linux/interrupt.h> 28#include <linux/interrupt.h>
28#include <linux/mfd/core.h> 29#include <linux/mfd/core.h>
@@ -138,7 +139,7 @@ static irqreturn_t twl6040_irq_thread(int irq, void *data)
138 139
139int twl6040_irq_init(struct twl6040 *twl6040) 140int twl6040_irq_init(struct twl6040 *twl6040)
140{ 141{
141 int i, nr_irqs, ret; 142 int i, nr_irqs, irq_base, ret;
142 u8 val; 143 u8 val;
143 144
144 mutex_init(&twl6040->irq_mutex); 145 mutex_init(&twl6040->irq_mutex);
@@ -149,8 +150,16 @@ int twl6040_irq_init(struct twl6040 *twl6040)
149 twl6040_reg_write(twl6040, TWL6040_REG_INTMR, TWL6040_ALLINT_MSK); 150 twl6040_reg_write(twl6040, TWL6040_REG_INTMR, TWL6040_ALLINT_MSK);
150 151
151 nr_irqs = ARRAY_SIZE(twl6040_irqs); 152 nr_irqs = ARRAY_SIZE(twl6040_irqs);
153
154 irq_base = irq_alloc_descs(-1, 0, nr_irqs, 0);
155 if (IS_ERR_VALUE(irq_base)) {
156 dev_err(twl6040->dev, "Fail to allocate IRQ descs\n");
157 return irq_base;
158 }
159 twl6040->irq_base = irq_base;
160
152 /* Register them with genirq */ 161 /* Register them with genirq */
153 for (i = twl6040->irq_base; i < twl6040->irq_base + nr_irqs; i++) { 162 for (i = irq_base; i < irq_base + nr_irqs; i++) {
154 irq_set_chip_data(i, twl6040); 163 irq_set_chip_data(i, twl6040);
155 irq_set_chip_and_handler(i, &twl6040_irq_chip, 164 irq_set_chip_and_handler(i, &twl6040_irq_chip,
156 handle_level_irq); 165 handle_level_irq);