]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ASoC: codec: tlv320aic32x4: Convert to GPIO descriptors
authorPeng Fan <peng.fan@nxp.com>
Thu, 10 Jul 2025 12:40:03 +0000 (20:40 +0800)
committerMark Brown <broonie@kernel.org>
Sun, 13 Jul 2025 21:36:56 +0000 (22:36 +0100)
of_gpio.h is deprecated, update the driver to use GPIO descriptors.
 - Use devm_gpiod_get_optional to get GPIO descriptor, and set consumer
   name.
 - Use gpiod_set_value to configure output value.

While at here, reorder the included headers.

Checking the DTS that use the device, all are using GPIOD_ACTIVE_LOW
polarity for reset-gpios, so all should work as expected with this patch.

Cc: Markus Niebel <Markus.Niebel@ew.tq-group.com>
Cc: Alexander Stein <alexander.stein@ew.tq-group.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
Link: https://patch.msgid.link/20250710-asoc-gpio-1-v2-3-2233b272a1a6@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/tlv320aic32x4.c

index 2f4147387c4f802bdac983c81b104c000b1fd6ed..3b89980e9bcf2fe93826b5af385d0dca517091a1 100644 (file)
 #include <linux/cdev.h>
 #include <linux/clk.h>
 #include <linux/delay.h>
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/of_clk.h>
-#include <linux/of_gpio.h>
 #include <linux/pm.h>
 #include <linux/regulator/consumer.h>
 #include <linux/slab.h>
@@ -38,7 +37,7 @@ struct aic32x4_priv {
        u32 power_cfg;
        u32 micpga_routing;
        bool swapdacs;
-       int rstn_gpio;
+       struct gpio_desc *rstn_gpio;
        const char *mclk_name;
 
        struct regulator *supply_ldo;
@@ -1236,7 +1235,14 @@ static int aic32x4_parse_dt(struct aic32x4_priv *aic32x4,
 
        aic32x4->swapdacs = false;
        aic32x4->micpga_routing = 0;
-       aic32x4->rstn_gpio = of_get_named_gpio(np, "reset-gpios", 0);
+       /* Assert reset using GPIOD_OUT_HIGH, because reset is GPIO_ACTIVE_LOW */
+       aic32x4->rstn_gpio = devm_gpiod_get_optional(aic32x4->dev, "reset", GPIOD_OUT_HIGH);
+       if (IS_ERR(aic32x4->rstn_gpio)) {
+               return dev_err_probe(aic32x4->dev, PTR_ERR(aic32x4->rstn_gpio),
+                                    "Failed to get reset gpio\n");
+       } else {
+               gpiod_set_consumer_name(aic32x4->rstn_gpio, "tlv320aic32x4_rstn");
+       }
 
        if (of_property_read_u32_array(np, "aic32x4-gpio-func",
                                aic32x4_setup->gpio_func, 5) >= 0)
@@ -1372,26 +1378,20 @@ int aic32x4_probe(struct device *dev, struct regmap *regmap,
                aic32x4->power_cfg = 0;
                aic32x4->swapdacs = false;
                aic32x4->micpga_routing = 0;
-               aic32x4->rstn_gpio = -1;
+               aic32x4->rstn_gpio = NULL;
                aic32x4->mclk_name = "mclk";
        }
 
-       if (gpio_is_valid(aic32x4->rstn_gpio)) {
-               ret = devm_gpio_request_one(dev, aic32x4->rstn_gpio,
-                               GPIOF_OUT_INIT_LOW, "tlv320aic32x4 rstn");
-               if (ret != 0)
-                       return ret;
-       }
-
        ret = aic32x4_setup_regulators(dev, aic32x4);
        if (ret) {
                dev_err(dev, "Failed to setup regulators\n");
                return ret;
        }
 
-       if (gpio_is_valid(aic32x4->rstn_gpio)) {
+       if (!aic32x4->rstn_gpio) {
                ndelay(10);
-               gpio_set_value_cansleep(aic32x4->rstn_gpio, 1);
+               /* deassert reset */
+               gpiod_set_value_cansleep(aic32x4->rstn_gpio, 0);
                mdelay(1);
        }