All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2] ASoC: tpa6130a2: Remove CPVSS and HPVdd supplies
@ 2010-05-19  7:30 Jarkko Nikula
  2010-05-19  7:52 ` [PATCHv3] " Jarkko Nikula
  0 siblings, 1 reply; 3+ messages in thread
From: Jarkko Nikula @ 2010-05-19  7:30 UTC (permalink / raw)
  To: alsa-devel; +Cc: Ilkka Koskinen, Mark Brown, Liam Girdwood

These pins are for decoupling capacitors for the internal charge pumps
in TPA6130A2 and TPA6140A2 and not for connecting external supply.

Thanks to Eduardo Valentin <eduardo.valentin@nokia.com> for pointing out the
issue with TPA6130A2 and Ilkka Koskinen <ilkka.koskinen@nokia.com> with
TPA6140A2.

Signed-off-by: Jarkko Nikula <jhnikula@gmail.com>
Acked-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Reviewed-by: Ilkka Koskinen <ilkka.koskinen@nokia.com>
---
v2:
- I took freedom to add ack and reviewed by lines as Peter and Ilkka gave
  those to v1
- HPVdd for the TPA6140A2 is also removed as it's for decoupling capacitor
  as well
- No need to use regulator_bulk API as there s only single supply for both
  supported chips now
---
 sound/soc/codecs/tpa6130a2.c |   50 ++++++++++++++---------------------------
 1 files changed, 17 insertions(+), 33 deletions(-)

diff --git a/sound/soc/codecs/tpa6130a2.c b/sound/soc/codecs/tpa6130a2.c
index 221bb90..f9b3d6d 100644
--- a/sound/soc/codecs/tpa6130a2.c
+++ b/sound/soc/codecs/tpa6130a2.c
@@ -36,22 +36,11 @@
 
 static struct i2c_client *tpa6130a2_client;
 
-#define TPA6130A2_NUM_SUPPLIES 2
-static const char *tpa6130a2_supply_names[TPA6130A2_NUM_SUPPLIES] = {
-	"CPVSS",
-	"Vdd",
-};
-
-static const char *tpa6140a2_supply_names[TPA6130A2_NUM_SUPPLIES] = {
-	"HPVdd",
-	"AVdd",
-};
-
 /* This struct is used to save the context */
 struct tpa6130a2_data {
 	struct mutex mutex;
 	unsigned char regs[TPA6130A2_CACHEREGNUM];
-	struct regulator_bulk_data supplies[TPA6130A2_NUM_SUPPLIES];
+	struct regulator *supply;
 	int power_gpio;
 	unsigned char power_state;
 	enum tpa_model id;
@@ -136,11 +125,10 @@ static int tpa6130a2_power(int power)
 		if (data->power_gpio >= 0)
 			gpio_set_value(data->power_gpio, 1);
 
-		ret = regulator_bulk_enable(ARRAY_SIZE(data->supplies),
-					    data->supplies);
+		ret = regulator_enable(data->supply);
 		if (ret != 0) {
 			dev_err(&tpa6130a2_client->dev,
-				"Failed to enable supplies: %d\n", ret);
+				"Failed to enable supply: %d\n", ret);
 			goto exit;
 		}
 
@@ -161,11 +149,10 @@ static int tpa6130a2_power(int power)
 		if (data->power_gpio >= 0)
 			gpio_set_value(data->power_gpio, 0);
 
-		ret = regulator_bulk_disable(ARRAY_SIZE(data->supplies),
-					     data->supplies);
+		ret = regulator_disable(data->supply);
 		if (ret != 0) {
 			dev_err(&tpa6130a2_client->dev,
-				"Failed to disable supplies: %d\n", ret);
+				"Failed to disable supply: %d\n", ret);
 			goto exit;
 		}
 
@@ -412,6 +399,7 @@ static int __devinit tpa6130a2_probe(struct i2c_client *client,
 	struct device *dev;
 	struct tpa6130a2_data *data;
 	struct tpa6130a2_platform_data *pdata;
+	const char *regulator;
 	int i, ret;
 
 	dev = &client->dev;
@@ -454,25 +442,21 @@ static int __devinit tpa6130a2_probe(struct i2c_client *client,
 	}
 
 	switch (data->id) {
+	default:
+		dev_warn(dev, "Unknown TPA model (%d). Assuming 6130A2\n",
+			 pdata->id);
 	case TPA6130A2:
-		for (i = 0; i < ARRAY_SIZE(data->supplies); i++)
-			data->supplies[i].supply = tpa6130a2_supply_names[i];
+		regulator = "Vdd";
 		break;
 	case TPA6140A2:
-		for (i = 0; i < ARRAY_SIZE(data->supplies); i++)
-			data->supplies[i].supply = tpa6140a2_supply_names[i];;
+		regulator = "AVdd";
 		break;
-	default:
-		dev_warn(dev, "Unknown TPA model (%d). Assuming 6130A2\n",
-			 pdata->id);
-		for (i = 0; i < ARRAY_SIZE(data->supplies); i++)
-			data->supplies[i].supply = tpa6130a2_supply_names[i];
 	}
 
-	ret = regulator_bulk_get(dev, ARRAY_SIZE(data->supplies),
-				 data->supplies);
-	if (ret != 0) {
-		dev_err(dev, "Failed to request supplies: %d\n", ret);
+	data->supply = regulator_get(dev, regulator);
+	if (IS_ERR(data->supply)) {
+		ret = PTR_ERR(data->supply);
+		dev_err(dev, "Failed to request supply: %d\n", ret);
 		goto err_regulator;
 	}
 
@@ -495,7 +479,7 @@ static int __devinit tpa6130a2_probe(struct i2c_client *client,
 	return 0;
 
 err_power:
-	regulator_bulk_free(ARRAY_SIZE(data->supplies), data->supplies);
+	regulator_put(data->supply);
 err_regulator:
 	if (data->power_gpio >= 0)
 		gpio_free(data->power_gpio);
@@ -516,7 +500,7 @@ static int __devexit tpa6130a2_remove(struct i2c_client *client)
 	if (data->power_gpio >= 0)
 		gpio_free(data->power_gpio);
 
-	regulator_bulk_free(ARRAY_SIZE(data->supplies), data->supplies);
+	regulator_put(data->supply);
 
 	kfree(data);
 	tpa6130a2_client = NULL;
-- 
1.7.1

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

* [PATCHv3] ASoC: tpa6130a2: Remove CPVSS and HPVdd supplies
  2010-05-19  7:30 [PATCHv2] ASoC: tpa6130a2: Remove CPVSS and HPVdd supplies Jarkko Nikula
@ 2010-05-19  7:52 ` Jarkko Nikula
  2010-05-20  9:31   ` Liam Girdwood
  0 siblings, 1 reply; 3+ messages in thread
From: Jarkko Nikula @ 2010-05-19  7:52 UTC (permalink / raw)
  To: alsa-devel; +Cc: Ilkka Koskinen, Mark Brown, Liam Girdwood

These pins are for decoupling capacitors for the internal charge pumps
in TPA6130A2 and TPA6140A2 and not for connecting external supply.

Thanks to Eduardo Valentin <eduardo.valentin@nokia.com> for pointing out the
issue with TPA6130A2 and Ilkka Koskinen <ilkka.koskinen@nokia.com> with
TPA6140A2.

Signed-off-by: Jarkko Nikula <jhnikula@gmail.com>
Acked-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Reviewed-by: Ilkka Koskinen <ilkka.koskinen@nokia.com>
---
v3:
- Removed unused variable i from tpa6130a2_probe

v2:
- I took freedom to add ack and reviewed by lines as Peter and Ilkka gave
  those to v1
- HPVdd for the TPA6140A2 is also removed as it's for decoupling capacitor
  as well
- No need to use regulator_bulk API as there s only single supply for both
  supported chips now
---
 sound/soc/codecs/tpa6130a2.c |   52 ++++++++++++++---------------------------
 1 files changed, 18 insertions(+), 34 deletions(-)

diff --git a/sound/soc/codecs/tpa6130a2.c b/sound/soc/codecs/tpa6130a2.c
index 221bb90..100a747 100644
--- a/sound/soc/codecs/tpa6130a2.c
+++ b/sound/soc/codecs/tpa6130a2.c
@@ -36,22 +36,11 @@
 
 static struct i2c_client *tpa6130a2_client;
 
-#define TPA6130A2_NUM_SUPPLIES 2
-static const char *tpa6130a2_supply_names[TPA6130A2_NUM_SUPPLIES] = {
-	"CPVSS",
-	"Vdd",
-};
-
-static const char *tpa6140a2_supply_names[TPA6130A2_NUM_SUPPLIES] = {
-	"HPVdd",
-	"AVdd",
-};
-
 /* This struct is used to save the context */
 struct tpa6130a2_data {
 	struct mutex mutex;
 	unsigned char regs[TPA6130A2_CACHEREGNUM];
-	struct regulator_bulk_data supplies[TPA6130A2_NUM_SUPPLIES];
+	struct regulator *supply;
 	int power_gpio;
 	unsigned char power_state;
 	enum tpa_model id;
@@ -136,11 +125,10 @@ static int tpa6130a2_power(int power)
 		if (data->power_gpio >= 0)
 			gpio_set_value(data->power_gpio, 1);
 
-		ret = regulator_bulk_enable(ARRAY_SIZE(data->supplies),
-					    data->supplies);
+		ret = regulator_enable(data->supply);
 		if (ret != 0) {
 			dev_err(&tpa6130a2_client->dev,
-				"Failed to enable supplies: %d\n", ret);
+				"Failed to enable supply: %d\n", ret);
 			goto exit;
 		}
 
@@ -161,11 +149,10 @@ static int tpa6130a2_power(int power)
 		if (data->power_gpio >= 0)
 			gpio_set_value(data->power_gpio, 0);
 
-		ret = regulator_bulk_disable(ARRAY_SIZE(data->supplies),
-					     data->supplies);
+		ret = regulator_disable(data->supply);
 		if (ret != 0) {
 			dev_err(&tpa6130a2_client->dev,
-				"Failed to disable supplies: %d\n", ret);
+				"Failed to disable supply: %d\n", ret);
 			goto exit;
 		}
 
@@ -412,7 +399,8 @@ static int __devinit tpa6130a2_probe(struct i2c_client *client,
 	struct device *dev;
 	struct tpa6130a2_data *data;
 	struct tpa6130a2_platform_data *pdata;
-	int i, ret;
+	const char *regulator;
+	int ret;
 
 	dev = &client->dev;
 
@@ -454,25 +442,21 @@ static int __devinit tpa6130a2_probe(struct i2c_client *client,
 	}
 
 	switch (data->id) {
+	default:
+		dev_warn(dev, "Unknown TPA model (%d). Assuming 6130A2\n",
+			 pdata->id);
 	case TPA6130A2:
-		for (i = 0; i < ARRAY_SIZE(data->supplies); i++)
-			data->supplies[i].supply = tpa6130a2_supply_names[i];
+		regulator = "Vdd";
 		break;
 	case TPA6140A2:
-		for (i = 0; i < ARRAY_SIZE(data->supplies); i++)
-			data->supplies[i].supply = tpa6140a2_supply_names[i];;
+		regulator = "AVdd";
 		break;
-	default:
-		dev_warn(dev, "Unknown TPA model (%d). Assuming 6130A2\n",
-			 pdata->id);
-		for (i = 0; i < ARRAY_SIZE(data->supplies); i++)
-			data->supplies[i].supply = tpa6130a2_supply_names[i];
 	}
 
-	ret = regulator_bulk_get(dev, ARRAY_SIZE(data->supplies),
-				 data->supplies);
-	if (ret != 0) {
-		dev_err(dev, "Failed to request supplies: %d\n", ret);
+	data->supply = regulator_get(dev, regulator);
+	if (IS_ERR(data->supply)) {
+		ret = PTR_ERR(data->supply);
+		dev_err(dev, "Failed to request supply: %d\n", ret);
 		goto err_regulator;
 	}
 
@@ -495,7 +479,7 @@ static int __devinit tpa6130a2_probe(struct i2c_client *client,
 	return 0;
 
 err_power:
-	regulator_bulk_free(ARRAY_SIZE(data->supplies), data->supplies);
+	regulator_put(data->supply);
 err_regulator:
 	if (data->power_gpio >= 0)
 		gpio_free(data->power_gpio);
@@ -516,7 +500,7 @@ static int __devexit tpa6130a2_remove(struct i2c_client *client)
 	if (data->power_gpio >= 0)
 		gpio_free(data->power_gpio);
 
-	regulator_bulk_free(ARRAY_SIZE(data->supplies), data->supplies);
+	regulator_put(data->supply);
 
 	kfree(data);
 	tpa6130a2_client = NULL;
-- 
1.7.1

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

* Re: [PATCHv3] ASoC: tpa6130a2: Remove CPVSS and HPVdd supplies
  2010-05-19  7:52 ` [PATCHv3] " Jarkko Nikula
