public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Christian Marangi <ansuelsmth@gmail.com>
To: Simon Glass <sjg@chromium.org>, Tom Rini <trini@konsulko.com>,
	Christian Marangi <ansuelsmth@gmail.com>,
	Sean Anderson <seanga2@gmail.com>,
	Sughosh Ganu <sughosh.ganu@linaro.org>,
	Caleb Connolly <caleb.connolly@linaro.org>,
	Mattijs Korpershoek <mkorpershoek@baylibre.com>,
	Patrick Rudolph <patrick.rudolph@9elements.com>,
	Yang Xiwen <forbidden405@outlook.com>,
	Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>,
	Rasmus Villemoes <rasmus.villemoes@prevas.dk>,
	Marek Vasut <marex@denx.de>,
	Michael Polyntsov <michael.polyntsov@iopsys.eu>,
	u-boot@lists.denx.de
Subject: [PATCH v2 5/8] dm: core: implement phandle ofnode_options helper
Date: Sun, 10 Nov 2024 12:50:24 +0100	[thread overview]
Message-ID: <20241110115054.2555-6-ansuelsmth@gmail.com> (raw)
In-Reply-To: <20241110115054.2555-1-ansuelsmth@gmail.com>

Implement ofnode_options phandle helper to get an ofnode from a phandle
option in /options/u-boot.

This helper can be useful since new DT yaml usually require to link a
phandle of a node instead of referencing it by name or other indirect
way.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 drivers/core/ofnode.c | 15 +++++++++++++++
 include/dm/ofnode.h   | 15 +++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index dc6ac069311..c8161827d1c 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -1871,6 +1871,21 @@ const char *ofnode_options_read_str(const char *prop_name)
 	return ofnode_read_string(uboot, prop_name);
 }
 
+int ofnode_options_get_by_phandle(const char *prop_name, ofnode *nodep)
+{
+	ofnode uboot;
+
+	uboot = ofnode_path("/options/u-boot");
+	if (!ofnode_valid(uboot))
+		return -EINVAL;
+
+	*nodep = ofnode_parse_phandle(uboot, prop_name, 0);
+	if (!ofnode_valid(*nodep))
+		return -EINVAL;
+
+	return 0;
+}
+
 int ofnode_read_bootscript_address(u64 *bootscr_address, u64 *bootscr_offset)
 {
 	int ret;
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index eea6b13217c..890f0e6cf40 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -1720,6 +1720,21 @@ int ofnode_options_read_int(const char *prop_name, int default_val);
  */
 const char *ofnode_options_read_str(const char *prop_name);
 
+/**
+ * ofnode_options_get_by_phandle() - Get a ofnode from phandle from the U-Boot options
+ *
+ * This reads a property from the /options/u-boot/ node of the devicetree.
+ *
+ * This only works with the control FDT.
+ *
+ * See dtschema/schemas/options/u-boot.yaml in dt-schema project for bindings
+ *
+ * @prop_name: property name to look up
+ * @nodep: pointer to ofnode where node is stored
+ * Return: 0, if found, or negative error if not
+ */
+int ofnode_options_get_by_phandle(const char *prop_name, ofnode *nodep);
+
 /**
  * ofnode_read_bootscript_address() - Read bootscr-address or bootscr-ram-offset
  *
-- 
2.45.2


  parent reply	other threads:[~2024-11-10 11:52 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-10 11:50 [PATCH v2 0/8] led: update LED boot/activity to new property implementation Christian Marangi
2024-11-10 11:50 ` [PATCH v2 1/8] dm: core: implement oftree variant of parse_phandle OPs Christian Marangi
2024-11-20 13:46   ` Simon Glass
2024-11-10 11:50 ` [PATCH v2 2/8] test: dm: fix broken dm_test_ofnode_phandle_ot and get_by_phandle_ot Christian Marangi
2024-11-20 13:46   ` Simon Glass
2024-11-10 11:50 ` [PATCH v2 3/8] dm: core: implement ofnode/tree_parse_phandle() helper Christian Marangi
2024-11-20 13:48   ` Simon Glass
2024-11-10 11:50 ` [PATCH v2 4/8] test: dm: Expand dm_test_ofnode_phandle(_ot) with new ofnode/tree_parse_phandle Christian Marangi
2024-11-20 13:48   ` Simon Glass
2024-11-10 11:50 ` Christian Marangi [this message]
2024-11-20 13:48   ` [PATCH v2 5/8] dm: core: implement phandle ofnode_options helper Simon Glass
2024-11-10 11:50 ` [PATCH v2 6/8] test: dm: Add test for ofnode options phandle helper Christian Marangi
2024-11-20 13:48   ` Simon Glass
2024-11-10 11:50 ` [PATCH v2 7/8] led: update LED boot/activity to new property implementation Christian Marangi
2024-11-10 11:50 ` [PATCH v2 8/8] test: dm: Update test for LED activity and boot Christian Marangi
2024-11-20 13:48   ` Simon Glass
2024-11-13 18:00 ` [PATCH v2 0/8] led: update LED boot/activity to new property implementation Tom Rini
2024-11-13 20:24   ` Christian Marangi
2024-11-23  2:41     ` Tom Rini
2024-12-06 17:30       ` Christian Marangi
2024-12-06 17:56         ` Tom Rini
2024-12-06 22:30 ` Tom Rini

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=20241110115054.2555-6-ansuelsmth@gmail.com \
    --to=ansuelsmth@gmail.com \
    --cc=caleb.connolly@linaro.org \
    --cc=forbidden405@outlook.com \
    --cc=marex@denx.de \
    --cc=michael.polyntsov@iopsys.eu \
    --cc=mikhail.kshevetskiy@iopsys.eu \
    --cc=mkorpershoek@baylibre.com \
    --cc=patrick.rudolph@9elements.com \
    --cc=rasmus.villemoes@prevas.dk \
    --cc=seanga2@gmail.com \
    --cc=sjg@chromium.org \
    --cc=sughosh.ganu@linaro.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox