aboutsummaryrefslogtreecommitdiff
path: root/drivers/ddr/fsl/main.c
diff options
context:
space:
mode:
authorPali Rohár <pali@kernel.org>2022-09-09 17:32:44 +0200
committerTom Rini <trini@konsulko.com>2022-09-23 15:13:18 -0400
commit272199765412182f82ff789eaeffb2d93d70a01e (patch)
treed8400022c4ccc1dfbd31b31d4ca7b0ea4c360dd1 /drivers/ddr/fsl/main.c
parent922460be0b72b40cae52f5e870d38c90b609b64b (diff)
ddr: fsl: Allow to detect 4 GB DDR modules in 32-bit mode
U-Boot core code already handles the case when RAM size is bigger than CONFIG_MAX_MEM_MAPPED. So there is no need to do duplicate check in fsl ddr driver for CONFIG_MAX_MEM_MAPPED. Instead simplify code to just check if RAM size can be representable in phys_size_t type. And avoid printing warning if phys_size_t is just 1 byte smaller than RAM size, which is the typical situation with 4 GB DDR module. Signed-off-by: Pali Rohár <pali@kernel.org>
Diffstat (limited to 'drivers/ddr/fsl/main.c')
-rw-r--r--drivers/ddr/fsl/main.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/ddr/fsl/main.c b/drivers/ddr/fsl/main.c
index d44f16cdba..ed3313a531 100644
--- a/drivers/ddr/fsl/main.c
+++ b/drivers/ddr/fsl/main.c
@@ -857,15 +857,18 @@ phys_size_t __fsl_ddr_sdram(fsl_ddr_info_t *pinfo)
debug("total_memory by %s = %llu\n", __func__, total_memory);
#if !defined(CONFIG_PHYS_64BIT)
- /* Check for more than max memory. Bad. */
- if ((first_ctrl == 0) && (total_memory > CONFIG_MAX_MEM_MAPPED)) {
+ /*
+ * Show warning about big DDR moodules. But avoid warning for 4 GB DDR
+ * modules when U-Boot supports RAM of maximal size 4 GB - 1 byte.
+ */
+ if ((first_ctrl == 0) && (total_memory - 1 > (phys_size_t)~0ULL)) {
puts("Detected ");
print_size(total_memory, " of memory\n");
#ifndef CONFIG_SPL_BUILD
puts(" "); /* re-align to match init_dram print */
#endif
puts("This U-Boot only supports <= ");
- print_size(CONFIG_MAX_MEM_MAPPED, " of DDR\n");
+ print_size((unsigned long long)((phys_size_t)~0ULL)+1, " of DDR\n");
#ifndef CONFIG_SPL_BUILD
puts(" "); /* re-align to match init_dram print */
#endif
@@ -873,10 +876,13 @@ phys_size_t __fsl_ddr_sdram(fsl_ddr_info_t *pinfo)
#ifndef CONFIG_SPL_BUILD
puts(" "); /* re-align to match init_dram print */
#endif
- total_memory = CONFIG_MAX_MEM_MAPPED;
}
#endif
+ /* Ensure that total_memory does not overflow on return */
+ if (total_memory > (phys_size_t)~0ULL)
+ total_memory = (phys_size_t)~0ULL;
+
return total_memory;
}