diff options
author | Michael Tretter <m.tretter@pengutronix.de> | 2019-09-13 15:14:44 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2019-09-16 09:06:18 +0200 |
commit | 7fdca8aa1fef0d9739ba89cd632ef76da6f86760 (patch) | |
tree | 8fead901cf8c8f7b3a441074b0b0be4fb109f0ba /common | |
parent | f41d37ce080c24e296b10b3997a43dfa88591593 (diff) | |
download | barebox-7fdca8aa1fef0d9739ba89cd632ef76da6f86760.tar.gz barebox-7fdca8aa1fef0d9739ba89cd632ef76da6f86760.tar.xz |
blspec: load firmware if specified in dt overlay
If a device tree overlay referenced by the blspec depends on firmware,
try to load the firmware from the default Linux firmware search path
/lib/firmware in the about to be started rootfs.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r-- | common/blspec.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/common/blspec.c b/common/blspec.c index fbba2fc78c..7c27e0b869 100644 --- a/common/blspec.c +++ b/common/blspec.c @@ -14,6 +14,7 @@ #include <environment.h> #include <globalvar.h> +#include <firmware.h> #include <readkey.h> #include <common.h> #include <driver.h> @@ -49,6 +50,7 @@ static int blspec_apply_oftree_overlay(char *file, const char *abspath, struct fdt_header *fdt; struct device_node *overlay; char *path; + char *firmware_path; path = basprintf("%s/%s", abspath, file); @@ -72,6 +74,21 @@ static int blspec_apply_oftree_overlay(char *file, const char *abspath, goto out; } + /* + * Unfortunately the device tree overlay contains only the filename of + * the firmware and relies on the firmware search paths to find the + * actual file. Use /lib/firmware in the Linux root directory and hope + * for the best. + */ + firmware_path = basprintf("%s/%s", abspath, "/lib/firmware"); + ret = of_firmware_load_overlay(overlay, firmware_path); + free(firmware_path); + if (ret) { + pr_warn("failed to load firmware: skip overlay \"%s\"\n", path); + of_delete_node(overlay); + goto out; + } + ret = of_register_overlay(overlay); if (ret) { pr_warn("cannot register devicetree overlay \"%s\"\n", path); |