alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Vasily Khoruzhick <anarsoul@gmail.com>
To: Mark Brown <broonie@opensource.wolfsonmicro.com>,
	alsa-devel <alsa-devel@alsa-project.org>,
	Philipp Zabel <philipp.zabel@gmail.com>
Cc: Vasily Khoruzhick <anarsoul@gmail.com>
Subject: [PATCH RFC 1/3] ASoC: uda1380: use callbacks instead of gpiolib
Date: Sat, 26 Jun 2010 18:14:43 +0300	[thread overview]
Message-ID: <1277565285-11563-2-git-send-email-anarsoul@gmail.com> (raw)
In-Reply-To: <1277565285-11563-1-git-send-email-anarsoul@gmail.com>

Some machines require some tricks to enable/disable
codec, i.e. disable or enable i2s clock before enabling/disabling
codec, and just configuring gpio is not enough; some machines
have no reset pin (reset is performed on codec power on automatically).
Fix that issue by using machine-specific callback to enable codec power.

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
---
 include/sound/uda1380.h    |    3 +--
 sound/soc/codecs/uda1380.c |   25 +++----------------------
 2 files changed, 4 insertions(+), 24 deletions(-)

diff --git a/include/sound/uda1380.h b/include/sound/uda1380.h
index 381319c..d2171dc 100644
--- a/include/sound/uda1380.h
+++ b/include/sound/uda1380.h
@@ -12,8 +12,7 @@
 #define __UDA1380_H
 
 struct uda1380_platform_data {
-	int gpio_power;
-	int gpio_reset;
+	void (*set_power)(int);
 	int dac_clk;
 #define UDA1380_DAC_CLK_SYSCLK 0
 #define UDA1380_DAC_CLK_WSPLL  1
diff --git a/sound/soc/codecs/uda1380.c b/sound/soc/codecs/uda1380.c
index 2f925a2..2b7f200 100644
--- a/sound/soc/codecs/uda1380.c
+++ b/sound/soc/codecs/uda1380.c
@@ -19,7 +19,6 @@
 #include <linux/types.h>
 #include <linux/slab.h>
 #include <linux/errno.h>
-#include <linux/gpio.h>
 #include <linux/delay.h>
 #include <linux/i2c.h>
 #include <linux/workqueue.h>
@@ -752,22 +751,11 @@ static int uda1380_register(struct uda1380_priv *uda1380)
 		return -EINVAL;
 	}
 
-	if (!pdata || !pdata->gpio_power || !pdata->gpio_reset)
+	if (!pdata || !pdata->set_power)
 		return -EINVAL;
 
-	ret = gpio_request(pdata->gpio_power, "uda1380 power");
-	if (ret)
-		goto err_out;
-	ret = gpio_request(pdata->gpio_reset, "uda1380 reset");
-	if (ret)
-		goto err_gpio;
-
-	gpio_direction_output(pdata->gpio_power, 1);
-
 	/* we may need to have the clock running here - pH5 */
-	gpio_direction_output(pdata->gpio_reset, 1);
-	udelay(5);
-	gpio_set_value(pdata->gpio_reset, 0);
+	pdata->set_power(1);
 
 	mutex_init(&codec->mutex);
 	INIT_LIST_HEAD(&codec->dapm_widgets);
@@ -818,11 +806,6 @@ static int uda1380_register(struct uda1380_priv *uda1380)
 err_dai:
 	snd_soc_unregister_codec(codec);
 err_reset:
-	gpio_set_value(pdata->gpio_power, 0);
-	gpio_free(pdata->gpio_reset);
-err_gpio:
-	gpio_free(pdata->gpio_power);
-err_out:
 	return ret;
 }
 
@@ -834,9 +817,7 @@ static void uda1380_unregister(struct uda1380_priv *uda1380)
 	snd_soc_unregister_dais(uda1380_dai, ARRAY_SIZE(uda1380_dai));
 	snd_soc_unregister_codec(&uda1380->codec);
 
-	gpio_set_value(pdata->gpio_power, 0);
-	gpio_free(pdata->gpio_reset);
-	gpio_free(pdata->gpio_power);
+	pdata->set_power(0);
 
 	kfree(uda1380);
 	uda1380_codec = NULL;
-- 
1.7.1

  reply	other threads:[~2010-06-26 15:15 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-26 15:14 [PATCH RFC 0/3] asoc: uda1380 cleanup Vasily Khoruzhick
2010-06-26 15:14 ` Vasily Khoruzhick [this message]
2010-06-26 16:40   ` [PATCH RFC 1/3] ASoC: uda1380: use callbacks instead of gpiolib Mark Brown
2010-06-26 16:53     ` Vasily Khoruzhick
2010-06-26 20:09       ` Mark Brown
2010-06-26 20:53         ` Vasily Khoruzhick
2010-06-26 20:57           ` Mark Brown
2010-06-26 21:12             ` Vasily Khoruzhick
2010-06-27 10:21               ` Mark Brown
2010-06-28 12:00             ` Vasily Khoruzhick
2010-06-28 13:41               ` Mark Brown
2010-06-28 13:49                 ` Vasily Khoruzhick
2010-06-28 13:50                   ` Mark Brown
2010-06-28 14:05                     ` Vasily Khoruzhick
2010-06-28 14:15                       ` Mark Brown
2010-06-28 14:25                         ` Vasily Khoruzhick
     [not found]                       ` <AANLkTilfEIEBaHO8FupS9wU3FR3VGc_yUVNP8KPJ30jW@mail.gmail.com>
2010-06-28 14:32                         ` Mark Brown
2010-06-26 15:14 ` [PATCH RFC 2/3] magician: pass .set_power callback to uda1380 pdata Vasily Khoruzhick
2010-06-26 15:14 ` [PATCH RFC 3/3] uda1380: make driver more powersave-friendly Vasily Khoruzhick
2010-06-26 20:45   ` Mark Brown
2010-06-26 21:07     ` Vasily Khoruzhick
2010-06-27 10:10       ` Mark Brown
2010-06-27 10:43         ` Vasily Khoruzhick
2010-06-27 20:55           ` Mark Brown
2010-06-27 21:15             ` Vasily Khoruzhick
2010-06-27 21:40               ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1277565285-11563-2-git-send-email-anarsoul@gmail.com \
    --to=anarsoul@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=philipp.zabel@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).