Commit 6f3a9b10 authored by ChiYuan Huang's avatar ChiYuan Huang Committed by Mark Brown

regulator: rtq6752: Enclose 'enable' gpio control by enable flag

Fix 'enable' gpio control logic from the below cases if it's specified.

1. All off and both are sequentially controlled to be on.
The 'enable' gpio control block to be called twice including the delay time.

2. Both are on and one is preparing to be off.
The 'enable' gpio control low before register cache is configured to be true.
Signed-off-by: default avatarChiYuan Huang <cy_huang@richtek.com>
Link: https://lore.kernel.org/r/1631629249-9998-1-git-send-email-u0084500@gmail.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent b1c36aae
......@@ -54,6 +54,7 @@ static int rtq6752_set_vdd_enable(struct regulator_dev *rdev)
int rid = rdev_get_id(rdev), ret;
mutex_lock(&priv->lock);
if (!priv->enable_flag) {
if (priv->enable_gpio) {
gpiod_set_value(priv->enable_gpio, 1);
......@@ -61,7 +62,6 @@ static int rtq6752_set_vdd_enable(struct regulator_dev *rdev)
RTQ6752_I2CRDY_TIMEUS + 100);
}
if (!priv->enable_flag) {
regcache_cache_only(priv->regmap, false);
ret = regcache_sync(priv->regmap);
if (ret) {
......@@ -91,11 +91,11 @@ static int rtq6752_set_vdd_disable(struct regulator_dev *rdev)
if (!priv->enable_flag) {
regcache_cache_only(priv->regmap, true);
regcache_mark_dirty(priv->regmap);
}
if (priv->enable_gpio)
gpiod_set_value(priv->enable_gpio, 0);
}
mutex_unlock(&priv->lock);
return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment