From: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
To: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
barebox@lists.infradead.org
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Subject: [PATCH 5/5] ARM: mvebu: add fixup for directly attached memory
Date: Wed, 23 Jul 2014 11:28:10 +0200 [thread overview]
Message-ID: <1406107690-8605-6-git-send-email-sebastian.hesselbarth@gmail.com> (raw)
In-Reply-To: <1406107690-8605-1-git-send-email-sebastian.hesselbarth@gmail.com>
On Marvell MVEBU SoCs memory size is set up by BootROM and can be read
from SoC's RAM controller. With early DT fixups available, set corresponding
DT node to reflect accessible amount of directly attached RAM.
This patch also removes non-DT call to arm_add_mem_device to silence a
warning about request_region conflict due to adding a mem device twice.
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
---
To: barebox@lists.infradead.org
To: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
arch/arm/mach-mvebu/armada-370-xp.c | 2 +-
arch/arm/mach-mvebu/common.c | 59 +++++++++++++++++++++++++++++++
arch/arm/mach-mvebu/dove.c | 2 +-
arch/arm/mach-mvebu/include/mach/common.h | 2 ++
arch/arm/mach-mvebu/kirkwood.c | 2 +-
5 files changed, 64 insertions(+), 3 deletions(-)
diff --git a/arch/arm/mach-mvebu/armada-370-xp.c b/arch/arm/mach-mvebu/armada-370-xp.c
index f5ff9640b770..666ae077f6e6 100644
--- a/arch/arm/mach-mvebu/armada-370-xp.c
+++ b/arch/arm/mach-mvebu/armada-370-xp.c
@@ -52,8 +52,8 @@ static int armada_370_xp_init_soc(void)
barebox_set_hostname("armada");
armada_370_xp_memory_find(&phys_base, &phys_size);
- arm_add_mem_device("ram0", phys_base, phys_size);
+ mvebu_set_memory(phys_base, phys_size);
mvebu_mbus_add_range(0xf0, 0x01, MVEBU_REMAP_INT_REG_BASE);
return 0;
diff --git a/arch/arm/mach-mvebu/common.c b/arch/arm/mach-mvebu/common.c
index b054bf5aff48..ac4b332e0180 100644
--- a/arch/arm/mach-mvebu/common.c
+++ b/arch/arm/mach-mvebu/common.c
@@ -79,3 +79,62 @@ static int mvebu_soc_id_init(void)
return 0;
}
postcore_initcall(mvebu_soc_id_init);
+
+static u64 mvebu_mem[2];
+
+void mvebu_set_memory(u64 phys_base, u64 phys_size)
+{
+ mvebu_mem[0] = phys_base;
+ mvebu_mem[1] = phys_size;
+}
+
+/*
+ * Memory size is set up by BootROM and can be read from SoC's ram controller
+ * registers. Fixup provided DTs to reflect accessible amount of directly
+ * attached RAM. Removable RAM, e.g. SODIMM, should be added by a per-board
+ * fixup.
+ */
+static int mvebu_memory_of_fixup(struct device_node *root, void *context)
+{
+ struct device_node *np;
+ __be32 reg[4];
+ int na, ns;
+
+ /* bail out on zero-sized mem */
+ if (!mvebu_mem[1])
+ return -ENODEV;
+
+ np = of_find_node_by_path("/memory");
+ if (!np)
+ np = of_create_node(root, "/memory");
+ if (!np)
+ return -EINVAL;
+
+ na = of_n_addr_cells(np);
+ ns = of_n_size_cells(np);
+
+ if (na == 2) {
+ reg[0] = cpu_to_be32(mvebu_mem[0] >> 32);
+ reg[1] = cpu_to_be32(mvebu_mem[0] & 0xffffffff);
+ } else {
+ reg[0] = cpu_to_be32(mvebu_mem[0] & 0xffffffff);
+ }
+
+ if (ns == 2) {
+ reg[2] = cpu_to_be32(mvebu_mem[1] >> 32);
+ reg[3] = cpu_to_be32(mvebu_mem[1] & 0xffffffff);
+ } else {
+ reg[1] = cpu_to_be32(mvebu_mem[1] & 0xffffffff);
+ }
+
+ if (of_set_property(np, "device_type", "memory", sizeof("memory"), 1) ||
+ of_set_property(np, "reg", reg, sizeof(u32) * (na + ns), 1))
+ pr_err("Unable to fixup memory node\n");
+
+ return 0;
+}
+
+static int mvebu_memory_fixup_register(void) {
+ return of_register_fixup(mvebu_memory_of_fixup, NULL);
+}
+pure_initcall(mvebu_memory_fixup_register);
diff --git a/arch/arm/mach-mvebu/dove.c b/arch/arm/mach-mvebu/dove.c
index 974f48074150..69c6436b2491 100644
--- a/arch/arm/mach-mvebu/dove.c
+++ b/arch/arm/mach-mvebu/dove.c
@@ -77,8 +77,8 @@ static int dove_init_soc(void)
dove_remap_mc_regs();
dove_memory_find(&phys_base, &phys_size);
- arm_add_mem_device("ram0", phys_base, phys_size);
+ mvebu_set_memory(phys_base, phys_size);
mvebu_mbus_add_range(0xf0, 0x01, MVEBU_REMAP_INT_REG_BASE);
mvebu_mbus_add_range(0xf0, 0x02, DOVE_REMAP_MC_REGS);
diff --git a/arch/arm/mach-mvebu/include/mach/common.h b/arch/arm/mach-mvebu/include/mach/common.h
index 3cc1bf71c0f7..9f6118e4ec84 100644
--- a/arch/arm/mach-mvebu/include/mach/common.h
+++ b/arch/arm/mach-mvebu/include/mach/common.h
@@ -20,4 +20,6 @@
#define MVEBU_REMAP_INT_REG_BASE 0xf1000000
+void mvebu_set_memory(u64 phys_base, u64 phys_size);
+
#endif
diff --git a/arch/arm/mach-mvebu/kirkwood.c b/arch/arm/mach-mvebu/kirkwood.c
index 2249b9bfc64b..c114bdb36006 100644
--- a/arch/arm/mach-mvebu/kirkwood.c
+++ b/arch/arm/mach-mvebu/kirkwood.c
@@ -51,8 +51,8 @@ static int kirkwood_init_soc(void)
barebox_set_hostname("kirkwood");
kirkwood_memory_find(&phys_base, &phys_size);
- arm_add_mem_device("ram0", phys_base, phys_size);
+ mvebu_set_memory(phys_base, phys_size);
mvebu_mbus_add_range(0xf0, 0x01, MVEBU_REMAP_INT_REG_BASE);
return 0;
--
2.0.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2014-07-23 9:28 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-23 9:28 [PATCH 0/5] Early DT and MVEBU DT fixups Sebastian Hesselbarth
2014-07-23 9:28 ` [PATCH 1/5] ARM: execute OF fixups early Sebastian Hesselbarth
2014-07-23 9:28 ` [PATCH 2/5] ARM: mvebu: allow to fixup mbus ranges Sebastian Hesselbarth
2014-07-23 9:28 ` [PATCH 3/5] ARM: mvebu: add register remap for mbus ids Sebastian Hesselbarth
2014-07-23 9:28 ` [PATCH 4/5] ARM: dts: mvebu: remove mbus ranges overwrite Sebastian Hesselbarth
2014-08-02 3:07 ` Ezequiel Garcia
2014-07-23 9:28 ` Sebastian Hesselbarth [this message]
2014-07-25 7:06 ` [PATCH 0/5] Early DT and MVEBU DT fixups Sascha Hauer
2014-07-25 7:24 ` Sebastian Hesselbarth
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=1406107690-8605-6-git-send-email-sebastian.hesselbarth@gmail.com \
--to=sebastian.hesselbarth@gmail.com \
--cc=barebox@lists.infradead.org \
--cc=thomas.petazzoni@free-electrons.com \
/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