[PATCH] ARM: stm32mp: ddrctl: add STM32MP131 RAM size querying support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



buswidth is read from HW. With nb_bytes == 2, there is a possibility
that we get a zero size out here, if driver and device are
mismatched, e.g. because barebox is booted in FIP with mismatched
external device tree.

As this runs very early before relocation, round up instead of crashing
to be a bit more on the safe side.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 arch/arm/mach-stm32mp/ddrctrl.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-stm32mp/ddrctrl.c b/arch/arm/mach-stm32mp/ddrctrl.c
index 7f0944d7e77c..ed211cf58ebc 100644
--- a/arch/arm/mach-stm32mp/ddrctrl.c
+++ b/arch/arm/mach-stm32mp/ddrctrl.c
@@ -101,7 +101,8 @@ static unsigned long ddrctrl_addrmap_ramsize(struct stm32mp1_ddrctl __iomem *d,
 	if (LINE_UNUSED(reg, ADDRMAP6_ROW_B13)) rows--;
 	if (LINE_UNUSED(reg, ADDRMAP6_ROW_B12)) rows--;
 
-	return memory_sdram_size(cols, rows, BIT(banks), nb_bytes / BIT(buswidth));
+	return memory_sdram_size(cols, rows, BIT(banks),
+				 DIV_ROUND_UP(nb_bytes, BIT(buswidth)));
 }
 
 static inline unsigned ddrctrl_ramsize(void __iomem *base, unsigned nb_bytes)
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux