linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] MFD: twl6040: Conversion to use regmap_irq
@ 2012-10-11 11:55 Peter Ujfalusi
  2012-10-11 11:55 ` [PATCH 1/6] MFD: twl6040: Fix typo for power on failure Peter Ujfalusi
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: Peter Ujfalusi @ 2012-10-11 11:55 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: linux-kernel, Mark Brown, peter.ujfalusi

Hello,

This series will convert the twl6040 MFD core driver to use regmap_irq instead
of the custom interrupt code it used. In this way considerable amount of code
can be removed and we are going to use common, well tested code for the interrupt
dispatch.

The series is for 3.8.

Regards,
Peter
---
Peter Ujfalusi (6):
  MFD: twl6040: Fix typo for power on failure
  MFD: twl6040: Remove unused parameter for
    twl6040_power_up_completion()
  MFD: twl6040: Restructure power up and down code
  MFD: twl6040: Correct Ready and Thermal interrupt handling
  MFD: twl6040: Convert to use regmap_irq
  MFD: twl6040: Rename the core driver

 drivers/mfd/Kconfig                       |   4 +-
 drivers/mfd/Makefile                      |   2 +-
 drivers/mfd/twl6040-irq.c                 | 205 ------------------------------
 drivers/mfd/{twl6040-core.c => twl6040.c} | 137 ++++++++++++--------
 include/linux/mfd/twl6040.h               |  10 +-
 5 files changed, 92 insertions(+), 266 deletions(-)
 delete mode 100644 drivers/mfd/twl6040-irq.c
 rename drivers/mfd/{twl6040-core.c => twl6040.c} (84%)

-- 
1.7.12


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/6] MFD: twl6040: Fix typo for power on failure
  2012-10-11 11:55 [PATCH 0/6] MFD: twl6040: Conversion to use regmap_irq Peter Ujfalusi
@ 2012-10-11 11:55 ` Peter Ujfalusi
  2012-10-11 11:55 ` [PATCH 2/6] MFD: twl6040: Remove unused parameter for twl6040_power_up_completion() Peter Ujfalusi
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Peter Ujfalusi @ 2012-10-11 11:55 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: linux-kernel, Mark Brown, peter.ujfalusi

Fix old copy paste bug:
automatic power-down failed -> automatic power-up failed

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 drivers/mfd/twl6040-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/twl6040-core.c b/drivers/mfd/twl6040-core.c
index 3f2a1cf..b220aa2 100644
--- a/drivers/mfd/twl6040-core.c
+++ b/drivers/mfd/twl6040-core.c
@@ -258,7 +258,7 @@ int twl6040_power(struct twl6040 *twl6040, int on)
 			ret = twl6040_power_up_completion(twl6040, naudint);
 			if (ret) {
 				dev_err(twl6040->dev,
-					"automatic power-down failed\n");
+					"automatic power-up failed\n");
 				twl6040->power_count = 0;
 				goto out;
 			}
-- 
1.7.12


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/6] MFD: twl6040: Remove unused parameter for twl6040_power_up_completion()
  2012-10-11 11:55 [PATCH 0/6] MFD: twl6040: Conversion to use regmap_irq Peter Ujfalusi
  2012-10-11 11:55 ` [PATCH 1/6] MFD: twl6040: Fix typo for power on failure Peter Ujfalusi
@ 2012-10-11 11:55 ` Peter Ujfalusi
  2012-10-11 11:55 ` [PATCH 3/6] MFD: twl6040: Restructure power up and down code Peter Ujfalusi
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Peter Ujfalusi @ 2012-10-11 11:55 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: linux-kernel, Mark Brown, peter.ujfalusi

