mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 08/10] ARM: stm32mp: add basic DDR controller driver
Date: Tue, 12 Nov 2019 10:19:54 +0100	[thread overview]
Message-ID: <20191112091956.26628-8-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20191112091956.26628-1-a.fatoum@pengutronix.de>

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>
---
 arch/arm/mach-stm32mp/ddrctrl.c | 34 +++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/arch/arm/mach-stm32mp/ddrctrl.c b/arch/arm/mach-stm32mp/ddrctrl.c
index 90fb5e8956d0..b959441455d5 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 stm32_ddrctrl_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 stm32_ddrctrl_dt_ids[] = {
+	{ .compatible = "st,stm32-ddrctrl" },
+	{ /* sentinel */ }
+};
+
+static struct driver_d stm32_ddrctrl_driver = {
+	.name   = "stm32-ddrctrl",
+	.probe  = stm32_ddrctrl_probe,
+	.of_compatible = DRV_OF_COMPAT(stm32_ddrctrl_dt_ids),
+};
+
+static int stm32_ddrctrl_init(void)
+{
+	return platform_driver_register(&stm32_ddrctrl_driver);
+}
+mem_initcall(stm32_ddrctrl_init);
-- 
2.24.0.rc1


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

  parent reply	other threads:[~2019-11-12  9:20 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-12  9:19 [PATCH 01/10] ARM: dts: stm32mp: move alias to SoC device tree Ahmad Fatoum
2019-11-12  9:19 ` [PATCH 02/10] ARM: stm32mp157c-dk2: add optional DEBUG_LL print to entry point Ahmad Fatoum
2019-11-12  9:19 ` [PATCH 03/10] mfd: stpmic1: use register define from header Ahmad Fatoum
2019-11-12  9:19 ` [PATCH 04/10] watchdog: stm32_iwdg: return -ENOSYS on attempt to disable Ahmad Fatoum
2019-11-12  9:19 ` [PATCH 05/10] i2c: stm32: use device_reset_us helper instead of open-coding Ahmad Fatoum
2019-11-12  9:19 ` [PATCH 06/10] Documentation: boards: stm32mp: document boot error LED Ahmad Fatoum
2019-11-12  9:19 ` [PATCH 07/10] ARM: stm32mp: add helper for querying ram size Ahmad Fatoum
2019-11-12  9:19 ` Ahmad Fatoum [this message]
2019-11-13  9:28   ` [PATCH] fixup! ARM: stm32mp: add basic DDR controller driver Ahmad Fatoum
2019-11-12  9:19 ` [PATCH 09/10] ARM: stm32mp: add stm32mp_cpu_lowlevel_init with stack set up Ahmad Fatoum
2019-11-12  9:19 ` [PATCH 10/10] ARM: stm32mp: dk2: don't hard-code memory size Ahmad Fatoum
2019-11-13  9:29   ` [PATCH] fixup! " Ahmad Fatoum
2019-11-13 14:25 ` [PATCH 01/10] ARM: dts: stm32mp: move alias to SoC device tree Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191112091956.26628-8-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox