From: Sam Protsenko Date: Tue, 18 Nov 2025 23:21:16 +0000 (-0600) Subject: board: samsung: e850-96: Split LDFW loading and init X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d1ae437a66795c34604a61104b2ff92ab493b9c;p=pandora-u-boot.git board: samsung: e850-96: Split LDFW loading and init The LDFW firmware loading is done in two steps: 1. Read the firmware binary from some block device 2. Provide it to EL3 monitor software via an SMC call, so it can copy it to a Secure World memory and start using it Let's split the load_ldfw() function by two functions correspondingly, to reflect that process better: - load_ldfw_from_blk() - init_ldfw() It can be useful in case when the LDFW binary should be obtained from some different media, e.g. downloaded over USB during USB boot. No functional change. Signed-off-by: Sam Protsenko Signed-off-by: Minkyu Kang --- diff --git a/board/samsung/e850-96/e850-96.c b/board/samsung/e850-96/e850-96.c index 34e01914032..3cf98a01b70 100644 --- a/board/samsung/e850-96/e850-96.c +++ b/board/samsung/e850-96/e850-96.c @@ -151,9 +151,14 @@ void load_firmware(void) } printf("Loading LDFW firmware (from %s %ld)...\n", ifname, dev); - err = load_ldfw(ifname, dev, part, LDFW_NWD_ADDR); - if (err) + err = load_ldfw_from_blk(ifname, dev, part, LDFW_NWD_ADDR); + if (err) { printf("ERROR: LDFW loading failed (%d)\n", err); + return; + } + err = init_ldfw(LDFW_NWD_ADDR); + if (err) + printf("ERROR: LDFW init failed (%d)\n", err); } int dram_init(void) diff --git a/board/samsung/e850-96/fw.c b/board/samsung/e850-96/fw.c index 64235c01a25..2d52433e38a 100644 --- a/board/samsung/e850-96/fw.c +++ b/board/samsung/e850-96/fw.c @@ -94,7 +94,7 @@ static int read_fw_from_raw(const char *ifname, int dev, const char *part_name, } /** - * load_ldfw - Load the loadable firmware (LDFW) + * load_ldfw_from_blk - Load the loadable firmware (LDFW) from block device * @ifname: Interface name of the block device to load the firmware from * @dev: Device number * @part: Partition number @@ -102,24 +102,37 @@ static int read_fw_from_raw(const char *ifname, int dev, const char *part_name, * * Return: 0 on success or a negative value on error. */ -int load_ldfw(const char *ifname, int dev, int part, phys_addr_t addr) +int load_ldfw_from_blk(const char *ifname, int dev, int part, phys_addr_t addr) { - struct ldfw_header *hdr; - struct arm_smccc_res res; void *buf = (void *)addr; - u64 size = 0; - int err, i; + int err; /* First try to read LDFW from EFI partition, then from the raw one */ err = read_fw_from_fat(ifname, dev, part, LDFW_FAT_PATH, buf); - if (err) { - err = read_fw_from_raw(ifname, dev, LDFW_RAW_PART, buf); - if (err) - return err; - } + if (err) + return read_fw_from_raw(ifname, dev, LDFW_RAW_PART, buf); + + return 0; +} + +/** + * init_ldfw - Provide the LDFW (loaded to RAM) to EL3 monitor to make use of it + * @addr: Memory address where LDFW resides + * + * EL3 monitor will copy the LDFW from the provided Normal World memory @addr to + * Secure World location, and start using it. + * + * Return: 0 on success or a negative value on error. + */ +int init_ldfw(phys_addr_t addr) +{ + struct ldfw_header *hdr; + struct arm_smccc_res res; + u64 size = 0; + int err, i; /* Validate LDFW by magic number in its header */ - hdr = buf; + hdr = (struct ldfw_header *)addr; if (hdr->magic != LDFW_MAGIC) { debug("%s: Wrong LDFW magic; is LDFW flashed?\n", __func__); return -EINVAL; diff --git a/board/samsung/e850-96/fw.h b/board/samsung/e850-96/fw.h index 73d9615d4a9..b061abc4df6 100644 --- a/board/samsung/e850-96/fw.h +++ b/board/samsung/e850-96/fw.h @@ -9,6 +9,7 @@ #include -int load_ldfw(const char *ifname, int dev, int part, phys_addr_t addr); +int load_ldfw_from_blk(const char *ifname, int dev, int part, phys_addr_t addr); +int init_ldfw(phys_addr_t addr); #endif /* __E850_96_FW_H */