Skip to contentSkip to conversation

drivers: regulator: regulator-uclass: disallow disable of always-on

PATCH New Richard Röjfors 4 participants 4 messages Nov 22, 2018 – Nov 27, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 drivers/power/regulator/regulator-uclass.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/power/regulator/regulator-uclass.c +5 -0
index 4da8e43259..d5be6ef424 100644
@@ -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);
 }
 
Signature · 1 line
2.19.1
#1 lore raw

PATCH 1/1 drivers: regulator: regulator-uclass: disallow disable of always-on

Quoted 24 lines · Richard Röjfors

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.

---
 drivers/power/regulator/regulator-uclass.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/power/regulator/regulator-uclass.c +1 -0
index 4da8e43259..d5be6ef424 100644
@@ -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;
 

drivers/power/regulator/regulator-uclass.c int regulator_get_enable(struct udevice *dev) · line 120

Quoted 10 lines
drivers/power/regulator/regulator-uclass.c +4 -0
 	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.

#2 lore raw

PATCH 1/1 drivers: regulator: regulator-uclass: disallow disable of always-on

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

Quoted 50 lines · Jack Mitchell
Quoted 24 lines · Richard Röjfors

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.

---
 drivers/power/regulator/regulator-uclass.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/power/regulator/regulator-uclass.c +1 -0
index 4da8e43259..d5be6ef424 100644
@@ -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;
 

drivers/power/regulator/regulator-uclass.c int regulator_get_enable(struct udevice *dev) · line 120

Quoted 10 lines
drivers/power/regulator/regulator-uclass.c +4 -0
 	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 at lists.denx.de
https://lists.denx.de/listinfo/u-boot

#3 lore raw

PATCH 1/1 drivers: regulator: regulator-uclass: disallow disable of always-on

In reply to Richard Röjfors
Quoted 6 lines · Richard Röjfors

It does not make sense to allow disable of a regulator that is defined always on.

Quoted 6 lines

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.