From: "André Draszik" <git@andred.net>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] imx: spl: inject 'u-boot, spl-boot-device' for next-stage
Date: Wed, 16 Oct 2019 16:48:55 +0100 [thread overview]
Message-ID: <20191016154855.40276-1-git@andred.net> (raw)
This implements the 'spl_perform_fixups' hook for i.MX-based
boards and injects the /chosen/u-boot,spl-boot-device with a string
representation corresponding to the boot device used.
The intended usage is for the full U-Boot stage to evaluate this in
scripts and then adapt its boot-order as needed.
This change is heavily based on commit e5f2ecc75001
("rockchip: rk3399: inject 'u-boot, spl-boot-device' for next-stage")
A string representation of the boot device was chosen
here (as opposed to an ofpath in the rockchip commit),
so as to make this less hardware dependent.
Signed-off-by: André Draszik <git@andred.net>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: "NXP i.MX U-Boot Team" <uboot-imx@nxp.com>
Cc: Albert Aribaud <albert.u.boot@aribaud.net>
---
arch/arm/mach-imx/spl.c | 49 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c
index f025c4b301..42ca719cd8 100644
--- a/arch/arm/mach-imx/spl.c
+++ b/arch/arm/mach-imx/spl.c
@@ -176,6 +176,55 @@ u32 spl_boot_device(void)
}
#endif /* CONFIG_MX7 || CONFIG_IMX8M || CONFIG_IMX8 */
+static const char *imx_decode_boot_device(u32 boot_device)
+{
+ int i;
+ static const struct {
+ u32 boot_device;
+ const char *ofpath;
+ } spl_boot_devices_tbl[] = {
+ { BOOT_DEVICE_MMC1, "mmc1" },
+ { BOOT_DEVICE_MMC2, "mmc2" },
+ { BOOT_DEVICE_SPI, "spi" },
+ { BOOT_DEVICE_NAND, "nand" },
+ };
+
+ for (i = 0; i < ARRAY_SIZE(spl_boot_devices_tbl); ++i)
+ if (spl_boot_devices_tbl[i].boot_device == boot_device)
+ return spl_boot_devices_tbl[i].ofpath;
+
+ return NULL;
+}
+
+void spl_perform_fixups(struct spl_image_info *spl_image)
+{
+ void *blob = spl_image->fdt_addr;
+ const char *boot_ofpath;
+ int chosen;
+
+ /*
+ * Inject the ofpath of the device the full U-Boot (or Linux in
+ * Falcon-mode) was booted from into the FDT, if a FDT has been
+ * loaded at the same time.
+ */
+ if (!blob)
+ return;
+ boot_ofpath = imx_decode_boot_device(spl_image->boot_device);
+ if (!boot_ofpath) {
+ pr_err("%s: could not map boot_device to ofpath\n", __func__);
+ return;
+ }
+
+ chosen = fdt_find_or_add_subnode(blob, 0, "chosen");
+ if (chosen < 0) {
+ pr_err("%s: could not find/create '/chosen'\n", __func__);
+ return;
+ }
+ fdt_setprop_string(blob, chosen,
+ "u-boot,spl-boot-device", boot_ofpath);
+}
+
+
#ifdef CONFIG_SPL_USB_GADGET
int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
{
--
2.23.0.rc1
reply other threads:[~2019-10-16 15:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20191016154855.40276-1-git@andred.net \
--to=git@andred.net \
--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