From: Sam Protsenko Date: Tue, 18 Nov 2025 23:21:17 +0000 (-0600) Subject: board: samsung: e850-96: Add routine for loading images over USB X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d9115a045d2d48c28019b3d6673ab30271819f5;p=pandora-u-boot.git board: samsung: e850-96: Add routine for loading images over USB 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 Signed-off-by: Minkyu Kang --- diff --git a/board/samsung/e850-96/fw.c b/board/samsung/e850-96/fw.c index 2d52433e38a..576167122ec 100644 --- a/board/samsung/e850-96/fw.c +++ b/board/samsung/e850-96/fw.c @@ -11,14 +11,19 @@ #include #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 b061abc4df6..68f943e8bbc 100644 --- a/board/samsung/e850-96/fw.h +++ b/board/samsung/e850-96/fw.h @@ -9,6 +9,13 @@ #include +/* 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);