From: Christian Marangi <ansuelsmth@gmail.com>
To: Tom Rini <trini@konsulko.com>, Simon Glass <sjg@chromium.org>,
Christian Marangi <ansuelsmth@gmail.com>,
Quentin Schulz <quentin.schulz@cherry.de>,
Peng Fan <peng.fan@nxp.com>,
Casey Connolly <casey.connolly@linaro.org>,
Jonas Karlman <jonas@kwiboo.se>,
Jamie Gibbons <jamie.gibbons@microchip.com>,
Neha Malcom Francis <n-francis@ti.com>,
Justin Klaassen <justin@tidylabs.net>,
Harsha Vardhan V M <h-vm@ti.com>,
Leo Yu-Chi Liang <ycliang@andestech.com>,
Weijie Gao <weijie.gao@mediatek.com>,
Marek Vasut <marek.vasut+renesas@mailbox.org>,
Alif Zakuan Yuslaimi <alif.zakuan.yuslaimi@altera.com>,
"Lucien.Jheng" <lucienzx159@gmail.com>,
u-boot@lists.denx.de
Subject: [PATCH v3 3/5] misc: fw_loader: implement generic get_fw_loader_from_node()
Date: Tue, 17 Mar 2026 16:36:07 +0100 [thread overview]
Message-ID: <20260317153614.18409-4-ansuelsmth@gmail.com> (raw)
In-Reply-To: <20260317153614.18409-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 loop over all the
available FW loader until one is found (as it will be probed by the
dedicated compatible)
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Reviewed-by: Neha Malcom Francis <n-francis@ti.com>
---
drivers/misc/fw_loader/fw_loader.c | 40 ++++++++++++++++++++++++++++++
include/fw_loader.h | 15 +++++++++++
2 files changed, 55 insertions(+)
diff --git a/drivers/misc/fw_loader/fw_loader.c b/drivers/misc/fw_loader/fw_loader.c
index 644b98de9f6c..2738d42d4721 100644
--- a/drivers/misc/fw_loader/fw_loader.c
+++ b/drivers/misc/fw_loader/fw_loader.c
@@ -8,6 +8,7 @@
#include <blk.h>
#include <linux/types.h>
#include <dm/device.h>
+#include <dm/uclass.h>
#include <fw_loader.h>
#ifdef CONFIG_CMD_UBIFS
@@ -90,6 +91,45 @@ int generic_fw_loader_probe(struct udevice *dev)
return 0;
}
+static int fw_loaders[] = {
+#if CONFIG_IS_ENABLED(FS_LOADER)
+ UCLASS_FS_FIRMWARE_LOADER,
+#endif
+};
+
+/**
+ * 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.
+ *
+ * Loop over all the supported FW loader and find a matching
+ * one.
+ *
+ * Return: Negative value if fail, 0 for successful.
+ */
+int get_fw_loader_from_node(ofnode node, struct udevice **dev)
+{
+ int i, ret;
+
+ node = ofnode_parse_phandle(node, "firmware-loader", 0);
+ if (!ofnode_valid(node))
+ return -ENODEV;
+
+ /*
+ * Loop over all the available FW loaders and stop when
+ * found one.
+ */
+ for (i = 0; i < ARRAY_SIZE(fw_loaders); i++) {
+ ret = uclass_get_device_by_ofnode(fw_loaders[i],
+ node, dev);
+ if (!ret)
+ return 0;
+ }
+
+ return -ENODEV;
+}
+
/**
* _request_firmware_prepare - Prepare firmware struct.
*
diff --git a/include/fw_loader.h b/include/fw_loader.h
index 56f5e3be6195..7053c7bc6f05 100644
--- a/include/fw_loader.h
+++ b/include/fw_loader.h
@@ -6,8 +6,23 @@
#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.
+ *
+ * Loop over all the supported FW loader and find a matching
+ * one.
+ *
+ * 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
next prev parent reply other threads:[~2026-03-17 15:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-17 15:36 [PATCH v3 0/5] misc: fs_loader: reorg and split to FS and FW loader + FIP loader Christian Marangi
2026-03-17 15:36 ` [PATCH v3 1/5] misc: fs_loader: fix ubifs not unmounted on dev_get_priv error Christian Marangi
2026-03-17 15:36 ` [PATCH v3 2/5] misc: fs_loader: reorganize and split to FS and FW loader Christian Marangi
2026-03-17 15:36 ` Christian Marangi [this message]
2026-03-17 15:36 ` [PATCH v3 4/5] misc: fw_loader: introduce FIP loader driver Christian Marangi
2026-03-17 15:36 ` [PATCH v3 5/5] misc: fw_loader: implement request_firmware_size() OP Christian Marangi
2026-03-30 23:07 ` [PATCH v3 0/5] misc: fs_loader: reorg and split to FS and FW loader + FIP loader Tom Rini
2026-03-31 7:54 ` Christian Marangi
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=20260317153614.18409-4-ansuelsmth@gmail.com \
--to=ansuelsmth@gmail.com \
--cc=alif.zakuan.yuslaimi@altera.com \
--cc=casey.connolly@linaro.org \
--cc=h-vm@ti.com \
--cc=jamie.gibbons@microchip.com \
--cc=jonas@kwiboo.se \
--cc=justin@tidylabs.net \
--cc=lucienzx159@gmail.com \
--cc=marek.vasut+renesas@mailbox.org \
--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=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox