]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - lib/fdtdec.c
Merge branch 'master' of git://git.denx.de/u-boot-arm
[karo-tx-uboot.git] / lib / fdtdec.c
index dc358562d19fa25ee4c6c47c716a7584f41ad6cf..8ecb80f1623bfb95ca02ee8c4be133818be0b87d 100644 (file)
@@ -3,6 +3,7 @@
  * SPDX-License-Identifier:    GPL-2.0+
  */
 
+#ifndef USE_HOSTCC
 #include <common.h>
 #include <serial.h>
 #include <libfdt.h>
@@ -32,6 +33,7 @@ static const char * const compat_names[COMPAT_COUNT] = {
        COMPAT(NVIDIA_TEGRA20_NAND, "nvidia,tegra20-nand"),
        COMPAT(NVIDIA_TEGRA20_PWM, "nvidia,tegra20-pwm"),
        COMPAT(NVIDIA_TEGRA20_DC, "nvidia,tegra20-dc"),
+       COMPAT(NVIDIA_TEGRA124_SDMMC, "nvidia,tegra124-sdhci"),
        COMPAT(NVIDIA_TEGRA30_SDMMC, "nvidia,tegra30-sdhci"),
        COMPAT(NVIDIA_TEGRA20_SDMMC, "nvidia,tegra20-sdhci"),
        COMPAT(NVIDIA_TEGRA20_SFLASH, "nvidia,tegra20-sflash"),
@@ -46,11 +48,15 @@ static const char * const compat_names[COMPAT_COUNT] = {
        COMPAT(GOOGLE_CROS_EC, "google,cros-ec"),
        COMPAT(GOOGLE_CROS_EC_KEYB, "google,cros-ec-keyb"),
        COMPAT(SAMSUNG_EXYNOS_EHCI, "samsung,exynos-ehci"),
+       COMPAT(SAMSUNG_EXYNOS5_XHCI, "samsung,exynos5250-xhci"),
        COMPAT(SAMSUNG_EXYNOS_USB_PHY, "samsung,exynos-usb-phy"),
+       COMPAT(SAMSUNG_EXYNOS5_USB3_PHY, "samsung,exynos5250-usb3-phy"),
        COMPAT(SAMSUNG_EXYNOS_TMU, "samsung,exynos-tmu"),
        COMPAT(SAMSUNG_EXYNOS_FIMD, "samsung,exynos-fimd"),
+       COMPAT(SAMSUNG_EXYNOS_MIPI_DSI, "samsung,exynos-mipi-dsi"),
        COMPAT(SAMSUNG_EXYNOS5_DP, "samsung,exynos5-dp"),
        COMPAT(SAMSUNG_EXYNOS5_DWMMC, "samsung,exynos5250-dwmmc"),
+       COMPAT(SAMSUNG_EXYNOS_MMC, "samsung,exynos-mmc"),
        COMPAT(SAMSUNG_EXYNOS_SERIAL, "samsung,exynos4210-uart"),
        COMPAT(MAXIM_MAX77686_PMIC, "maxim,max77686_pmic"),
        COMPAT(GENERIC_SPI_FLASH, "spi-flash"),
@@ -58,6 +64,8 @@ static const char * const compat_names[COMPAT_COUNT] = {
        COMPAT(INFINEON_SLB9635_TPM, "infineon,slb9635-tpm"),
        COMPAT(INFINEON_SLB9645_TPM, "infineon,slb9645-tpm"),
        COMPAT(SAMSUNG_EXYNOS5_I2C, "samsung,exynos5-hsi2c"),
+       COMPAT(SANDBOX_HOST_EMULATION, "sandbox,host-emulation"),
+       COMPAT(SANDBOX_LCD_SDL, "sandbox,lcd-sdl"),
 };
 
 const char *fdtdec_get_compatible(enum fdt_compat_id id)
@@ -84,10 +92,10 @@ fdt_addr_t fdtdec_get_addr_size(const void *blob, int node,
                        size = (fdt_size_t *)((char *)cell +
                                        sizeof(fdt_addr_t));
                        *sizep = fdt_size_to_cpu(*size);
-                       debug("addr=%p, size=%p\n", (void *)addr,
-                             (void *)*sizep);
+                       debug("addr=%08lx, size=%08x\n",
+                             (ulong)addr, *sizep);
                } else {
-                       debug("%p\n", (void *)addr);
+                       debug("%08lx\n", (ulong)addr);
                }
                return addr;
        }
@@ -609,8 +617,51 @@ int fdtdec_decode_region(const void *blob, int node,
        if (!cell || (len != sizeof(fdt_addr_t) * 2))
                return -1;
 
-       *ptrp = (void *)fdt_addr_to_cpu(*cell);
+       *ptrp = map_sysmem(fdt_addr_to_cpu(*cell), *size);
        *size = fdt_size_to_cpu(cell[1]);
        debug("%s: size=%zx\n", __func__, *size);
        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)
+{
+       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];
+
+       return 0;
+}
+#else
+#include "libfdt.h"
+#include "fdt_support.h"
+
+int fdtdec_get_int(const void *blob, int node, const char *prop_name,
+               int default_val)
+{
+       const int *cell;
+       int len;
+
+       cell = fdt_getprop_w((void *)blob, node, prop_name, &len);
+       if (cell && len >= sizeof(int)) {
+               int val = fdt32_to_cpu(cell[0]);
+
+               return val;
+       }
+       return default_val;
+}
+#endif