All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Palmer <daniel@0x0f.com>
To: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org, arnd@arndb.de, robh@kernel.org,
	w@1wt.eu, daniel@0x0f.com
Subject: [PATCH 9/9] ARM: mstar: SMP support
Date: Mon, 30 Nov 2020 22:10:47 +0900	[thread overview]
Message-ID: <20201130131047.2648960-10-daniel@0x0f.com> (raw)
In-Reply-To: <20201130131047.2648960-1-daniel@0x0f.com>

This patch adds SMP support for MStar/Sigmastar chips that have a second core
like those in the infinity2m family.

So far only single and dual core chips have been found so this does
the bare minimum to boot the second core. From what I can tell not having
the "holding pen" code to handle multiple cores is fine if there is only
one core the will get booted. This might need to be reconsidered if chips
with more cores turn up.

Signed-off-by: Daniel Palmer <daniel@0x0f.com>
---
 arch/arm/mach-mstar/mstarv7.c | 50 +++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/arch/arm/mach-mstar/mstarv7.c b/arch/arm/mach-mstar/mstarv7.c
index 1aa748fa006e..23fe47a8f1a5 100644
--- a/arch/arm/mach-mstar/mstarv7.c
+++ b/arch/arm/mach-mstar/mstarv7.c
@@ -31,6 +31,13 @@
 #define MSTARV7_L3BRIDGE_FLUSH_TRIGGER	BIT(0)
 #define MSTARV7_L3BRIDGE_STATUS_DONE	BIT(12)
 
+#ifdef CONFIG_SMP
+#define MSTARV7_CPU1_BOOT_ADDR_HIGH	0x4c
+#define MSTARV7_CPU1_BOOT_ADDR_LOW	0x50
+#define MSTARV7_CPU1_UNLOCK		0x58
+#define MSTARV7_CPU1_UNLOCK_MAGIC	0xbabe
+#endif
+
 static void __iomem *l3bridge;
 
 static const char * const mstarv7_board_dt_compat[] __initconst = {
@@ -63,6 +70,46 @@ static void mstarv7_mb(void)
 	}
 }
 
+#ifdef CONFIG_SMP
+static int mstarv7_boot_secondary(unsigned int cpu, struct task_struct *idle)
+{
+	struct device_node *np;
+	u32 bootaddr = (u32) __pa_symbol(secondary_startup_arm);
+	void __iomem *smpctrl = 0;
+
+	/*
+	 * right now we don't know how to boot anything except
+	 * cpu 1.
+	 */
+	if (cpu != 1)
+		return -EINVAL;
+
+	np = of_find_compatible_node(NULL, NULL, "mstar,smpctrl");
+	smpctrl = of_iomap(np, 0);
+
+	if (!smpctrl)
+		return -ENODEV;
+
+	/* set the boot address for the second cpu */
+	writew(bootaddr & 0xffff, smpctrl + MSTARV7_CPU1_BOOT_ADDR_LOW);
+	writew((bootaddr >> 16) & 0xffff, smpctrl + MSTARV7_CPU1_BOOT_ADDR_HIGH);
+
+	/* unlock the second cpu */
+	writew(MSTARV7_CPU1_UNLOCK_MAGIC, smpctrl + MSTARV7_CPU1_UNLOCK);
+
+	/* and away we go...*/
+	arch_send_wakeup_ipi_mask(cpumask_of(cpu));
+
+	iounmap(smpctrl);
+
+	return 0;
+}
+
+struct smp_operations __initdata mstarv7_smp_ops  = {
+	.smp_boot_secondary = mstarv7_boot_secondary,
+};
+#endif
+
 static void __init mstarv7_init(void)
 {
 	struct device_node *np;
@@ -78,4 +125,7 @@ static void __init mstarv7_init(void)
 DT_MACHINE_START(MSTARV7_DT, "MStar/Sigmastar Armv7 (Device Tree)")
 	.dt_compat	= mstarv7_board_dt_compat,
 	.init_machine	= mstarv7_init,
+#ifdef CONFIG_SMP
+	.smp		= smp_ops(mstarv7_smp_ops),
+#endif
 MACHINE_END
-- 
2.29.2


WARNING: multiple messages have this Message-ID (diff)
From: Daniel Palmer <daniel@0x0f.com>
To: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Cc: robh@kernel.org, daniel@0x0f.com, linux-kernel@vger.kernel.org,
	arnd@arndb.de, w@1wt.eu
Subject: [PATCH 9/9] ARM: mstar: SMP support
Date: Mon, 30 Nov 2020 22:10:47 +0900	[thread overview]
Message-ID: <20201130131047.2648960-10-daniel@0x0f.com> (raw)
In-Reply-To: <20201130131047.2648960-1-daniel@0x0f.com>

This patch adds SMP support for MStar/Sigmastar chips that have a second core
like those in the infinity2m family.

So far only single and dual core chips have been found so this does
the bare minimum to boot the second core. From what I can tell not having
the "holding pen" code to handle multiple cores is fine if there is only
one core the will get booted. This might need to be reconsidered if chips
with more cores turn up.

Signed-off-by: Daniel Palmer <daniel@0x0f.com>
---
 arch/arm/mach-mstar/mstarv7.c | 50 +++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/arch/arm/mach-mstar/mstarv7.c b/arch/arm/mach-mstar/mstarv7.c
index 1aa748fa006e..23fe47a8f1a5 100644
--- a/arch/arm/mach-mstar/mstarv7.c
+++ b/arch/arm/mach-mstar/mstarv7.c
@@ -31,6 +31,13 @@
 #define MSTARV7_L3BRIDGE_FLUSH_TRIGGER	BIT(0)
 #define MSTARV7_L3BRIDGE_STATUS_DONE	BIT(12)
 
+#ifdef CONFIG_SMP
+#define MSTARV7_CPU1_BOOT_ADDR_HIGH	0x4c
+#define MSTARV7_CPU1_BOOT_ADDR_LOW	0x50
+#define MSTARV7_CPU1_UNLOCK		0x58
+#define MSTARV7_CPU1_UNLOCK_MAGIC	0xbabe
+#endif
+
 static void __iomem *l3bridge;
 
 static const char * const mstarv7_board_dt_compat[] __initconst = {
@@ -63,6 +70,46 @@ static void mstarv7_mb(void)
 	}
 }
 
