aboutsummaryrefslogtreecommitdiff
path: root/drivers/misc/fs_loader.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/misc/fs_loader.c')
-rw-r--r--drivers/misc/fs_loader.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/misc/fs_loader.c b/drivers/misc/fs_loader.c
index 5b4d03639c..ccf5c7a803 100644
--- a/drivers/misc/fs_loader.c
+++ b/drivers/misc/fs_loader.c
@@ -15,6 +15,8 @@
#include <fs_loader.h>
#include <log.h>
#include <asm/global_data.h>
+#include <dm/device-internal.h>
+#include <dm/root.h>
#include <linux/string.h>
#include <mapmem.h>
#include <malloc.h>
@@ -297,6 +299,31 @@ U_BOOT_DRIVER(fs_loader) = {
.priv_auto = sizeof(struct firmware),
};
+static struct device_plat default_plat = { 0 };
+
+int get_fs_loader(struct udevice **dev)
+{
+ int ret;
+ ofnode node = ofnode_get_chosen_node("firmware-loader");
+
+ if (ofnode_valid(node))
+ return uclass_get_device_by_ofnode(UCLASS_FS_FIRMWARE_LOADER,
+ node, dev);
+
+ /* Try the first device if none was chosen */
+ ret = uclass_first_device_err(UCLASS_FS_FIRMWARE_LOADER, dev);
+ if (ret != -ENODEV)
+ return ret;
+
+ /* Just create a new device */
+ ret = device_bind(dm_root(), DM_DRIVER_GET(fs_loader), "default-loader",
+ &default_plat, ofnode_null(), dev);
+ if (ret)
+ return ret;
+
+ return device_probe(*dev);
+}
+
UCLASS_DRIVER(fs_loader) = {
.id = UCLASS_FS_FIRMWARE_LOADER,
.name = "fs-loader",