mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Andrej Picej <andrej.picej@norik.com>
To: barebox@lists.infradead.org
Subject: [PATCH v2 4/6] regulator: allow use of dummy regulator
Date: Fri, 19 Nov 2021 10:54:27 +0100
Message-ID: <20211119095429.1905473-5-andrej.picej@norik.com> (raw)
In-Reply-To: <20211119095429.1905473-1-andrej.picej@norik.com>

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>
---
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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


  parent reply	other threads:[~2021-11-19  9:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-19  9:54 [PATCH v2 0/6] PHYTEC patches to be mainlined Andrej Picej
2021-11-19  9:54 ` [PATCH v2 1/6] flash-header-phytec-pcl063: Set SOC voltage to 1.25 V during boot Andrej Picej
2021-11-19  9:54 ` [PATCH v2 2/6] ARM: configs: imx_v7_defconfig: add OF commands Andrej Picej
2021-11-19  9:54 ` [PATCH v2 3/6] ARM: configs: imx_v7_defconfig: add OCOTP write support Andrej Picej
2021-11-19  9:54 ` Andrej Picej [this message]
2021-11-19 10:49   ` [PATCH v2 4/6] regulator: allow use of dummy regulator Trent Piepho
2021-11-19 12:35     ` Andrej Picej
2021-11-19 13:06     ` [PATCH] regulator: fix memory leak Andrej Picej
2021-11-19  9:54 ` [PATCH v2 5/6] ARM: dts: imx6qdl: pfla02: use dummy regulators Andrej Picej
2021-11-19  9:54 ` [PATCH v2 6/6] documentation: regulator: add allow-dummy-supply Andrej Picej
2021-11-25  7:30 ` [PATCH v2 0/6] PHYTEC patches to be mainlined Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211119095429.1905473-5-andrej.picej@norik.com \
    --to=andrej.picej@norik.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

mail archive of the barebox mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://lore.barebox.org/barebox/0 barebox/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 barebox barebox/ https://lore.barebox.org/barebox \
		barebox@lists.infradead.org barebox@lists.infradead.org
	public-inbox-index barebox

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git