Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Peter Robinson <pbrobinson@gmail.com>
To: Shenghao Ding <shenghao-ding@ti.com>, Kevin Lu <kevin-lu@ti.com>,
	Baojun Xu <baojun.xu@ti.com>, Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
	Takashi Iwai <tiwai@suse.com>,
	linux-sound@vger.kernel.org
Cc: Peter Robinson <pbrobinson@gmail.com>
Subject: [PATCH] ASoC: pcm5102a: Add support for optional reset gpio
Date: Sat, 12 Sep 2026 09:24:18 +0100	[thread overview]
Message-ID: <20260912082422.331962-1-pbrobinson@gmail.com> (raw)

Add support for optional reset/enable gpios as per the trivial-codec.yaml
bindings that cover this basic PCM5102A driver. Some addons gate the
PCM5102A's supply through an external GPIO, and rather than forcing
this by using a manual config to drive the GPIO high use the documented
mechanism to do this. Based on similar functionality in the pcm1789 driver.

Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
---

The Pimoroni Pirate Audio [1] uses a PCM5100A DAC for audio and in it's docs
has you manually driving a GPIO high to enable the DAC. While creating
an overlay for the HAT I looked at the trivial codec bindings for the
DAC and it seems the details were already documented so this just adds
the ability to control this from the DAC DT rather than the documented
hack.

[1] https://shop.pimoroni.com/products/pirate-audio-line-out?variant=31189750546515

 sound/soc/codecs/pcm5102a.c | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/pcm5102a.c b/sound/soc/codecs/pcm5102a.c
index 9bca53de2475f..ed1e29e54ef8b 100644
--- a/sound/soc/codecs/pcm5102a.c
+++ b/sound/soc/codecs/pcm5102a.c
@@ -6,12 +6,17 @@
  *		Copyright 2013
  */
 
+#include <linux/gpio/consumer.h>
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 
 #include <sound/soc.h>
 
+struct pcm5102a_priv {
+	struct gpio_desc *gpio_reset;
+};
+
 static struct snd_soc_dai_driver pcm5102a_dai = {
 	.name = "pcm5102a-hifi",
 	.playback = {
@@ -32,10 +37,32 @@ static const struct snd_soc_component_driver soc_component_dev_pcm5102a = {
 
 static int pcm5102a_probe(struct platform_device *pdev)
 {
-	return devm_snd_soc_register_component(&pdev->dev, &soc_component_dev_pcm5102a,
+	struct device *dev = &pdev->dev;
+	struct pcm5102a_priv *pcm5102a;
+
+	pcm5102a = devm_kzalloc(dev, sizeof(*pcm5102a), GFP_KERNEL);
+	if (!pcm5102a)
+		return -ENOMEM;
+
+	pcm5102a->gpio_reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
+
+	if (IS_ERR(pcm5102a->gpio_reset))
+		return dev_err_probe(dev, PTR_ERR(pcm5102a->gpio_reset),
+					"failed to acquire reset gpio\n");
+
+	platform_set_drvdata(pdev, pcm5102a);
+
+	return devm_snd_soc_register_component(dev, &soc_component_dev_pcm5102a,
 			&pcm5102a_dai, 1);
 }
 
+static void pcm5102a_remove(struct platform_device *pdev)
+{
+	struct pcm5102a_priv *priv = platform_get_drvdata(pdev);
+
+	gpiod_set_value_cansleep(priv->gpio_reset, 1);
+}
+
 static const struct of_device_id pcm5102a_of_match[] = {
 	{ .compatible = "ti,pcm5102a", },
 	{ }
@@ -44,6 +71,7 @@ MODULE_DEVICE_TABLE(of, pcm5102a_of_match);
 
 static struct platform_driver pcm5102a_codec_driver = {
 	.probe		= pcm5102a_probe,
+	.remove		= pcm5102a_remove,
 	.driver		= {
 		.name	= "pcm5102a-codec",
 		.of_match_table = pcm5102a_of_match,
-- 
2.55.0


                 reply	other threads:[~2026-09-12  8:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260912082422.331962-1-pbrobinson@gmail.com \
    --to=pbrobinson@gmail.com \
    --cc=baojun.xu@ti.com \
    --cc=broonie@kernel.org \
    --cc=kevin-lu@ti.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=shenghao-ding@ti.com \
    --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