1 // SPDX-License-Identifier: GPL-2.0+
4 * Texas Instruments, <www.ti.com>
6 * Franklin S Cooper Jr. <fcooper@ti.com>
13 #include <linux/libfdt.h>
15 static int fdt_offset(const void *fit)
17 int images, node, fdt_len, fdt_node, fdt_offset;
20 node = fit_find_config_node(fit);
24 images = fdt_path_offset(fit, FIT_IMAGES_PATH);
26 debug("%s: Cannot find /images node: %d\n", __func__, images);
30 fdt_name = fdt_getprop(fit, node, FIT_FDT_PROP, &fdt_len);
32 debug("%s: Cannot find fdt name property: %d\n",
37 fdt_node = fdt_subnode_offset(fit, images, fdt_name);
39 debug("%s: Cannot find fdt node '%s': %d\n",
40 __func__, fdt_name, fdt_node);
44 fdt_offset = fdt_getprop_u32(fit, fdt_node, "data-offset");
46 if (fdt_offset == FDT_ERROR)
49 fdt_len = fdt_getprop_u32(fit, fdt_node, "data-size");
57 void *locate_dtb_in_fit(const void *fit)
59 struct image_header *header;
63 size = fdt_totalsize(fit);
64 size = (size + 3) & ~3;
66 header = (struct image_header *)fit;
68 if (image_get_magic(header) != FDT_MAGIC) {
69 debug("No FIT image appended to U-boot\n");
73 ret = fdt_offset(fit);
78 return (void *)fit+size+ret;