[PATCH v2 2/5] mux: gpio: add optional regulator support

srinivas.kandagatla@linaro.org posted 5 patches 9 months ago
There is a newer version of this series
[PATCH v2 2/5] mux: gpio: add optional regulator support
Posted by srinivas.kandagatla@linaro.org 9 months ago
From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

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>
---
 drivers/mux/gpio.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/mux/gpio.c b/drivers/mux/gpio.c
index cc5f2c1861d4..12cd9b5c32fb 100644
--- a/drivers/mux/gpio.c
+++ b/drivers/mux/gpio.c
@@ -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;
@@ -82,6 +83,13 @@ 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) {
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Couldn't retrieve/enable gpio mux supply\n");
+		return ret;
+	}
+
 	ret = devm_mux_chip_register(dev, mux_chip);
 	if (ret < 0)
 		return ret;
-- 
2.39.5
Re: [PATCH v2 2/5] mux: gpio: add optional regulator support
Posted by Krzysztof Kozlowski 9 months ago
On 20/03/2025 12:56, srinivas.kandagatla@linaro.org wrote:
>  struct mux_gpio {
>  	struct gpio_descs *gpios;
> @@ -82,6 +83,13 @@ 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) {
> +		if (ret != -EPROBE_DEFER)
> +			dev_err(dev, "Couldn't retrieve/enable gpio mux supply\n");

return dev_err_probe



Best regards,
Krzysztof