All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] ASoC: tlv320aic3x: Use gpio_is_valid in checking for valid gpio_reset
@ 2010-11-01 12:03 Jarkko Nikula
  2010-11-01 12:03 ` [PATCH 2/2] ASoC: tlv320aic3x: Add support to shared common reset line Jarkko Nikula
  2010-11-01 13:07 ` [PATCH 1/2] ASoC: tlv320aic3x: Use gpio_is_valid in checking for valid gpio_reset Mark Brown
  0 siblings, 2 replies; 5+ messages in thread
From: Jarkko Nikula @ 2010-11-01 12:03 UTC (permalink / raw)
  To: alsa-devel; +Cc: Mark Brown, Liam Girdwood

I promised to convert this at some point.

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

diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index fc68779..157b534 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -1075,7 +1075,7 @@ static int aic3x_regulator_event(struct notifier_block *nb,
 		 * Put codec to reset and require cache sync as at least one
 		 * of the supplies was disabled
 		 */
-		if (aic3x->gpio_reset >= 0)
+		if (gpio_is_valid(aic3x->gpio_reset))
 			gpio_set_value(aic3x->gpio_reset, 0);
 		aic3x->codec->cache_sync = 1;
 	}
@@ -1102,7 +1102,7 @@ static int aic3x_set_power(struct snd_soc_codec *codec, int power)
 		if (!codec->cache_sync)
 			goto out;
 
-		if (aic3x->gpio_reset >= 0) {
+		if (gpio_is_valid(aic3x->gpio_reset)) {
 			udelay(1);
 			gpio_set_value(aic3x->gpio_reset, 1);
 		}
@@ -1359,7 +1359,7 @@ static int aic3x_probe(struct snd_soc_codec *codec)
 		return ret;
 	}
 
