summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Delaunay <[email protected]>2018-11-15 13:45:31 +0100
committerSimon Glass <[email protected]>2018-12-05 06:06:44 -0700
commit4f86a724e82c0b74d9ffb7b65f8ae4b011dd0b03 (patch)
treeaddbdb07007e58578bc2438884faaabfd4672fe9
parent7959882049a9b389c131eff9a128437ee8ebe08e (diff)
power: regulator: denied disable on always-on regulator
Don't disable regulator which are tagged as "regulator-always-on" in DT. Signed-off-by: Patrick Delaunay <[email protected]> Reviewed-by: Simon Glass <[email protected]> Reviewed-by: Jack Mitchell <[email protected]> Tested-by: Jack Mitchell <[email protected]> Signed-off-by: Patrice Chotard <[email protected]> Reviewed-by: Richard Röjfors <[email protected]> Tested-by: Richard Röjfors <[email protected]> Reviewed-by: Felix Brack <[email protected]> Tested-by: Felix Brack <[email protected]>
-rw-r--r--drivers/power/regulator/regulator-uclass.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/regulator/regulator-uclass.c
index 4da8e43259f..4511625ff25 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 (!enable && uc_pdata->always_on)
+ return -EACCES;
+
return ops->set_enable(dev, enable);
}