Devicetree
 help / color / mirror / Atom feed
From: Wadim Mueller <wafgo01@gmail.com>
To: linux-arm-kernel@lists.infradead.org,
	"Florian Fainelli" <florian.fainelli@broadcom.com>,
	"William Zhang" <william.zhang@broadcom.com>,
	"Anand Gore" <anand.gore@broadcom.com>,
	"Kursad Oney" <kursad.oney@broadcom.com>,
	"Rafał Miłecki" <rafal@milecki.pl>
Cc: Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>, Lee Jones <lee@kernel.org>,
	Ray Jui <ray.jui@broadcom.com>,
	Scott Branden <scott.branden@broadcom.com>,
	Russell King <linux@armlinux.org.uk>,
	Lorenzo Pieralisi <lpieralisi@kernel.org>,
	bcm-kernel-feedback-list@broadcom.com,
	devicetree@vger.kernel.org, mfd@lists.linux.dev,
	linux-kernel@vger.kernel.org, Wadim Mueller <wafgo01@gmail.com>
Subject: [RFC PATCH 2/6] ARM: bcm: Add brcm,bca-smp enable-method
Date: Fri,  4 Dec 2026 16:10:48 +0100	[thread overview]
Message-ID: <20261204151052.393800-3-wafgo01@gmail.com> (raw)
In-Reply-To: <20261204151052.393800-1-wafgo01@gmail.com>

CFE without secure firmware does not provide PSCI. It keeps the
secondary cores in WFI and on wakeup they jump to the address in the
GPIO GeneralPurpose register (0xff800568).

All cores wake up together, so use a holding pen like mach-versatile.

Tested on BCM6755 (ASUS RT-AX56U).

Signed-off-by: Wadim Mueller <wafgo01@gmail.com>
---
 arch/arm/mach-bcm/Makefile         |  1 +
 arch/arm/mach-bcm/headsmp-bcmbca.S | 36 ++++++++++++++
 arch/arm/mach-bcm/platsmp-bcmbca.c | 79 ++++++++++++++++++++++++++++++
 3 files changed, 116 insertions(+)
 create mode 100644 arch/arm/mach-bcm/headsmp-bcmbca.S
 create mode 100644 arch/arm/mach-bcm/platsmp-bcmbca.c

diff --git a/arch/arm/mach-bcm/Makefile b/arch/arm/mach-bcm/Makefile
index 6baedf4c6..d13011a8d 100644
--- a/arch/arm/mach-bcm/Makefile
+++ b/arch/arm/mach-bcm/Makefile
@@ -60,4 +60,5 @@ endif
 ifeq ($(CONFIG_ARCH_BCMBCA),y)
 obj-$(CONFIG_DEBUG_BCMBCA)	+= board_bcmbca.o
 obj-$(CONFIG_SMP)		+= bcm63xx_smp.o bcm63xx_pmb.o
+obj-$(CONFIG_ARCH_BCMBCA_CORTEXA7)	+= platsmp-bcmbca.o headsmp-bcmbca.o
 endif
