devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nuno Sa <nuno.sa@analog.com>
To: <linux-sound@vger.kernel.org>, <devicetree@vger.kernel.org>
Cc: Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
	Takashi Iwai <tiwai@suse.com>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>
Subject: [PATCH 4/4] ASoC: codecs: adau1373: add powerdown gpio
Date: Mon, 21 Oct 2024 15:46:48 +0200	[thread overview]
Message-ID: <20241021-adau1373-shutdown-v1-4-bec4ff9dfa16@analog.com> (raw)
In-Reply-To: <20241021-adau1373-shutdown-v1-0-bec4ff9dfa16@analog.com>

If the powerdown GPIO is specified, we use it for reset. Otherwise,
fallback to a software reset.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
---
 sound/soc/codecs/adau1373.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/adau1373.c b/sound/soc/codecs/adau1373.c
index 9568ff933e12ba939134a696c8d9c16a2ef04795..d5566b4c444f3a8be07cc17fbdbb5fee1b6442e9 100644
--- a/sound/soc/codecs/adau1373.c
+++ b/sound/soc/codecs/adau1373.c
@@ -8,6 +8,7 @@
 
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/gpio/consumer.h>
 #include <linux/delay.h>
 #include <linux/pm.h>
 #include <linux/property.h>
@@ -1547,6 +1548,7 @@ static int adau1373_parse_fw(struct device *dev, struct adau1373 *adau1373)
 static int adau1373_i2c_probe(struct i2c_client *client)
 {
 	struct adau1373 *adau1373;
+	struct gpio_desc *gpiod;
 	int ret;
 
 	adau1373 = devm_kzalloc(&client->dev, sizeof(*adau1373), GFP_KERNEL);
@@ -1558,7 +1560,21 @@ static int adau1373_i2c_probe(struct i2c_client *client)
 	if (IS_ERR(adau1373->regmap))
 		return PTR_ERR(adau1373->regmap);
 
-	regmap_write(adau1373->regmap, ADAU1373_SOFT_RESET, 0x00);
+	/*
+	 * If the powerdown GPIO is specified, we use it for reset. Otherwise
+	 * a software reset is done.
+	 */
+	gpiod = devm_gpiod_get_optional(&client->dev, "powerdown",
+					GPIOD_OUT_HIGH);
+	if (IS_ERR(gpiod))
+		return PTR_ERR(gpiod);
+
+	if (gpiod) {
+		gpiod_set_value_cansleep(gpiod, 0);
+		fsleep(10);
+	} else {
+		regmap_write(adau1373->regmap, ADAU1373_SOFT_RESET, 0x00);
+	}
 
 	dev_set_drvdata(&client->dev, adau1373);
 

-- 
2.47.0


  parent reply	other threads:[~2024-10-21 13:43 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-21 13:46 [PATCH 0/4] ASoC: codecs: adau1373: drop platform data Nuno Sa
2024-10-21 13:46 ` [PATCH 1/4] ASoC: codecs: adau1373: add some kconfig text Nuno Sa
2024-10-21 13:46 ` [PATCH 2/4] ASoC: dt-bindings: document the adau1373 Codec Nuno Sa
2024-10-22  6:06   ` Krzysztof Kozlowski
2024-10-22  6:42     ` Nuno Sá
2024-10-26 18:14       ` Krzysztof Kozlowski
2024-10-28 14:10         ` Nuno Sá
2024-10-21 13:46 ` [PATCH 3/4] ASoC: codecs: adau1373: drop patform_data Nuno Sa
2024-10-21 13:46 ` Nuno Sa [this message]
2024-10-21 15:30   ` [PATCH 4/4] ASoC: codecs: adau1373: add powerdown gpio Mark Brown
2024-10-22  6:39     ` Nuno Sá

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=20241021-adau1373-shutdown-v1-4-bec4ff9dfa16@analog.com \
    --to=nuno.sa@analog.com \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=lars@metafoo.de \
    --cc=lgirdwood@gmail.com \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=robh@kernel.org \
    --cc=tiwai@suse.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).