[U-Boot] [PATCH] drivers: regulator: regulator-uclass: disallow disable of always-on

It does not make sense to allow disable of a regulator that is defined always on.
I found this because the new mmc code that tests if the mmc power can be switched off. That results in the rk3288 firefly board to die since the regulator, which is always-on, is shared with more than just mmc.
Signed-off-by: Richard Röjfors richard@puffinpack.se --- drivers/power/regulator/regulator-uclass.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/regulator/regulator-uclass.c index 4da8e43259..d5be6ef424 100644 --- a/drivers/power/regulator/regulator-uclass.c +++ b/drivers/power/regulator/regulator-uclass.c @@ -106,10 +106,15 @@ int regulator_get_enable(struct udevice *dev) int regulator_set_enable(struct udevice *dev, bool enable) { const struct dm_regulator_ops *ops = dev_get_driver_ops(dev); + struct dm_regulator_uclass_platdata *uc_pdata;
if (!ops || !ops->set_enable) return -ENOSYS;
+ uc_pdata = dev_get_uclass_platdata(dev); + if (uc_pdata->always_on && !enable) + return -EINVAL; + return ops->set_enable(dev, enable); }

On 22/11/2018 21:12, Richard Röjfors wrote:
It does not make sense to allow disable of a regulator that is defined always on.
I found this because the new mmc code that tests if the mmc power can be switched off. That results in the rk3288 firefly board to die since the regulator, which is always-on, is shared with more than just mmc.
Signed-off-by: Richard Röjfors richard@puffinpack.se
drivers/power/regulator/regulator-uclass.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/regulator/regulator-uclass.c index 4da8e43259..d5be6ef424 100644 --- a/drivers/power/regulator/regulator-uclass.c +++ b/drivers/power/regulator/regulator-uclass.c @@ -106,10 +106,15 @@ int regulator_get_enable(struct udevice *dev) int regulator_set_enable(struct udevice *dev, bool enable) { const struct dm_regulator_ops *ops = dev_get_driver_ops(dev);
struct dm_regulator_uclass_platdata *uc_pdata;
if (!ops || !ops->set_enable) return -ENOSYS;
uc_pdata = dev_get_uclass_platdata(dev);
if (uc_pdata->always_on && !enable)
return -EINVAL;
return ops->set_enable(dev, enable);
}
Hi Richard,
Please add your reviewed/tested by to this patch and an extra ping, it's been waiting to be merged for a while.
https://lists.denx.de/pipermail/u-boot/2018-May/330186.html
Cheers, Jack.

Hi Richard,
As pointed by Jack, i already sent a similar patch on May. I resend it few days ago [1], it's preferable you add your tested-by on this last one.
Thanks
Patrice
[1] https://lists.denx.de/pipermail/u-boot/2018-November/347511.html
On 11/23/18 8:13 PM, Jack Mitchell wrote:
On 22/11/2018 21:12, Richard Röjfors wrote:
It does not make sense to allow disable of a regulator that is defined always on.
I found this because the new mmc code that tests if the mmc power can be switched off. That results in the rk3288 firefly board to die since the regulator, which is always-on, is shared with more than just mmc.
Signed-off-by: Richard Röjfors richard@puffinpack.se
drivers/power/regulator/regulator-uclass.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/regulator/regulator-uclass.c index 4da8e43259..d5be6ef424 100644 --- a/drivers/power/regulator/regulator-uclass.c +++ b/drivers/power/regulator/regulator-uclass.c @@ -106,10 +106,15 @@ int regulator_get_enable(struct udevice *dev) int regulator_set_enable(struct udevice *dev, bool enable) { const struct dm_regulator_ops *ops = dev_get_driver_ops(dev);
struct dm_regulator_uclass_platdata *uc_pdata;
if (!ops || !ops->set_enable) return -ENOSYS;
uc_pdata = dev_get_uclass_platdata(dev);
if (uc_pdata->always_on && !enable)
return -EINVAL;
return ops->set_enable(dev, enable);
}
Hi Richard,
Please add your reviewed/tested by to this patch and an extra ping, it's been waiting to be merged for a while.
https://lists.denx.de/pipermail/u-boot/2018-May/330186.html
Cheers, Jack. _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot

On 22.11.2018, at 22:12, Richard Röjfors richard.rojfors@gmail.com wrote:
It does not make sense to allow disable of a regulator that is defined always on.
I found this because the new mmc code that tests if the mmc power can be switched off. That results in the rk3288 firefly board to die since the regulator, which is always-on, is shared with more than just mmc.
Signed-off-by: Richard Röjfors richard@puffinpack.se
Reviewed-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com
participants (4)
-
Jack Mitchell
-
Patrice CHOTARD
-
Philipp Tomsich
-
Richard Röjfors