diff mbox

[U-Boot] ARM: OMAP: Fix omap_sdram_size calculation

Message ID 1399882773-26145-1-git-send-email-lokeshvutla@ti.com
State Accepted
Delegated to: Tom Rini
Headers show

Commit Message

Lokesh Vutla May 12, 2014, 8:19 a.m. UTC
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 |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Comments

Tom Rini May 23, 2014, 11:49 p.m. UTC | #1
On Mon, May 12, 2014 at 01:49:33PM +0530, Lokesh Vutla wrote:

> 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>

Applied to u-boot-ti/master, thanks!
diff mbox

Patch

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;
 }