summaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-stm32mp
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2022-02-23 12:38:47 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2022-03-08 09:59:59 +0100
commitfb884f25a53aa25924bf9171ad6c8e3305a2ecf3 (patch)
tree66a71e2707149edeed79606e78afb879e93e6cf2 /arch/arm/mach-stm32mp
parentc7bb31362687174027660c2d393e7686523be856 (diff)
downloadbarebox-fb884f25a53aa25924bf9171ad6c8e3305a2ecf3.tar.gz
barebox-fb884f25a53aa25924bf9171ad6c8e3305a2ecf3.tar.xz
ARM: stm32mp: ddrctl: add STM32MP131 RAM size querying support
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@pengutronix.de> Link: https://lore.barebox.org/20220223113846.3022227-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/mach-stm32mp')
-rw-r--r--arch/arm/mach-stm32mp/ddrctrl.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/arch/arm/mach-stm32mp/ddrctrl.c b/arch/arm/mach-stm32mp/ddrctrl.c
index 7f0944d7e7..ed211cf58e 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)