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>
#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;
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;