mux: gpio: add optional regulator support
authorSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Thu, 27 Mar 2025 10:06:29 +0000 (10:06 +0000)
committerKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Thu, 8 May 2025 12:55:36 +0000 (14:55 +0200)
Some of the external muxes needs powering up using a regulator.
This is the case with Lenovo T14s laptop which has a external audio mux
to handle US/EURO headsets.

Add support to the driver to handle this optional regulator.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Tested-by: Christopher Obbard <christopher.obbard@linaro.org>
Reviewed-by: Johan Hovold <johan+linaro@kernel.org>
Tested-by: Johan Hovold <johan+linaro@kernel.org>
Link: https://lore.kernel.org/r/20250327100633.11530-3-srinivas.kandagatla@linaro.org
[krzk: Adjust dev_err message per Johan's review]
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
drivers/mux/gpio.c

index 5710879cd47f89b6ef4458d6b4419a1fe9ad349f..4cc3202c58f364e80ad9f632763f568d184d4173 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/mux/driver.h>
 #include <linux/platform_device.h>
 #include <linux/property.h>
+#include <linux/regulator/consumer.h>
 
 struct mux_gpio {
        struct gpio_descs *gpios;
@@ -80,6 +81,10 @@ static int mux_gpio_probe(struct platform_device *pdev)
                mux_chip->mux->idle_state = idle_state;
        }
 
+       ret = devm_regulator_get_enable_optional(dev, "mux");
+       if (ret && ret != -ENODEV)
+               return dev_err_probe(dev, ret, "failed to get/enable mux supply\n");
+
        ret = devm_mux_chip_register(dev, mux_chip);
        if (ret < 0)
                return ret;