alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] ASoC: tlv320aic3x: Remove unused version string
@ 2010-04-26 12:49 Jarkko Nikula
  2010-04-26 12:49 ` [PATCH 2/4] ASoC: tlv320aic3x: Remove needless power off from aic3x_set_bias_level Jarkko Nikula
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Jarkko Nikula @ 2010-04-26 12:49 UTC (permalink / raw)
  To: alsa-devel; +Cc: Mark Brown

Signed-off-by: Jarkko Nikula <jhnikula@gmail.com>
---
 sound/soc/codecs/tlv320aic3x.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index 5be580e..af463d8 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -50,8 +50,6 @@
 
 #include "tlv320aic3x.h"
 
-#define AIC3X_VERSION "0.2"
-
 /* codec private data */
 struct aic3x_priv {
 	struct snd_soc_codec codec;
-- 
1.7.0

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

* [PATCH 2/4] ASoC: tlv320aic3x: Remove needless power off from aic3x_set_bias_level
  2010-04-26 12:49 [PATCH 1/4] ASoC: tlv320aic3x: Remove unused version string Jarkko Nikula
@ 2010-04-26 12:49 ` Jarkko Nikula
  2010-04-26 12:49 ` [PATCH 3/4] ASoC: tlv320aic3x: Change bias management semantics Jarkko Nikula
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Jarkko Nikula @ 2010-04-26 12:49 UTC (permalink / raw)
  To: alsa-devel; +Cc: Mark Brown

These ADC, DAC and output pin power off commands are needless in
aic3x_set_bias_level since they are not enabled in aic3x_init and they are
defined in aic3x_dapm_widgets so the ASoC DAPM will take care of them
anyway.

Signed-off-by: Jarkko Nikula <jhnikula@gmail.com>
---
 sound/soc/codecs/tlv320aic3x.c |   34 ----------------------------------
 1 files changed, 0 insertions(+), 34 deletions(-)

diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index af463d8..7548c9d 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -1013,41 +1013,7 @@ static int aic3x_set_bias_level(struct snd_soc_codec *codec,
 		 * all power is driven by DAPM system,
 		 * so output power is safe if bypass was set
 		 */
-		if (aic3x->master) {
-			/* disable pll */
-			reg = aic3x_read_reg_cache(codec, AIC3X_PLL_PROGA_REG);
-			aic3x_write(codec, AIC3X_PLL_PROGA_REG,
-				    reg & ~PLL_ENABLE);
-		}
-		break;
 	case SND_SOC_BIAS_OFF:
-		/* force all power off */
-		reg = aic3x_read_reg_cache(codec, LINE1L_2_LADC_CTRL);
-		aic3x_write(codec, LINE1L_2_LADC_CTRL, reg & ~LADC_PWR_ON);
-		reg = aic3x_read_reg_cache(codec, LINE1R_2_RADC_CTRL);
-		aic3x_write(codec, LINE1R_2_RADC_CTRL, reg & ~RADC_PWR_ON);
-
-		reg = aic3x_read_reg_cache(codec, DAC_PWR);
-		aic3x_write(codec, DAC_PWR, reg & ~(LDAC_PWR_ON | RDAC_PWR_ON));
-
-		reg = aic3x_read_reg_cache(codec, HPLOUT_CTRL);
-		aic3x_write(codec, HPLOUT_CTRL, reg & ~HPLOUT_PWR_ON);
-		reg = aic3x_read_reg_cache(codec, HPROUT_CTRL);
-		aic3x_write(codec, HPROUT_CTRL, reg & ~HPROUT_PWR_ON);
-
-		reg = aic3x_read_reg_cache(codec, HPLCOM_CTRL);
-		aic3x_write(codec, HPLCOM_CTRL, reg & ~HPLCOM_PWR_ON);
-		reg = aic3x_read_reg_cache(codec, HPRCOM_CTRL);
-		aic3x_write(codec, HPRCOM_CTRL, reg & ~HPRCOM_PWR_ON);
-
-		reg = aic3x_read_reg_cache(codec, MONOLOPM_CTRL);
-		aic3x_write(codec, MONOLOPM_CTRL, reg & ~MONOLOPM_PWR_ON);
-
-		reg = aic3x_read_reg_cache(codec, LLOPM_CTRL);
-		aic3x_write(codec, LLOPM_CTRL, reg & ~LLOPM_PWR_ON);
-		reg = aic3x_read_reg_cache(codec, RLOPM_CTRL);
-		aic3x_write(codec, RLOPM_CTRL, reg & ~RLOPM_PWR_ON);
-
 		if (aic3x->master) {
 			/* disable pll */
 			reg = aic3x_read_reg_cache(codec, AIC3X_PLL_PROGA_REG);
-- 
1.7.0

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

* [PATCH 3/4] ASoC: tlv320aic3x: Change bias management semantics
  2010-04-26 12:49 [PATCH 1/4] ASoC: tlv320aic3x: Remove unused version string Jarkko Nikula
  2010-04-26 12:49 ` [PATCH 2/4] ASoC: tlv320aic3x: Remove needless power off from aic3x_set_bias_level Jarkko Nikula
