diff mbox series

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

Message ID 20181122211205.14200-1-richard@puffinpack.se
State Deferred
Delegated to: Peng Fan
Headers show
Series [U-Boot] drivers: regulator: regulator-uclass: disallow disable of always-on | expand

Commit Message

Richard Röjfors Nov. 22, 2018, 9:12 p.m. UTC
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(+)

Comments

Jack Mitchell Nov. 23, 2018, 7:13 p.m. UTC | #1
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.
Philipp Tomsich Nov. 23, 2018, 7:37 p.m. UTC | #2
> 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>
Patrice CHOTARD Nov. 27, 2018, 3:31 p.m. UTC | #3
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
>
diff mbox series

Patch

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);
 }