All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: max98390: Add reset gpio control
@ 2022-03-10  8:15 Steve Lee
  2022-03-10  8:48 ` Sa, Nuno
  0 siblings, 1 reply; 8+ messages in thread
From: Steve Lee @ 2022-03-10  8:15 UTC (permalink / raw)
  To: lgirdwood, broonie, perex, tiwai, ckeepax, geert, rf, shumingf,
	srinivas.kandagatla, krzk, dmurphy, jack.yu, nuno.sa, steves.lee,
	linux-kernel, alsa-devel
  Cc: Steve Lee

 Add reset gpio control to support RESET PIN connected to gpio.

Signed-off-by: Steve Lee <steve.lee.analog@gmail.com>
---
 sound/soc/codecs/max98390.c | 18 ++++++++++++++++++
 sound/soc/codecs/max98390.h |  1 +
 2 files changed, 19 insertions(+)

diff --git a/sound/soc/codecs/max98390.c b/sound/soc/codecs/max98390.c
index b392567c2b3e..574d8d5f1119 100644
--- a/sound/soc/codecs/max98390.c
+++ b/sound/soc/codecs/max98390.c
@@ -1073,6 +1073,24 @@ static int max98390_i2c_probe(struct i2c_client *i2c,
 		return ret;
 	}
 
+	max98390->reset_gpio = of_get_named_gpio(i2c->dev.of_node,
+						"maxim,reset-gpios", 0);
+
+	/* Power on device */
+	if (gpio_is_valid(max98390->reset_gpio)) {
+		ret = devm_gpio_request(&i2c->dev, max98390->reset_gpio,
+					"MAX98390_RESET");
+		if (ret) {
+			dev_err(&i2c->dev, "%s: Failed to request gpio %d\n",
+				__func__, max98390->reset_gpio);
+			return -EINVAL;
+		}
+		gpio_direction_output(max98390->reset_gpio, 0);
+		usleep_range(1000, 2000);
+		gpio_direction_output(max98390->reset_gpio, 1);
+		usleep_range(1000, 2000);
+	}
+
 	/* Check Revision ID */
 	ret = regmap_read(max98390->regmap,
 		MAX98390_R24FF_REV_ID, &reg);
diff --git a/sound/soc/codecs/max98390.h b/sound/soc/codecs/max98390.h
index c250740f73a2..5518f2340247 100644
--- a/sound/soc/codecs/max98390.h
+++ b/sound/soc/codecs/max98390.h
@@ -655,6 +655,7 @@
 
 struct max98390_priv {
 	struct regmap *regmap;
+	int reset_gpio;
 	unsigned int sysclk;
 	unsigned int master;
 	unsigned int tdm_mode;
-- 
2.17.1


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

* RE: [PATCH] ASoC: max98390: Add reset gpio control
  2022-03-10  8:15 [PATCH] ASoC: max98390: Add reset gpio control Steve Lee
@ 2022-03-10  8:48 ` Sa, Nuno
  2022-03-10 11:29     ` Mark Brown
  2022-03-11  5:50     ` Lee Steve
  0 siblings, 2 replies; 8+ messages in thread
From: Sa, Nuno @ 2022-03-10  8:48 UTC (permalink / raw)
  To: Steve Lee, lgirdwood, broonie, perex, tiwai, ckeepax, geert, rf,
	shumingf, srinivas.kandagatla, krzk, dmurphy, jack.yu,
	steves.lee, linux-kernel, alsa-devel

Hi Steve,

> From: Steve Lee <steve.lee.analog@gmail.com>
> Sent: Thursday, March 10, 2022 9:16 AM
> To: lgirdwood@gmail.com; broonie@kernel.org; perex@perex.cz;
> tiwai@suse.com; ckeepax@opensource.cirrus.com; geert@linux-
> m68k.org; rf@opensource.wolfsonmicro.com; shumingf@realtek.com;
> srinivas.kandagatla@linaro.org; krzk@kernel.org; dmurphy@ti.com;
> jack.yu@realtek.com; Sa, Nuno <Nuno.Sa@analog.com>;
> steves.lee@maximintegrated.com; linux-kernel@vger.kernel.org;
> alsa-devel@alsa-project.org
> Cc: Steve Lee <steve.lee.analog@gmail.com>
> Subject: [PATCH] ASoC: max98390: Add reset gpio control
> 
> [External]
> 
>  Add reset gpio control to support RESET PIN connected to gpio.
> 
> Signed-off-by: Steve Lee <steve.lee.analog@gmail.com>
> ---
>  sound/soc/codecs/max98390.c | 18 ++++++++++++++++++
>  sound/soc/codecs/max98390.h |  1 +
>  2 files changed, 19 insertions(+)
> 
> diff --git a/sound/soc/codecs/max98390.c
> b/sound/soc/codecs/max98390.c
> index b392567c2b3e..574d8d5f1119 100644
> --- a/sound/soc/codecs/max98390.c
> +++ b/sound/soc/codecs/max98390.c
> @@ -1073,6 +1073,24 @@ static int max98390_i2c_probe(struct
> i2c_client *i2c,
>  		return ret;
>  	}
> 
> +	max98390->reset_gpio = of_get_named_gpio(i2c-
> >dev.of_node,
> +						"maxim,reset-gpios", 0);