@ 2010-04-26 12:49 ` Jarkko Nikula
  2010-04-26 12:49 ` [PATCH 4/4] ASoC: tlv320aic3x: Add basic regulator support Jarkko Nikula
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Jarkko Nikula @ 2010-04-26 12:49 UTC (permalink / raw)
  To: alsa-devel; +Cc: Mark Brown

Move PLL enable from BIAS_ON state to BIAS_PREPARE to be pair with
BIAS_STANDBY where PLL is disabled. Remove also old comments about power
control.

Signed-off-by: Jarkko Nikula <jhnikula@gmail.com>
---
 sound/soc/codecs/tlv320aic3x.c |   10 +++-------
 1 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index 7548c9d..d8f1b86 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -998,7 +998,8 @@ static int aic3x_set_bias_level(struct snd_soc_codec *codec,
 
 	switch (level) {
 	case SND_SOC_BIAS_ON:
-		/* all power is driven by DAPM system */
+		break;
+	case SND_SOC_BIAS_PREPARE:
 		if (aic3x->master) {
 			/* enable pll */
 			reg = aic3x_read_reg_cache(codec, AIC3X_PLL_PROGA_REG);
@@ -1006,13 +1007,8 @@ static int aic3x_set_bias_level(struct snd_soc_codec *codec,
 				    reg | PLL_ENABLE);
 		}
 		break;
-	case SND_SOC_BIAS_PREPARE:
-		break;
 	case SND_SOC_BIAS_STANDBY:
-		/*
-		 * all power is driven by DAPM system,
-		 * so output power is safe if bypass was set
-		 */
+		/* fall through and disable pll */
 	case SND_SOC_BIAS_OFF:
 		if (aic3x->master) {
 			/* disable pll */
-- 
1.7.0

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

* [PATCH 4/4] ASoC: tlv320aic3x: Add basic regulator support
  2010-04-26 12:49 [PATCH 1/4] ASoC: tlv320aic3x: Remove unused version string Jarkko Nikula
  2010-04-26 12:49 ` [PATCH 2/4] ASoC: tlv320aic3x: Remove needless power off from aic3x_set_bias_level Jarkko Nikula
  2010-04-26 12:49 ` [PATCH 3/4] ASoC: tlv320aic3x: Change bias management semantics Jarkko Nikula
@ 2010-04-26 12:49 ` Jarkko Nikula
  2010-04-26 14:25 ` [PATCH 1/4] ASoC: tlv320aic3x: Remove unused version string Mark Brown
  2010-04-27 10:38 ` Liam Girdwood
  4 siblings, 0 replies; 6+ messages in thread
From: Jarkko Nikula @ 2010-04-26 12:49 UTC (permalink / raw)
  To: alsa-devel; +Cc: Mark Brown

This patch adds the TLV320AIC3x supplies and enables all of them for the
entire lifetime of the device.

Signed-off-by: Jarkko Nikula <jhnikula@gmail.com>

---

TODO:
In theory it should be possible to cut analogue powers of the codec while
it is idle or suspended but experimenting with this showed that e.g. HP
outputs were more silent after ramping up than they were before cutting the
analogue powers.
It seems that some sort of workaround might be needed for recovering.

I don't have a hardware test with digital power domain gating so now all
the supplies are grouped together and they are kept on always.
---
 sound/soc/codecs/tlv320aic3x.c |   37 +++++++++++++++++++++++++++++++++++++
 1 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index d8f1b86..b2c2794 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -38,6 +38,7 @@
 #include <linux/delay.h>
 #include <linux/pm.h>
 #include <linux/i2c.h>
+#include <linux/regulator/consumer.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <sound/core.h>
@@ -50,9 +51,18 @@
 
 #include "tlv320aic3x.h"
 
+#define AIC3X_NUM_SUPPLIES	4
+static const char *aic3x_supply_names[AIC3X_NUM_SUPPLIES] = {
+	"IOVDD",	/* I/O Voltage */
+	"DVDD",		/* Digital Core Voltage */
+	"AVDD",		/* Analog DAC Voltage */
+	"DRVDD",	/* ADC Analog and Output Driver Voltage */
+};
+
 /* codec private data */
 struct aic3x_priv {
 	struct snd_soc_codec codec;
+	struct regulator_bulk_data supplies[AIC3X_NUM_SUPPLIES];
 	unsigned int sysclk;
 	int master;
 };
@@ -1269,6 +1279,9 @@ static int aic3x_unregister(struct aic3x_priv *aic3x)
 	snd_soc_unregister_dai(&aic3x_dai);
 	snd_soc_unregister_codec(&aic3x->codec);
 
+	regulator_bulk_disable(ARRAY_SIZE(aic3x->supplies), aic3x->supplies);
+	regulator_bulk_free(ARRAY_SIZE(aic3x->supplies), aic3x->supplies);
+
 	kfree(aic3x);
 	aic3x_codec = NULL;
 
@@ -1290,6 +1303,7 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
 {
 	struct snd_soc_codec *codec;
 	struct aic3x_priv *aic3x;
+	int ret, i;
 
 	aic3x = kzalloc(sizeof(struct aic3x_priv), GFP_KERNEL);
 	if (aic3x == NULL) {
@@ -1305,7 +1319,30 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
 
 	i2c_set_clientdata(i2c, aic3x);
 
+	for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++)
+		aic3x->supplies[i].supply = aic3x_supply_names[i];
+
+	ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(aic3x->supplies),
+				 aic3x->supplies);
+	if (ret != 0) {
+		dev_err(codec->dev, "Failed to request supplies: %d\n", ret);
+		goto err_get;
+	}
+
+	ret = regulator_bulk_enable(ARRAY_SIZE(aic3x->supplies),
+				    aic3x->supplies);
+	if (ret != 0) {
+		dev_err(codec->dev, "Failed to enable supplies: %d\n", ret);
+		goto err_enable;
+	}
+
 	return aic3x_register(codec);
+
+err_enable:
+	regulator_bulk_free(ARRAY_SIZE(aic3x->supplies), aic3x->supplies);
+err_get:
+	kfree(aic3x);
+	return ret;
 }
 
 static int aic3x_i2c_remove(struct i2c_client *client)
-- 
1.7.0

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

* Re: [PATCH 1/4] ASoC: tlv320aic3x: Remove unused version string
  2010-04-26 12:49 [PATCH 1/4] ASoC: tlv320aic3x: Remove unused version string Jarkko Nikula
                   ` (2 preceding siblings ...)
  2010-04-26 12:49 ` [PATCH 4/4] ASoC: tlv320aic3x: Add basic regulator support Jarkko Nikula
@ 2010-04-26 14:25 ` Mark Brown
  2010-04-27 10:38 ` Liam Girdwood
  4 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2010-04-26 14:25 UTC (permalink / raw)
  To: Jarkko Nikula; +Cc: alsa-devel

On Mon, Apr 26, 2010 at 03:49:11PM +0300, Jarkko Nikula wrote:
> Signed-off-by: Jarkko Nikula <jhnikula@gmail.com>

All of these are 

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

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

* Re: [PATCH 1/4] ASoC: tlv320aic3x: Remove unused version string
  2010-04-26 12:49 [PATCH 1/4] ASoC: tlv320aic3x: Remove unused version string Jarkko Nikula
                   ` (3 preceding siblings ...)
  2010-04-26 14:25 ` [PATCH 1/4] ASoC: tlv320aic3x: Remove unused version string Mark Brown
@ 2010-04-27 10:38 ` Liam Girdwood
  4 siblings, 0 replies; 6+ messages in thread
From: Liam Girdwood @ 2010-04-27 10:38 UTC (permalink / raw)
  To: Jarkko Nikula; +Cc: alsa-devel, Mark Brown

On Mon, 2010-04-26 at 15:49 +0300, Jarkko Nikula wrote:
> Signed-off-by: Jarkko Nikula <jhnikula@gmail.com>
> ---
>  sound/soc/codecs/tlv320aic3x.c |    2 --
>  1 files changed, 0 insertions(+), 2 deletions(-)

All applied.

Thanks

Liam

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

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

end of thread, other threads:[~2010-04-27 10:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-26 12:49 [PATCH 1/4] ASoC: tlv320aic3x: Remove unused version string Jarkko Nikula
2010-04-26 12:49 ` [PATCH 2/4] ASoC: tlv320aic3x: Remove needless power off from aic3x_set_bias_level Jarkko Nikula
2010-04-26 12:49 ` [PATCH 3/4] ASoC: tlv320aic3x: Change bias management semantics Jarkko Nikula
2010-04-26 12:49 ` [PATCH 4/4] ASoC: tlv320aic3x: Add basic regulator support Jarkko Nikula
2010-04-26 14:25 ` [PATCH 1/4] ASoC: tlv320aic3x: Remove unused version string Mark Brown
2010-04-27 10:38 ` Liam Girdwood

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).