#ifndef USE_HOSTCC
#include <common.h>
#include <boot_fit.h>
+#include <display_options.h>
#include <dm.h>
#include <hang.h>
#include <init.h>
COMPAT(ALTERA_SOCFPGA_CLK_INIT, "altr,socfpga-a10-clk-init")
};
+static const char *const fdt_src_name[] = {
+ [FDTSRC_SEPARATE] = "separate",
+ [FDTSRC_FIT] = "fit",
+ [FDTSRC_BOARD] = "board",
+ [FDTSRC_EMBED] = "embed",
+ [FDTSRC_ENV] = "env",
+};
+
+const char *fdtdec_get_srcname(void)
+{
+ return fdt_src_name[gd->fdt_src];
+}
+
const char *fdtdec_get_compatible(enum fdt_compat_id id)
{
/* We allow reading of the 'unknown' ID for testing purposes */
barnum = (barnum - PCI_BASE_ADDRESS_0) / 4;
- /*
- * There is a strange toolchain bug with nds32 which complains about
- * an undefined reference here, even if fdtdec_get_pci_bar32() is never
- * called. An #ifdef seems to be the only fix!
- */
-#if !IS_ENABLED(CONFIG_NDS32)
*bar = dm_pci_read_bar32(dev, barnum);
-#endif
return 0;
}
* Adding an extra check to distinguish DT nodes with
* same name
*/
- if (IS_ENABLED(CONFIG_PHANDLE_CHECK_SEQ)) {
- if (fdt_get_phandle(blob, offset) !=
- fdt_get_phandle(blob, fdt_path_offset(blob, prop)))
- continue;
- }
+ if (offset != fdt_path_offset(blob, prop))
+ continue;
val = trailing_strtol(name);
if (val != -1) {
* @param min_len minimum property length in bytes
* @param err 0 if ok, or -FDT_ERR_NOTFOUND if the property is not
found, or -FDT_ERR_BADLAYOUT if not enough data
- * @return pointer to cell, which is only valid if err == 0
+ * Return: pointer to cell, which is only valid if err == 0
*/
static const void *get_prop_check_min_len(const void *blob, int node,
const char *prop_name, int min_len,
return 0;
}
-/*
- * For CONFIG_OF_SEPARATE, the board may optionally implement this to
- * provide and/or fixup the fdt.
+/**
+ * fdt_find_separate() - Find a devicetree at the end of the image
+ *
+ * Return: pointer to FDT blob
*/
-__weak void *board_fdt_blob_setup(int *err)
+static void *fdt_find_separate(void)
{
void *fdt_blob = NULL;
- *err = 0;
+ if (IS_ENABLED(CONFIG_SANDBOX))
+ return NULL;
+
#ifdef CONFIG_SPL_BUILD
/* FDT is at end of BSS unless it is in a different memory region */
if (IS_ENABLED(CONFIG_SPL_SEPARATE_BSS))
return 0;
}
+/* TODO(sjg@chromium.org): This function should not be weak */
__weak int fdtdec_board_setup(const void *fdt_blob)
{
return 0;
if (blob) {
gd_set_multi_dtb_fit(gd->fdt_blob);
gd->fdt_blob = blob;
+ gd->fdt_src = FDTSRC_FIT;
}
}
int fdtdec_setup(void)
{
int ret;
-#if CONFIG_IS_ENABLED(OF_CONTROL)
-# ifdef CONFIG_OF_EMBED
- /* Get a pointer to the FDT */
- gd->fdt_blob = dtb_dt_embedded();
-# elif defined(CONFIG_OF_BOARD) || defined(CONFIG_OF_SEPARATE)
+
+ /* The devicetree is typically appended to U-Boot */
+ if (IS_ENABLED(CONFIG_OF_SEPARATE)) {
+ gd->fdt_blob = fdt_find_separate();
+ gd->fdt_src = FDTSRC_SEPARATE;
+ } else { /* embed dtb in ELF file for testing / development */
+ gd->fdt_blob = dtb_dt_embedded();
+ gd->fdt_src = FDTSRC_EMBED;
+ }
+
/* Allow the board to override the fdt address. */
- gd->fdt_blob = board_fdt_blob_setup(&ret);
- if (ret)
- return ret;
-# endif
+ if (IS_ENABLED(CONFIG_OF_BOARD)) {
+ gd->fdt_blob = board_fdt_blob_setup(&ret);
+ if (ret)
+ return ret;
+ gd->fdt_src = FDTSRC_BOARD;
+ }
+
+ /* Allow the early environment to override the fdt address */
if (!IS_ENABLED(CONFIG_SPL_BUILD)) {
- /* Allow the early environment to override the fdt address */
- gd->fdt_blob = map_sysmem(env_get_ulong("fdtcontroladdr", 16,
- (unsigned long)map_to_sysmem(gd->fdt_blob)), 0);
+ ulong addr;
+
+ addr = env_get_hex("fdtcontroladdr", 0);
+ if (addr) {
+ gd->fdt_blob = map_sysmem(addr, 0);
+ gd->fdt_src = FDTSRC_ENV;
+ }
}
if (CONFIG_IS_ENABLED(MULTI_DTB_FIT))
setup_multi_dtb_fit();
-#endif
ret = fdtdec_prepare_fdt();
if (!ret)