On Wed, Dec 29, 2021 at 08:44:56AM -0300, Fabio Estevam wrote:
From: Fabio Estevam festevam@denx.de
Currently, the reset_gpio polarity handling is done backwards.
The gpiod API takes the logic value of the GPIO, not the physical one.
As per the CS4265 datasheet:
"When RESET is low, the CS4265 enters a low-power mode and all internal states are reset"
If a devicetree describes reset_gpio as active-low, the correct behaviour would be to retrieve the GPIO and put in its active state (GPIOD_OUT_HIGH) and then move it to its inactive state so that it can be operational (logic level 0).
Fix it accordingly.
Fixes: fb6f806967f6 ("ASoC: Add support for the CS4265 CODEC") Signed-off-by: Fabio Estevam festevam@denx.de
Changes since v1:
- Newly introduced patch.
sound/soc/codecs/cs4265.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/soc/codecs/cs4265.c b/sound/soc/codecs/cs4265.c index b89002189a2b..294fa7ac16cb 100644 --- a/sound/soc/codecs/cs4265.c +++ b/sound/soc/codecs/cs4265.c @@ -590,13 +590,13 @@ static int cs4265_i2c_probe(struct i2c_client *i2c_client, }
cs4265->reset_gpio = devm_gpiod_get_optional(&i2c_client->dev,
"reset", GPIOD_OUT_LOW);
"reset", GPIOD_OUT_HIGH);
if (IS_ERR(cs4265->reset_gpio)) return PTR_ERR(cs4265->reset_gpio);
if (cs4265->reset_gpio) { mdelay(1);
gpiod_set_value_cansleep(cs4265->reset_gpio, 1);
gpiod_set_value_cansleep(cs4265->reset_gpio, 0);
Hmm... I might defer to Mark on this one. I totally agree your new code is more correct, however, I would have a slight worry about existing device trees not correctly specifying the GPIO. As in if existing systems had been specifying the GPIO correctly they are presumably currently broken. But I am not sure what the obvious solution would be, and I don't really have a good feel for how widely used this part is.
Thanks, Charles