public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] MFD: twl6040: Add regulator support for VIO, V2V1 supplies
@ 2012-05-02 13:54 Peter Ujfalusi
  2012-05-09 20:02 ` Samuel Ortiz
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Ujfalusi @ 2012-05-02 13:54 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: linux-kernel, Mark Brown, linux-omap

twl6040 has three power supply source:
VBAT needs to be connected to VBAT, VIO, and V2V1.
Add regulator support for the VIO, V2V1 supplies.
Initially handle the two supply together with bulk commands.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 drivers/mfd/twl6040-core.c  |   33 +++++++++++++++++++++++++++++----
 include/linux/mfd/twl6040.h |    2 ++
 2 files changed, 31 insertions(+), 4 deletions(-)

Hi Samuel,

The runtime dependencies for this patch has been sent to linux-omap list:
http://marc.info/?l=linux-omap&m=133596645010228&w=2
http://marc.info/?l=linux-omap&m=133596645610232&w=2
http://marc.info/?l=linux-omap&m=133596644310224&w=2
http://marc.info/?l=linux-omap&m=133596643310220&w=2

Alone this patch does not cause compile time regression but in runtime it needs
the arch/arm/mach-omap2 patches.
I try to avoid cross tree issues as much as I can and I'm happy if these will
come together in linux-next (and finally in 3.5).

Regards,
Peter

diff --git a/drivers/mfd/twl6040-core.c b/drivers/mfd/twl6040-core.c
index 493f4a6..7a92d95 100644
--- a/drivers/mfd/twl6040-core.c
+++ b/drivers/mfd/twl6040-core.c
@@ -27,6 +27,7 @@
 #include <linux/types.h>
 #include <linux/slab.h>
 #include <linux/kernel.h>
+#include <linux/err.h>
 #include <linux/platform_device.h>
 #include <linux/gpio.h>
 #include <linux/delay.h>
@@ -35,8 +36,10 @@
 #include <linux/err.h>
 #include <linux/mfd/core.h>
 #include <linux/mfd/twl6040.h>
+#include <linux/regulator/consumer.h>
 
 #define VIBRACTRL_MEMBER(reg) ((reg == TWL6040_REG_VIBCTLL) ? 0 : 1)
+#define TWL6040_NUM_SUPPLIES	(2)
 
 int twl6040_reg_read(struct twl6040 *twl6040, unsigned int reg)
 {
@@ -532,6 +535,21 @@ static int __devinit twl6040_probe(struct i2c_client *client,
 
 	i2c_set_clientdata(client, twl6040);
 
+	twl6040->supplies[0].supply = "vio";
+	twl6040->supplies[1].supply = "v2v1";
+	ret = regulator_bulk_get(&client->dev, TWL6040_NUM_SUPPLIES,
+				 twl6040->supplies);
+	if (ret != 0) {
+		dev_err(&client->dev, "Failed to get supplies: %d\n", ret);
+		goto regulator_get_err;
+	}
+
+	ret = regulator_bulk_enable(TWL6040_NUM_SUPPLIES, twl6040->supplies);
+	if (ret != 0) {
+		dev_err(&client->dev, "Failed to enable supplies: %d\n", ret);
+		goto power_err;
+	}
+
 	twl6040->dev = &client->dev;
 	twl6040->irq = client->irq;
 	twl6040->irq_base = pdata->irq_base;
@@ -552,13 +570,13 @@ static int __devinit twl6040_probe(struct i2c_client *client,
 		ret = gpio_request_one(twl6040->audpwron, GPIOF_OUT_INIT_LOW,
 				       "audpwron");
 		if (ret)
-			goto gpio1_err;
+			goto gpio_err;
 	}
 
 	/* codec interrupt */
 	ret = twl6040_irq_init(twl6040);
 	if (ret)
-		goto gpio2_err;
+		goto irq_init_err;
 
 	ret = request_threaded_irq(twl6040->irq_base + TWL6040_IRQ_READY,
 				   NULL, twl6040_naudint_handler, 0,
@@ -618,10 +636,14 @@ mfd_err:
 	free_irq(twl6040->irq_base + TWL6040_IRQ_READY, twl6040);
 irq_err:
 	twl6040_irq_exit(twl6040);
-gpio2_err:
+irq_init_err:
 	if (gpio_is_valid(twl6040->audpwron))
 		gpio_free(twl6040->audpwron);
-gpio1_err:
+gpio_err:
+	regulator_bulk_disable(TWL6040_NUM_SUPPLIES, twl6040->supplies);
+power_err:
+	regulator_bulk_free(TWL6040_NUM_SUPPLIES, twl6040->supplies);
+regulator_get_err:
 	i2c_set_clientdata(client, NULL);
 err:
 	return ret;
@@ -643,6 +665,9 @@ static int __devexit twl6040_remove(struct i2c_client *client)
 	mfd_remove_devices(&client->dev);
 	i2c_set_clientdata(client, NULL);
 
+	regulator_bulk_disable(TWL6040_NUM_SUPPLIES, twl6040->supplies);
+	regulator_bulk_free(TWL6040_NUM_SUPPLIES, twl6040->supplies);
+
 	return 0;
 }
 
diff --git a/include/linux/mfd/twl6040.h b/include/linux/mfd/twl6040.h
index b15b5f0..6659487 100644
--- a/include/linux/mfd/twl6040.h
+++ b/include/linux/mfd/twl6040.h
@@ -27,6 +27,7 @@
 
 #include <linux/interrupt.h>
 #include <linux/mfd/core.h>
+#include <linux/regulator/consumer.h>
 
 #define TWL6040_REG_ASICID		0x01
 #define TWL6040_REG_ASICREV		0x02
@@ -203,6 +204,7 @@ struct regmap;
 struct twl6040 {
 	struct device *dev;
 	struct regmap *regmap;
+	struct regulator_bulk_data supplies[2]; /* supplies for vio, v2v1 */
 	struct mutex mutex;
 	struct mutex io_mutex;
 	struct mutex irq_mutex;
-- 
1.7.8.6


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

* Re: [PATCH] MFD: twl6040: Add regulator support for VIO, V2V1 supplies
  2012-05-02 13:54 [PATCH] MFD: twl6040: Add regulator support for VIO, V2V1 supplies Peter Ujfalusi
@ 2012-05-09 20:02 ` Samuel Ortiz
  0 siblings, 0 replies; 2+ messages in thread
