board: samsung: e850-96: Add bootdev var to choose boot device
authorSam Protsenko <semen.protsenko@linaro.org>
Wed, 6 Aug 2025 22:27:07 +0000 (17:27 -0500)
committerMinkyu Kang <mk7.kang@samsung.com>
Mon, 1 Sep 2025 07:37:13 +0000 (16:37 +0900)
Provide a way for the user to select which storage to load the LDFW
firmware from, by setting the corresponding environment variables:
  - bootdev: block device interface name
  - bootdevnum: block device number
  - bootdevpart: partition number

This might be useful when the OS is flashed and booted from a different
storage device than eMMC (e.g. USB flash drive). In this case it should
be sufficient to just set:

    => setenv bootdev usb
    => env save

assuming that the USB drive layout follows the same partitioning scheme
as defined in $partitions.

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
board/samsung/e850-96/e850-96.c

index b5f6ba2..3df241e 100644 (file)
@@ -9,6 +9,7 @@
 #include <init.h>
 #include <mapmem.h>
 #include <net.h>
+#include <usb.h>
 #include <asm/io.h>
 #include "fw.h"
 #include "pmic.h"
@@ -136,21 +137,40 @@ static void setup_ethaddr(void)
                eth_env_set_enetaddr("ethaddr", mac_addr);
 }
 
-int board_late_init(void)
+/*
+ * Call this in board_late_init() to avoid probing block devices before
+ * efi_init_early().
+ */
+void load_firmware(void)
 {
+       const char *ifname;
+       ulong dev, part;
        int err;
 
-       setup_serial();
-       setup_ethaddr();
-
-       /*
-        * Do this in board_late_init() to make sure MMC is not probed before
-        * efi_init_early().
-        */
-       err = load_ldfw(EMMC_IFNAME, EMMC_DEV_NUM, EMMC_ESP_PART,
-                       LDFW_NWD_ADDR);
+       ifname = env_get("bootdev");
+       if (!ifname)
+               ifname = EMMC_IFNAME;
+       dev = env_get_ulong("bootdevnum", 10, EMMC_DEV_NUM);
+       part = env_get_ulong("bootdevpart", 10, EMMC_ESP_PART);
+
+       if (!strcmp(ifname, "usb")) {
+               printf("Starting USB (bootdev=usb)...\n");
+               err = usb_init();
+               if (err)
+                       return;
+       }
+
+       printf("Loading LDFW firmware (from %s %ld)...\n", ifname, dev);
+       err = load_ldfw(ifname, dev, part, LDFW_NWD_ADDR);
        if (err)
                printf("ERROR: LDFW loading failed (%d)\n", err);
+}
+
+int board_late_init(void)
+{
+       setup_serial();
+       setup_ethaddr();
+       load_firmware();
 
        return 0;
 }