[PATCH 1/3] platform: generic: spacemit: k3: de-vote cluster power-downs and ungate DMASYS before CCI enable

Valentin Haudiquet valentin.haudiquet at canonical.com
Mon Aug 31 13:07:50 PDT 2026


The v3 patch enables CCI-550 snoop/DVM requests for all seven slave
interfaces before de-voting cluster power-downs.  Clusters that are
still voted for power-down cause the CCI status change-pending
busy-wait to hang indefinitely when snoop/DVM is enabled on their
slave interfaces.

De-vote power-down for all four clusters and the boot hart's core
BEFORE enabling CCI.  Also deassert DMASYS reset and enable its clock
before CCI: the DMA engine sits behind the AIDMA CCI slave interface,
and if DMASYS is held in reset the CCI busy-wait hangs when enabling
snoop/DVM on that interface.

Add DMASYS_RESET and DMASYS_CLK_EN register definitions to k3.h.

Signed-off-by: Valentin Haudiquet <valentin.haudiquet at canonical.com>
---
 platform/generic/include/spacemit/k3.h |  5 +++
 platform/generic/spacemit/k3.c         | 50 ++++++++++++++++++++++----
 2 files changed, 48 insertions(+), 7 deletions(-)

diff --git a/platform/generic/include/spacemit/k3.h b/platform/generic/include/spacemit/k3.h
index f444d064..ed1637b9 100644
--- a/platform/generic/include/spacemit/k3.h
+++ b/platform/generic/include/spacemit/k3.h
@@ -124,4 +124,9 @@
 #define PLAT_CCI_K3_CLUSTER3_0_IFACE_IX	5
 #define PLAT_CCI_K3_CLUSTER3_1_IFACE_IX	6
 
+/* DMASYS reset and clock enable */
+#define DMASYS_RESET				(0xd8440000 + 0x22c)
+#define DMASYS_CLK_EN				(0xd8440000 + 0x234)
+#define DMASYS_RESET_DEASSERT			BIT(0)
+#define DMASYS_CLK_EN_BIT			BIT(0)
 #endif /* __RISCV_SPACEMIT_K3_H__ */
diff --git a/platform/generic/spacemit/k3.c b/platform/generic/spacemit/k3.c
index 967d09bf..12c991b6 100644
--- a/platform/generic/spacemit/k3.c
+++ b/platform/generic/spacemit/k3.c
@@ -56,14 +56,39 @@ static void spacemit_k3_hart_init(u32 hartid)
 	}
 }
 
-/* The boot hart is already running, so it is never started by the HSM. */
-static void spacemit_k3_keep_boot_hart_powered(void)
+/*
+ * De-vote power-down for all four clusters.  This must happen BEFORE
+ * CCI snoop/DVM enable: clusters still in power-down vote cause the
+ * CCI busy-wait to hang when enabling snoop/DVM on their slave interfaces.
+ */
+static void spacemit_k3_keep_all_clusters_powered(void)
 {
 	u32 value;
+	int i;
 
-	value = readl((void *)(unsigned long)PMU_CX_CAPMP_IDLE_CFG0);
-	value &= ~CLUSTER_PWR_DOWN_VALUE;
-	writel(value, (void *)(unsigned long)PMU_CX_CAPMP_IDLE_CFG0);
+	static const u32 cluster_idle_regs[] = {
+		PMU_CX_CAPMP_IDLE_CFG0,   /* cluster 0 (harts 0-3)  */
+		PMU_CX_CAPMP_IDLE_CFG4,   /* cluster 1 (harts 4-7)  */
+		PMU_CX_CAPMP_IDLE_CFG8,   /* cluster 2 (harts 8-11) */
+		PMU_CX_CAPMP_IDLE_CFG12,  /* cluster 3 (harts 12-15) */
+	};
+
+	for (i = 0; i < 4; i++) {
+		value = readl((void *)(unsigned long)cluster_idle_regs[i]);
+		value &= ~CLUSTER_PWR_DOWN_VALUE;
+		writel(value, (void *)(unsigned long)cluster_idle_regs[i]);
+	}
+}
+
+/*
+ * De-vote the boot hart's core-level power-down.  The cluster-level
+ * de-vote for cluster 0 is already done by keep_all_clusters_powered();
+ * this clears the per-core idle config so the boot hart is never
+ * powered down by the PMU.
+ */
+static void spacemit_k3_keep_boot_hart_powered(void)
+{
+	u32 value;
 
 	value = readl((void *)(unsigned long)PMU_AP_CORE0_IDLE_CFG);
 	value &= ~PMU_AP_IDLE_PWRDOWN_K3_MASK;
@@ -88,10 +113,21 @@ static void spacemit_k3_pre_init(void)
 	writel((u32)entry, (void *)(unsigned long)C3_RVBADDR_LO_ADDR);
 	writel((u32)(entry >> 32), (void *)(unsigned long)C3_RVBADDR_HI_ADDR);
 
+	/* De-vote all cluster power-downs BEFORE CCI enable. */
+	spacemit_k3_keep_all_clusters_powered();
+	spacemit_k3_keep_boot_hart_powered();
+
+	/*
+	 * Deassert DMASYS reset and enable its clock before CCI: the DMA
+	 * engine sits behind the AIDMA CCI slave interface.  If DMASYS is
+	 * held in reset or its clock is gated, the CCI busy-wait hangs when
+	 * enabling snoop/DVM on that interface.
+	 */
+	writel(DMASYS_RESET_DEASSERT, (void *)(unsigned long)DMASYS_RESET);
+	writel(DMASYS_CLK_EN_BIT, (void *)(unsigned long)DMASYS_CLK_EN);
+
 	for (i = 0; i < array_size(cci_map); i++)
 		cci_enable_snoop_dvm_reqs(cci_map, i);
-
-	spacemit_k3_keep_boot_hart_powered();
 }
 
 static int spacemit_k3_early_init(bool cold_boot)
-- 
2.53.0




More information about the opensbi mailing list