diff --git a/arch/arm/mach-bcm/headsmp-bcmbca.S b/arch/arm/mach-bcm/headsmp-bcmbca.S
new file mode 100644
index 000000000..9e7d462e8
--- /dev/null
+++ b/arch/arm/mach-bcm/headsmp-bcmbca.S
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ *  Copyright (c) 2003 ARM Limited (holding pen from mach-versatile)
+ *  All Rights Reserved
+ */
+#include <linux/linkage.h>
+#include <linux/init.h>
+#include <asm/assembler.h>
+
+/*
+ * Entry point for secondary CPUs on BCMBCA (CFE, no PSCI).
+ * This provides a "holding pen" into which all secondary cores are held
+ * until we're ready for them to initialise.
+ */
+ENTRY(bca_secondary_startup)
+ ARM_BE8(setend	be)
+	mrc	p15, 0, r0, c0, c0, 5
+	bic	r0, #0xff000000
+	adr	r4, 1f
+	ldmia	r4, {r5, r6}
+	sub	r4, r4, r5
+	add	r6, r6, r4
+pen:	ldr	r7, [r6]
+	cmp	r7, r0
+	bne	pen
+
+	/*
+	 * we've been released from the holding pen: secondary_stack
+	 * should now contain the SVC stack for this core
+	 */
+	b	secondary_startup
+
+	.align
+1:	.long	.
+	.long	bca_cpu_release
+ENDPROC(bca_secondary_startup)
diff --git a/arch/arm/mach-bcm/platsmp-bcmbca.c b/arch/arm/mach-bcm/platsmp-bcmbca.c
new file mode 100644
index 000000000..e888a2a37
--- /dev/null
+++ b/arch/arm/mach-bcm/platsmp-bcmbca.c
@@ -0,0 +1,79 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * SMP for BCMBCA Cortex-A7 SoCs booted by CFE without PSCI.
+ *
+ * CFE keeps the secondary cores in WFI. On wakeup all of them jump to the
+ * address in GPIO GeneralPurpose register, so we hold them in a pen.
+ */
+
+#include <linux/cacheflush.h>
+#include <linux/delay.h>
+#include <linux/init.h>
+#include <linux/io.h>
+#include <linux/jiffies.h>
+#include <linux/smp.h>
+
+#include <asm/smp_plat.h>
+
+#define BCA_SMP_BOOT_ADDR	0xff800568	/* GPIO->GeneralPurpose */
+
+asmlinkage void bca_secondary_startup(void);
+int bca_cpu_release = -1;
+static DEFINE_RAW_SPINLOCK(bca_lock);
+
+/* pen runs with caches off */
+static void bca_write_cpu_release(int val)
+{
+	WRITE_ONCE(bca_cpu_release, val);
+	smp_wmb();	/* before cache clean */
+	sync_cache_w(&bca_cpu_release);
+}
+
+static void bca_secondary_init(unsigned int cpu)
+{
+	bca_write_cpu_release(-1);
+
+	raw_spin_lock(&bca_lock);
+	raw_spin_unlock(&bca_lock);
+}
+
+static int bca_boot_secondary(unsigned int cpu, struct task_struct *idle)
+{
+	unsigned long timeout;
+	int released;
+
+	raw_spin_lock(&bca_lock);
+
+	bca_write_cpu_release(cpu_logical_map(cpu));
+	arch_send_wakeup_ipi_mask(cpumask_of(cpu));
+
+	timeout = jiffies + HZ;
+	do {
+		smp_rmb();	/* pairs with bca_write_cpu_release() */
+		released = READ_ONCE(bca_cpu_release) == -1;
+		if (released)
+			break;
+		udelay(10);
+	} while (time_before(jiffies, timeout));
+
+	raw_spin_unlock(&bca_lock);
+
+	return released ? 0 : -ETIMEDOUT;
+}
+
+static void __init bca_smp_prepare_cpus(unsigned int max_cpus)
+{
+	void __iomem *reg = ioremap(BCA_SMP_BOOT_ADDR, 4);
+
+	if (WARN_ON(!reg))
+		return;
+	writel(__pa_symbol(bca_secondary_startup), reg);
+	iounmap(reg);
+}
+
+static const struct smp_operations bca_smp_ops __initconst = {
+	.smp_prepare_cpus	= bca_smp_prepare_cpus,
+	.smp_secondary_init	= bca_secondary_init,
+	.smp_boot_secondary	= bca_boot_secondary,
+};
+CPU_METHOD_OF_DECLARE(bca_smp, "brcm,bca-smp", &bca_smp_ops);
-- 
2.56.1


  parent reply	other threads:[~2026-12-04 15:11 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 15:10 [RFC PATCH 0/6] ARM: bcmbca: Add BCM47622 SMP and ASUS RT-AX56U Wadim Mueller
2026-12-04 15:10 ` [RFC PATCH 1/6] dt-bindings: arm: cpus: Add brcm,bca-smp enable-method Wadim Mueller
2026-12-04 15:10 ` Wadim Mueller [this message]
2026-12-04 15:34   ` [RFC PATCH 2/6] ARM: bcm: " sashiko-bot
2026-12-04 17:29   ` William Zhang
2026-12-04 15:10 ` [RFC PATCH 3/6] dt-bindings: mfd: brcm,twd: Add BCM47622 Wadim Mueller
2026-12-04 15:23   ` sashiko-bot
2026-12-04 15:10 ` [RFC PATCH 4/6] ARM: dts: broadcom: bcm47622: Add TWD, reboot, MDIO and SYSTEMPORT0 Wadim Mueller
2026-12-04 15:34   ` sashiko-bot
2026-12-04 17:45   ` Florian Fainelli
2026-12-04 15:10 ` [RFC PATCH 5/6] dt-bindings: arm: bcmbca: Add ASUS RT-AX56U Wadim Mueller
2026-12-04 15:17   ` sashiko-bot
2026-12-04 15:10 ` [RFC PATCH 6/6] ARM: dts: broadcom: " Wadim Mueller
2026-12-04 15:25   ` sashiko-bot
2026-12-04 18:01   ` Florian Fainelli

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=20261204151052.393800-3-wafgo01@gmail.com \
    --to=wafgo01@gmail.com \
    --cc=anand.gore@broadcom.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=florian.fainelli@broadcom.com \
    --cc=krzk+dt@kernel.org \
    --cc=kursad.oney@broadcom.com \
    --cc=lee@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=lpieralisi@kernel.org \
    --cc=mfd@lists.linux.dev \
    --cc=rafal@milecki.pl \
    --cc=ray.jui@broadcom.com \
    --cc=robh@kernel.org \
    --cc=scott.branden@broadcom.com \
    --cc=william.zhang@broadcom.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