diff options
author | Andrej Picej <andrej.picej@norik.com> | 2021-11-19 10:54:27 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-11-25 08:29:57 +0100 |
commit | b72062565937f8e9a98101a2dc1879c44a96ba25 (patch) | |
tree | f73a28d2ea615a27e477576da6508e64b7067d01 /drivers/regulator/core.c | |
parent | c7beb9e75ea14413cf83b84d83072b92cec9dc3b (diff) | |
download | barebox-b72062565937f8e9a98101a2dc1879c44a96ba25.tar.gz barebox-b72062565937f8e9a98101a2dc1879c44a96ba25.tar.xz |
regulator: allow use of dummy regulator
The idea of devicetree property which allows use of dummy regulator is
not new but has not been implemented until now.
This implementation uses barebox specific devicetree property
"barebox,allow-dummy-supply" to allow switching to a dummy power
regulator in cases where proper regulator driver is not available. This
property can be set for regulator or for PMIC regulators nodes, which
then allow use of dummy regulator for all its child nodes. Basically
just catch the regulators ensure_probed error, if
"barebox,allow-dummy-supply" property is set and return dummy regulator.
Signed-off-by: Andrej Picej <andrej.picej@norik.com>
Link: https://lore.barebox.org/20211119095429.1905473-5-andrej.picej@norik.com
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/regulator/core.c')
-rw-r--r-- | drivers/regulator/core.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 7eb849cd31..4cf6e34de8 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -188,7 +188,7 @@ static struct regulator_internal *of_regulator_get(struct device_d *dev, const c { char *propname; struct regulator_internal *ri; - struct device_node *node; + struct device_node *node, *node_parent; int ret; propname = basprintf("%s-supply", supply); @@ -222,8 +222,24 @@ static struct regulator_internal *of_regulator_get(struct device_d *dev, const c } ret = of_device_ensure_probed(node); - if (ret) + if (ret) { + /* + * If "barebox,allow-dummy-supply" property is set for regulator + * provider allow use of dummy regulator (NULL is returned). + * Check regulator node and its parent if this setting is set + * PMIC wide. + */ + node_parent = of_get_parent(node); + if (of_get_property(node, "barebox,allow-dummy-supply", NULL) || + of_get_property(node_parent, "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); + } list_for_each_entry(ri, ®ulator_list, list) { if (ri->node == node) { |