]> git.sur5r.net Git - u-boot/blobdiff - common/fdt_support.c
Merge git://git.denx.de/u-boot-mmc
[u-boot] / common / fdt_support.c
index dfdc04dfbae3bac471651c0233010d404de8f7a7..f4f9543d5475d804e9059a51ccb199604605fc7b 100644 (file)
@@ -197,7 +197,7 @@ int fdt_root(void *fdt)
                return err;
        }
 
-       serial = getenv("serial#");
+       serial = env_get("serial#");
        if (serial) {
                err = fdt_setprop(fdt, 0, "serial-number", serial,
                                  strlen(serial) + 1);
@@ -289,7 +289,7 @@ int fdt_chosen(void *fdt)
        if (nodeoffset < 0)
                return nodeoffset;
 
-       str = getenv("bootargs");
+       str = env_get("bootargs");
        if (str) {
                err = fdt_setprop(fdt, nodeoffset, "bootargs", str,
                                  strlen(str) + 1);
@@ -509,7 +509,7 @@ void fdt_fixup_ethernet(void *fdt)
                        } else {
                                continue;
                        }
-                       tmp = getenv(mac);
+                       tmp = env_get(mac);
                        if (!tmp)
                                continue;
 
@@ -642,84 +642,6 @@ int fdt_pci_dma_ranges(void *blob, int phb_off, struct pci_controller *hose) {
 }
 #endif
 
-#ifdef CONFIG_FDT_FIXUP_NOR_FLASH_SIZE
-/*
- * Provide a weak default function to return the flash bank size.
- * There might be multiple non-identical flash chips connected to one
- * chip-select, so we need to pass an index as well.
- */
-u32 __flash_get_bank_size(int cs, int idx)
-{
-       extern flash_info_t flash_info[];
-
-       /*
-        * As default, a simple 1:1 mapping is provided. Boards with
-        * a different mapping need to supply a board specific mapping
-        * routine.
-        */
-       return flash_info[cs].size;
-}
-u32 flash_get_bank_size(int cs, int idx)
-       __attribute__((weak, alias("__flash_get_bank_size")));
-
-/*
- * This function can be used to update the size in the "reg" property
- * of all NOR FLASH device nodes. This is necessary for boards with
- * non-fixed NOR FLASH sizes.
- */
-int fdt_fixup_nor_flash_size(void *blob)
-{
-       char compat[][16] = { "cfi-flash", "jedec-flash" };
-       int off;
-       int len;
-       struct fdt_property *prop;
-       u32 *reg, *reg2;
-       int i;
-
-       for (i = 0; i < 2; i++) {
-               off = fdt_node_offset_by_compatible(blob, -1, compat[i]);
-               while (off != -FDT_ERR_NOTFOUND) {
-                       int idx;
-
-                       /*
-                        * Found one compatible node, so fixup the size
-                        * int its reg properties
-                        */
-                       prop = fdt_get_property_w(blob, off, "reg", &len);
-                       if (prop) {
-                               int tuple_size = 3 * sizeof(reg);
-
-                               /*
-                                * There might be multiple reg-tuples,
-                                * so loop through them all
-                                */
-                               reg = reg2 = (u32 *)&prop->data[0];
-                               for (idx = 0; idx < (len / tuple_size); idx++) {
-                                       /*
-                                        * Update size in reg property
-                                        */
-                                       reg[2] = flash_get_bank_size(reg[0],
-                                                                    idx);
-
-                                       /*
-                                        * Point to next reg tuple
-                                        */
-                                       reg += 3;
-                               }
-
-                               fdt_setprop(blob, off, "reg", reg2, len);
-                       }
-
-                       /* Move to next compatible node */
-                       off = fdt_node_offset_by_compatible(blob, off,
-                                                           compat[i]);
-               }
-       }
-
-       return 0;
-}
-#endif
-
 int fdt_increase_size(void *fdt, int add_len)
 {
        int newlen;
@@ -1542,14 +1464,11 @@ int fdt_verify_alias_address(void *fdt, int anode, const char *alias, u64 addr)
 u64 fdt_get_base_address(const void *fdt, int node)
 {
        int size;
-       u32 naddr;
        const fdt32_t *prop;
 
-       naddr = fdt_address_cells(fdt, node);
-
-       prop = fdt_getprop(fdt, node, "ranges", &size);
+       prop = fdt_getprop(fdt, node, "reg", &size);
 
-       return prop ? fdt_translate_address(fdt, node, prop + naddr) : 0;
+       return prop ? fdt_translate_address(fdt, node, prop) : 0;
 }
 
 /*
@@ -1736,3 +1655,34 @@ int fdt_fixup_display(void *blob, const char *path, const char *display)
        }
        return toff;
 }
+
+#ifdef CONFIG_OF_LIBFDT_OVERLAY
+/**
+ * fdt_overlay_apply_verbose - Apply an overlay with verbose error reporting
+ *
+ * @fdt: ptr to device tree
+ * @fdto: ptr to device tree overlay
+ *
+ * Convenience function to apply an overlay and display helpful messages
+ * in the case of an error
+ */
+int fdt_overlay_apply_verbose(void *fdt, void *fdto)
+{
+       int err;
+       bool has_symbols;
+
+       err = fdt_path_offset(fdt, "/__symbols__");
+       has_symbols = err >= 0;
+
+       err = fdt_overlay_apply(fdt, fdto);
+       if (err < 0) {
+               printf("failed on fdt_overlay_apply(): %s\n",
+                               fdt_strerror(err));
+               if (!has_symbols) {
+                       printf("base fdt does did not have a /__symbols__ node\n");
+                       printf("make sure you've compiled with -@\n");
+               }
+       }
+       return err;
+}
+#endif