mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Roland Hieber <r.hieber@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Roland Hieber <r.hieber@pengutronix.de>
Subject: [PATCH 05/13] ARM: MXS: i.MX28: add autodetection of memory banks
Date: Wed, 25 Jul 2018 15:36:10 +0200	[thread overview]
Message-ID: <20180725133618.1510-6-r.hieber@pengutronix.de> (raw)
In-Reply-To: <20180725133618.1510-1-r.hieber@pengutronix.de>

If the prebootloader has set up the EMI controller correctly, we can
autodetect the size of available RAM by looking at the respective
configuration registers.

Signed-off-by: Roland Hieber <r.hieber@pengutronix.de>
---
 arch/arm/mach-mxs/Makefile    |  2 +-
 arch/arm/mach-mxs/mem-imx28.c | 39 +++++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/mach-mxs/mem-imx28.c

diff --git a/arch/arm/mach-mxs/Makefile b/arch/arm/mach-mxs/Makefile
index e3843368c2..0761f909a1 100644
--- a/arch/arm/mach-mxs/Makefile
+++ b/arch/arm/mach-mxs/Makefile
@@ -1,7 +1,7 @@
 obj-y += imx.o iomux-imx.o power.o
 pbl-y += iomux-imx.o
 obj-$(CONFIG_ARCH_IMX23) += clocksource-imx23.o usb-imx23.o soc-imx23.o
-obj-$(CONFIG_ARCH_IMX28) += clocksource-imx28.o usb-imx28.o soc-imx28.o
+obj-$(CONFIG_ARCH_IMX28) += clocksource-imx28.o usb-imx28.o soc-imx28.o mem-imx28.o
 obj-$(CONFIG_MXS_OCOTP) += ocotp.o
 obj-$(CONFIG_MXS_CMD_BCB) += bcb.o
 pbl-y += power-init.o mem-init.o lradc-init.o
diff --git a/arch/arm/mach-mxs/mem-imx28.c b/arch/arm/mach-mxs/mem-imx28.c
new file mode 100644
index 0000000000..e827e0906f
--- /dev/null
+++ b/arch/arm/mach-mxs/mem-imx28.c
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2018 Pengutronix, Roland Hieber <r.hieber@pengutronix.de>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <init.h>
+#include <asm/memory.h>
+#include <mach/imx28-regs.h>
+#include <printk.h>
+
+static int mx28_add_mem(void)
+{
+	if (!of_machine_is_compatible("fsl,imx28"))
+		return 0;
+
+	int * sdramc = (int *)IMX_SDRAMC_BASE;
+
+	uint8_t columns = 12 - ((sdramc[29] >> 16) & 0b111);
+	uint8_t rows    = 15 - ((sdramc[29] >>  8) & 0b111);
+	uint8_t banks   =      ((sdramc[31] >> 16) & 0b1)  ?  8  :  4;
+	uint8_t width   = sizeof (unsigned short);
+
+	uint32_t size = (1 << columns) * (1 << rows) * banks * width;
+	pr_info("i.MX28: detected %d cols, %d rows, %d banks = %d MiB of RAM\n",
+			columns, rows, banks, size / 1024 / 1024);
+
+	arm_add_mem_device("ram0", IMX_MEMORY_BASE, size);
+
+	return 0;
+}
+mem_initcall(mx28_add_mem);
-- 
2.18.0


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

  parent reply	other threads:[~2018-07-25 13:36 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-25 13:36 [PATCH 00/13] MXS/MX28 low-level improvements Roland Hieber
2018-07-25 13:36 ` [PATCH 01/13] scripts: mxsimage: Allow unencrypted images Roland Hieber
2018-07-25 13:36 ` [PATCH 02/13] images: MXS: allow generation of unencrypted bootstreams Roland Hieber
2018-07-25 13:36 ` [PATCH 03/13] ARM: MXS: i.MX28: allow setup of low-voltage SDRAM Roland Hieber
2018-07-25 13:36 ` [PATCH 04/13] ARM: MXS: allow configuration of EMI clock dividers Roland Hieber
2018-08-08  6:41   ` Sascha Hauer
2018-07-25 13:36 ` Roland Hieber [this message]
2018-07-27  8:28   ` [PATCH 05/13] ARM: MXS: i.MX28: add autodetection of memory banks Roland Hieber
2018-07-31 10:07   ` Roland Hieber
2018-08-08  6:40     ` Sascha Hauer
2018-07-25 13:36 ` [PATCH 06/13] ARM: MXS: refactor mx2*_power_init source configuration Roland Hieber
2018-07-25 13:36 ` [PATCH 07/13] ARM: MXS: allow starting from battery input without 4P2 source enabled Roland Hieber
2018-07-25 13:36 ` [PATCH 08/13] ARM: MXS: make power levels configurable in mx2*_power_init Roland Hieber
2018-07-25 13:36 ` [PATCH 09/13] ARM: MXS: fix VDDx brownout setup logic Roland Hieber
2018-07-25 13:36 ` [PATCH 10/13] ARM: MXS: make VDDx brownout setup more understandable Roland Hieber
2018-07-25 13:36 ` [PATCH 11/13] ARM: MXS: mxs_power_status: use less magic values Roland Hieber
2018-07-25 13:36 ` [PATCH 12/13] ARM: MXS: mxs_power_status: align output Roland Hieber
2018-07-25 13:36 ` [PATCH 13/13] Documentation: MXS: general update and improvements Roland Hieber

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=20180725133618.1510-6-r.hieber@pengutronix.de \
    --to=r.hieber@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