fdtdec: sort include files
[oweals/u-boot.git] / lib / fdtdec.c
index 760732014dbe4959ad2ca2bce9b01e5bcdb6acce..f26d2eb91bb3ca1c2a419d38dd2733ba0e869b7e 100644 (file)
@@ -5,14 +5,15 @@
 
 #ifndef USE_HOSTCC
 #include <common.h>
+#include <boot_fit.h>
 #include <dm.h>
+#include <dm/of_extra.h>
 #include <errno.h>
-#include <serial.h>
-#include <libfdt.h>
-#include <fdt_support.h>
 #include <fdtdec.h>
+#include <fdt_support.h>
+#include <libfdt.h>
+#include <serial.h>
 #include <asm/sections.h>
-#include <dm/of_extra.h>
 #include <linux/ctype.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -33,12 +34,6 @@ static const char * const compat_names[COMPAT_COUNT] = {
        COMPAT(NVIDIA_TEGRA20_EMC, "nvidia,tegra20-emc"),
        COMPAT(NVIDIA_TEGRA20_EMC_TABLE, "nvidia,tegra20-emc-table"),
        COMPAT(NVIDIA_TEGRA20_NAND, "nvidia,tegra20-nand"),
-       COMPAT(NVIDIA_TEGRA124_PMC, "nvidia,tegra124-pmc"),
-       COMPAT(NVIDIA_TEGRA186_SDMMC, "nvidia,tegra186-sdhci"),
-       COMPAT(NVIDIA_TEGRA210_SDMMC, "nvidia,tegra210-sdhci"),
-       COMPAT(NVIDIA_TEGRA124_SDMMC, "nvidia,tegra124-sdhci"),
-       COMPAT(NVIDIA_TEGRA30_SDMMC, "nvidia,tegra30-sdhci"),
-       COMPAT(NVIDIA_TEGRA20_SDMMC, "nvidia,tegra20-sdhci"),
        COMPAT(NVIDIA_TEGRA124_XUSB_PADCTL, "nvidia,tegra124-xusb-padctl"),
        COMPAT(NVIDIA_TEGRA210_XUSB_PADCTL, "nvidia,tegra210-xusb-padctl"),
        COMPAT(SMSC_LAN9215, "smsc,lan9215"),
@@ -941,38 +936,6 @@ int fdtdec_decode_region(const void *blob, int node, const char *prop_name,
        return 0;
 }
 
-/**
- * Read a flash entry from the fdt
- *
- * @param blob         FDT blob
- * @param node         Offset of node to read
- * @param name         Name of node being read
- * @param entry                Place to put offset and size of this node
- * @return 0 if ok, -ve on error
- */
-int fdtdec_read_fmap_entry(const void *blob, int node, const char *name,
-                          struct fmap_entry *entry)
-{
-       const char *prop;
-       u32 reg[2];
-
-       if (fdtdec_get_int_array(blob, node, "reg", reg, 2)) {
-               debug("Node '%s' has bad/missing 'reg' property\n", name);
-               return -FDT_ERR_NOTFOUND;
-       }
-       entry->offset = reg[0];
-       entry->length = reg[1];
-       entry->used = fdtdec_get_int(blob, node, "used", entry->length);
-       prop = fdt_getprop(blob, node, "compress", NULL);
-       entry->compress_algo = prop && !strcmp(prop, "lzo") ?
-               FMAP_COMPRESS_LZO : FMAP_COMPRESS_NONE;
-       prop = fdt_getprop(blob, node, "hash", &entry->hash_size);
-       entry->hash_algo = prop ? FMAP_HASH_SHA256 : FMAP_HASH_NONE;
-       entry->hash = (uint8_t *)prop;
-
-       return 0;
-}
-
 u64 fdtdec_get_number(const fdt32_t *ptr, unsigned int cells)
 {
        u64 number = 0;
@@ -1201,7 +1164,8 @@ int fdtdec_setup_memory_size(void)
        }
 
        gd->ram_size = (phys_size_t)(res.end - res.start + 1);
-       debug("%s: Initial DRAM size %llx\n", __func__, (u64)gd->ram_size);
+       debug("%s: Initial DRAM size %llx\n", __func__,
+             (unsigned long long)gd->ram_size);
 
        return 0;
 }
@@ -1252,6 +1216,15 @@ int fdtdec_setup(void)
                gd->fdt_blob = (ulong *)&_image_binary_end;
        else
                gd->fdt_blob = (ulong *)&__bss_end;
+
+#  elif defined CONFIG_MULTI_DTB_FIT
+       gd->fdt_blob = locate_dtb_in_fit(&_end);
+
+       if (gd->fdt_blob == NULL || gd->fdt_blob <= ((void *)&_end)) {
+               puts("Failed to find proper dtb in embedded FIT Image\n");
+               return -1;
+       }
+
 #  else
        /* FDT is at end of image */
        gd->fdt_blob = (ulong *)&_end;
@@ -1267,7 +1240,7 @@ int fdtdec_setup(void)
 # endif
 # ifndef CONFIG_SPL_BUILD
        /* Allow the early environment to override the fdt address */
-       gd->fdt_blob = (void *)getenv_ulong("fdtcontroladdr", 16,
+       gd->fdt_blob = (void *)env_get_ulong("fdtcontroladdr", 16,
                                                (uintptr_t)gd->fdt_blob);
 # endif
 #endif