summaryrefslogtreecommitdiff
path: root/drivers/regulator/sy7636a-regulator.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/regulator/sy7636a-regulator.c')
-rw-r--r--drivers/regulator/sy7636a-regulator.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/drivers/regulator/sy7636a-regulator.c b/drivers/regulator/sy7636a-regulator.c
index 29fc27c2cda0..551647bc1052 100644
--- a/drivers/regulator/sy7636a-regulator.c
+++ b/drivers/regulator/sy7636a-regulator.c
@@ -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)
@@ -83,9 +86,11 @@ static int sy7636a_regulator_probe(struct platform_device *pdev)
if (!regmap)
return -EPROBE_DEFER;
- gdp = devm_gpiod_get(pdev->dev.parent, "epd-pwr-good", GPIOD_IN);
+ device_set_of_node_from_dev(&pdev->dev, pdev->dev.parent);
+
+ gdp = devm_gpiod_get(&pdev->dev, "epd-pwr-good", GPIOD_IN);
if (IS_ERR(gdp)) {
- dev_err(pdev->dev.parent, "Power good GPIO fault %ld\n", PTR_ERR(gdp));
+ dev_err(&pdev->dev, "Power good GPIO fault %ld\n", PTR_ERR(gdp));
return PTR_ERR(gdp);
}
@@ -96,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);
@@ -105,7 +134,6 @@ static int sy7636a_regulator_probe(struct platform_device *pdev)
}
config.dev = &pdev->dev;
- config.dev->of_node = pdev->dev.parent->of_node;
config.regmap = regmap;
rdev = devm_regulator_register(&pdev->dev, &desc, &config);
@@ -127,6 +155,7 @@ MODULE_DEVICE_TABLE(platform, sy7636a_regulator_id_table);
static struct platform_driver sy7636a_regulator_driver = {
.driver = {
.name = "sy7636a-regulator",
+ .probe_type = PROBE_PREFER_ASYNCHRONOUS,
},
.probe = sy7636a_regulator_probe,
.id_table = sy7636a_regulator_id_table,