[PATCH v2 4/6] regulator: allow use of dummy regulator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
Changes in v2:
 - node is now added on regulator side, so check for property on
   provider side
---
 drivers/regulator/core.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 097f7d779..4f45c23cd 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -197,7 +197,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);
@@ -231,8 +231,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, &regulator_list, list) {
 		if (ri->node == node) {
-- 
2.25.1


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux