alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Mack <zonque@gmail.com>
To: alsa-devel@alsa-project.org
Cc: Timur Tabi <timur@freescale.com>,
	broonie@opensource.wolfsonmicro.com, lrg@ti.com,
	Daniel Mack <zonque@gmail.com>
Subject: [PATCH v3 2/2] ALSA: ASoC: Add reset-gpio DT property to cs4270 driver
Date: Wed, 25 Jul 2012 15:28:35 +0200	[thread overview]
Message-ID: <1343222915-26108-2-git-send-email-zonque@gmail.com> (raw)
In-Reply-To: <1343222915-26108-1-git-send-email-zonque@gmail.com>

In the process of moving over from static board files to the device
tree, reset pins of peripheral reset pins should be handled by their
corresponding drivers.

Add a reset-gpio DT property to the cs4270 driver, and de-assert it
before probing the chip. The logic could be augmented some day to
re-assert it when codec is put to suspend.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Cc: Timur Tabi <timur@freescale.com>
---
 v2: cleanups as requested by Timur
 v3: return error code in case devm_gpio_request_one() fails

 Documentation/devicetree/bindings/sound/cs4270.txt |    5 +++++
 sound/soc/codecs/cs4270.c                          |   17 +++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/cs4270.txt b/Documentation/devicetree/bindings/sound/cs4270.txt
index 7f0bfd8..6b222f9 100644
--- a/Documentation/devicetree/bindings/sound/cs4270.txt
+++ b/Documentation/devicetree/bindings/sound/cs4270.txt
@@ -8,6 +8,11 @@ Required properties:
 
   - reg : the I2C address of the device for I2C
 
+Optional properties:
+
+  - reset-gpio : a GPIO spec for the reset pin. If specified, it will be
+		 deasserted before communication to the codec starts.
+
 Example:
 
 codec: cs4270@48 {
diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c
index 4b71b01..fd11bb6 100644
--- a/sound/soc/codecs/cs4270.c
+++ b/sound/soc/codecs/cs4270.c
@@ -30,6 +30,7 @@
 #include <linux/delay.h>
 #include <linux/regulator/consumer.h>
 #include <linux/of_device.h>
+#include <linux/of_gpio.h>
 
 /*
  * The codec isn't really big-endian or little-endian, since the I2S
@@ -660,9 +661,25 @@ MODULE_DEVICE_TABLE(of, cs4270_of_match);
 static int cs4270_i2c_probe(struct i2c_client *i2c_client,
 	const struct i2c_device_id *id)
 {
+	struct device_node *np = i2c_client->dev.of_node;
 	struct cs4270_private *cs4270;
 	int ret;
 
+	/* See if we have a way to bring the codec out of reset */
+	if (np) {
+		enum of_gpio_flags flags;
+		int gpio = of_get_named_gpio_flags(np, "reset-gpio", 0, &flags);
+
+		if (gpio_is_valid(gpio)) {
+			ret = devm_gpio_request_one(&i2c_client->dev, gpio,
+				     flags & OF_GPIO_ACTIVE_LOW ?
+					GPIOF_OUT_INIT_LOW : GPIOF_OUT_INIT_HIGH,
+				     "cs4270 reset");
+			if (ret < 0)
+				return ret;
+		}
+	}
+
 	/* Verify that we have a CS4270 */
 
 	ret = i2c_smbus_read_byte_data(i2c_client, CS4270_CHIPID);
-- 
1.7.10.4

  reply	other threads:[~2012-07-25 13:28 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-25 13:28 [PATCH v3 1/2] ALSA: ASoC: add DT bindings for cs4270 Daniel Mack
2012-07-25 13:28 ` Daniel Mack [this message]
2012-07-25 22:08 ` Timur Tabi
2012-07-30 20:42 ` Timur Tabi
2012-07-30 21:06   ` Daniel Mack
2012-07-30 21:11     ` Timur Tabi
2012-07-31  3:54   ` Hebbar, Gururaja
2012-07-31 14:09   ` Mark Brown
2012-07-31 14:49     ` Timur Tabi
2012-07-31 16:00       ` Mark Brown
2012-07-31 16:02         ` Timur Tabi
2012-07-31 16:06           ` Mark Brown
2012-07-31 16:04 ` 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=1343222915-26108-2-git-send-email-zonque@gmail.com \
    --to=zonque@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=lrg@ti.com \
    --cc=timur@freescale.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).