[PATCH 3/5] regulator: allow use of dummy regulator

Sascha Hauer sha at pengutronix.de
Tue Nov 16 23:21:18 PST 2021


On Mon, Nov 15, 2021 at 02:02:06PM +0100, Andrej Picej wrote:
> It is quite common for users to delete power supply nodes of regulators
> which aren't yet supported.
> The idea of a function call or devicetree property which allows use of
> dummy regulator is not new. This implementation uses barebox specific
> devicetree property "barebox,allow-dummy-supply" to allow switching to
> dummy power regulator.
> Basically just catch the regulators ensure_probed error, if this
> property is set.
> 
> Signed-off-by: Andrej Picej <andrej.picej at norik.com>
> ---
>  drivers/regulator/core.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
> index 097f7d779..1c58932e1 100644
> --- a/drivers/regulator/core.c
> +++ b/drivers/regulator/core.c
> @@ -231,8 +231,15 @@ static struct regulator_internal *of_regulator_get(struct device_d *dev, const c
>  	}
>  
>  	ret = of_device_ensure_probed(node);
> -	if (ret)
> +	if (ret) {
> +		if (of_get_property(dev->device_node, "barebox,allow-dummy-supply", NULL)) {
> +			dev_dbg(dev, "Allow use of dummy regulator for " \
> +				"%s-supply\n", supply);
> +			ri = NULL;
> +			goto out;
> +		}
>  		return ERR_PTR(ret);

I wonder if we should rather add a property on the producer side than on
the consumer side, i.e. Add a barebox,status = "disabled" property to
the regulator node. We had the same discussion with phys recently, maybe
we can use the same approach for both issues.

Sascha


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



More information about the barebox mailing list