On 26-01-29, Sascha Hauer wrote:
> In Linux the off_on_delay field in a regulator is described as:
> 
> > The guard time (in uS), before re-enabling a regulator
> 
> The primary user is the fixed regulator which puts the value of
> the "off-on-delay-us" property into it.
> 
> In barebox we put the off_on_delay into the enable_time_us field
> which is the delay we introduce when turning on a regulator. This
> is wrong and fixed in this commit.
> 
> The off_on_delay is defined as the time we should take before
> re-enabling a regulator. Linux does it the complicated way of
> remembering the time when it was last disabled and delays the
> re-enabling if necessary. We use the simple approach here of
> just waiting the off_on_delay time in the regulator disable path.
> 
> Fixes: 26a4c78917 ("regulator: add support for struct 
> regulator_desc::off_on_delay")
> Signed-off-by: Sascha Hauer <[email protected]>
> ---
>  drivers/regulator/core.c | 5 ++++-
>  include/regulator.h      | 1 +
>  2 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
> index cd07955894..8ca937e8bd 100644
> --- a/drivers/regulator/core.c
> +++ b/drivers/regulator/core.c
> @@ -96,6 +96,9 @@ static int regulator_disable_rdev(struct regulator_dev 
> *rdev)
>  
>       rdev->enable_count--;
>  
> +     if (rdev->off_on_delay)
> +             udelay(rdev->off_on_delay);
> +
>       return regulator_disable(rdev->supply);
>  }
>  
> @@ -309,7 +312,7 @@ int of_regulator_register(struct regulator_dev *rdev, 
> struct device_node *node)
>       node->dev = rdev->dev;
>  
>       if (rdev->desc->off_on_delay)
> -             rdev->enable_time_us = rdev->desc->off_on_delay;

Nit: is is worth to remove the enable_time_us completely and
re-introduce it within the next commit?

Reviewed-by: Marco Felsch <[email protected]>

> +             rdev->off_on_delay = rdev->desc->off_on_delay;
>  
>       if (rdev->desc->fixed_uV && rdev->desc->n_voltages == 1)
>               rdev->min_uv = rdev->max_uv = rdev->desc->fixed_uV;
> diff --git a/include/regulator.h b/include/regulator.h
> index bca2d37d1a..09b4969c74 100644
> --- a/include/regulator.h
> +++ b/include/regulator.h
> @@ -123,6 +123,7 @@ struct regulator_dev {
>       struct device_node *node;
>       int enable_count;
>       int enable_time_us;
> +     unsigned int off_on_delay;
>       int min_uv;
>       int max_uv;
>       struct list_head consumer_list;
> 
> -- 
> 2.47.3
> 
> 
> 

-- 
#gernperDu 
#CallMeByMyFirstName

Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | https://www.pengutronix.de/ |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-9    |

Reply via email to