From: Samuel Ortiz @ 2012-05-09 20:02 UTC (permalink / raw)
  To: Peter Ujfalusi; +Cc: linux-kernel, Mark Brown, linux-omap, Tero Kristo

Hi Peter,

On Wed, May 02, 2012 at 04:54:42PM +0300, Peter Ujfalusi wrote:
> twl6040 has three power supply source:
> VBAT needs to be connected to VBAT, VIO, and V2V1.
> Add regulator support for the VIO, V2V1 supplies.
> Initially handle the two supply together with bulk commands.
> 
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
> Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> ---
>  drivers/mfd/twl6040-core.c  |   33 +++++++++++++++++++++++++++++----
>  include/linux/mfd/twl6040.h |    2 ++
>  2 files changed, 31 insertions(+), 4 deletions(-)
> 
> Hi Samuel,
> 
> The runtime dependencies for this patch has been sent to linux-omap list:
> http://marc.info/?l=linux-omap&m=133596645010228&w=2
> http://marc.info/?l=linux-omap&m=133596645610232&w=2
> http://marc.info/?l=linux-omap&m=133596644310224&w=2
> http://marc.info/?l=linux-omap&m=133596643310220&w=2
> 
> Alone this patch does not cause compile time regression but in runtime it needs
> the arch/arm/mach-omap2 patches.
> I try to avoid cross tree issues as much as I can and I'm happy if these will
> come together in linux-next (and finally in 3.5).
I applied this one to my nfc-next branch, thanks.

Cheers,
Samuel.

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

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

end of thread, other threads:[~2012-05-09 19:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-02 13:54 [PATCH] MFD: twl6040: Add regulator support for VIO, V2V1 supplies Peter Ujfalusi
2012-05-09 20:02 ` Samuel Ortiz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox