]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
ARM: OMAP: Fix omap_sdram_size calculation
authorLokesh Vutla <lokeshvutla@ti.com>
Mon, 12 May 2014 08:19:33 +0000 (13:49 +0530)
committerTom Rini <trini@ti.com>
Fri, 23 May 2014 23:40:38 +0000 (19:40 -0400)
Last section of DMM is used for trapping tiler unmapped sections.
Corresponding trap_size should be deducted from total SDRAM size
only if trap section is overlapping with available SDRAM
based on DMM sections. Fixing the same.

Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
arch/arm/cpu/armv7/omap-common/hwinit-common.c

index 132454c7b4149354687f77002fe0c2f24ff1adff..ba97d9ec565af9ea4d83e1c69118868ffed43063 100644 (file)
@@ -185,7 +185,7 @@ u32 omap_sdram_size(void)
 {
        u32 section, i, valid;
        u64 sdram_start = 0, sdram_end = 0, addr,
-           size, total_size = 0, trap_size = 0;
+           size, total_size = 0, trap_size = 0, trap_start = 0;
 
        for (i = 0; i < 4; i++) {
                section = __raw_readl(DMM_BASE + i*4);
@@ -208,12 +208,15 @@ u32 omap_sdram_size(void)
                                        sdram_end = addr + size;
                        } else {
                                trap_size = size;
+                               trap_start = addr;
                        }
-
                }
-
        }
-       total_size = (sdram_end - sdram_start) - (trap_size);
+
+       if ((trap_start >= sdram_start) && (trap_start < sdram_end))
+               total_size = (sdram_end - sdram_start) - (trap_size);
+       else
+               total_size = sdram_end - sdram_start;
 
        return total_size;
 }