Why not using devm_gpiod_get_optional()? We could request the pin
already in the asserted state and make the code slightly better...

/* I guess there's no need to save it in our struct as we only use it here? */
struct gpio_desc *reset_gpio; 

reset_gpio = devm_gpiod_get_optional(&i2c->dev, "reset", GPIOD_OUT_HIGH);
if (reset_gpio) {
      usleep_range(1000, 2000);
     /* bring out of reset */
      gpio_direction_output(max98390->reset_gpio, 0);
      usleep_range(1000, 2000);
}

Also, do we have this on the bindings doc? If not, it should be done on a second
patch on this series...

- Nuno Sá


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

* Re: [PATCH] ASoC: max98390: Add reset gpio control
  2022-03-10  8:48 ` Sa, Nuno
@ 2022-03-10 11:29     ` Mark Brown
  2022-03-11  5:50     ` Lee Steve
  1 sibling, 0 replies; 8+ messages in thread
From: Mark Brown @ 2022-03-10 11:29 UTC (permalink / raw)
  To: Sa, Nuno
  Cc: Steve Lee, lgirdwood, perex, tiwai, ckeepax, geert, rf, shumingf,
	srinivas.kandagatla, krzk, dmurphy, jack.yu, steves.lee,
	linux-kernel, alsa-devel

[-- Attachment #1: Type: text/plain, Size: 539 bytes --]

On Thu, Mar 10, 2022 at 08:48:09AM +0000, Sa, Nuno wrote:

> > +	max98390->reset_gpio = of_get_named_gpio(i2c-
> > >dev.of_node,
> > +						"maxim,reset-gpios", 0);

> Why not using devm_gpiod_get_optional()? We could request the pin
> already in the asserted state and make the code slightly better...

Yes, and it'd support other firmware interfaces too.  We also need an
update to the binding document covering the new property.

Might also be worth putting the device into reset when unloading the
driver, though that's not essential.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH] ASoC: max98390: Add reset gpio control
@ 2022-03-10 11:29     ` Mark Brown
  0 siblings, 0 replies; 8+ messages in thread
From: Mark Brown @ 2022-03-10 11:29 UTC (permalink / raw)
  To: Sa, Nuno
  Cc: Steve Lee, jack.yu, alsa-devel, ckeepax, steves.lee,
	linux-kernel, tiwai, krzk, lgirdwood, geert, dmurphy, shumingf,
	srinivas.kandagatla, rf

