Commit 513d1404 authored by ChiYuan Huang's avatar ChiYuan Huang Committed by Mark Brown

regulator: rtq6752: fix reg reset behavior

Reg will be reset in below two conditions.
1. 'Enable' pin from H to L.
2. Both PAVDD and NAVDD are all disabled.

And 'Enable' pin also control i2c communication capability.

This patch is to Seperate the if condition in enable/disable callback for
reg cache manipulation.
Signed-off-by: default avatarChiYuan Huang <cy_huang@richtek.com>
Link: https://lore.kernel.org/r/1626407746-23156-1-git-send-email-u0084500@gmail.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 541ee8f6
...@@ -54,12 +54,14 @@ static int rtq6752_set_vdd_enable(struct regulator_dev *rdev) ...@@ -54,12 +54,14 @@ static int rtq6752_set_vdd_enable(struct regulator_dev *rdev)
int rid = rdev_get_id(rdev), ret; int rid = rdev_get_id(rdev), ret;
mutex_lock(&priv->lock); mutex_lock(&priv->lock);
if (!priv->enable_flag && priv->enable_gpio) { if (priv->enable_gpio) {
gpiod_set_value(priv->enable_gpio, 1); gpiod_set_value(priv->enable_gpio, 1);
usleep_range(RTQ6752_I2CRDY_TIMEUS, usleep_range(RTQ6752_I2CRDY_TIMEUS,
RTQ6752_I2CRDY_TIMEUS + 100); RTQ6752_I2CRDY_TIMEUS + 100);
}
if (!priv->enable_flag) {
regcache_cache_only(priv->regmap, false); regcache_cache_only(priv->regmap, false);
ret = regcache_sync(priv->regmap); ret = regcache_sync(priv->regmap);
if (ret) { if (ret) {
...@@ -86,12 +88,14 @@ static int rtq6752_set_vdd_disable(struct regulator_dev *rdev) ...@@ -86,12 +88,14 @@ static int rtq6752_set_vdd_disable(struct regulator_dev *rdev)
mutex_lock(&priv->lock); mutex_lock(&priv->lock);
priv->enable_flag &= ~BIT(rid); priv->enable_flag &= ~BIT(rid);
if (!priv->enable_flag && priv->enable_gpio) { if (!priv->enable_flag) {
regcache_cache_only(priv->regmap, true); regcache_cache_only(priv->regmap, true);
regcache_mark_dirty(priv->regmap); regcache_mark_dirty(priv->regmap);
}
if (priv->enable_gpio)
gpiod_set_value(priv->enable_gpio, 0); gpiod_set_value(priv->enable_gpio, 0);
}
mutex_unlock(&priv->lock); mutex_unlock(&priv->lock);
return 0; 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