]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
regulator: sy7636a: add gpios and input regulator
authorAndreas Kemnade <akemnade@kernel.org>
Wed, 17 Sep 2025 07:14:30 +0000 (09:14 +0200)
committerMark Brown <broonie@kernel.org>
Wed, 15 Oct 2025 20:52:32 +0000 (21:52 +0100)
Initialize input regulator and gpios to proper values to have things
basically working as well as in the case when these things are
hardwired.

Reviewed-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Andreas Kemnade <akemnade@kernel.org>
Link: https://patch.msgid.link/20250917-sy7636-rsrc-v3-2-331237d507a2@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/regulator/sy7636a-regulator.c

index 27e3d939b7bb9e9af8821bbda053b7d961710fb3..551647bc10520295f1d86e45f87065e8ba70a35f 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/mfd/sy7636a.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/regulator/consumer.h>
 #include <linux/regulator/driver.h>
 #include <linux/regulator/machine.h>
 #include <linux/regmap.h>
@@ -19,6 +20,8 @@
 struct sy7636a_data {
        struct regmap *regmap;
        struct gpio_desc *pgood_gpio;
+       struct gpio_desc *en_gpio;
+       struct gpio_desc *vcom_en_gpio;
 };
 
 static int sy7636a_get_vcom_voltage_op(struct regulator_dev *rdev)
@@ -98,6 +101,30 @@ static int sy7636a_regulator_probe(struct platform_device *pdev)
        data->regmap = regmap;
        data->pgood_gpio = gdp;
 
+       ret = devm_regulator_get_enable_optional(&pdev->dev, "vin");
+       if (ret)
+               return dev_err_probe(&pdev->dev, ret,
+                                    "failed to get vin regulator\n");
+
+       data->en_gpio = devm_gpiod_get_optional(&pdev->dev, "enable",
+                                               GPIOD_OUT_HIGH);
+       if (IS_ERR(data->en_gpio))
+               return dev_err_probe(&pdev->dev,
+                                    PTR_ERR(data->en_gpio),
+                                    "failed to get en gpio\n");
+
+       /* Let VCOM just follow the default power on sequence */
+       data->vcom_en_gpio = devm_gpiod_get_optional(&pdev->dev,
+                                                    "vcom-en", GPIOD_OUT_LOW);
+       if (IS_ERR(data->vcom_en_gpio))
+               return dev_err_probe(&pdev->dev,
+                                    PTR_ERR(data->vcom_en_gpio),
+                                    "failed to get vcom-en gpio\n");
+
+       /* if chip was not enabled, give it time to wake up */
+       if (data->en_gpio)
+               usleep_range(2500, 4000);
+
        platform_set_drvdata(pdev, data);
 
        ret = regmap_write(regmap, SY7636A_REG_POWER_ON_DELAY_TIME, 0x0);