mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
To: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Cc: barebox@lists.infradead.org
Subject: [PATCH v2 1/6] ARM: mvebu: Add common reset_cpu function
Date: Wed, 17 Sep 2014 22:22:39 +0200	[thread overview]
Message-ID: <1410985364-7105-2-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>

mvebu has a reset_cpu function per SoC this does not work when multiple
SoCs are selected, so add a common reset_cpu function which calls into
the SoC specific ones.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
---
Changelog:
v1->v2:
- do not remove pure_initcall(mvebu_memory_fixup_register)

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       | 19 ++++++++++---------
 arch/arm/mach-mvebu/common.c              | 14 ++++++++++++++
 arch/arm/mach-mvebu/dove.c                | 21 +++++++++++----------
 arch/arm/mach-mvebu/include/mach/common.h |  1 +
 arch/arm/mach-mvebu/kirkwood.c            | 19 ++++++++++---------
 5 files changed, 46 insertions(+), 28 deletions(-)

diff --git a/arch/arm/mach-mvebu/armada-370-xp.c b/arch/arm/mach-mvebu/armada-370-xp.c
index f2b991e5a79f..6251100e886d 100644
--- a/arch/arm/mach-mvebu/armada-370-xp.c
+++ b/arch/arm/mach-mvebu/armada-370-xp.c
@@ -44,11 +44,21 @@ static inline void armada_370_xp_memory_find(unsigned long *phys_base,
 	}
 }
 
+static void __noreturn armada_370_xp_reset_cpu(unsigned long addr)
+{
+	writel(0x1, ARMADA_370_XP_SYSCTL_BASE + 0x60);
+	writel(0x1, ARMADA_370_XP_SYSCTL_BASE + 0x64);
+	while (1)
+		;
+}
+
 static int armada_370_xp_init_soc(void)
 {
 	unsigned long phys_base, phys_size;
 	u32 reg;
 
+	mvebu_set_reset(armada_370_xp_reset_cpu);
+
 	barebox_set_model("Marvell Armada 370/XP");
 	barebox_set_hostname("armada");
 
@@ -65,12 +75,3 @@ static int armada_370_xp_init_soc(void)
 	return 0;
 }
 core_initcall(armada_370_xp_init_soc);
-
-void __noreturn reset_cpu(unsigned long addr)
-{
-	writel(0x1, ARMADA_370_XP_SYSCTL_BASE + 0x60);
-	writel(0x1, ARMADA_370_XP_SYSCTL_BASE + 0x64);
-	while (1)
-		;
-}
-EXPORT_SYMBOL(reset_cpu);
diff --git a/arch/arm/mach-mvebu/common.c b/arch/arm/mach-mvebu/common.c
index ac4b332e0180..05c9ae4c493e 100644
--- a/arch/arm/mach-mvebu/common.c
+++ b/arch/arm/mach-mvebu/common.c
@@ -21,6 +21,7 @@
 #include <of.h>
 #include <of_address.h>
 #include <linux/clk.h>
+#include <mach/common.h>
 
 /*
  * Marvell MVEBU SoC id and revision can be read from any PCIe
@@ -138,3 +139,16 @@ 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)
+{
+	mvebu_reset_cpu(addr);
+}
+EXPORT_SYMBOL(reset_cpu);
+
+void mvebu_set_reset(void __noreturn (*reset)(unsigned long addr))
+{
+	mvebu_reset_cpu = reset;
+}
diff --git a/arch/arm/mach-mvebu/dove.c b/arch/arm/mach-mvebu/dove.c
index 69c6436b2491..17cee0b9017c 100644
--- a/arch/arm/mach-mvebu/dove.c
+++ b/arch/arm/mach-mvebu/dove.c
@@ -68,10 +68,21 @@ static inline void dove_memory_find(unsigned long *phys_base,
 	}
 }
 
+static void __noreturn dove_reset_cpu(unsigned long addr)
+{
+	/* enable and assert RSTOUTn */
+	writel(SOFT_RESET_OUT_EN, DOVE_BRIDGE_BASE + BRIDGE_RSTOUT_MASK);
+	writel(SOFT_RESET_EN, DOVE_BRIDGE_BASE + BRIDGE_SYS_SOFT_RESET);
+	while (1)
+		;
+}
+
 static int dove_init_soc(void)
 {
 	unsigned long phys_base, phys_size;
 
+	mvebu_set_reset(dove_reset_cpu);
+
 	barebox_set_model("Marvell Dove");
 	barebox_set_hostname("dove");
 
@@ -85,13 +96,3 @@ static int dove_init_soc(void)
 	return 0;
 }
 core_initcall(dove_init_soc);
-
-void __noreturn reset_cpu(unsigned long addr)
-{
-	/* enable and assert RSTOUTn */
-	writel(SOFT_RESET_OUT_EN, DOVE_BRIDGE_BASE + BRIDGE_RSTOUT_MASK);
-	writel(SOFT_RESET_EN, DOVE_BRIDGE_BASE + BRIDGE_SYS_SOFT_RESET);
-	while (1)
-		;
-}
-EXPORT_SYMBOL(reset_cpu);
diff --git a/arch/arm/mach-mvebu/include/mach/common.h b/arch/arm/mach-mvebu/include/mach/common.h
index 9f6118e4ec84..30862e02c7da 100644
--- a/arch/arm/mach-mvebu/include/mach/common.h
+++ b/arch/arm/mach-mvebu/include/mach/common.h
@@ -21,5 +21,6 @@
 #define MVEBU_REMAP_INT_REG_BASE	0xf1000000
 
 void 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 c114bdb36006..7c0526b885a0 100644
--- a/arch/arm/mach-mvebu/kirkwood.c
+++ b/arch/arm/mach-mvebu/kirkwood.c
@@ -43,10 +43,20 @@ static inline void kirkwood_memory_find(unsigned long *phys_base,
 	}
 }
 
+static void __noreturn kirkwood_reset_cpu(unsigned long addr)
+{
+	writel(SOFT_RESET_OUT_EN, KIRKWOOD_BRIDGE_BASE + BRIDGE_RSTOUT_MASK);
+	writel(SOFT_RESET_EN, KIRKWOOD_BRIDGE_BASE + BRIDGE_SYS_SOFT_RESET);
+	for(;;)
+		;
+}
+
 static int kirkwood_init_soc(void)
 {
 	unsigned long phys_base, phys_size;
 
+	mvebu_set_reset(kirkwood_reset_cpu);
+
 	barebox_set_model("Marvell Kirkwood");
 	barebox_set_hostname("kirkwood");
 
@@ -58,12 +68,3 @@ static int kirkwood_init_soc(void)
 	return 0;
 }
 core_initcall(kirkwood_init_soc);
-
-void __noreturn reset_cpu(unsigned long addr)
-{
-	writel(SOFT_RESET_OUT_EN, KIRKWOOD_BRIDGE_BASE + BRIDGE_RSTOUT_MASK);
-	writel(SOFT_RESET_EN, KIRKWOOD_BRIDGE_BASE + BRIDGE_SYS_SOFT_RESET);
-	for(;;)
-		;
-}
-EXPORT_SYMBOL(reset_cpu);
-- 
2.0.0


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

  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 ` Sebastian Hesselbarth [this message]
2014-09-17 20:22 ` [PATCH v2 2/6] ARM: mvebu: Add machine compatible to mbus ranges Sebastian Hesselbarth
2014-09-17 20:22 ` [PATCH v2 3/6] ARM: mvebu: Simplify memory init order Sebastian Hesselbarth
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-2-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