1 // SPDX-License-Identifier: GPL-2.0+
4 * Texas Instruments, <www.ti.com>
6 * Franklin S Cooper Jr. <fcooper@ti.com>
14 #include <linux/libfdt.h>
16 static int fdt_offset(const void *fit)
18 int images, node, fdt_len, fdt_node, fdt_offset;
21 node = fit_find_config_node(fit);
25 images = fdt_path_offset(fit, FIT_IMAGES_PATH);
27 debug("%s: Cannot find /images node: %d\n", __func__, images);
31 fdt_name = fdt_getprop(fit, node, FIT_FDT_PROP, &fdt_len);
33 debug("%s: Cannot find fdt name property: %d\n",
38 fdt_node = fdt_subnode_offset(fit, images, fdt_name);
40 debug("%s: Cannot find fdt node '%s': %d\n",
41 __func__, fdt_name, fdt_node);
45 fdt_offset = fdt_getprop_u32(fit, fdt_node, "data-offset");
47 if (fdt_offset == FDT_ERROR)
50 fdt_len = fdt_getprop_u32(fit, fdt_node, "data-size");
58 void *locate_dtb_in_fit(const void *fit)
60 struct image_header *header;
64 size = fdt_totalsize(fit);
65 size = (size + 3) & ~3;
67 header = (struct image_header *)fit;
69 if (image_get_magic(header) != FDT_MAGIC) {
70 debug("No FIT image appended to U-boot\n");
74 ret = fdt_offset(fit);
79 return (void *)fit+size+ret;