]> git.sur5r.net Git - u-boot/blobdiff - common/fdt_support.c
ARM: relocation: don't undef CONFIG_SYS_ARM_WITHOUT_RELOC
[u-boot] / common / fdt_support.c
index aef4fe23e058c0294a714bc1313725d7c1ddeea3..0ed6e77292df179b953f6d1ad760bd9e4a236ac5 100644 (file)
@@ -590,37 +590,71 @@ 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 the NOR FLASH device nodes. This is necessary for boards with
+ * 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, int cs, u32 size)
+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;
+       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, now check if this one
-                        * has the correct CS
+                        * Found one compatible node, so fixup the size
+                        * int its reg properties
                         */
                        prop = fdt_get_property_w(blob, off, "reg", &len);
                        if (prop) {
-                               reg = (u32 *)&prop->data[0];
-                               if (reg[0] == cs) {
-                                       reg[2] = size;
-                                       fdt_setprop(blob, off, "reg", reg,
-                                                   3 * sizeof(u32));
-
-                                       return 0;
+                               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 */
@@ -629,7 +663,7 @@ int fdt_fixup_nor_flash_size(void *blob, int cs, u32 size)
                }
        }
 
-       return -1;
+       return 0;
 }
 #endif