Skip to contentSkip to conversation

ASoC: max98390: Add reset gpio control

PATCH Superseded Steve Lee 2 participants 6 messages Mar 28, 2022

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Steve Lee

author
#0 lore raw

PATCH v3 1/2 ASoC: max98390: Add reset gpio control

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

---
 sound/soc/codecs/max98390.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
sound/soc/codecs/max98390.c +12 -0
index 40fd6f363f35..05df9b85d9b0 100644
@@ -1022,6 +1022,7 @@ static int max98390_i2c_probe(struct i2c_client *i2c,
 
 	struct max98390_priv *max98390 = NULL;
 	struct i2c_adapter *adapter = i2c->adapter;
+	struct gpio_desc *reset_gpio;
 
 	ret = i2c_check_functionality(adapter,
 		I2C_FUNC_SMBUS_BYTE
@@ -1073,6 +1074,17 @@ static int max98390_i2c_probe(struct i2c_client *i2c,
 		return ret;
 	}
 
+	reset_gpio = devm_gpiod_get_optional(&i2c->dev,
+					     "reset", GPIOD_OUT_LOW);
+
+	/* Power on device */
+	if (reset_gpio) {
+		usleep_range(1000, 2000);
+		/* bring out of reset */
+		gpiod_set_value_cansleep(reset_gpio, 1);
+		usleep_range(1000, 2000);
+	}
+
 	/* Check Revision ID */
 	ret = regmap_read(max98390->regmap,
 		MAX98390_R24FF_REV_ID, &reg);
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v3 2/2 ASoC: dt-bindings: max98390: add reset gpio bindings

This adds support for the reset gpio binding.

---
 Documentation/devicetree/bindings/sound/maxim,max98390.yaml | 5 +++++
 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/sound/maxim,max98390.yaml +5 -0
index fea9a1b6619a..deaa6886c42f 100644
@@ -29,6 +29,9 @@ properties:
     minimum: 1
     maximum: 8388607
 
+  reset-gpios:
+    maxItems: 1
+
 required:
   - compatible
   - reg
@@ -37,6 +40,7 @@ additionalProperties: false
 
 examples:
   - |
+    #include <dt-bindings/gpio/gpio.h>
     i2c {
       #address-cells = <1>;
       #size-cells = <0>;
@@ -45,5 +49,6 @@ examples:
         reg = <0x38>;
         maxim,temperature_calib = <1024>;
         maxim,r0_calib = <100232>;
+        reset-gpios = <&gpio 9 GPIO_ACTIVE_LOW>;
       };
     };
Signature · 1 line
2.17.1
#2 lore raw
In reply to Steve Lee
Quoted 35 lines

From: Steve Lee <[email protected]>
Sent: Monday, March 28, 2022 4:12 AM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; [email protected]
Cc: [email protected]; Sa, Nuno <[email protected]>; Steve Lee <[email protected]>
Subject: [V3 1/2] ASoC: max98390: Add reset gpio control

[External]

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

---
 sound/soc/codecs/max98390.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
sound/soc/codecs/max98390.c +1 -0
index 40fd6f363f35..05df9b85d9b0 100644
@@ -1022,6 +1022,7 @@ static int max98390_i2c_probe(struct
 i2c_client *i2c,
 
 	struct max98390_priv *max98390 = NULL;
 	struct i2c_adapter *adapter = i2c->adapter;
+	struct gpio_desc *reset_gpio;
 
 	ret = i2c_check_functionality(adapter,
sound/soc/codecs/max98390.c +0 -0
 		I2C_FUNC_SMBUS_BYTE
@@ -1073,6 +1074,17 @@ static int max98390_i2c_probe(struct
 i2c_client *i2c,
 		return ret;

sound/soc/codecs/max98390.c static int max98390_i2c_probe(struct · line 1085

Quoted 10 lines
sound/soc/codecs/max98390.c +8 -0
 	}
 
+	reset_gpio = devm_gpiod_get_optional(&i2c->dev,
+					     "reset", GPIOD_OUT_LOW);
+
+	/* Power on device */
+	if (reset_gpio) {
+		usleep_range(1000, 2000);
+		/* bring out of reset */
+		gpiod_set_value_cansleep(reset_gpio, 1);

Note this will set the gpio in the asserted state. Being it active low, this will do the opposite thing that you are trying to accomplish...

- Nuno Sá

author
#3 lore raw
Quoted 50 lines · Nuno
Quoted 36 lines

From: Steve Lee <[email protected]>
Sent: Monday, March 28, 2022 4:12 AM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; [email protected]
Cc: [email protected]; Sa, Nuno <[email protected]>; Steve Lee <[email protected]>
Subject: [V3 1/2] ASoC: max98390: Add reset gpio control

[External]

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

---
 sound/soc/codecs/max98390.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
sound/soc/codecs/max98390.c +1 -0
index 40fd6f363f35..05df9b85d9b0 100644
@@ -1022,6 +1022,7 @@ static int max98390_i2c_probe(struct
 i2c_client *i2c,
 
      struct max98390_priv *max98390 = NULL;
      struct i2c_adapter *adapter = i2c->adapter;
+     struct gpio_desc *reset_gpio;
 
      ret = i2c_check_functionality(adapter,

I2C_FUNC_SMBUS_BYTE

sound/soc/codecs/max98390.c +0 -0
@@ -1073,6 +1074,17 @@ static int max98390_i2c_probe(struct
 i2c_client *i2c,
              return ret;

sound/soc/codecs/max98390.c static int max98390_i2c_probe(struct · line 1085

Quoted 10 lines
sound/soc/codecs/max98390.c +8 -0
      }
 
+     reset_gpio = devm_gpiod_get_optional(&i2c->dev,
+                                          "reset", GPIOD_OUT_LOW);
+
+     /* Power on device */
+     if (reset_gpio) {
+             usleep_range(1000, 2000);
+             /* bring out of reset */
+             gpiod_set_value_cansleep(reset_gpio, 1);

Note this will set the gpio in the asserted state. Being it active low, this will do the opposite thing that you are trying to accomplish...

Quoted 1 line

- Nuno Sá

I agree with your comment. I will update next version patch if there is other concern.

#4 lore raw
In reply to Steve Lee
Quoted 36 lines

-----Original Message-----
From: Steve Lee <[email protected]>
Sent: Monday, March 28, 2022 4:12 AM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; [email protected]
Cc: [email protected]; Sa, Nuno <[email protected]>; Steve Lee <[email protected]>
Subject: [V3 1/2] ASoC: max98390: Add reset gpio control

[External]

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

---
 sound/soc/codecs/max98390.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
sound/soc/codecs/max98390.c +1 -0
index 40fd6f363f35..05df9b85d9b0 100644
@@ -1022,6 +1022,7 @@ static int max98390_i2c_probe(struct
 i2c_client *i2c,
 
 	struct max98390_priv *max98390 = NULL;
 	struct i2c_adapter *adapter = i2c->adapter;
+	struct gpio_desc *reset_gpio;
 
 	ret = i2c_check_functionality(adapter,
sound/soc/codecs/max98390.c +0 -0
 		I2C_FUNC_SMBUS_BYTE

sound/soc/codecs/max98390.c static int max98390_i2c_probe(struct · line 1079

Quoted 6 lines
sound/soc/codecs/max98390.c +2 -0
@@ -1073,6 +1074,17 @@ static int max98390_i2c_probe(struct
 i2c_client *i2c,
 		return ret;
 	}
 
+	reset_gpio = devm_gpiod_get_optional(&i2c->dev,
+					     "reset", GPIOD_OUT_LOW);

Forgot to mention,

As you stated in the bindings the gpio is active low, this should also be GPIOD_OUT_HIGH, if we want to have the device in reset after this call.

- Nuno Sá

author
#5 lore raw
Quoted 46 lines · Nuno
Quoted 37 lines

-----Original Message-----
From: Steve Lee <[email protected]>
Sent: Monday, March 28, 2022 4:12 AM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; [email protected]
Cc: [email protected]; Sa, Nuno <[email protected]>; Steve Lee <[email protected]>
Subject: [V3 1/2] ASoC: max98390: Add reset gpio control

[External]

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

---
 sound/soc/codecs/max98390.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
sound/soc/codecs/max98390.c +1 -0
index 40fd6f363f35..05df9b85d9b0 100644
@@ -1022,6 +1022,7 @@ static int max98390_i2c_probe(struct
 i2c_client *i2c,
 
      struct max98390_priv *max98390 = NULL;
      struct i2c_adapter *adapter = i2c->adapter;
+     struct gpio_desc *reset_gpio;
 
      ret = i2c_check_functionality(adapter,

I2C_FUNC_SMBUS_BYTE

sound/soc/codecs/max98390.c static int max98390_i2c_probe(struct · line 1079

Quoted 6 lines
sound/soc/codecs/max98390.c +2 -0
@@ -1073,6 +1074,17 @@ static int max98390_i2c_probe(struct
 i2c_client *i2c,
              return ret;
      }
 
+     reset_gpio = devm_gpiod_get_optional(&i2c->dev,
+                                          "reset", GPIOD_OUT_LOW);

Forgot to mention,

Quoted 5 lines

As you stated in the bindings the gpio is active low, this should also be GPIOD_OUT_HIGH, if we want to have the device in reset after this call.

- Nuno Sá

This also agree with your comment. I will update next version patch if there is other concern.