[PATCH v2 4/5] board: samsung: e850-96: Add routine for loading images over USB
Sam Protsenko
semen.protsenko at linaro.org
Mon Oct 27 07:14:51 CET 2025
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 at linaro.org>
---
Changes in v2:
- Return 0 on success in load_image_usb()
board/samsung/e850-96/fw.c | 39 +++++++++++++++++++++++++++++++-------
board/samsung/e850-96/fw.h | 7 +++++++
2 files changed, 39 insertions(+), 7 deletions(-)
diff --git a/board/samsung/e850-96/fw.c b/board/samsung/e850-96/fw.c
index 2d52433e38ad..576167122ec7 100644
--- a/board/samsung/e850-96/fw.c
+++ b/board/samsung/e850-96/fw.c
@@ -11,14 +11,19 @@
#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
diff --git a/board/samsung/e850-96/fw.h b/board/samsung/e850-96/fw.h
index b061abc4df69..68f943e8bbce 100644
--- a/board/samsung/e850-96/fw.h
+++ b/board/samsung/e850-96/fw.h
@@ -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);
--
2.39.5
More information about the U-Boot
mailing list