aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorMarek Vasut2022-01-25 03:46:52 +0100
committerStefano Babic2022-02-05 15:49:01 +0100
commit1b7f00eb1f239973ef459a3608ab5335011c6ab5 (patch)
treeb653f252598f0205eb7d940c961f4b5097040680 /drivers
parent1289ff7bd7e4429aabbc33d37c4a93fd1e437d07 (diff)
regulator: bd718x7: Bypass bogus warnings
When regulator consumer attempts to set enabled DVS regulator voltage, the driver aborts with "Only DVS bucks can be changed when enabled". In case the regulator is already set to specified voltage, do nothing instead of failing outright. When regulator consumer attempts to set enables regulator which cannot be controlled because it is already always enabled, the driver aborts with -EINVAL. Again, do nothing in such case and return 0, because the request is really fulfilled, the regulator is enabled. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/power/regulator/bd71837.c69
1 files changed, 36 insertions, 33 deletions
diff --git a/drivers/power/regulator/bd71837.c b/drivers/power/regulator/bd71837.c
index 74011d62985..d4f8da80ad7 100644
--- a/drivers/power/regulator/bd71837.c
+++ b/drivers/power/regulator/bd71837.c
@@ -306,7 +306,7 @@ static int bd71837_set_enable(struct udevice *dev, bool enable)
* reseted to snvs state. Hence we can't set the state here.
*/
if (plat->enablemask == HW_STATE_CONTROL)
- return -EINVAL;
+ return enable ? 0 : -EINVAL;
if (enable)
val = plat->enablemask;
@@ -315,6 +315,38 @@ static int bd71837_set_enable(struct udevice *dev, bool enable)
val);
}
+static int bd71837_get_value(struct udevice *dev)
+{
+ unsigned int reg, range;
+ unsigned int tmp;
+ struct bd71837_plat *plat = dev_get_plat(dev);
+ int i;
+
+ reg = pmic_reg_read(dev->parent, plat->volt_reg);
+ if (((int)reg) < 0)
+ return reg;
+
+ range = reg & plat->rangemask;
+
+ reg &= plat->volt_mask;
+ reg >>= ffs(plat->volt_mask) - 1;
+
+ for (i = 0; i < plat->numranges; i++) {
+ struct bd71837_vrange *r = &plat->ranges[i];
+
+ if (plat->rangemask && ((plat->rangemask & range) !=
+ r->rangeval))
+ continue;
+
+ if (!vrange_find_value(r, reg, &tmp))
+ return tmp;
+ }
+
+ pr_err("Unknown voltage value read from pmic\n");
+
+ return -EINVAL;
+}
+
static int bd71837_set_value(struct udevice *dev, int uvolt)
{
unsigned int sel;
@@ -330,6 +362,9 @@ static int bd71837_set_value(struct udevice *dev, int uvolt)
*/
if (!plat->dvs)
if (bd71837_get_enable(dev)) {
+ /* If the value is already set, skip the warning. */
+ if (bd71837_get_value(dev) == uvolt)
+ return 0;
pr_err("Only DVS bucks can be changed when enabled\n");
return -EINVAL;
}
@@ -365,38 +400,6 @@ static int bd71837_set_value(struct udevice *dev, int uvolt)
plat->rangemask, sel);
}
-static int bd71837_get_value(struct udevice *dev)
-{
- unsigned int reg, range;
- unsigned int tmp;
- struct bd71837_plat *plat = dev_get_plat(dev);
- int i;
-
- reg = pmic_reg_read(dev->parent, plat->volt_reg);
- if (((int)reg) < 0)
- return reg;
-
- range = reg & plat->rangemask;
-
- reg &= plat->volt_mask;
- reg >>= ffs(plat->volt_mask) - 1;
-
- for (i = 0; i < plat->numranges; i++) {
- struct bd71837_vrange *r = &plat->ranges[i];
-
- if (plat->rangemask && ((plat->rangemask & range) !=
- r->rangeval))
- continue;
-
- if (!vrange_find_value(r, reg, &tmp))
- return tmp;
- }
-
- pr_err("Unknown voltage value read from pmic\n");
-
- return -EINVAL;
-}
-
static int bd71837_regulator_probe(struct udevice *dev)
{
struct bd71837_plat *plat = dev_get_plat(dev);