mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ASoC: cs42xx8: Add reset gpio handling
@ 2019-04-29 10:46 S.j. Wang
  2019-05-08  8:12 ` Mark Brown
  0 siblings, 1 reply; 3+ messages in thread
From: S.j. Wang @ 2019-04-29 10:46 UTC (permalink / raw)
  To: brian.austin, Paul.Handrigan, lgirdwood, broonie, perex, tiwai,
	alsa-devel
  Cc: linux-kernel

Handle the reset GPIO and reset the device in
pm_runtime_resume

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
---
 sound/soc/codecs/cs42xx8.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/sound/soc/codecs/cs42xx8.c b/sound/soc/codecs/cs42xx8.c
index ebb9e0cf8364..fc28e6d26c6d 100644
--- a/sound/soc/codecs/cs42xx8.c
+++ b/sound/soc/codecs/cs42xx8.c
@@ -14,6 +14,7 @@
 #include <linux/delay.h>
 #include <linux/module.h>
 #include <linux/of_device.h>
+#include <linux/of_gpio.h>
 #include <linux/pm_runtime.h>
 #include <linux/regulator/consumer.h>
 #include <sound/pcm_params.h>
@@ -45,6 +46,7 @@ struct cs42xx8_priv {
 	bool slave_mode;
 	unsigned long sysclk;
 	u32 tx_channels;
+	int gpio_reset;
 };
 
 /* -127.5dB to 0dB with step of 0.5dB */
@@ -467,6 +469,17 @@ int cs42xx8_probe(struct device *dev, struct regmap *regmap)
 		return -EINVAL;
 	}
 
+	cs42xx8->gpio_reset = of_get_named_gpio(dev->of_node, "gpio-reset", 0);
+	if (gpio_is_valid(cs42xx8->gpio_reset)) {
+		ret = devm_gpio_request_one(dev, cs42xx8->gpio_reset,
+				GPIOF_OUT_INIT_LOW, "cs42xx8 reset");
+		if (ret) {
+			dev_err(dev, "unable to get reset gpio\n");
+			return ret;
+		}
+		gpio_set_value_cansleep(cs42xx8->gpio_reset, 1);
+	}
+
 	cs42xx8->clk = devm_clk_get(dev, "mclk");
 	if (IS_ERR(cs42xx8->clk)) {
 		dev_err(dev, "failed to get the clock: %ld\n",
@@ -547,6 +560,11 @@ static int cs42xx8_runtime_resume(struct device *dev)
 		return ret;
 	}
 
+	if (gpio_is_valid(cs42xx8->gpio_reset)) {
+		gpio_set_value_cansleep(cs42xx8->gpio_reset, 0);
+		gpio_set_value_cansleep(cs42xx8->gpio_reset, 1);
+	}
+
 	ret = regulator_bulk_enable(ARRAY_SIZE(cs42xx8->supplies),
 				    cs42xx8->supplies);
 	if (ret) {
@@ -559,6 +577,7 @@ static int cs42xx8_runtime_resume(struct device *dev)
 
 	regcache_cache_only(cs42xx8->regmap, false);
 
+	regcache_mark_dirty(cs42xx8->regmap);
 	ret = regcache_sync(cs42xx8->regmap);
 	if (ret) {
 		dev_err(dev, "failed to sync regmap: %d\n", ret);
-- 
1.9.1


^ permalink raw reply	[flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: cs42xx8: Add reset gpio handling
@ 2019-05-16  5:50 S.j. Wang
  0 siblings, 0 replies; 3+ messages in thread
From: S.j. Wang @ 2019-05-16  5:50 UTC (permalink / raw)
  To: Mark Brown
  Cc: brian.austin, Paul.Handrigan, lgirdwood, perex, tiwai,
	alsa-devel, linux-kernel

Hi Mark

> 
> On Mon, Apr 29, 2019 at 10:46:03AM +0000, S.j. Wang wrote:
> 
> > +	cs42xx8->gpio_reset = of_get_named_gpio(dev->of_node, "gpio-
> reset", 0);
> > +	if (gpio_is_valid(cs42xx8->gpio_reset)) {
> > +		ret = devm_gpio_request_one(dev, cs42xx8->gpio_reset,
> > +				GPIOF_OUT_INIT_LOW, "cs42xx8 reset");
> 
> You should just be able to request the GPIO by name without going
> through of_get_named_gpio() using devm_gpio_get().
> 
Will send v2.

> > @@ -559,6 +577,7 @@ static int cs42xx8_runtime_resume(struct device
> > *dev)
> >
> >  	regcache_cache_only(cs42xx8->regmap, false);
> >
> > +	regcache_mark_dirty(cs42xx8->regmap);
> >  	ret = regcache_sync(cs42xx8->regmap);
> >  	if (ret) {
> >  		dev_err(dev, "failed to sync regmap: %d\n", ret);
> 
> This looks like an unrelated bugfix.

Will separate it to another patch.

Best regards
Wang shengjiu

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-05-16  5:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-29 10:46 [PATCH] ASoC: cs42xx8: Add reset gpio handling S.j. Wang
2019-05-08  8:12 ` Mark Brown
2019-05-16  5:50 S.j. Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®