diff mbox

[U-Boot,1/3] power: regulator: Introduce regulator_set_value_force function

Message ID 1477469552-10510-1-git-send-email-j-keerthy@ti.com
State Accepted
Commit 2f5d532f3b8a7697dc1b5700000b1e350323d50c
Delegated to: Simon Glass
Headers show

Commit Message

J, KEERTHY Oct. 26, 2016, 8:12 a.m. UTC
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>
---
 cmd/regulator.c                            |  5 ++++-
 drivers/power/regulator/regulator-uclass.c | 14 ++++++++++++++
 include/power/regulator.h                  | 10 ++++++++++
 3 files changed, 28 insertions(+), 1 deletion(-)

Comments

Simon Glass Oct. 26, 2016, 4:31 p.m. UTC | #1
On 26 October 2016 at 01:12, Keerthy <j-keerthy@ti.com> wrote:
> 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>
> ---
>  cmd/regulator.c                            |  5 ++++-
>  drivers/power/regulator/regulator-uclass.c | 14 ++++++++++++++
>  include/power/regulator.h                  | 10 ++++++++++
>  3 files changed, 28 insertions(+), 1 deletion(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
Simon Glass Nov. 25, 2016, 7:38 p.m. UTC | #2
On 26 October 2016 at 10:31, Simon Glass <sjg@chromium.org> wrote:
> On 26 October 2016 at 01:12, Keerthy <j-keerthy@ti.com> wrote:
>> 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>
>> ---
>>  cmd/regulator.c                            |  5 ++++-
>>  drivers/power/regulator/regulator-uclass.c | 14 ++++++++++++++
>>  include/power/regulator.h                  | 10 ++++++++++
>>  3 files changed, 28 insertions(+), 1 deletion(-)
>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot-rockchip, thanks!
diff mbox

Patch

diff --git a/cmd/regulator.c b/cmd/regulator.c
index bfea6e0..2ef5bc9 100644
--- a/cmd/regulator.c
+++ b/cmd/regulator.c
@@ -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);
diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/regulator/regulator-uclass.c
index 4434e36..d644009 100644
--- a/drivers/power/regulator/regulator-uclass.c
+++ b/drivers/power/regulator/regulator-uclass.c
@@ -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);
diff --git a/include/power/regulator.h b/include/power/regulator.h
index f47ab67..1a8e575 100644
--- a/include/power/regulator.h
+++ b/include/power/regulator.h
@@ -261,6 +261,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
  *
  * @dev    - pointer to the regulator device