+#ifdef CONFIG_SMP
+static int mstarv7_boot_secondary(unsigned int cpu, struct task_struct *idle)
+{
+	struct device_node *np;
+	u32 bootaddr = (u32) __pa_symbol(secondary_startup_arm);
+	void __iomem *smpctrl = 0;
+
+	/*
+	 * right now we don't know how to boot anything except
+	 * cpu 1.
+	 */
+	if (cpu != 1)
+		return -EINVAL;
+
+	np = of_find_compatible_node(NULL, NULL, "mstar,smpctrl");
+	smpctrl = of_iomap(np, 0);
+
+	if (!smpctrl)
+		return -ENODEV;
+
+	/* set the boot address for the second cpu */
+	writew(bootaddr & 0xffff, smpctrl + MSTARV7_CPU1_BOOT_ADDR_LOW);
+	writew((bootaddr >> 16) & 0xffff, smpctrl + MSTARV7_CPU1_BOOT_ADDR_HIGH);
+
+	/* unlock the second cpu */
+	writew(MSTARV7_CPU1_UNLOCK_MAGIC, smpctrl + MSTARV7_CPU1_UNLOCK);
+
+	/* and away we go...*/
+	arch_send_wakeup_ipi_mask(cpumask_of(cpu));
+
+	iounmap(smpctrl);
+
+	return 0;
+}
+
+struct smp_operations __initdata mstarv7_smp_ops  = {
+	.smp_boot_secondary = mstarv7_boot_secondary,
+};
+#endif
+
 static void __init mstarv7_init(void)
 {
 	struct device_node *np;
@@ -78,4 +125,7 @@ static void __init mstarv7_init(void)
 DT_MACHINE_START(MSTARV7_DT, "MStar/Sigmastar Armv7 (Device Tree)")
 	.dt_compat	= mstarv7_board_dt_compat,
 	.init_machine	= mstarv7_init,
+#ifdef CONFIG_SMP
+	.smp		= smp_ops(mstarv7_smp_ops),
+#endif
 MACHINE_END
-- 
2.29.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2020-11-30 13:13 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-30 13:10 [PATCH 0/9] ARM: mstar: Add basic support for i2m and SMP Daniel Palmer
2020-11-30 13:10 ` Daniel Palmer
2020-11-30 13:10 ` [PATCH 1/9] dt-bindings: mstar: Add binding details for mstar,smpctrl Daniel Palmer
2020-11-30 13:10   ` [PATCH 1/9] dt-bindings: mstar: Add binding details for mstar, smpctrl Daniel Palmer
2020-11-30 13:10 ` [PATCH 2/9] dt-bindings: vendor-prefixes: Add honestar vendor prefix Daniel Palmer
2020-11-30 13:10   ` Daniel Palmer
2020-11-30 13:10 ` [PATCH 3/9] dt-bindings: mstar: Add Honestar SSD201_HT_V2 to mstar boards Daniel Palmer
2020-11-30 13:10   ` Daniel Palmer
2020-11-30 13:10 ` [PATCH 4/9] ARM: mstar: Add infinity2m support Daniel Palmer
2020-11-30 13:10   ` Daniel Palmer
2020-11-30 13:10 ` [PATCH 5/9] ARM: mstar: Add common dtsi for SSD201/SSD202D Daniel Palmer
2020-11-30 13:10   ` Daniel Palmer
2020-11-30 13:10 ` [PATCH 6/9] ARM: mstar: Add chip level dtsi for SSD202D Daniel Palmer
2020-11-30 13:10   ` Daniel Palmer
2020-11-30 13:10 ` [PATCH 7/9] ARM: mstar: Add dts for Honestar ssd201htv2 Daniel Palmer
2020-11-30 13:10   ` Daniel Palmer
2020-11-30 13:10 ` [PATCH 8/9] ARM: mstar: Add smp ctrl registers to infinity2m dtsi Daniel Palmer
2020-11-30 13:10   ` Daniel Palmer
2020-11-30 13:43   ` Arnd Bergmann
2020-11-30 13:43     ` Arnd Bergmann
2020-11-30 14:11     ` Daniel Palmer
2020-11-30 14:11       ` Daniel Palmer
2020-11-30 14:57       ` Arnd Bergmann
2020-11-30 14:57         ` Arnd Bergmann
2020-11-30 13:10 ` Daniel Palmer [this message]
2020-11-30 13:10   ` [PATCH 9/9] ARM: mstar: SMP support Daniel Palmer
2020-11-30 13:42   ` Arnd Bergmann
2020-11-30 13:42     ` Arnd Bergmann
2020-11-30 14:25     ` Daniel Palmer
2020-11-30 14:25       ` Daniel Palmer
2020-11-30 16:03       ` Arnd Bergmann
2020-11-30 16:03         ` Arnd Bergmann

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=20201130131047.2648960-10-daniel@0x0f.com \
    --to=daniel@0x0f.com \
    --cc=arnd@arndb.de \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=w@1wt.eu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.