linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Add reset-gpios handling for max98927
@ 2021-08-29 15:45 Alejandro Tafalla
  2021-08-29 15:45 ` [PATCH 1/2] ASoC: max98927: Handle reset gpio when probing i2c Alejandro Tafalla
  2021-08-29 15:45 ` [PATCH 2/2] dt-bindings: sound: max98927: Add reset-gpios optional property Alejandro Tafalla
  0 siblings, 2 replies; 3+ messages in thread
From: Alejandro Tafalla @ 2021-08-29 15:45 UTC (permalink / raw)
  Cc: Alejandro Tafalla, Liam Girdwood, Mark Brown, Rob Herring,
	Jaroslav Kysela, Takashi Iwai, alsa-devel, devicetree,
	linux-kernel

The max98927 codec on some devices (i.e. Xiaomi Mi A2 Lite phone) require
hardware-resetting the codec by driving a reset-gpio. This series add
support for it through an optional reset-gpios property.

Alejandro Tafalla (2):
  ASoC: max98927: Handle reset gpio when probing i2c
  dt-bindings: sound: max98927: Add reset-gpios optional property

 .../devicetree/bindings/sound/max9892x.txt       |  3 +++
 sound/soc/codecs/max98927.c                      | 16 ++++++++++++++++
 sound/soc/codecs/max98927.h                      |  1 +
 3 files changed, 20 insertions(+)

-- 
2.32.0


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

* [PATCH 1/2] ASoC: max98927: Handle reset gpio when probing i2c
  2021-08-29 15:45 [PATCH 0/2] Add reset-gpios handling for max98927 Alejandro Tafalla
@ 2021-08-29 15:45 ` Alejandro Tafalla
  2021-08-29 15:45 ` [PATCH 2/2] dt-bindings: sound: max98927: Add reset-gpios optional property Alejandro Tafalla
  1 sibling, 0 replies; 3+ messages in thread
From: Alejandro Tafalla @ 2021-08-29 15:45 UTC (permalink / raw)
  Cc: Alejandro Tafalla, Liam Girdwood, Mark Brown, Rob Herring,
	Jaroslav Kysela, Takashi Iwai, alsa-devel, devicetree,
	linux-kernel

Drive the reset gpio if defined in the DTS node.

Signed-off-by: Alejandro Tafalla <atafalla@dnyon.com>
---
 sound/soc/codecs/max98927.c | 16 ++++++++++++++++
 sound/soc/codecs/max98927.h |  1 +
 2 files changed, 17 insertions(+)

diff --git a/sound/soc/codecs/max98927.c b/sound/soc/codecs/max98927.c
index 8b206ee77709..dacf64c4cdf7 100644
--- a/sound/soc/codecs/max98927.c
+++ b/sound/soc/codecs/max98927.c
@@ -898,6 +898,22 @@ static int max98927_i2c_probe(struct i2c_client *i2c,
 		return ret;
 	}
 
+	max98927->reset_gpio
+		= devm_gpiod_get_optional(&i2c->dev, "reset", GPIOD_OUT_HIGH);
+	if (IS_ERR(max98927->reset_gpio)) {
+		ret = PTR_ERR(max98927->reset_gpio);
+		dev_err(&i2c->dev,
+			"Failed to request GPIO reset pin, error %d\n", ret);
+		return ret;
+	}
+
+	if (max98927->reset_gpio) {
+		gpiod_set_value_cansleep(max98927->reset_gpio, 0);
+		usleep_range(5, 10)
+		gpiod_set_value_cansleep(max98927->reset_gpio, 1);
+		usleep_range(1, 5)
+	}
+
 	/* Check Revision ID */
 	ret = regmap_read(max98927->regmap,
 		MAX98927_R01FF_REV_ID, &reg);
diff --git a/sound/soc/codecs/max98927.h b/sound/soc/codecs/max98927.h
index 05f495db914d..5c04bf38e24a 100644
--- a/sound/soc/codecs/max98927.h
+++ b/sound/soc/codecs/max98927.h
@@ -255,6 +255,7 @@ struct max98927_priv {
 	struct regmap *regmap;
 	struct snd_soc_component *component;
 	struct max98927_pdata *pdata;
+	struct gpio_desc *reset_gpio;
 	unsigned int spk_gain;
 	unsigned int sysclk;
 	unsigned int v_l_slot;
-- 
2.32.0


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

* [PATCH 2/2] dt-bindings: sound: max98927: Add reset-gpios optional property
  2021-08-29 15:45 [PATCH 0/2] Add reset-gpios handling for max98927 Alejandro Tafalla
  2021-08-29 15:45 ` [PATCH 1/2] ASoC: max98927: Handle reset gpio when probing i2c Alejandro Tafalla
@ 2021-08-29 15:45 ` Alejandro Tafalla
  1 sibling, 0 replies; 3+ messages in thread
From: Alejandro Tafalla @ 2021-08-29 15:45 UTC (permalink / raw)
  Cc: Alejandro Tafalla, Liam Girdwood, Mark Brown, Rob Herring,
	Jaroslav Kysela, Takashi Iwai, alsa-devel, devicetree,
	linux-kernel

Add the reset-gpios as an optional property because some devices might 
not need it to work properly.

Signed-off-by: Alejandro Tafalla <atafalla@dnyon.com>
---
 Documentation/devicetree/bindings/sound/max9892x.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/max9892x.txt b/Documentation/devicetree/bindings/sound/max9892x.txt
index f6171591ddc6..73733fb60136 100644
--- a/Documentation/devicetree/bindings/sound/max9892x.txt
+++ b/Documentation/devicetree/bindings/sound/max9892x.txt
@@ -30,6 +30,9 @@ Required properties:
 
   - reg : the I2C address of the device for I2C
 
+Optional Properties:
+  - reset-gpios : reference to the GPIO connected to the reset pin, if any.
+
 Example:
 
 codec: max98927@3a {
-- 
2.32.0


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

end of thread, other threads:[~2021-08-29 15:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-29 15:45 [PATCH 0/2] Add reset-gpios handling for max98927 Alejandro Tafalla
2021-08-29 15:45 ` [PATCH 1/2] ASoC: max98927: Handle reset gpio when probing i2c Alejandro Tafalla
2021-08-29 15:45 ` [PATCH 2/2] dt-bindings: sound: max98927: Add reset-gpios optional property Alejandro Tafalla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).