+/**
+ * spl_load_fit_image(): load the image described in a certain FIT node
+ * @info: points to information about the device to load data from
+ * @sector: the start sector of the FIT image on the device
+ * @fit: points to the flattened device tree blob describing the FIT
+ * image
+ * @base_offset: the beginning of the data area containing the actual
+ * image data, relative to the beginning of the FIT
+ * @node: offset of the DT node describing the image to load (relative
+ * to @fit)
+ * @image_info: will be filled with information about the loaded image
+ * If the FIT node does not contain a "load" (address) property,
+ * the image gets loaded to the address pointed to by the
+ * load_addr member in this struct.
+ *
+ * Return: 0 on success or a negative error number.
+ */
+static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
+ void *fit, ulong base_offset, int node,
+ struct spl_image_info *image_info)
+{
+ int offset, sector_offset;
+ size_t length;
+ int len;
+ ulong size;
+ ulong load_addr, load_ptr;
+ void *src;
+ ulong overhead;
+ int nr_sectors;
+ int align_len = ARCH_DMA_MINALIGN - 1;
+ uint8_t image_comp = -1, type = -1;
+ const void *data;
+ bool external_data = false;
+#ifdef CONFIG_SPL_FIT_SIGNATURE
+ int ret;
+#endif
+
+ if (IS_ENABLED(CONFIG_SPL_OS_BOOT) && IS_ENABLED(CONFIG_SPL_GZIP)) {
+ if (fit_image_get_comp(fit, node, &image_comp))
+ puts("Cannot get image compression format.\n");
+ else
+ debug("%s ", genimg_get_comp_name(image_comp));
+
+ if (fit_image_get_type(fit, node, &type))
+ puts("Cannot get image type.\n");
+ else
+ debug("%s ", genimg_get_type_name(type));
+ }
+
+ if (fit_image_get_load(fit, node, &load_addr))
+ load_addr = image_info->load_addr;
+
+ if (!fit_image_get_data_position(fit, node, &offset)) {
+ external_data = true;
+ } else if (!fit_image_get_data_offset(fit, node, &offset)) {
+ offset += base_offset;
+ external_data = true;
+ }
+
+ if (external_data) {
+ /* External data */
+ if (fit_image_get_data_size(fit, node, &len))
+ return -ENOENT;
+
+ load_ptr = (load_addr + align_len) & ~align_len;
+ length = len;
+
+ overhead = get_aligned_image_overhead(info, offset);
+ nr_sectors = get_aligned_image_size(info, length, offset);
+ sector_offset = sector + get_aligned_image_offset(info, offset);
+
+#ifdef CONFIG_SPL_FPGA_SUPPORT
+ if (type == IH_TYPE_FPGA) {
+ return spl_load_fpga_image(info, length, nr_sectors,
+ sector_offset);