naudint parameter has not been used, remove it.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 drivers/mfd/twl6040-core.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/mfd/twl6040-core.c b/drivers/mfd/twl6040-core.c
index b220aa2..a46d987 100644
--- a/drivers/mfd/twl6040-core.c
+++ b/drivers/mfd/twl6040-core.c
@@ -218,8 +218,7 @@ static irqreturn_t twl6040_naudint_handler(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
-static int twl6040_power_up_completion(struct twl6040 *twl6040,
-				       int naudint)
+static int twl6040_power_up_completion(struct twl6040 *twl6040)
 {
 	int time_left;
 	u8 intid;
@@ -241,7 +240,6 @@ static int twl6040_power_up_completion(struct twl6040 *twl6040,
 int twl6040_power(struct twl6040 *twl6040, int on)
 {
 	int audpwron = twl6040->audpwron;
-	int naudint = twl6040->irq;
 	int ret = 0;
 
 	mutex_lock(&twl6040->mutex);
@@ -255,7 +253,7 @@ int twl6040_power(struct twl6040 *twl6040, int on)
 			/* use AUDPWRON line */
 			gpio_set_value(audpwron, 1);
 			/* wait for power-up completion */
-			ret = twl6040_power_up_completion(twl6040, naudint);
+			ret = twl6040_power_up_completion(twl6040);
 			if (ret) {
 				dev_err(twl6040->dev,
 					"automatic power-up failed\n");
-- 
1.7.12


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/6] MFD: twl6040: Restructure power up and down code
  2012-10-11 11:55 [PATCH 0/6] MFD: twl6040: Conversion to use regmap_irq Peter Ujfalusi
  2012-10-11 11:55 ` [PATCH 1/6] MFD: twl6040: Fix typo for power on failure Peter Ujfalusi
  2012-10-11 11:55 ` [PATCH 2/6] MFD: twl6040: Remove unused parameter for twl6040_power_up_completion() Peter Ujfalusi
@ 2012-10-11 11:55 ` Peter Ujfalusi
  2012-10-11 11:55 ` [PATCH 4/6] MFD: twl6040: Correct Ready and Thermal interrupt handling Peter Ujfalusi
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Peter Ujfalusi @ 2012-10-11 11:55 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: linux-kernel, Mark Brown, peter.ujfalusi

Rearrange the code path for power up and down sequence.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 drivers/mfd/twl6040-core.c | 38 ++++++++++++++++++--------------------
 1 file changed, 18 insertions(+), 20 deletions(-)

diff --git a/drivers/mfd/twl6040-core.c b/drivers/mfd/twl6040-core.c
index a46d987..6d9db27 100644
--- a/drivers/mfd/twl6040-core.c
+++ b/drivers/mfd/twl6040-core.c
@@ -104,7 +104,7 @@ int twl6040_clear_bits(struct twl6040 *twl6040, unsigned int reg, u8 mask)
 EXPORT_SYMBOL(twl6040_clear_bits);
 
 /* twl6040 codec manual power-up sequence */
-static int twl6040_power_up(struct twl6040 *twl6040)
+static int twl6040_power_up_manual(struct twl6040 *twl6040)
 {
 	u8 ldoctl, ncpctl, lppllctl;
 	int ret;
@@ -158,11 +158,12 @@ ncp_err:
 	ldoctl &= ~(TWL6040_HSLDOENA | TWL6040_REFENA | TWL6040_OSCENA);
 	twl6040_reg_write(twl6040, TWL6040_REG_LDOCTL, ldoctl);
 
+	dev_err(twl6040->dev, "manual power-up failed\n");
 	return ret;
 }
 
 /* twl6040 manual power-down sequence */
-static void twl6040_power_down(struct twl6040 *twl6040)
+static void twl6040_power_down_manual(struct twl6040 *twl6040)
 {
 	u8 ncpctl, ldoctl, lppllctl;
 
@@ -218,18 +219,22 @@ static irqreturn_t twl6040_naudint_handler(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
-static int twl6040_power_up_completion(struct twl6040 *twl6040)
+static int twl6040_power_up_automatic(struct twl6040 *twl6040)
 {
 	int time_left;
-	u8 intid;
+
+	gpio_set_value(twl6040->audpwron, 1);
 
 	time_left = wait_for_completion_timeout(&twl6040->ready,
 						msecs_to_jiffies(144));
 	if (!time_left) {
+		u8 intid;
+
+		dev_warn(twl6040->dev, "timeout waiting for READYINT\n");
 		intid = twl6040_reg_read(twl6040, TWL6040_REG_INTID);
 		if (!(intid & TWL6040_READYINT)) {
-			dev_err(twl6040->dev,
-				"timeout waiting for READYINT\n");
+			dev_err(twl6040->dev, "automatic power-up failed\n");
+			gpio_set_value(twl6040->audpwron, 0);
 			return -ETIMEDOUT;
 		}
 	}
@@ -239,7 +244,6 @@ static int twl6040_power_up_completion(struct twl6040 *twl6040)
 
 int twl6040_power(struct twl6040 *twl6040, int on)
 {
-	int audpwron = twl6040->audpwron;
 	int ret = 0;
 
 	mutex_lock(&twl6040->mutex);
@@ -249,23 +253,17 @@ int twl6040_power(struct twl6040 *twl6040, int on)
 		if (twl6040->power_count++)
 			goto out;
 
-		if (gpio_is_valid(audpwron)) {
-			/* use AUDPWRON line */
-			gpio_set_value(audpwron, 1);
-			/* wait for power-up completion */
-			ret = twl6040_power_up_completion(twl6040);
+		if (gpio_is_valid(twl6040->audpwron)) {
+			/* use automatic power-up sequence */
+			ret = twl6040_power_up_automatic(twl6040);
 			if (ret) {
-				dev_err(twl6040->dev,
-					"automatic power-up failed\n");
 				twl6040->power_count = 0;
 				goto out;
 			}
 		} else {
 			/* use manual power-up sequence */
-			ret = twl6040_power_up(twl6040);
+			ret = twl6040_power_up_manual(twl6040);
 			if (ret) {
-				dev_err(twl6040->dev,
-					"manual power-up failed\n");
 				twl6040->power_count = 0;
 				goto out;
 			}
@@ -286,15 +284,15 @@ int twl6040_power(struct twl6040 *twl6040, int on)
 		if (--twl6040->power_count)
 			goto out;
 
-		if (gpio_is_valid(audpwron)) {
+		if (gpio_is_valid(twl6040->audpwron)) {
 			/* use AUDPWRON line */
-			gpio_set_value(audpwron, 0);
+			gpio_set_value(twl6040->audpwron, 0);
 
 			/* power-down sequence latency */
 			usleep_range(500, 700);
 		} else {
 			/* use manual power-down sequence */
-			twl6040_power_down(twl6040);
+			twl6040_power_down_manual(twl6040);
 		}
 		twl6040->sysclk = 0;
 		twl6040->mclk = 0;
-- 
1.7.12


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/6] MFD: twl6040: Correct Ready and Thermal interrupt handling
  2012-10-11 11:55 [PATCH 0/6] MFD: twl6040: Conversion to use regmap_irq Peter Ujfalusi
                   ` (2 preceding siblings ...)
  2012-10-11 11:55 ` [PATCH 3/6] MFD: twl6040: Restructure power up and down code Peter Ujfalusi
@ 2012-10-11 11:55 ` Peter Ujfalusi
  2012-10-11 11:55 ` [PATCH 5/6] MFD: twl6040: Convert to use regmap_irq Peter Ujfalusi
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Peter Ujfalusi @ 2012-10-11 11:55 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: linux-kernel, Mark Brown, peter.ujfalusi

Create new irq handler for thermal events in order to be able to handle the
event and clean up the code regarding to interrupt handling:
Use proper function names for the irq handlers
No need to read the INTD register anymore.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 drivers/mfd/twl6040-core.c | 52 +++++++++++++++++++++++++++-------------------
 1 file changed, 31 insertions(+), 21 deletions(-)

diff --git a/drivers/mfd/twl6040-core.c b/drivers/mfd/twl6040-core.c
index 6d9db27..5817bc6 100644
--- a/drivers/mfd/twl6040-core.c
+++ b/drivers/mfd/twl6040-core.c
@@ -193,27 +193,27 @@ static void twl6040_power_down_manual(struct twl6040 *twl6040)
 	twl6040_reg_write(twl6040, TWL6040_REG_LDOCTL, ldoctl);
 }
 
-static irqreturn_t twl6040_naudint_handler(int irq, void *data)
+static irqreturn_t twl6040_readyint_handler(int irq, void *data)
 {
 	struct twl6040 *twl6040 = data;
-	u8 intid, status;
 
-	intid = twl6040_reg_read(twl6040, TWL6040_REG_INTID);
+	complete(&twl6040->ready);
 
-	if (intid & TWL6040_READYINT)
-		complete(&twl6040->ready);
+	return IRQ_HANDLED;
+}
 
-	if (intid & TWL6040_THINT) {
-		status = twl6040_reg_read(twl6040, TWL6040_REG_STATUS);
-		if (status & TWL6040_TSHUTDET) {
-			dev_warn(twl6040->dev,
-				 "Thermal shutdown, powering-off");
-			twl6040_power(twl6040, 0);
-		} else {
-			dev_warn(twl6040->dev,
-				 "Leaving thermal shutdown, powering-on");
-			twl6040_power(twl6040, 1);
-		}
+static irqreturn_t twl6040_thint_handler(int irq, void *data)
+{
+	struct twl6040 *twl6040 = data;
+	u8 status;
+
+	status = twl6040_reg_read(twl6040, TWL6040_REG_STATUS);
+	if (status & TWL6040_TSHUTDET) {
+		dev_warn(twl6040->dev, "Thermal shutdown, powering-off");
+		twl6040_power(twl6040, 0);
+	} else {
+		dev_warn(twl6040->dev, "Leaving thermal shutdown, powering-on");
+		twl6040_power(twl6040, 1);
 	}
 
 	return IRQ_HANDLED;
@@ -580,12 +580,19 @@ static int __devinit twl6040_probe(struct i2c_client *client,
 		goto irq_init_err;
 
 	ret = request_threaded_irq(twl6040->irq_base + TWL6040_IRQ_READY,
-				   NULL, twl6040_naudint_handler, IRQF_ONESHOT,
+				   NULL, twl6040_readyint_handler, IRQF_ONESHOT,
 				   "twl6040_irq_ready", twl6040);
 	if (ret) {
-		dev_err(twl6040->dev, "READY IRQ request failed: %d\n",
-			ret);
-		goto irq_err;
+		dev_err(twl6040->dev, "READY IRQ request failed: %d\n", ret);
+		goto readyirq_err;
+	}
+
+	ret = request_threaded_irq(twl6040->irq_base + TWL6040_IRQ_TH,
+				   NULL, twl6040_thint_handler, IRQF_ONESHOT,
+				   "twl6040_irq_th", twl6040);
+	if (ret) {
+		dev_err(twl6040->dev, "Thermal IRQ request failed: %d\n", ret);
+		goto thirq_err;
 	}
 
 	/* dual-access registers controlled by I2C only */
@@ -650,8 +657,10 @@ static int __devinit twl6040_probe(struct i2c_client *client,
 	return 0;
 
 mfd_err:
+	free_irq(twl6040->irq_base + TWL6040_IRQ_TH, twl6040);
+thirq_err:
 	free_irq(twl6040->irq_base + TWL6040_IRQ_READY, twl6040);
-irq_err:
+readyirq_err:
 	twl6040_irq_exit(twl6040);
 irq_init_err:
 	if (gpio_is_valid(twl6040->audpwron))
@@ -677,6 +686,7 @@ static int __devexit twl6040_remove(struct i2c_client *client)
 		gpio_free(twl6040->audpwron);
 
 	free_irq(twl6040->irq_base + TWL6040_IRQ_READY, twl6040);
+	free_irq(twl6040->irq_base + TWL6040_IRQ_TH, twl6040);
 	twl6040_irq_exit(twl6040);
 
 	mfd_remove_devices(&client->dev);
-- 
1.7.12


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5/6] MFD: twl6040: Convert to use regmap_irq
  2012-10-11 11:55 [PATCH 0/6] MFD: twl6040: Conversion to use regmap_irq Peter Ujfalusi
                   ` (3 preceding siblings ...)
  2012-10-11 11:55 ` [PATCH 4/6] MFD: twl6040: Correct Ready and Thermal interrupt handling Peter Ujfalusi
@ 2012-10-11 11:55 ` Peter Ujfalusi
  2012-10-16  6:20   ` Mark Brown
  2012-10-11 11:55 ` [PATCH 6/6] MFD: twl6040: Rename the core driver Peter Ujfalusi
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 10+ messages in thread
From: Peter Ujfalusi @ 2012-10-11 11:55 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: linux-kernel, Mark Brown, peter.ujfalusi

With regmap_irq it is possibole to remove the twl6040-irq.c file and
simplify the code.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 drivers/mfd/Kconfig         |   4 +-
 drivers/mfd/Makefile        |   2 +-
 drivers/mfd/twl6040-core.c  |  55 ++++++++----
 drivers/mfd/twl6040-irq.c   | 205 --------------------------------------------
 include/linux/mfd/twl6040.h |  10 +--
 5 files changed, 48 insertions(+), 228 deletions(-)
 delete mode 100644 drivers/mfd/twl6040-irq.c

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index acab3ef..a0d0758 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -300,10 +300,10 @@ config MFD_TWL4030_AUDIO
 
 config TWL6040_CORE
 	bool "Support for TWL6040 audio codec"
-	depends on I2C=y && GENERIC_HARDIRQS
+	depends on I2C=y
 	select MFD_CORE
 	select REGMAP_I2C
-	select IRQ_DOMAIN
+	select REGMAP_IRQ
 	default n
 	help
 	  Say yes here if you want support for Texas Instruments TWL6040 audio
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index d8ccb63..360233f 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -63,7 +63,7 @@ obj-$(CONFIG_TWL4030_CORE)	+= twl-core.o twl4030-irq.o twl6030-irq.o
 obj-$(CONFIG_TWL4030_MADC)      += twl4030-madc.o
 obj-$(CONFIG_TWL4030_POWER)    += twl4030-power.o
 obj-$(CONFIG_MFD_TWL4030_AUDIO)	+= twl4030-audio.o
-obj-$(CONFIG_TWL6040_CORE)	+= twl6040-core.o twl6040-irq.o
+obj-$(CONFIG_TWL6040_CORE)	+= twl6040-core.o
 
 obj-$(CONFIG_MFD_MC13XXX)	+= mc13xxx-core.o
 obj-$(CONFIG_MFD_MC13XXX_SPI)	+= mc13xxx-spi.o
diff --git a/drivers/mfd/twl6040-core.c b/drivers/mfd/twl6040-core.c
index 5817bc6..e5f7b79 100644
--- a/drivers/mfd/twl6040-core.c
+++ b/drivers/mfd/twl6040-core.c
@@ -499,6 +499,25 @@ static struct regmap_config twl6040_regmap_config = {
 	.readable_reg = twl6040_readable_reg,
 };
 
+static const struct regmap_irq twl6040_irqs[] = {
+	{ .reg_offset = 0, .mask = TWL6040_THINT, },
+	{ .reg_offset = 0, .mask = TWL6040_PLUGINT | TWL6040_UNPLUGINT, },
+	{ .reg_offset = 0, .mask = TWL6040_HOOKINT, },
+	{ .reg_offset = 0, .mask = TWL6040_HFINT, },
+	{ .reg_offset = 0, .mask = TWL6040_VIBINT, },
+	{ .reg_offset = 0, .mask = TWL6040_READYINT, },
+};
+
+static struct regmap_irq_chip twl6040_irq_chip = {
+	.name = "twl6040",
+	.irqs = twl6040_irqs,
+	.num_irqs = ARRAY_SIZE(twl6040_irqs),
+
+	.num_regs = 1,
+	.status_base = TWL6040_REG_INTID,
+	.mask_base = TWL6040_REG_INTMR,
+};
+
 static int __devinit twl6040_probe(struct i2c_client *client,
 				     const struct i2c_device_id *id)
 {
@@ -574,21 +593,27 @@ static int __devinit twl6040_probe(struct i2c_client *client,
 			goto gpio_err;
 	}
 
-	/* codec interrupt */
-	ret = twl6040_irq_init(twl6040);
-	if (ret)
+	ret = regmap_add_irq_chip(twl6040->regmap, twl6040->irq,
+			IRQF_ONESHOT, 0, &twl6040_irq_chip,
+			&twl6040->irq_data);
+	if (ret < 0)
 		goto irq_init_err;
 
-	ret = request_threaded_irq(twl6040->irq_base + TWL6040_IRQ_READY,
-				   NULL, twl6040_readyint_handler, IRQF_ONESHOT,
+	twl6040->irq_ready = regmap_irq_get_virq(twl6040->irq_data,
+					       TWL6040_IRQ_READY);
+	twl6040->irq_th = regmap_irq_get_virq(twl6040->irq_data,
+					       TWL6040_IRQ_TH);
+
+	ret = request_threaded_irq(twl6040->irq_ready, NULL,
+				   twl6040_readyint_handler, IRQF_ONESHOT,
 				   "twl6040_irq_ready", twl6040);
 	if (ret) {
 		dev_err(twl6040->dev, "READY IRQ request failed: %d\n", ret);
 		goto readyirq_err;
 	}
 
-	ret = request_threaded_irq(twl6040->irq_base + TWL6040_IRQ_TH,
-				   NULL, twl6040_thint_handler, IRQF_ONESHOT,
+	ret = request_threaded_irq(twl6040->irq_th, NULL,
+				   twl6040_thint_handler, IRQF_ONESHOT,
 				   "twl6040_irq_th", twl6040);
 	if (ret) {
 		dev_err(twl6040->dev, "Thermal IRQ request failed: %d\n", ret);
@@ -604,7 +629,7 @@ static int __devinit twl6040_probe(struct i2c_client *client,
 	 * The ASoC codec can work without pdata, pass the platform_data only if
 	 * it has been provided.
 	 */
-	irq = twl6040->irq_base + TWL6040_IRQ_PLUG;
+	irq = regmap_irq_get_virq(twl6040->irq_data, TWL6040_IRQ_PLUG);
 	cell = &twl6040->cells[children];
 	cell->name = "twl6040-codec";
 	twl6040_codec_rsrc[0].start = irq;
@@ -618,7 +643,7 @@ static int __devinit twl6040_probe(struct i2c_client *client,
 	children++;
 
 	if (twl6040_has_vibra(pdata, node)) {
-		irq = twl6040->irq_base + TWL6040_IRQ_VIB;
+		irq = regmap_irq_get_virq(twl6040->irq_data, TWL6040_IRQ_VIB);
 
 		cell = &twl6040->cells[children];
 		cell->name = "twl6040-vibra";
@@ -657,11 +682,11 @@ static int __devinit twl6040_probe(struct i2c_client *client,
 	return 0;
 
 mfd_err:
-	free_irq(twl6040->irq_base + TWL6040_IRQ_TH, twl6040);
+	free_irq(twl6040->irq_th, twl6040);
 thirq_err:
-	free_irq(twl6040->irq_base + TWL6040_IRQ_READY, twl6040);
+	free_irq(twl6040->irq_ready, twl6040);
 readyirq_err:
-	twl6040_irq_exit(twl6040);
+	regmap_del_irq_chip(twl6040->irq, twl6040->irq_data);
 irq_init_err:
 	if (gpio_is_valid(twl6040->audpwron))
 		gpio_free(twl6040->audpwron);
@@ -685,9 +710,9 @@ static int __devexit twl6040_remove(struct i2c_client *client)
 	if (gpio_is_valid(twl6040->audpwron))
 		gpio_free(twl6040->audpwron);
 
-	free_irq(twl6040->irq_base + TWL6040_IRQ_READY, twl6040);
-	free_irq(twl6040->irq_base + TWL6040_IRQ_TH, twl6040);
-	twl6040_irq_exit(twl6040);
+	free_irq(twl6040->irq_ready, twl6040);
+	free_irq(twl6040->irq_th, twl6040);
+	regmap_del_irq_chip(twl6040->irq, twl6040->irq_data);
 
 	mfd_remove_devices(&client->dev);
 	i2c_set_clientdata(client, NULL);
diff --git a/drivers/mfd/twl6040-irq.c b/drivers/mfd/twl6040-irq.c
deleted file mode 100644
index 4b42543..0000000
--- a/drivers/mfd/twl6040-irq.c
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * Interrupt controller support for TWL6040
- *
- * Author:     Misael Lopez Cruz <misael.lopez@ti.com>
- *
- * Copyright:   (C) 2011 Texas Instruments, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
- *
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/err.h>
-#include <linux/irq.h>
-#include <linux/of.h>
-#include <linux/irqdomain.h>
-#include <linux/interrupt.h>
-#include <linux/mfd/core.h>
-#include <linux/mfd/twl6040.h>
-
-struct twl6040_irq_data {
-	int mask;
-	int status;
-};
-
-static struct twl6040_irq_data twl6040_irqs[] = {
-	{
-		.mask = TWL6040_THMSK,
-		.status = TWL6040_THINT,
-	},
-	{
-		.mask = TWL6040_PLUGMSK,
-		.status = TWL6040_PLUGINT | TWL6040_UNPLUGINT,
-	},
-	{
-		.mask = TWL6040_HOOKMSK,
-		.status = TWL6040_HOOKINT,
-	},
-	{
-		.mask = TWL6040_HFMSK,
-		.status = TWL6040_HFINT,
-	},
-	{
-		.mask = TWL6040_VIBMSK,
-		.status = TWL6040_VIBINT,
-	},
-	{
-		.mask = TWL6040_READYMSK,
-		.status = TWL6040_READYINT,
-	},
-};
-
-static inline
-struct twl6040_irq_data *irq_to_twl6040_irq(struct twl6040 *twl6040,
-					    int irq)
-{
-	return &twl6040_irqs[irq - twl6040->irq_base];
-}
-
-static void twl6040_irq_lock(struct irq_data *data)
-{
-	struct twl6040 *twl6040 = irq_data_get_irq_chip_data(data);
-
-	mutex_lock(&twl6040->irq_mutex);
-}
-
-static void twl6040_irq_sync_unlock(struct irq_data *data)
-{
-	struct twl6040 *twl6040 = irq_data_get_irq_chip_data(data);
-
-	/* write back to hardware any change in irq mask */
-	if (twl6040->irq_masks_cur != twl6040->irq_masks_cache) {
-		twl6040->irq_masks_cache = twl6040->irq_masks_cur;
-		twl6040_reg_write(twl6040, TWL6040_REG_INTMR,
-				  twl6040->irq_masks_cur);
-	}
-
-	mutex_unlock(&twl6040->irq_mutex);
-}
-
-static void twl6040_irq_enable(struct irq_data *data)
-{
-	struct twl6040 *twl6040 = irq_data_get_irq_chip_data(data);
-	struct twl6040_irq_data *irq_data = irq_to_twl6040_irq(twl6040,
-							       data->irq);
-
-	twl6040->irq_masks_cur &= ~irq_data->mask;
-}
-
-static void twl6040_irq_disable(struct irq_data *data)
-{
-	struct twl6040 *twl6040 = irq_data_get_irq_chip_data(data);
-	struct twl6040_irq_data *irq_data = irq_to_twl6040_irq(twl6040,
-							       data->irq);
-
-	twl6040->irq_masks_cur |= irq_data->mask;
-}
-
-static struct irq_chip twl6040_irq_chip = {
-	.name			= "twl6040",
-	.irq_bus_lock		= twl6040_irq_lock,
-	.irq_bus_sync_unlock	= twl6040_irq_sync_unlock,
-	.irq_enable		= twl6040_irq_enable,
-	.irq_disable		= twl6040_irq_disable,
-};
-
-static irqreturn_t twl6040_irq_thread(int irq, void *data)
-{
-	struct twl6040 *twl6040 = data;
-	u8 intid;
-	int i;
-
-	intid = twl6040_reg_read(twl6040, TWL6040_REG_INTID);
-
-	/* apply masking and report (backwards to handle READYINT first) */
-	for (i = ARRAY_SIZE(twl6040_irqs) - 1; i >= 0; i--) {
-		if (twl6040->irq_masks_cur & twl6040_irqs[i].mask)
-			intid &= ~twl6040_irqs[i].status;
-		if (intid & twl6040_irqs[i].status)
-			handle_nested_irq(twl6040->irq_base + i);
-	}
-
-	/* ack unmasked irqs */
-	twl6040_reg_write(twl6040, TWL6040_REG_INTID, intid);
-
-	return IRQ_HANDLED;
-}
-
-int twl6040_irq_init(struct twl6040 *twl6040)
-{
-	struct device_node *node = twl6040->dev->of_node;
-	int i, nr_irqs, irq_base, ret;
-	u8 val;
-
-	mutex_init(&twl6040->irq_mutex);
-
-	/* mask the individual interrupt sources */
-	twl6040->irq_masks_cur = TWL6040_ALLINT_MSK;
-	twl6040->irq_masks_cache = TWL6040_ALLINT_MSK;
-	twl6040_reg_write(twl6040, TWL6040_REG_INTMR, TWL6040_ALLINT_MSK);
-
-	nr_irqs = ARRAY_SIZE(twl6040_irqs);
-
-	irq_base = irq_alloc_descs(-1, 0, nr_irqs, 0);
-	if (IS_ERR_VALUE(irq_base)) {
-		dev_err(twl6040->dev, "Fail to allocate IRQ descs\n");
-		return irq_base;
-	}
-	twl6040->irq_base = irq_base;
-
-	irq_domain_add_legacy(node, ARRAY_SIZE(twl6040_irqs), irq_base, 0,
-			      &irq_domain_simple_ops, NULL);
-
-	/* Register them with genirq */
-	for (i = irq_base; i < irq_base + nr_irqs; i++) {
-		irq_set_chip_data(i, twl6040);
-		irq_set_chip_and_handler(i, &twl6040_irq_chip,
-					 handle_level_irq);
-		irq_set_nested_thread(i, 1);
-
-		/* ARM needs us to explicitly flag the IRQ as valid
-		 * and will set them noprobe when we do so. */
-#ifdef CONFIG_ARM
-		set_irq_flags(i, IRQF_VALID);
-#else
-		irq_set_noprobe(i);
-#endif
-	}
-
-	ret = request_threaded_irq(twl6040->irq, NULL, twl6040_irq_thread,
-				   IRQF_ONESHOT, "twl6040", twl6040);
-	if (ret) {
-		dev_err(twl6040->dev, "failed to request IRQ %d: %d\n",
-			twl6040->irq, ret);
-		return ret;
-	}
-
-	/* reset interrupts */
-	val = twl6040_reg_read(twl6040, TWL6040_REG_INTID);
-
-	/* interrupts cleared on write */
-	twl6040_clear_bits(twl6040, TWL6040_REG_ACCCTL, TWL6040_INTCLRMODE);
-
-	return 0;
-}
-EXPORT_SYMBOL(twl6040_irq_init);
-
-void twl6040_irq_exit(struct twl6040 *twl6040)
-{
-	free_irq(twl6040->irq, twl6040);
-}
-EXPORT_SYMBOL(twl6040_irq_exit);
diff --git a/include/linux/mfd/twl6040.h b/include/linux/mfd/twl6040.h
index a8eff4a..94ac944 100644
--- a/include/linux/mfd/twl6040.h
+++ b/include/linux/mfd/twl6040.h
@@ -207,10 +207,12 @@ struct twl6040_platform_data {
 };
 
 struct regmap;
+struct regmap_irq_chips_data;
 
 struct twl6040 {
 	struct device *dev;
 	struct regmap *regmap;
+	struct regmap_irq_chip_data *irq_data;
 	struct regulator_bulk_data supplies[2]; /* supplies for vio, v2v1 */
 	struct mutex mutex;
 	struct mutex irq_mutex;
@@ -228,9 +230,8 @@ struct twl6040 {
 	unsigned int mclk;
 
 	unsigned int irq;
-	unsigned int irq_base;
-	u8 irq_masks_cur;
-	u8 irq_masks_cache;
+	unsigned int irq_ready;
+	unsigned int irq_th;
 };
 
 int twl6040_reg_read(struct twl6040 *twl6040, unsigned int reg);
@@ -245,8 +246,7 @@ int twl6040_set_pll(struct twl6040 *twl6040, int pll_id,
 		    unsigned int freq_in, unsigned int freq_out);
 int twl6040_get_pll(struct twl6040 *twl6040);
 unsigned int twl6040_get_sysclk(struct twl6040 *twl6040);
-int twl6040_irq_init(struct twl6040 *twl6040);
-void twl6040_irq_exit(struct twl6040 *twl6040);
+
 /* Get the combined status of the vibra control register */
 int twl6040_get_vibralr_status(struct twl6040 *twl6040);
 
-- 
1.7.12


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 6/6] MFD: twl6040: Rename the core driver
  2012-10-11 11:55 [PATCH 0/6] MFD: twl6040: Conversion to use regmap_irq Peter Ujfalusi
                   ` (4 preceding siblings ...)
  2012-10-11 11:55 ` [PATCH 5/6] MFD: twl6040: Convert to use regmap_irq Peter Ujfalusi
@ 2012-10-11 11:55 ` Peter Ujfalusi
  2012-11-12 14:52 ` [PATCH 0/6] MFD: twl6040: Conversion to use regmap_irq Peter Ujfalusi
  2012-11-13 18:55 ` Samuel Ortiz
  7 siblings, 0 replies; 10+ messages in thread
From: Peter Ujfalusi @ 2012-10-11 11:55 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: linux-kernel, Mark Brown, peter.ujfalusi

After the regmap_irq conversion there is no need to call the driver
as twl6040-core.c since there is only one c file remained.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 drivers/mfd/Makefile                      | 2 +-
 drivers/mfd/{twl6040-core.c => twl6040.c} | 0
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename drivers/mfd/{twl6040-core.c => twl6040.c} (100%)

diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 360233f..8c8331b 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -63,7 +63,7 @@ obj-$(CONFIG_TWL4030_CORE)	+= twl-core.o twl4030-irq.o twl6030-irq.o
 obj-$(CONFIG_TWL4030_MADC)      += twl4030-madc.o
 obj-$(CONFIG_TWL4030_POWER)    += twl4030-power.o
 obj-$(CONFIG_MFD_TWL4030_AUDIO)	+= twl4030-audio.o
-obj-$(CONFIG_TWL6040_CORE)	+= twl6040-core.o
+obj-$(CONFIG_TWL6040_CORE)	+= twl6040.o
 
 obj-$(CONFIG_MFD_MC13XXX)	+= mc13xxx-core.o
 obj-$(CONFIG_MFD_MC13XXX_SPI)	+= mc13xxx-spi.o
diff --git a/drivers/mfd/twl6040-core.c b/drivers/mfd/twl6040.c
similarity index 100%
rename from drivers/mfd/twl6040-core.c
rename to drivers/mfd/twl6040.c
-- 
1.7.12


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 5/6] MFD: twl6040: Convert to use regmap_irq
  2012-10-11 11:55 ` [PATCH 5/6] MFD: twl6040: Convert to use regmap_irq Peter Ujfalusi
@ 2012-10-16  6:20   ` Mark Brown
  0 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2012-10-16  6:20 UTC (permalink / raw)
  To: Peter Ujfalusi; +Cc: Samuel Ortiz, linux-kernel

On Thu, Oct 11, 2012 at 01:55:32PM +0200, Peter Ujfalusi wrote:
> With regmap_irq it is possibole to remove the twl6040-irq.c file and
> simplify the code.

Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/6] MFD: twl6040: Conversion to use regmap_irq
  2012-10-11 11:55 [PATCH 0/6] MFD: twl6040: Conversion to use regmap_irq Peter Ujfalusi
                   ` (5 preceding siblings ...)
  2012-10-11 11:55 ` [PATCH 6/6] MFD: twl6040: Rename the core driver Peter Ujfalusi
@ 2012-11-12 14:52 ` Peter Ujfalusi
  2012-11-13 18:55 ` Samuel Ortiz
  7 siblings, 0 replies; 10+ messages in thread
From: Peter Ujfalusi @ 2012-11-12 14:52 UTC (permalink / raw)
  To: Peter Ujfalusi; +Cc: Samuel Ortiz, linux-kernel, Mark Brown

Hi Samuel,

On 10/11/2012 01:55 PM, Peter Ujfalusi wrote:
> Hello,
> 
> This series will convert the twl6040 MFD core driver to use regmap_irq instead
> of the custom interrupt code it used. In this way considerable amount of code
> can be removed and we are going to use common, well tested code for the interrupt
> dispatch.
> 
> The series is for 3.8.

Did you had time to look at this series?
I can resend it if it is better for you.

Regards,
Péter

> 
> Regards,
> Peter
> ---
> Peter Ujfalusi (6):
>   MFD: twl6040: Fix typo for power on failure
>   MFD: twl6040: Remove unused parameter for
>     twl6040_power_up_completion()
>   MFD: twl6040: Restructure power up and down code
>   MFD: twl6040: Correct Ready and Thermal interrupt handling
>   MFD: twl6040: Convert to use regmap_irq
>   MFD: twl6040: Rename the core driver
> 
>  drivers/mfd/Kconfig                       |   4 +-
>  drivers/mfd/Makefile                      |   2 +-
>  drivers/mfd/twl6040-irq.c                 | 205 ------------------------------
>  drivers/mfd/{twl6040-core.c => twl6040.c} | 137 ++++++++++++--------
>  include/linux/mfd/twl6040.h               |  10 +-
>  5 files changed, 92 insertions(+), 266 deletions(-)
>  delete mode 100644 drivers/mfd/twl6040-irq.c
>  rename drivers/mfd/{twl6040-core.c => twl6040.c} (84%)
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/6] MFD: twl6040: Conversion to use regmap_irq
  2012-10-11 11:55 [PATCH 0/6] MFD: twl6040: Conversion to use regmap_irq Peter Ujfalusi
                   ` (6 preceding siblings ...)
  2012-11-12 14:52 ` [PATCH 0/6] MFD: twl6040: Conversion to use regmap_irq Peter Ujfalusi
@ 2012-11-13 18:55 ` Samuel Ortiz
  7 siblings, 0 replies; 10+ messages in thread
From: Samuel Ortiz @ 2012-11-13 18:55 UTC (permalink / raw)
  To: Peter Ujfalusi; +Cc: linux-kernel, Mark Brown

On Thu, Oct 11, 2012 at 01:55:27PM +0200, Peter Ujfalusi wrote:
> Hello,
> 
> This series will convert the twl6040 MFD core driver to use regmap_irq instead
> of the custom interrupt code it used. In this way considerable amount of code
> can be removed and we are going to use common, well tested code for the interrupt
> dispatch.
Looks great. I applied all 6 patches to my for-next branch, thanks.
Mark, thanks for the review.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-11-13 18:55 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-11 11:55 [PATCH 0/6] MFD: twl6040: Conversion to use regmap_irq Peter Ujfalusi
2012-10-11 11:55 ` [PATCH 1/6] MFD: twl6040: Fix typo for power on failure Peter Ujfalusi
2012-10-11 11:55 ` [PATCH 2/6] MFD: twl6040: Remove unused parameter for twl6040_power_up_completion() Peter Ujfalusi
2012-10-11 11:55 ` [PATCH 3/6] MFD: twl6040: Restructure power up and down code Peter Ujfalusi
2012-10-11 11:55 ` [PATCH 4/6] MFD: twl6040: Correct Ready and Thermal interrupt handling Peter Ujfalusi
2012-10-11 11:55 ` [PATCH 5/6] MFD: twl6040: Convert to use regmap_irq Peter Ujfalusi
2012-10-16  6:20   ` Mark Brown
2012-10-11 11:55 ` [PATCH 6/6] MFD: twl6040: Rename the core driver Peter Ujfalusi
2012-11-12 14:52 ` [PATCH 0/6] MFD: twl6040: Conversion to use regmap_irq Peter Ujfalusi
2012-11-13 18:55 ` Samuel Ortiz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).