]> git.sur5r.net Git - u-boot/commitdiff
power: regulator: Introduce regulator_set_value_force function
authorKeerthy <j-keerthy@ti.com>
Wed, 26 Oct 2016 08:12:30 +0000 (13:42 +0530)
committerSimon Glass <sjg@chromium.org>
Fri, 25 Nov 2016 17:00:04 +0000 (10:00 -0700)
In case we want to force a particular value on a regulator
irrespective of the min/max constraints for testing purposes
one can call regulator_set_value_force function.

Signed-off-by: Keerthy <j-keerthy@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
cmd/regulator.c
drivers/power/regulator/regulator-uclass.c
include/power/regulator.h

index bfea6e04b6746dbb5d8efaa26073761ad9d390f9..2ef5bc9a828967f913b3d13a16f62f05342ff839 100644 (file)
@@ -292,7 +292,10 @@ static int do_value(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                return CMD_RET_FAILURE;
        }
 
-       ret = regulator_set_value(dev, value);
+       if (!force)
+               ret = regulator_set_value(dev, value);
+       else
+               ret = regulator_set_value_force(dev, value);
        if (ret) {
                printf("Regulator: %s - can't set the Voltage!\n",
                       uc_pdata->name);
index 4434e36312ac9f9f322bcf364b523e82494290ac..d64400981fa9a4a9ff144d3415cbad4a8c4dc0b2 100644 (file)
@@ -48,6 +48,20 @@ int regulator_set_value(struct udevice *dev, int uV)
        return ops->set_value(dev, uV);
 }
 
+/*
+ * To be called with at most caution as there is no check
+ * before setting the actual voltage value.
+ */
+int regulator_set_value_force(struct udevice *dev, int uV)
+{
+       const struct dm_regulator_ops *ops = dev_get_driver_ops(dev);
+
+       if (!ops || !ops->set_value)
+               return -ENOSYS;
+
+       return ops->set_value(dev, uV);
+}
+
 int regulator_get_current(struct udevice *dev)
 {
        const struct dm_regulator_ops *ops = dev_get_driver_ops(dev);
index f47ab6740bdd6951056184b755831efe956d6ea6..1a8e5753d789f1cd786b0ad7e5564334bca460d4 100644 (file)
@@ -260,6 +260,16 @@ int regulator_get_value(struct udevice *dev);
  */
 int regulator_set_value(struct udevice *dev, int uV);
 
+/**
+ * regulator_set_value_force: set the microvoltage value of a given regulator
+ *                           without any min-,max condition check
+ *
+ * @dev    - pointer to the regulator device
+ * @uV     - the output value to set [micro Volts]
+ * @return - 0 on success or -errno val if fails
+ */
+int regulator_set_value_force(struct udevice *dev, int uV);
+
 /**
  * regulator_get_current: get microampere value of a given regulator
  *