summaryrefslogtreecommitdiffstats
path: root/bsp/meta-altera/recipes-bsp/u-boot/files/v2019.07/0002-ARM-socfpga-stratix10-Enable-PSCI-CPU_ON.patch
blob: ebf6fe7e1001cfe0479243620fb237c8f1176199 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
From 257cff780ec1a50600a77cf361df27746801d684 Mon Sep 17 00:00:00 2001
From: "Ang, Chee Hong" <chee.hong.ang@intel.com>
Date: Mon, 14 Jan 2019 01:07:50 -0800
Subject: [PATCH 02/12] ARM: socfpga: stratix10: Enable PSCI CPU_ON

Enable psci_cpu_on support for Stratix10. This PSCI function
will pass the cpu release address for CPU1-CPU3. Then send event
signal shall be triggered to get these CPUs running Linux code.

Signed-off-by: Ang, Chee Hong <chee.hong.ang@intel.com>
---
 arch/arm/mach-socfpga/psci.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/arch/arm/mach-socfpga/psci.c b/arch/arm/mach-socfpga/psci.c
index 9ef393110d..0af3eb195c 100644
--- a/arch/arm/mach-socfpga/psci.c
+++ b/arch/arm/mach-socfpga/psci.c
@@ -11,6 +11,9 @@
 #include <asm/arch/mailbox_s10.h>
 #include <asm/secure.h>
 
+static u64 psci_cpu_on_64_cpuid __secure_data;
+static u64 psci_cpu_on_64_entry_point __secure_data;
+
 void __noreturn __secure psci_system_reset(void)
 {
 	mbox_send_cmd_psci(MBOX_ID_UBOOT, MBOX_REBOOT_HPS,
@@ -19,3 +22,35 @@ void __noreturn __secure psci_system_reset(void)
 	while (1)
 		;
 }
+
+/* This function will handle multiple core release based PSCI */
+void __secure psci_cpu_on_64_mpidr(void)
+{
+	asm volatile(
+		".align	5			\n"
+		"1:	wfe			\n"
+		"	ldr	x0, [%0]	\n"
+		"	ldr	x1, [%1]	\n"
+		"	mrs	x2, mpidr_el1	\n"
+		"	and	x2, x2, #0xff	\n"
+		"	cmp	x0, x2		\n"
+		"	b.ne	1b		\n"
+		"	br	x1		\n"
+	: : "r"(&psci_cpu_on_64_cpuid), "r"(&psci_cpu_on_64_entry_point)
+	: "x0", "x1", "x2", "memory", "cc");
+}
+
+int __secure psci_cpu_on_64(u32 function_id, u64 cpuid, u64 entry_point)
+{
+	/* Releases all secondary CPUs to jump into psci_cpu_on_64_mpidr */
+	writeq(0, &psci_cpu_on_64_cpuid);
+	writeq(0, &psci_cpu_on_64_entry_point);
+	writeq((u64)&psci_cpu_on_64_mpidr, CPU_RELEASE_ADDR);
+
+	/* to store in global so psci_cpu_on_64_mpidr function can refer */
+	writeq(entry_point, &psci_cpu_on_64_entry_point);
+	writeq(cpuid, &psci_cpu_on_64_cpuid);
+	asm volatile("sev");
+
+	return ARM_PSCI_RET_SUCCESS;
+}
-- 
2.21.0