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 <lokeshvu...@ti.com>
---
 arch/arm/cpu/armv7/omap-common/hwinit-common.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/arch/arm/cpu/armv7/omap-common/hwinit-common.c 
b/arch/arm/cpu/armv7/omap-common/hwinit-common.c
index 8ebc0ce..1a8acc8 100644
--- a/arch/arm/cpu/armv7/omap-common/hwinit-common.c
+++ b/arch/arm/cpu/armv7/omap-common/hwinit-common.c
@@ -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;
 }
-- 
1.7.9.5

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to