[-- Attachment #1: Type: text/plain, Size: 539 bytes --]

On Thu, Mar 10, 2022 at 08:48:09AM +0000, Sa, Nuno wrote:

> > +	max98390->reset_gpio = of_get_named_gpio(i2c-
> > >dev.of_node,
> > +						"maxim,reset-gpios", 0);

> Why not using devm_gpiod_get_optional()? We could request the pin
> already in the asserted state and make the code slightly better...

Yes, and it'd support other firmware interfaces too.  We also need an
update to the binding document covering the new property.

Might also be worth putting the device into reset when unloading the
driver, though that's not essential.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH] ASoC: max98390: Add reset gpio control
  2022-03-10  8:48 ` Sa, Nuno
@ 2022-03-11  5:50     ` Lee Steve
  2022-03-11  5:50     ` Lee Steve
  1 sibling, 0 replies; 8+ messages in thread
From: Lee Steve @ 2022-03-11  5:50 UTC (permalink / raw)
  To: Sa, Nuno
  Cc: lgirdwood, broonie, perex, tiwai, ckeepax, geert, rf, shumingf,
	srinivas.kandagatla, krzk, dmurphy, jack.yu, steves.lee,
	linux-kernel, alsa-devel

On Thu, Mar 10, 2022 at 5:48 PM Sa, Nuno <Nuno.Sa@analog.com> wrote:
>
> Hi Steve,
>
> > From: Steve Lee <steve.lee.analog@gmail.com>
> > Sent: Thursday, March 10, 2022 9:16 AM
> > To: lgirdwood@gmail.com; broonie@kernel.org; perex@perex.cz;
> > tiwai@suse.com; ckeepax@opensource.cirrus.com; geert@linux-
> > m68k.org; rf@opensource.wolfsonmicro.com; shumingf@realtek.com;
> > srinivas.kandagatla@linaro.org; krzk@kernel.org; dmurphy@ti.com;
> > jack.yu@realtek.com; Sa, Nuno <Nuno.Sa@analog.com>;
> > steves.lee@maximintegrated.com; linux-kernel@vger.kernel.org;
> > alsa-devel@alsa-project.org
> > Cc: Steve Lee <steve.lee.analog@gmail.com>
> > Subject: [PATCH] ASoC: max98390: Add reset gpio control
> >
> > [External]
> >
> >  Add reset gpio control to support RESET PIN connected to gpio.
> >
> > Signed-off-by: Steve Lee <steve.lee.analog@gmail.com>
> > ---
> >  sound/soc/codecs/max98390.c | 18 ++++++++++++++++++
> >  sound/soc/codecs/max98390.h |  1 +
> >  2 files changed, 19 insertions(+)
> >
> > diff --git a/sound/soc/codecs/max98390.c
> > b/sound/soc/codecs/max98390.c
> > index b392567c2b3e..574d8d5f1119 100644
> > --- a/sound/soc/codecs/max98390.c
> > +++ b/sound/soc/codecs/max98390.c
> > @@ -1073,6 +1073,24 @@ static int max98390_i2c_probe(struct
> > i2c_client *i2c,
> >               return ret;
> >       }
> >
> > +     max98390->reset_gpio = of_get_named_gpio(i2c-
> > >dev.of_node,
> > +                                             "maxim,reset-gpios", 0);
>
> Why not using devm_gpiod_get_optional()? We could request the pin
> already in the asserted state and make the code slightly better...
>
> /* I guess there's no need to save it in our struct as we only use it here? */
> struct gpio_desc *reset_gpio;
>
> reset_gpio = devm_gpiod_get_optional(&i2c->dev, "reset", GPIOD_OUT_HIGH);
> if (reset_gpio) {
>       usleep_range(1000, 2000);
>      /* bring out of reset */
>       gpio_direction_output(max98390->reset_gpio, 0);
>       usleep_range(1000, 2000);
> }
>
> Also, do we have this on the bindings doc? If not, it should be done on a second
> patch on this series...
>
> - Nuno Sá
>

Thanks for comment on this patch. I will check and update as commented.

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

* Re: [PATCH] ASoC: max98390: Add reset gpio control
@ 2022-03-11  5:50     ` Lee Steve
  0 siblings, 0 replies; 8+ messages in thread
From: Lee Steve @ 2022-03-11  5:50 UTC (permalink / raw)
  To: Sa, Nuno
  Cc: jack.yu, alsa-devel, ckeepax, steves.lee, linux-kernel, tiwai,
	krzk, lgirdwood, broonie, geert, dmurphy, shumingf,
	srinivas.kandagatla, rf

On Thu, Mar 10, 2022 at 5:48 PM Sa, Nuno <Nuno.Sa@analog.com> wrote:
>
> Hi Steve,
>
> > From: Steve Lee <steve.lee.analog@gmail.com>
> > Sent: Thursday, March 10, 2022 9:16 AM
> > To: lgirdwood@gmail.com; broonie@kernel.org; perex@perex.cz;
> > tiwai@suse.com; ckeepax@opensource.cirrus.com; geert@linux-
> > m68k.org; rf@opensource.wolfsonmicro.com; shumingf@realtek.com;
> > srinivas.kandagatla@linaro.org; krzk@kernel.org; dmurphy@ti.com;
> > jack.yu@realtek.com; Sa, Nuno <Nuno.Sa@analog.com>;
> > steves.lee@maximintegrated.com; linux-kernel@vger.kernel.org;
> > alsa-devel@alsa-project.org
> > Cc: Steve Lee <steve.lee.analog@gmail.com>
> > Subject: [PATCH] ASoC: max98390: Add reset gpio control
> >
> > [External]
> >
> >  Add reset gpio control to support RESET PIN connected to gpio.
> >
> > Signed-off-by: Steve Lee <steve.lee.analog@gmail.com>
> > ---
> >  sound/soc/codecs/max98390.c | 18 ++++++++++++++++++
> >  sound/soc/codecs/max98390.h |  1 +
> >  2 files changed, 19 insertions(+)
> >
> > diff --git a/sound/soc/codecs/max98390.c
> > b/sound/soc/codecs/max98390.c
> > index b392567c2b3e..574d8d5f1119 100644
> > --- a/sound/soc/codecs/max98390.c
> > +++ b/sound/soc/codecs/max98390.c
> > @@ -1073,6 +1073,24 @@ static int max98390_i2c_probe(struct
> > i2c_client *i2c,
> >               return ret;
> >       }
> >
> > +     max98390->reset_gpio = of_get_named_gpio(i2c-
> > >dev.of_node,
> > +                                             "maxim,reset-gpios", 0);
>
> Why not using devm_gpiod_get_optional()? We could request the pin
> already in the asserted state and make the code slightly better...
>
> /* I guess there's no need to save it in our struct as we only use it here? */
> struct gpio_desc *reset_gpio;
>
> reset_gpio = devm_gpiod_get_optional(&i2c->dev, "reset", GPIOD_OUT_HIGH);
> if (reset_gpio) {
>       usleep_range(1000, 2000);
>      /* bring out of reset */
>       gpio_direction_output(max98390->reset_gpio, 0);
>       usleep_range(1000, 2000);
> }
>
> Also, do we have this on the bindings doc? If not, it should be done on a second
> patch on this series...
>
> - Nuno Sá
>

Thanks for comment on this patch. I will check and update as commented.

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

* Re: [PATCH] ASoC: max98390: Add reset gpio control
  2022-03-10 11:29     ` Mark Brown
@ 2022-03-11  5:53       ` Lee Steve
  -1 siblings, 0 replies; 8+ messages in thread
From: Lee Steve @ 2022-03-11  5:53 UTC (permalink / raw)
  To: Mark Brown
  Cc: Sa, Nuno, lgirdwood, perex, tiwai, ckeepax, geert, rf, shumingf,
	srinivas.kandagatla, krzk, dmurphy, jack.yu, steves.lee,
	linux-kernel, alsa-devel

On Thu, Mar 10, 2022 at 8:29 PM Mark Brown <broonie@kernel.org> wrote:
>
> On Thu, Mar 10, 2022 at 08:48:09AM +0000, Sa, Nuno wrote:
>
> > > +   max98390->reset_gpio = of_get_named_gpio(i2c-
> > > >dev.of_node,
> > > +                                           "maxim,reset-gpios", 0);
>
> > Why not using devm_gpiod_get_optional()? We could request the pin
> > already in the asserted state and make the code slightly better...
>
> Yes, and it'd support other firmware interfaces too.  We also need an
> update to the binding document covering the new property.
>
> Might also be worth putting the device into reset when unloading the
> driver, though that's not essential.

I will check and update v2 patch.

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

* Re: [PATCH] ASoC: max98390: Add reset gpio control
@ 2022-03-11  5:53       ` Lee Steve
  0 siblings, 0 replies; 8+ messages in thread
From: Lee Steve @ 2022-03-11  5:53 UTC (permalink / raw)
  To: Mark Brown
  Cc: jack.yu, alsa-devel, ckeepax, lgirdwood, steves.lee,
	linux-kernel, tiwai, krzk, geert, dmurphy, shumingf,
	srinivas.kandagatla, Sa, Nuno, rf

On Thu, Mar 10, 2022 at 8:29 PM Mark Brown <broonie@kernel.org> wrote:
>
> On Thu, Mar 10, 2022 at 08:48:09AM +0000, Sa, Nuno wrote:
>
> > > +   max98390->reset_gpio = of_get_named_gpio(i2c-
> > > >dev.of_node,
> > > +                                           "maxim,reset-gpios", 0);
>
> > Why not using devm_gpiod_get_optional()? We could request the pin
> > already in the asserted state and make the code slightly better...
>
> Yes, and it'd support other firmware interfaces too.  We also need an
> update to the binding document covering the new property.
>
> Might also be worth putting the device into reset when unloading the
> driver, though that's not essential.

I will check and update v2 patch.

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

end of thread, other threads:[~2022-03-14  7:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-10  8:15 [PATCH] ASoC: max98390: Add reset gpio control Steve Lee
2022-03-10  8:48 ` Sa, Nuno
2022-03-10 11:29   ` Mark Brown
2022-03-10 11:29     ` Mark Brown
2022-03-11  5:53     ` Lee Steve
2022-03-11  5:53       ` Lee Steve
2022-03-11  5:50   ` Lee Steve
2022-03-11  5:50     ` Lee Steve

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.