-	if (aic3x->gpio_reset >= 0) {
+	if (gpio_is_valid(aic3x->gpio_reset)) {
 		ret = gpio_request(aic3x->gpio_reset, "tlv320aic3x reset");
 		if (ret != 0)
 			goto err_gpio;
@@ -1414,7 +1414,7 @@ err_notif:
 					      &aic3x->disable_nb[i].nb);
 	regulator_bulk_free(ARRAY_SIZE(aic3x->supplies), aic3x->supplies);
 err_get:
-	if (aic3x->gpio_reset >= 0)
+	if (gpio_is_valid(aic3x->gpio_reset))
 		gpio_free(aic3x->gpio_reset);
 err_gpio:
 	kfree(aic3x);
@@ -1427,7 +1427,7 @@ static int aic3x_remove(struct snd_soc_codec *codec)
 	int i;
 
 	aic3x_set_bias_level(codec, SND_SOC_BIAS_OFF);
-	if (aic3x->gpio_reset >= 0) {
+	if (gpio_is_valid(aic3x->gpio_reset)) {
 		gpio_set_value(aic3x->gpio_reset, 0);
 		gpio_free(aic3x->gpio_reset);
 	}
-- 
1.7.2.3

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

* [PATCH 2/2] ASoC: tlv320aic3x: Add support to shared common reset line
  2010-11-01 12:03 [PATCH 1/2] ASoC: tlv320aic3x: Use gpio_is_valid in checking for valid gpio_reset Jarkko Nikula
@ 2010-11-01 12:03 ` Jarkko Nikula
  2010-11-01 13:08   ` Mark Brown
  2010-11-01 13:07 ` [PATCH 1/2] ASoC: tlv320aic3x: Use gpio_is_valid in checking for valid gpio_reset Mark Brown
  1 sibling, 1 reply; 5+ messages in thread
From: Jarkko Nikula @ 2010-11-01 12:03 UTC (permalink / raw)
  To: alsa-devel; +Cc: Mark Brown, Liam Girdwood

This is aimed to configurations where multiple aic3x codecs share the same
reset line and are powered from same supply voltages.

Currently aic3x_probe will fail if trying to request already requested
gpio_reset and passing -1 to another aic3x instances cause that those
instances cannot release reset in aic3x_set_power. That is, another
instances can work only if primary aic3x instance is powered and reset is
released.

Solve this by implementing a list of probed instances that is used for
checking if other instance shares the same gpio_reset number. If a shared
reset line exists, then only first instance tries to request and configure
it and the last instance releases it.

Runtime modifications are not needed since aic3x_regulator_event with help
of regulator framework takes already care that reset is pulled down only
when some or all supplies are disabled meaning that all instances using them
are idle.

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

diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index 157b534..684ca3a 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -61,6 +61,8 @@ static const char *aic3x_supply_names[AIC3X_NUM_SUPPLIES] = {
 	"DRVDD",	/* ADC Analog and Output Driver Voltage */
 };
 
+static LIST_HEAD(reset_list);
+
 struct aic3x_priv;
 
 struct aic3x_disable_nb {
@@ -77,6 +79,7 @@ struct aic3x_priv {
 	struct aic3x_setup_data *setup;
 	void *control_data;
 	unsigned int sysclk;
+	struct list_head list;
 	int master;
 	int gpio_reset;
 	int power;
@@ -1344,11 +1347,25 @@ static int aic3x_init(struct snd_soc_codec *codec)
 	return 0;
 }
 
+static bool aic3x_is_shared_reset(struct aic3x_priv *aic3x)
+{
+	struct aic3x_priv *a;
+
+	list_for_each_entry(a, &reset_list, list) {
+		if (gpio_is_valid(aic3x->gpio_reset) &&
+		    aic3x->gpio_reset == a->gpio_reset)
+			return true;
+	}
+
+	return false;
+}
+
 static int aic3x_probe(struct snd_soc_codec *codec)
 {
 	struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec);
 	int ret, i;
 
+	INIT_LIST_HEAD(&aic3x->list);
 	codec->control_data = aic3x->control_data;
 	aic3x->codec = codec;
 	codec->idle_bias_off = 1;
@@ -1359,7 +1376,8 @@ static int aic3x_probe(struct snd_soc_codec *codec)
 		return ret;
 	}
 
-	if (gpio_is_valid(aic3x->gpio_reset)) {
+	if (gpio_is_valid(aic3x->gpio_reset) &&
+	    !aic3x_is_shared_reset(aic3x)) {
 		ret = gpio_request(aic3x->gpio_reset, "tlv320aic3x reset");
 		if (ret != 0)
 			goto err_gpio;
@@ -1405,6 +1423,7 @@ static int aic3x_probe(struct snd_soc_codec *codec)
 		snd_soc_add_controls(codec, &aic3x_classd_amp_gain_ctrl, 1);
 
 	aic3x_add_widgets(codec);
+	list_add(&aic3x->list, &reset_list);
 
 	return 0;
 
@@ -1414,7 +1433,8 @@ err_notif:
 					      &aic3x->disable_nb[i].nb);
 	regulator_bulk_free(ARRAY_SIZE(aic3x->supplies), aic3x->supplies);
 err_get:
-	if (gpio_is_valid(aic3x->gpio_reset))
+	if (gpio_is_valid(aic3x->gpio_reset) &&
+	    !aic3x_is_shared_reset(aic3x))
 		gpio_free(aic3x->gpio_reset);
 err_gpio:
 	kfree(aic3x);
@@ -1427,7 +1447,9 @@ static int aic3x_remove(struct snd_soc_codec *codec)
 	int i;
 
 	aic3x_set_bias_level(codec, SND_SOC_BIAS_OFF);
-	if (gpio_is_valid(aic3x->gpio_reset)) {
+	list_del(&aic3x->list);
+	if (gpio_is_valid(aic3x->gpio_reset) &&
+	    !aic3x_is_shared_reset(aic3x)) {
 		gpio_set_value(aic3x->gpio_reset, 0);
 		gpio_free(aic3x->gpio_reset);
 	}
-- 
1.7.2.3

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

* Re: [PATCH 1/2] ASoC: tlv320aic3x: Use gpio_is_valid in checking for valid gpio_reset
  2010-11-01 12:03 [PATCH 1/2] ASoC: tlv320aic3x: Use gpio_is_valid in checking for valid gpio_reset Jarkko Nikula
  2010-11-01 12:03 ` [PATCH 2/2] ASoC: tlv320aic3x: Add support to shared common reset line Jarkko Nikula
@ 2010-11-01 13:07 ` Mark Brown
  2010-11-03 14:21   ` Liam Girdwood
  1 sibling, 1 reply; 5+ messages in thread
From: Mark Brown @ 2010-11-01 13:07 UTC (permalink / raw)
  To: Jarkko Nikula; +Cc: alsa-devel, Liam Girdwood

On Mon, Nov 01, 2010 at 02:03:55PM +0200, Jarkko Nikula wrote:
> I promised to convert this at some point.
> 
> Signed-off-by: Jarkko Nikula <jhnikula@gmail.com>

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

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

* Re: [PATCH 2/2] ASoC: tlv320aic3x: Add support to shared common reset line
  2010-11-01 12:03 ` [PATCH 2/2] ASoC: tlv320aic3x: Add support to shared common reset line Jarkko Nikula
@ 2010-11-01 13:08   ` Mark Brown
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2010-11-01 13:08 UTC (permalink / raw)
  To: Jarkko Nikula; +Cc: alsa-devel, Liam Girdwood

On Mon, Nov 01, 2010 at 02:03:56PM +0200, Jarkko Nikula wrote:
> This is aimed to configurations where multiple aic3x codecs share the same
> reset line and are powered from same supply voltages.
> 
> Currently aic3x_probe will fail if trying to request already requested
> gpio_reset and passing -1 to another aic3x instances cause that those
> instances cannot release reset in aic3x_set_power. That is, another
> instances can work only if primary aic3x instance is powered and reset is
> released.
> 
> Solve this by implementing a list of probed instances that is used for
> checking if other instance shares the same gpio_reset number. If a shared
> reset line exists, then only first instance tries to request and configure
> it and the last instance releases it.

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

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

* Re: [PATCH 1/2] ASoC: tlv320aic3x: Use gpio_is_valid in checking for valid gpio_reset
  2010-11-01 13:07 ` [PATCH 1/2] ASoC: tlv320aic3x: Use gpio_is_valid in checking for valid gpio_reset Mark Brown
@ 2010-11-03 14:21   ` Liam Girdwood
  0 siblings, 0 replies; 5+ messages in thread
From: Liam Girdwood @ 2010-11-03 14:21 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel

On Mon, 2010-11-01 at 09:07 -0400, Mark Brown wrote:
> On Mon, Nov 01, 2010 at 02:03:55PM +0200, Jarkko Nikula wrote:
> > I promised to convert this at some point.
> > 
> > Signed-off-by: Jarkko Nikula <jhnikula@gmail.com>
> 
> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

Both applied.

Thanks

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

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

end of thread, other threads:[~2010-11-03 14:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-01 12:03 [PATCH 1/2] ASoC: tlv320aic3x: Use gpio_is_valid in checking for valid gpio_reset Jarkko Nikula
2010-11-01 12:03 ` [PATCH 2/2] ASoC: tlv320aic3x: Add support to shared common reset line Jarkko Nikula
2010-11-01 13:08   ` Mark Brown
2010-11-01 13:07 ` [PATCH 1/2] ASoC: tlv320aic3x: Use gpio_is_valid in checking for valid gpio_reset Mark Brown
2010-11-03 14:21   ` 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.