@ 2010-05-20  9:31   ` Liam Girdwood
  0 siblings, 0 replies; 3+ messages in thread
From: Liam Girdwood @ 2010-05-20  9:31 UTC (permalink / raw)
  To: Jarkko Nikula; +Cc: Ilkka Koskinen, alsa-devel, Mark Brown

On Wed, 2010-05-19 at 10:52 +0300, Jarkko Nikula wrote:
> These pins are for decoupling capacitors for the internal charge pumps
> in TPA6130A2 and TPA6140A2 and not for connecting external supply.
> 
> Thanks to Eduardo Valentin <eduardo.valentin@nokia.com> for pointing out the
> issue with TPA6130A2 and Ilkka Koskinen <ilkka.koskinen@nokia.com> with
> TPA6140A2.
> 
> Signed-off-by: Jarkko Nikula <jhnikula@gmail.com>
> Acked-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
> Reviewed-by: Ilkka Koskinen <ilkka.koskinen@nokia.com>

Sorry, missed this one yesterday.

Applied.

Thanks

Liam
-- 
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk

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

end of thread, other threads:[~2010-05-20  9:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-19  7:30 [PATCHv2] ASoC: tpa6130a2: Remove CPVSS and HPVdd supplies Jarkko Nikula
2010-05-19  7:52 ` [PATCHv3] " Jarkko Nikula
2010-05-20  9:31   ` Liam Girdwood

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.