[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180227212433.2189-4-mylene.josserand@bootlin.com>
Date: Tue, 27 Feb 2018 22:24:32 +0100
From: Mylène Josserand <mylene.josserand@...tlin.com>
To: lgirdwood@...il.com, broonie@...nel.org, robh+dt@...nel.org,
mark.rutland@....com, perex@...ex.cz, tiwai@...e.com
Cc: alsa-devel@...a-project.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, mylene.josserand@...tlin.com,
alexandre.belloni@...tlin.com, thomas.petazzoni@...tlin.com
Subject: [PATCH v1 3/4] ASoC: codecs: pcm179x: Add reset gpio
Add a reset gpio to be able to reset this line at startup.
Signed-off-by: Mylène Josserand <mylene.josserand@...tlin.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
Powered by blists - more mailing lists