From: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
To: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Cc: barebox@lists.infradead.org
Subject: [PATCH v2 3/6] ARM: mvebu: Simplify memory init order
Date: Wed, 17 Sep 2014 22:22:41 +0200 [thread overview]
Message-ID: <1410985364-7105-4-git-send-email-sebastian.hesselbarth@gmail.com> (raw)
In-Reply-To: <1410985364-7105-1-git-send-email-sebastian.hesselbarth@gmail.com>
From: Sascha Hauer <s.hauer@pengutronix.de>
The initialisation of the memory nodes on mvebu is a bit
compilcated:
pure_initcall(mvebu_memory_fixup_register)
of_register_fixup(mvebu_memory_of_fixup, NULL)
core_initcall(kirkwood_init_soc)
mvebu_set_memory()
core_initcall(of_arm_init)
of_fix_tree()
mvebu_memory_of_fixup()
First a mvebu common of_fixup function is registered, then the SoC
calls mvebu_set_memory which stores the memory base and size in global
variables. Afterwards the of_fixup is executed which fixes the memory
nodes according to the global variables.
Instead register a SoC specific fixup which directly calls mvebu_set_memory
with the memory base and size as arguments:
pure_initcall(kirkwood_register_soc_fixup);
of_register_fixup(kirkwood_init_soc, NULL);
core_initcall(of_arm_init)
of_fix_tree()
kirkwood_init_soc()
mvebu_set_memory(phys_base, phys_size);
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
---
Changelog:
v1->v2:
- remove pure_initcall(mvebu_memory_fixup_register) here
- also move mvebu_mbus_add_range() to pure_initcall(foo_soc_init)
- fix missing _xp_ in armada_370_register_soc_fixup()
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Cc: barebox@lists.infradead.org
---
arch/arm/mach-mvebu/armada-370-xp.c | 13 ++++++++----
arch/arm/mach-mvebu/common.c | 35 ++++++++++---------------------
arch/arm/mach-mvebu/dove.c | 13 ++++++++----
arch/arm/mach-mvebu/include/mach/common.h | 2 +-
arch/arm/mach-mvebu/kirkwood.c | 13 ++++++++----
5 files changed, 39 insertions(+), 37 deletions(-)
diff --git a/arch/arm/mach-mvebu/armada-370-xp.c b/arch/arm/mach-mvebu/armada-370-xp.c
index 92096fcccabe..1dedcfc55467 100644
--- a/arch/arm/mach-mvebu/armada-370-xp.c
+++ b/arch/arm/mach-mvebu/armada-370-xp.c
@@ -52,7 +52,7 @@ static void __noreturn armada_370_xp_reset_cpu(unsigned long addr)
;
}
-static int armada_370_xp_init_soc(void)
+static int armada_370_xp_init_soc(struct device_node *root, void *context)
{
unsigned long phys_base, phys_size;
u32 reg;
@@ -70,9 +70,14 @@ static int armada_370_xp_init_soc(void)
armada_370_xp_memory_find(&phys_base, &phys_size);
mvebu_set_memory(phys_base, phys_size);
- mvebu_mbus_add_range("marvell,armada-370-xp", 0xf0, 0x01,
- MVEBU_REMAP_INT_REG_BASE);
return 0;
}
-core_initcall(armada_370_xp_init_soc);
+
+static int armada_370_xp_register_soc_fixup(void)
+{
+ mvebu_mbus_add_range("marvell,armada-370-xp", 0xf0, 0x01,
+ MVEBU_REMAP_INT_REG_BASE);
+ return of_register_fixup(armada_370_xp_init_soc, NULL);
+}
+pure_initcall(armada_370_xp_register_soc_fixup);
diff --git a/arch/arm/mach-mvebu/common.c b/arch/arm/mach-mvebu/common.c
index 05c9ae4c493e..309f7a6aaa52 100644
--- a/arch/arm/mach-mvebu/common.c
+++ b/arch/arm/mach-mvebu/common.c
@@ -81,29 +81,21 @@ static int mvebu_soc_id_init(void)
}
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)
+int mvebu_set_memory(u64 phys_base, u64 phys_size)
{
- struct device_node *np;
+ struct device_node *np, *root;
__be32 reg[4];
int na, ns;
- /* bail out on zero-sized mem */
- if (!mvebu_mem[1])
- return -ENODEV;
+ root = of_get_root_node();
+ if (!root)
+ return -EINVAL;
np = of_find_node_by_path("/memory");
if (!np)
@@ -115,17 +107,17 @@ static int mvebu_memory_of_fixup(struct device_node *root, void *context)
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);
+ reg[0] = cpu_to_be32(phys_base >> 32);
+ reg[1] = cpu_to_be32(phys_base & 0xffffffff);
} else {
- reg[0] = cpu_to_be32(mvebu_mem[0] & 0xffffffff);
+ reg[0] = cpu_to_be32(phys_base & 0xffffffff);
}
if (ns == 2) {
- reg[2] = cpu_to_be32(mvebu_mem[1] >> 32);
- reg[3] = cpu_to_be32(mvebu_mem[1] & 0xffffffff);
+ reg[2] = cpu_to_be32(phys_size >> 32);
+ reg[3] = cpu_to_be32(phys_size & 0xffffffff);
} else {
- reg[1] = cpu_to_be32(mvebu_mem[1] & 0xffffffff);
+ reg[1] = cpu_to_be32(phys_size & 0xffffffff);
}
if (of_set_property(np, "device_type", "memory", sizeof("memory"), 1) ||
@@ -135,11 +127,6 @@ static int mvebu_memory_of_fixup(struct device_node *root, void *context)
return 0;
}
-static int mvebu_memory_fixup_register(void) {
- return of_register_fixup(mvebu_memory_of_fixup, NULL);
-}
-pure_initcall(mvebu_memory_fixup_register);
-
static __noreturn void (*mvebu_reset_cpu)(unsigned long addr);
void __noreturn reset_cpu(unsigned long addr)
diff --git a/arch/arm/mach-mvebu/dove.c b/arch/arm/mach-mvebu/dove.c
index 85fdbe41b55c..31d2bb57f832 100644
--- a/arch/arm/mach-mvebu/dove.c
+++ b/arch/arm/mach-mvebu/dove.c
@@ -77,7 +77,7 @@ static void __noreturn dove_reset_cpu(unsigned long addr)
;
}
-static int dove_init_soc(void)
+static int dove_init_soc(struct device_node *root, void *context)
{
unsigned long phys_base, phys_size;
@@ -90,11 +90,16 @@ static int dove_init_soc(void)
dove_memory_find(&phys_base, &phys_size);
mvebu_set_memory(phys_base, phys_size);
+
+ return 0;
+}
+
+static int dove_register_soc_fixup(void)
+{
mvebu_mbus_add_range("marvell,dove", 0xf0, 0x01,
MVEBU_REMAP_INT_REG_BASE);
mvebu_mbus_add_range("marvell,dove", 0xf0, 0x02,
DOVE_REMAP_MC_REGS);
-
- return 0;
+ return of_register_fixup(dove_init_soc, NULL);
}
-core_initcall(dove_init_soc);
+pure_initcall(dove_register_soc_fixup);
diff --git a/arch/arm/mach-mvebu/include/mach/common.h b/arch/arm/mach-mvebu/include/mach/common.h
index 30862e02c7da..5ce33fd88274 100644
--- a/arch/arm/mach-mvebu/include/mach/common.h
+++ b/arch/arm/mach-mvebu/include/mach/common.h
@@ -20,7 +20,7 @@
#define MVEBU_REMAP_INT_REG_BASE 0xf1000000
-void mvebu_set_memory(u64 phys_base, u64 phys_size);
+int mvebu_set_memory(u64 phys_base, u64 phys_size);
void mvebu_set_reset(void __noreturn (*reset)(unsigned long addr));
#endif
diff --git a/arch/arm/mach-mvebu/kirkwood.c b/arch/arm/mach-mvebu/kirkwood.c
index b6cbd02592a4..8ab2849ba2e4 100644
--- a/arch/arm/mach-mvebu/kirkwood.c
+++ b/arch/arm/mach-mvebu/kirkwood.c
@@ -51,7 +51,7 @@ static void __noreturn kirkwood_reset_cpu(unsigned long addr)
;
}
-static int kirkwood_init_soc(void)
+static int kirkwood_init_soc(struct device_node *root, void *context)
{
unsigned long phys_base, phys_size;
@@ -63,9 +63,14 @@ static int kirkwood_init_soc(void)
kirkwood_memory_find(&phys_base, &phys_size);
mvebu_set_memory(phys_base, phys_size);
- mvebu_mbus_add_range("marvell,kirkwood", 0xf0, 0x01,
- MVEBU_REMAP_INT_REG_BASE);
return 0;
}
-core_initcall(kirkwood_init_soc);
+
+static int kirkwood_register_soc_fixup(void)
+{
+ mvebu_mbus_add_range("marvell,kirkwood", 0xf0, 0x01,
+ MVEBU_REMAP_INT_REG_BASE);
+ return of_register_fixup(kirkwood_init_soc, NULL);
+}
+pure_initcall(kirkwood_register_soc_fixup);
--
2.0.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2014-09-17 20:23 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-17 20:22 [PATCH v2 0/6] mvebu multi SoC support Sebastian Hesselbarth
2014-09-17 20:22 ` [PATCH v2 1/6] ARM: mvebu: Add common reset_cpu function Sebastian Hesselbarth
2014-09-17 20:22 ` [PATCH v2 2/6] ARM: mvebu: Add machine compatible to mbus ranges Sebastian Hesselbarth
2014-09-17 20:22 ` Sebastian Hesselbarth [this message]
2014-09-17 20:22 ` [PATCH v2 4/6] ARM: mvebu: Check for correct SoC in of_fixup callback Sebastian Hesselbarth
2014-09-17 20:22 ` [PATCH v2 5/6] ARM: mvebu: Allow multiple SoCs Sebastian Hesselbarth
2014-09-17 20:22 ` [PATCH v2 6/6] ARM: Add mvebu_defconfig Sebastian Hesselbarth
2014-09-20 17:24 ` Sebastian Hesselbarth
2014-09-23 5:58 ` Sascha Hauer
2014-09-19 5:47 ` [PATCH v2 0/6] mvebu multi SoC support Sascha Hauer
2014-09-19 6:44 ` Sebastian Hesselbarth
2014-09-19 7:55 ` Sascha Hauer
2014-09-19 8:25 ` 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=1410985364-7105-4-git-send-email-sebastian.hesselbarth@gmail.com \
--to=sebastian.hesselbarth@gmail.com \
--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