[U-Boot] [PATCH] regulator: Allow autosetting fixed regulators
Peng Fan
peng.fan at nxp.com
Fri May 31 09:34:59 UTC 2019
> Subject: [PATCH] regulator: Allow autosetting fixed regulators
>
> Fixed regulators don't have a set_value method. Therefore,
> regulator_set_value will return -ENOSYS when called from regulator_autoset.
>
> Accepting this return value allows autosetting fixed regulators.
>
> Signed-off-by: Sven Schwermer <sven at svenschwermer.de>
> Cc: Jaehoon Chung <jh80.chung at samsung.com>
> Cc: Peng Fan <peng.fan at nxp.com>
> ---
> drivers/power/regulator/regulator-uclass.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/power/regulator/regulator-uclass.c
> b/drivers/power/regulator/regulator-uclass.c
> index 9118b8eb39..0b99c262ac 100644
> --- a/drivers/power/regulator/regulator-uclass.c
> +++ b/drivers/power/regulator/regulator-uclass.c
> @@ -243,7 +243,7 @@ int regulator_autoset(struct udevice *dev)
> if (!ret && (uc_pdata->flags & REGULATOR_FLAG_AUTOSET_UA))
> ret = regulator_set_current(dev, uc_pdata->min_uA);
>
> - if (!ret)
> + if (!ret || ret == -ENOSYS)
> ret = regulator_set_enable(dev, true);
How about the following patch? not tested
diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/regulator/regulator-uclass.c
index 9118b8eb39..76be95bcd1 100644
--- a/drivers/power/regulator/regulator-uclass.c
+++ b/drivers/power/regulator/regulator-uclass.c
@@ -238,6 +238,9 @@ int regulator_autoset(struct udevice *dev)
if (!uc_pdata->always_on && !uc_pdata->boot_on)
return -EMEDIUMTYPE;
+ if (uc_pdata->type == REGULATOR_TYPE_FIXED)
+ return regulator_set_enable(dev, true);
+
if (uc_pdata->flags & REGULATOR_FLAG_AUTOSET_UV)
ret = regulator_set_value(dev, uc_pdata->min_uV);
if (!ret && (uc_pdata->flags & REGULATOR_FLAG_AUTOSET_UA))
Regards,
Peng.
>
> return ret;
> --
> 2.17.1
More information about the U-Boot
mailing list