ASoC: pcm5102a: Add support for optional reset gpio
Subsystems (3)
PATCH 1/1 ASoC: pcm5102a: Add support for optional reset gpio
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.
---
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(-)
sound/soc/codecs/pcm5102a.c +29 -1
@@ -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,
Signature · 1 line
2.55.0
Mark Brown
maintainerQuoted 1 line · Peter Robinson
ASoC: pcm5102a: Add support for optional reset gpio
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.4
Thanks!
[1/1] ASoC: pcm5102a: Add support for optional reset gpio
https://git.kernel.org/broonie/sound/c/81d2ec6f924e
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark