board: samsung: e850-96: Add routine for loading images over USB
authorSam Protsenko <semen.protsenko@linaro.org>
Tue, 18 Nov 2025 23:21:17 +0000 (17:21 -0600)
committerMinkyu Kang <mk7.kang@samsung.com>
Wed, 26 Nov 2025 08:55:57 +0000 (17:55 +0900)
During USB boot U-Boot is supposed to download some firmware over USB.
It's done by EL3 software, so it has to be requested via corresponding
SMC call. Implement a routine for doing that.

No functional change.

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

index 2d52433..5761671 100644 (file)
 #include <linux/arm-smccc.h>
 #include "fw.h"
 
-#define LDFW_RAW_PART          "ldfw"
-#define LDFW_FAT_PATH          "/EFI/firmware/ldfw.bin"
+#define LDFW_RAW_PART                  "ldfw"
+#define LDFW_FAT_PATH                  "/EFI/firmware/ldfw.bin"
+#define LDFW_MAGIC                     0x10adab1e
 
-#define LDFW_MAGIC             0x10adab1e
-#define SMC_CMD_LOAD_LDFW      -0x500
-#define SDM_HW_RESET_STATUS    0x1230
-#define SDM_SW_RESET_STATUS    0x1231
-#define SB_ERROR_PREFIX                0xfdaa0000
+/* SMC command for providing LDFW to EL3 monitor */
+#define SMC_CMD_LOAD_LDFW              -0x500
+/* SMC command for loading some binary over USB */
+#define SMC_CMD_LOAD_IMAGE_BY_USB      -0x512
+
+/* Error codes for SMC_CMD_LOAD_LDFW */
+#define SDM_HW_RESET_STATUS            0x1230
+#define SDM_SW_RESET_STATUS            0x1231
+#define SB_ERROR_PREFIX                        0xfdaa0000
 
 struct ldfw_header {
        u32 magic;
@@ -93,6 +98,26 @@ static int read_fw_from_raw(const char *ifname, int dev, const char *part_name,
        return 0;
 }
 
+/**
+ * load_image_usb - Load some binary over USB during USB boot
+ * @type: Image type
+ * @addr: Memory address where the image should be downloaded to
+ * @size: Image size
+ *
+ * Return: 0 on success or a negative value on error.
+ */
+int load_image_usb(enum usb_dn_image type, phys_addr_t addr, phys_size_t size)
+{
+       struct arm_smccc_res res;
+
+       arm_smccc_smc(SMC_CMD_LOAD_IMAGE_BY_USB, (u64)type, addr, size,
+                     0, 0, 0, 0, &res);
+       if (res.a0)
+               return -EIO;
+
+       return 0;
+}
+
 /**
  * load_ldfw_from_blk - Load the loadable firmware (LDFW) from block device
  * @ifname: Interface name of the block device to load the firmware from
index b061abc..68f943e 100644 (file)
@@ -9,6 +9,13 @@
 
 #include <asm/types.h>
 
+/* Image types for downloading over USB */
+enum usb_dn_image {
+       USB_DN_IMAGE_LDFW       = 1,    /* Loadable Firmware */
+       USB_DN_IMAGE_SP         = 2,    /* Secure Payload (tzsw.img) */
+};
+
+int load_image_usb(enum usb_dn_image type, phys_addr_t addr, phys_size_t size);
 int load_ldfw_from_blk(const char *ifname, int dev, int part, phys_addr_t addr);
 int init_ldfw(phys_addr_t addr);