summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2019-11-12 10:19:54 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2019-11-13 15:20:40 +0100
commit2905fb431af7962c8fe7107326c051df7f4503f3 (patch)
treeb1312660faf431848aba615d520babdc3f122e13 /arch
parentf0f07ea7dc50847be5f775fedf926a1c6a8b6852 (diff)
downloadbarebox-2905fb431af7962c8fe7107326c051df7f4503f3.tar.gz
barebox-2905fb431af7962c8fe7107326c051df7f4503f3.tar.xz
ARM: stm32mp: add basic DDR controller driver
The STM32MP DDR Controller has a very flexible way of mapping address bits to columns/rows/banks. This is so far configured by the ARM TF-A as part of the SDRAM setup, so we don't need to do this in barebox. Nevertheless reading it out in barebox, allows us to determine unused address bits and thus the total size of SDRAM configured. Add a simple driver that parses the ddrctrl node and adds an appropriate memory bank. This can later be used to remove explicit calls to arm_add_mem_device in board code. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-stm32mp/ddrctrl.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/arch/arm/mach-stm32mp/ddrctrl.c b/arch/arm/mach-stm32mp/ddrctrl.c
index 90fb5e8956..962d4c0d52 100644
--- a/arch/arm/mach-stm32mp/ddrctrl.c
+++ b/arch/arm/mach-stm32mp/ddrctrl.c
@@ -4,6 +4,7 @@
*/
#include <common.h>
+#include <init.h>
#include <mach/stm32.h>
#include <mach/ddr_regs.h>
#include <mach/entry.h>
@@ -119,3 +120,36 @@ void __noreturn stm32mp1_barebox_entry(void *boarddata)
{
barebox_arm_entry(STM32_DDR_BASE, stm32mp1_ddrctrl_ramsize(), boarddata);
}
+
+
+static int stm32mp1_ddr_probe(struct device_d *dev)
+{
+ struct resource *iores;
+ void __iomem *base;
+
+ iores = dev_request_mem_resource(dev, 0);
+ if (IS_ERR(iores))
+ return PTR_ERR(iores);
+ base = IOMEM(iores->start);
+
+ arm_add_mem_device("ram0", STM32_DDR_BASE, ddrctrl_ramsize(base));
+
+ return 0;
+}
+
+static __maybe_unused struct of_device_id stm32mp1_ddr_dt_ids[] = {
+ { .compatible = "st,stm32mp1-ddr" },
+ { /* sentinel */ }
+};
+
+static struct driver_d stm32mp1_ddr_driver = {
+ .name = "stm32mp1-ddr",
+ .probe = stm32mp1_ddr_probe,
+ .of_compatible = DRV_OF_COMPAT(stm32mp1_ddr_dt_ids),
+};
+
+static int stm32mp1_ddr_init(void)
+{
+ return platform_driver_register(&stm32mp1_ddr_driver);
+}
+mem_initcall(stm32mp1_ddr_init);