Add reset-gpios handling for max98927
Subsystems (3)
v2 cover Add reset-gpios handling for max98927
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 | 15 +++++++++++++++ 2 files changed, 18 insertions(+)
Signature · 1 line
2.32.0
PATCH v2 1/2 ASoC: max98927: Handle reset gpio when probing i2c
Drive the reset gpio if defined in the DTS node.
--- sound/soc/codecs/max98927.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
sound/soc/codecs/max98927.c +15 -0
@@ -868,6 +868,7 @@ static int max98927_i2c_probe(struct i2c_client *i2c,int ret =0 , value;int reg =0 ;struct max98927_priv *max98927 =NULL ; +struct gpio_desc *reset_gpio; max98927 =devm_kzalloc (&i2c->dev,sizeof (*max98927),GFP_KERNEL );
@@ -898,6 +899,20 @@ static int max98927_i2c_probe(struct i2c_client *i2c,return ret; } + reset_gpio + =devm_gpiod_get_optional (&i2c->dev,"reset" ,GPIOD_OUT_LOW ); +if (IS_ERR (reset_gpio)) { + ret =PTR_ERR (reset_gpio); +return dev_err_probe (&i2c->dev, ret, +"failed to request GPIO reset pin" ); + } + +if (reset_gpio) { +usleep_range (8000 ,10000 ); +gpiod_set_value_cansleep (reset_gpio,1 ); +usleep_range (1000 ,5000 ); + } +/* Check Revision ID */ ret =regmap_read (max98927->regmap,MAX98927_R01FF_REV_ID , ®);
Signature · 1 line
2.32.0
Re: [PATCH v2 1/2] ASoC: max98927: Handle reset gpio when probing i2c
Quoted 2 lines · Alejandro Tafalla
Drive the reset gpio if defined in the DTS node.
...
sound/soc/codecs/max98927.c static int max98927_i2c_probe(struct i2c_client *i2c, · line 903
Quoted 2 lines
sound/soc/codecs/max98927.c +2
-0+ reset_gpio + =devm_gpiod_get_optional (&i2c->dev,"reset" ,GPIOD_OUT_LOW );
A bit of a strange indentation, shouldn't it be one line?
sound/soc/codecs/max98927.c static int max98927_i2c_probe(struct i2c_client *i2c, · line 907
Quoted 5 lines
sound/soc/codecs/max98927.c +4
-0+if (IS_ERR (reset_gpio)) { + ret =PTR_ERR (reset_gpio); +return dev_err_probe (&i2c->dev, ret, +"failed to request GPIO reset pin" );
It simply as
return dev_err_probe(&i2c->dev, PTR_ERR(reset_gpio),
"failed to request GPIO reset pin");Quoted 1 line
+ }
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 1/2] ASoC: max98927: Handle reset gpio when probing i2c
Quoted 6 lines · On lunes, 30 de agosto de 2021 12:56:23 (CEST) Andy Shevchenko wrote:
It simply as
return dev_err_probe(&i2c->dev, PTR_ERR(reset_gpio), "failed to request GPIO reset pin");Quoted 1 line
+ }
Alright, I'll make that change. Thank you.
PATCH v2 2/2 dt-bindings: sound: max98927: Add reset-gpios optional property
In reply to Alejandro TafallaAdd the reset-gpios as an optional property because some devices might not need it to work properly.
--- Documentation/devicetree/bindings/sound/max9892x.txt | 3 +++ 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/sound/max9892x.txt +3 -0
@@ -30,6 +30,9 @@ Required properties: - reg : the I2C address of the device for I2C +Optional properties: + - reset-gpios : GPIO to reset the device + Example: codec: max98927@3a {
Signature · 1 line
2.32.0
Re: [PATCH v2 2/2] dt-bindings: sound: max98927: Add reset-gpios optional property
Quoted 8 lines · Alejandro Tafalla
Add the reset-gpios as an optional property because some devices might not need it to work properly.
Signed-off-by Alejandro Tafalla <[email protected]>--- Documentation/devicetree/bindings/sound/max9892x.txt | 3 +++ 1 file changed, 3 insertions(+)