All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Marangi <ansuelsmth@gmail.com>
To: Tom Rini <trini@konsulko.com>, Simon Glass <sjg@chromium.org>,
	Christian Marangi <ansuelsmth@gmail.com>,
	Casey Connolly <casey.connolly@linaro.org>,
	Quentin Schulz <quentin.schulz@cherry.de>,
	Peng Fan <peng.fan@nxp.com>,
	Kever Yang <kever.yang@rock-chips.com>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Mateus Lima Alves <mateuslima.ti@gmail.com>,
	Jamie Gibbons <jamie.gibbons@microchip.com>,
	Neha Malcom Francis <n-francis@ti.com>,
	Justin Klaassen <justin@tidylabs.net>,
	Leo Yu-Chi Liang <ycliang@andestech.com>,
	Weijie Gao <weijie.gao@mediatek.com>,
	Marek Vasut <marek.vasut+renesas@mailbox.org>,
	"Lucien.Jheng" <lucienzx159@gmail.com>,
	u-boot@lists.denx.de
Subject: [PATCH v6 3/6] misc: fw_loader: implement generic get_fw_loader_from_node()
Date: Thu,  9 Apr 2026 15:32:59 +0200	[thread overview]
Message-ID: <20260409133303.31875-4-ansuelsmth@gmail.com> (raw)
In-Reply-To: <20260409133303.31875-1-ansuelsmth@gmail.com>

Implement a generic function to get a FW loader dev from a node.

There is currently only get_fs_loader() but that is limited to chosen
node and is limited only to FS loader.

Introduce get_fw_loader_from_node() that will parse the
"firmware-loader" from a specified node and will search and probe a
matching FW loader device, if found.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 drivers/misc/fw_loader/fw_loader-uclass.c | 23 +++++++++++++++++++++++
 include/fw_loader.h                       | 14 ++++++++++++++
 2 files changed, 37 insertions(+)

diff --git a/drivers/misc/fw_loader/fw_loader-uclass.c b/drivers/misc/fw_loader/fw_loader-uclass.c
index 16a1fe2d4a65..c32c213b5b38 100644
--- a/drivers/misc/fw_loader/fw_loader-uclass.c
+++ b/drivers/misc/fw_loader/fw_loader-uclass.c
@@ -9,6 +9,8 @@
 #include <linux/types.h>
 #include <dm.h>
 #include <dm/device.h>
+#include <dm/device-internal.h>
+#include <dm/uclass.h>
 #include <fw_loader.h>
 
 #ifdef CONFIG_CMD_UBIFS
@@ -96,6 +98,27 @@ UCLASS_DRIVER(fw_loader) = {
 	.per_device_auto = sizeof(struct firmware),
 };
 
+int get_fw_loader_from_node(ofnode node, struct udevice **dev)
+{
+	struct udevice *fw_dev;
+	int ret;
+
+	node = ofnode_parse_phandle(node, "firmware-loader", 0);
+	if (!ofnode_valid(node))
+		return -ENODEV;
+
+	ret = device_find_global_by_ofnode(node, &fw_dev);
+	if (ret)
+		return ret;
+
+	ret = device_probe(fw_dev);
+	if (ret)
+		return ret;
+
+	*dev = fw_dev;
+	return 0;
+}
+
 /**
  * _request_firmware_prepare - Prepare firmware struct.
  *
diff --git a/include/fw_loader.h b/include/fw_loader.h
index 56f5e3be6195..99c47380a172 100644
--- a/include/fw_loader.h
+++ b/include/fw_loader.h
@@ -6,8 +6,22 @@
 #ifndef _FW_LOADER_H_
 #define _FW_LOADER_H_
 
+#include <dm/ofnode_decl.h>
+
 struct udevice;
 
+/**
+ * get_fw_loader_from_node - Get FW loader dev from @node.
+ *
+ * @node: ofnode where "firmware-loader" phandle is stored.
+ * @dev: pointer where to store the FW loader dev.
+ *
+ * Search and probe a matching FW loader device, if found.
+ *
+ * Return: Negative value if fail, 0 for successful.
+ */
+int get_fw_loader_from_node(ofnode node, struct udevice **dev);
+
 /**
  * request_firmware_into_buf - Load firmware into a previously allocated buffer.
  * @dev: An instance of a driver.
-- 
2.53.0


  parent reply	other threads:[~2026-04-09 13:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-09 13:32 [PATCH v6 0/6] misc: fs_loader: reorg and split to FS and FW loader + FIP loader Christian Marangi
2026-04-09 13:32 ` [PATCH v6 1/6] misc: fs_loader: fix ubifs not unmounted on dev_get_priv error Christian Marangi
2026-04-09 13:32 ` [PATCH v6 2/6] misc: fs_loader: reorganize and split to FS loader and FW UCLASS Christian Marangi
2026-04-11 14:56   ` Simon Glass
2026-04-09 13:32 ` Christian Marangi [this message]
2026-04-11 14:56   ` [PATCH v6 3/6] misc: fw_loader: implement generic get_fw_loader_from_node() Simon Glass
2026-04-09 13:33 ` [PATCH v6 4/6] misc: fw_loader: implement request_firmware_size() OP Christian Marangi
2026-04-11 14:57   ` Simon Glass
2026-04-09 13:33 ` [PATCH v6 5/6] misc: fw_loader: introduce FIP loader driver Christian Marangi
2026-04-11 14:57   ` Simon Glass
2026-04-09 13:33 ` [PATCH v6 6/6] doc: dtbinding: Update documentation for Generic Firmware loader Christian Marangi
2026-04-11 13:49   ` Heinrich Schuchardt
2026-04-11 14:58   ` Simon Glass
2026-04-11 14:56 ` [v6,0/6] misc: fs_loader: reorg and split to FS and FW loader + FIP loader Simon Glass

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=20260409133303.31875-4-ansuelsmth@gmail.com \
    --to=ansuelsmth@gmail.com \
    --cc=casey.connolly@linaro.org \
    --cc=jamie.gibbons@microchip.com \
    --cc=justin@tidylabs.net \
    --cc=kever.yang@rock-chips.com \
    --cc=lucienzx159@gmail.com \
    --cc=marek.vasut+renesas@mailbox.org \
    --cc=mateuslima.ti@gmail.com \
    --cc=n-francis@ti.com \
    --cc=peng.fan@nxp.com \
    --cc=quentin.schulz@cherry.de \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=weijie.gao@mediatek.com \
    --cc=xypron.glpk@gmx.de \
    --cc=ycliang@andestech.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.