ASoC: max98390: Add reset gpio control
PATCH 1/1 ASoC: max98390: Add reset gpio control
Add reset gpio control to support RESET PIN connected to gpio.
--- sound/soc/codecs/max98390.c | 18 ++++++++++++++++++ sound/soc/codecs/max98390.h | 1 + 2 files changed, 19 insertions(+)
sound/soc/codecs/max98390.c +18 -0
@@ -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 , ®);
sound/soc/codecs/max98390.h +1 -0
@@ -655,6 +655,7 @@struct max98390_priv {struct regmap *regmap; +int reset_gpio;unsigned int sysclk;unsigned int master;unsigned int tdm_mode;
Signature · 1 line
2.17.1
Hi Steve,
Quoted 28 lines
From: Steve Lee <[email protected]>
Sent: Thursday, March 10, 2022 9:16 AM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; geert@linux- m68k.org; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Sa, Nuno <[email protected]>; [email protected]; [email protected]; [email protected]
Cc: Steve Lee <[email protected]>
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 <[email protected]>--- sound/soc/codecs/max98390.c | 18 ++++++++++++++++++ sound/soc/codecs/max98390.h | 1 + 2 files changed, 19 insertions(+)sound/soc/codecs/max98390.c +0
-0
sound/soc/codecs/max98390.c static int max98390_i2c_probe(struct · line 1079
Quoted 7 lines
sound/soc/codecs/max98390.c +2
-0@@ -1073,6 +1073,24 @@ static int max98390_i2c_probe(structi2c_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á
Mark Brown
maintainerQuoted 6 lines · Nuno
sound/soc/codecs/max98390.c static int max98390_i2c_probe(struct i2c_client *i2c, · line 1077
Quoted 3 lines
(quoted diff) +1
-0+ max98390->reset_gpio = of_get_named_gpio(i2c-Quoted 1 line
dev.of_node,
sound/soc/codecs/max98390.c +1
-0+ "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.
Quoted 7 lines · Mark Brown
Quoted 3 lines · Nuno
Quoted 3 lines
+
max98390->reset_gpio= of_get_named_gpio(i2c-Quoted 1 line
dev.of_node,
+ "maxim,reset-gpios", 0);
Quoted 8 lines
Quoted 2 lines
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.
Quoted 53 lines · Nuno
Hi Steve,
Quoted 28 lines
From: Steve Lee <[email protected]>
Sent: Thursday, March 10, 2022 9:16 AM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; geert@linux- m68k.org; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Sa, Nuno <[email protected]>; [email protected]; [email protected]; [email protected]
Cc: Steve Lee <[email protected]>
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 <[email protected]>--- sound/soc/codecs/max98390.c | 18 ++++++++++++++++++ sound/soc/codecs/max98390.h | 1 + 2 files changed, 19 insertions(+)sound/soc/codecs/max98390.c +0
-0sound/soc/codecs/max98390.c static int max98390_i2c_probe(struct · line 1079
Quoted 7 lines
sound/soc/codecs/max98390.c +2
-0@@ -1073,6 +1073,24 @@ static int max98390_i2c_probe(structi2c_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); }
Quoted 5 lines
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.