lkml.org 
[lkml]   [2018]   [Feb]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v1 3/4] ASoC: codecs: pcm179x: Add reset gpio
Date
Add a reset gpio to be able to reset this line at startup.

Signed-off-by: Mylène Josserand <mylene.josserand@bootlin.com>
---
sound/soc/codecs/pcm179x.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)

diff --git a/sound/soc/codecs/pcm179x.c b/sound/soc/codecs/pcm179x.c
index 2285a51ff9e9..0242dfd67b53 100644
--- a/sound/soc/codecs/pcm179x.c
+++ b/sound/soc/codecs/pcm179x.c
@@ -22,6 +22,8 @@
#include <linux/device.h>

#include <sound/core.h>
+#include <linux/gpio.h>
+#include <linux/of_gpio.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/initval.h>
@@ -106,6 +108,7 @@ struct pcm179x_private {
struct regmap *regmap;
unsigned int format;
unsigned int rate;
+ int reset;
};

static int pcm179x_set_dai_fmt(struct snd_soc_dai *codec_dai,
@@ -381,6 +384,8 @@ int pcm179x_common_init(struct device *dev, struct regmap *regmap,
enum pcm17xx_type type)
{
struct pcm179x_private *pcm179x;
+ struct device_node *np = dev->of_node;
+ int ret;

pcm179x = devm_kzalloc(dev, sizeof(struct pcm179x_private),
GFP_KERNEL);
@@ -390,6 +395,21 @@ int pcm179x_common_init(struct device *dev, struct regmap *regmap,
pcm179x->regmap = regmap;
dev_set_drvdata(dev, pcm179x);

+ pcm179x->reset = of_get_named_gpio(np, "reset-gpios", 0);
+ if (gpio_is_valid(pcm179x->reset)) {
+ ret = devm_gpio_request_one(dev, pcm179x->reset,
+ GPIOF_OUT_INIT_LOW,
+ "pcm179x reset");
+ if (ret) {
+ dev_err(dev,
+ "Failed to request GPIO %d as reset pin, error %d\n",
+ pcm179x->reset, ret);
+ return ret;
+ }
+
+ gpio_set_value(pcm179x->reset, 1);
+ }
+
if (type == PCM1789)
return devm_snd_soc_register_component(dev,
&soc_component_dev_pcm1789,
--
2.11.0
\
 
 \ /
  Last update: 2018-02-27 22:26    [W:0.141 / U:0.504 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site