
The calculation in `rockchip_sdram_size` would overflow for 4GB on 32bit systems (i.e. when PHYS_64BIT is not defined).
This makes the internal variables and the signature prototype use a u64 to ensure that we can represent the 33rd bit (as in '4GB').
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com ---
arch/arm/include/asm/arch-rockchip/sdram_common.h | 2 +- arch/arm/mach-rockchip/sdram_common.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/arch/arm/include/asm/arch-rockchip/sdram_common.h b/arch/arm/include/asm/arch-rockchip/sdram_common.h index 671c318..edf5911 100644 --- a/arch/arm/include/asm/arch-rockchip/sdram_common.h +++ b/arch/arm/include/asm/arch-rockchip/sdram_common.h @@ -50,7 +50,7 @@ #define SYS_REG_DBW_MASK 3
/* Get sdram size decode from reg */ -size_t rockchip_sdram_size(phys_addr_t reg); +u64 rockchip_sdram_size(phys_addr_t reg);
/* Called by U-Boot board_init_r for Rockchip SoCs */ int dram_init(void); diff --git a/arch/arm/mach-rockchip/sdram_common.c b/arch/arm/mach-rockchip/sdram_common.c index 650d53e..6bad537 100644 --- a/arch/arm/mach-rockchip/sdram_common.c +++ b/arch/arm/mach-rockchip/sdram_common.c @@ -11,11 +11,11 @@ #include <dm/uclass-internal.h>
DECLARE_GLOBAL_DATA_PTR; -size_t rockchip_sdram_size(phys_addr_t reg) +u64 rockchip_sdram_size(phys_addr_t reg) { u32 rank, col, bk, cs0_row, cs1_row, bw, row_3_4; - size_t chipsize_mb = 0; - size_t size_mb = 0; + u64 chipsize_mb = 0; + u64 size_mb = 0; u32 ch;
u32 sys_reg = readl(reg); @@ -48,7 +48,7 @@ size_t rockchip_sdram_size(phys_addr_t reg) rank, col, bk, cs0_row, bw, row_3_4); }
- return (size_t)size_mb << 20; + return (u64)size_mb << 20; }
int dram_init(void)