Re: [PATCH] ASoC: codec: ak5386: Convert to GPIO descriptors
From: Andy Shevchenko
Date: Fri Mar 28 2025 - 09:50:24 EST
On Fri, Mar 28, 2025 at 07:39:17PM +0800, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@xxxxxxx>
>
> of_gpio.h is deprecated, update the driver to use GPIO descriptors.
> - Use dev_gpiod_get_optional to get GPIO descriptor.
devm
> - Use gpiod_set_value to configure output value.
>
> With legacy of_gpio API, the driver set gpio value 1 to power up
sets GPIO
> AK5386, and set value 0 to power down.
> Per datasheet for PDN(reset_gpio in the driver):
> Power Down & Reset Mode Pin
> “H”: Power up, “L”: Power down & Reset
> The AK5386 must be reset once upon power-up.
>
> There is no in-tree DTS using this codec, and the dt-bindings not
bindings does not
> specify polarity. Per driver and datasheet, the gpio polarity should be
GPIO
> active-high which is to power up the codec. So using GPIOD_OUT_LOW
> when get the GPIO descriptor matches GPIOF_OUT_INIT_LOW when using
> of_gpio API.
...
> The Documentation/devicetree/bindings/sound/ak5386.txt not specify
> polarity(this seems bug), so per code and datasheet, I think it
> should be active-high. I could add a quirk in gpiolib-of to force
> active-high or acitive-low if you think needed.
I don't think we need a quirk as long as the default is the same,
I mean if the DTS is written without setting polarity, would it be
active-high or active-low?
...
> + if (priv->reset_gpio)
Redundant as it duplicates the one in the below call.
> + gpiod_set_value(priv->reset_gpio, 1);
...
> + if (priv->reset_gpio)
Ditto.
> + gpiod_set_value(priv->reset_gpio, 0);
...
> + priv->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
> + if (IS_ERR(priv->reset_gpio))
> + return dev_err_probe(dev, PTR_ERR(priv->reset_gpio),
+ dev_printk.h // or even device.h, depending on the current code base
+ err.h
> + "Failed to get AK5386 reset GPIO\n");
> + gpiod_set_consumer_name(priv->reset_gpio, "AK5386 Reset");
--
With Best Regards,
Andy Shevchenko