Skip to contentSkip to conversation

Enable PSCI services for booting Linux

PATCH New chee.hong.ang at intel.com 3 participants 8 messages May 7, 2019 – May 9, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Enable PSCI services for booting Linux

From: "Ang, Chee Hong" <[email protected]>

Add "SYTEM_RESET" (cold reset) and "CPU_ON" (SMP) PSCI support for booting Linux on Stratix 10 platform.

Ang, Chee Hong (3):
ARM: socfpga: stratix10: Enable PSCI system reset
ARM: socfpga: stratix10: Enable PSCI CPU_ON
ARM: socfpga: stratix10: Enable PSCI support for Stratix 10

 arch/arm/mach-socfpga/Kconfig  |  9 ++++++-
 arch/arm/mach-socfpga/Makefile |  3 +++
 arch/arm/mach-socfpga/psci.c   | 56 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 67 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/mach-socfpga/psci.c
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/3 ARM: socfpga: stratix10: Enable PSCI system reset

From: "Ang, Chee Hong" <[email protected]>

Enable psci_system_reset support for Stratix10. This PSCI function will eventually trigger the mailbox HPS_REBOOT to SDM.

---
 arch/arm/mach-socfpga/Makefile |  3 +++
 arch/arm/mach-socfpga/psci.c   | 21 +++++++++++++++++++++
 2 files changed, 24 insertions(+)
 create mode 100644 arch/arm/mach-socfpga/psci.c
arch/arm/mach-socfpga/Makefile +3 -0
index e667204..f77b229 100644
@@ -38,6 +38,9 @@ obj-y	+= system_manager_s10.o
 obj-y	+= timer_s10.o
 obj-y	+= wrap_pinmux_config_s10.o
 obj-y	+= wrap_pll_config_s10.o
+ifndef CONFIG_SPL_BUILD
+obj-$(CONFIG_ARMV8_PSCI)	+= psci.o
+endif
 endif
 
 ifdef CONFIG_SPL_BUILD
arch/arm/mach-socfpga/psci.c new file +21 -0
new file mode 100644
index 0000000..9ef3931
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/psci.h>
+#include <errno.h>
+#include <asm/arch/mailbox_s10.h>
+#include <asm/secure.h>
+
+void __noreturn __secure psci_system_reset(void)
+{
+	mbox_send_cmd_psci(MBOX_ID_UBOOT, MBOX_REBOOT_HPS,
+			   MBOX_CMD_DIRECT, 0, NULL, 0, 0, NULL);
+
+	while (1)
+		;
+}
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/3 ARM: socfpga: stratix10: Enable PSCI CPU_ON

In reply to chee.hong.ang at intel.com

From: "Ang, Chee Hong" <[email protected]>

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.

---
 arch/arm/mach-socfpga/psci.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
arch/arm/mach-socfpga/psci.c +35 -0
index 9ef3931..0af3eb1 100644
@@ -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;
+}
Signature · 1 line
2.7.4
#3 lore raw

PATCH 3/3 ARM: socfpga: stratix10: Enable PSCI support for Stratix 10

In reply to chee.hong.ang at intel.com

From: "Ang, Chee Hong" <[email protected]>

The address of PSCI text, data and stack sections start at 0x00001000 (SDRAM).

---
 arch/arm/mach-socfpga/Kconfig | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
arch/arm/mach-socfpga/Kconfig +8 -1
index 8f7b79f..6fb508e 100644
@@ -12,6 +12,12 @@ config SPL_SYS_MALLOC_F_LEN
 config SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION_TYPE
 	default 0xa2
 
+config ARMV8_SECURE_BASE
+	default 0x00001000 if TARGET_SOCFPGA_STRATIX10
+
+config SYS_HAS_ARMV8_SECURE_BASE
+	default y if TARGET_SOCFPGA_STRATIX10
+
 config SYS_MALLOC_F_LEN
 	default 0x2000 if TARGET_SOCFPGA_ARRIA10
 	default 0x2000 if TARGET_SOCFPGA_GEN5
@@ -56,8 +62,9 @@ config TARGET_SOCFPGA_GEN5
 config TARGET_SOCFPGA_STRATIX10
 	bool
 	select ARMV8_MULTIENTRY
+	select ARMV8_PSCI
+	select ARMV8_SEC_FIRMWARE_SUPPORT
 	select ARMV8_SET_SMPEN
-	select ARMV8_SPIN_TABLE
 	select FPGA_STRATIX10
 
 choice
Signature · 1 line
2.7.4
#4 lore raw

cover Enable PSCI services for booting Linux

In reply to chee.hong.ang at intel.com
Quoted 10 lines · chee.hong.ang at intel.com

From: "Ang, Chee Hong" <[email protected]>

Add "SYTEM_RESET" (cold reset) and "CPU_ON" (SMP) PSCI support for booting Linux on Stratix 10 platform.

Ang, Chee Hong (3):
  ARM: socfpga: stratix10: Enable PSCI system reset
  ARM: socfpga: stratix10: Enable PSCI CPU_ON
  ARM: socfpga: stratix10: Enable PSCI support for Stratix 10

Quoted 7 lines

 arch/arm/mach-socfpga/Kconfig  |  9 ++++++-
 arch/arm/mach-socfpga/Makefile |  3 +++
 arch/arm/mach-socfpga/psci.c   | 56
++++++++++++++++++++++++++++++++++++++++++

 3 files changed, 67 insertions(+), 1 deletion(-)

 create mode 100644 arch/arm/mach-socfpga/psci.c

Hi Marek,

Any comment on this ? These PSCI patches are needed for booting Linux on our S10 platform.

BR,
Ang

#5 lore raw

cover Enable PSCI services for booting Linux

Quoted 18 lines · Chee Hong
Quoted 10 lines · chee.hong.ang at intel.com

From: "Ang, Chee Hong" <[email protected]>

Add "SYTEM_RESET" (cold reset) and "CPU_ON" (SMP) PSCI support for booting Linux on Stratix 10 platform.

Ang, Chee Hong (3):
  ARM: socfpga: stratix10: Enable PSCI system reset
  ARM: socfpga: stratix10: Enable PSCI CPU_ON
  ARM: socfpga: stratix10: Enable PSCI support for Stratix 10

Quoted 7 lines

 arch/arm/mach-socfpga/Kconfig  |  9 ++++++-
 arch/arm/mach-socfpga/Makefile |  3 +++
 arch/arm/mach-socfpga/psci.c   | 56
++++++++++++++++++++++++++++++++++++++++++

 3 files changed, 67 insertions(+), 1 deletion(-)

 create mode 100644 arch/arm/mach-socfpga/psci.c

Quoted 4 lines

Hi Marek,

Any comment on this ? These PSCI patches are needed for booting Linux on our S10 platform.

Same questions as in Re: [PATCH v1 0/3] Enable HPS execution stage notification , can we stop adding more and more stuff to arch/ and instead add it to drivers/ ? As you might have noticed, we are trying to remove stuff from arch/ and move as much as possible to drivers/ , but S10 is doing the exact opposite :(

Signature · 2 lines
Best regards,
Marek Vasut
#6 lore raw

cover Enable PSCI services for booting Linux

Quoted 26 lines · Marek Vasut
Quoted 20 lines · Chee Hong
Quoted 11 lines · chee.hong.ang at intel.com

From: "Ang, Chee Hong" <[email protected]>

Add "SYTEM_RESET" (cold reset) and "CPU_ON" (SMP) PSCI support for booting Linux on Stratix 10 platform.

Ang, Chee Hong (3):
  ARM: socfpga: stratix10: Enable PSCI system reset
  ARM: socfpga: stratix10: Enable PSCI CPU_ON
  ARM: socfpga: stratix10: Enable PSCI support for Stratix 10

Quoted 7 lines

 arch/arm/mach-socfpga/Kconfig  |  9 ++++++-
 arch/arm/mach-socfpga/Makefile |  3 +++
 arch/arm/mach-socfpga/psci.c   | 56
++++++++++++++++++++++++++++++++++++++++++

 3 files changed, 67 insertions(+), 1 deletion(-)

 create mode 100644 arch/arm/mach-socfpga/psci.c

Quoted 5 lines

Hi Marek,

Any comment on this ? These PSCI patches are needed for booting Linux
on our S10 platform.

Quoted 8 lines

Same questions as in Re: [PATCH v1 0/3] Enable HPS execution stage notification , can we stop adding more and more stuff to arch/ and instead add it to drivers/ ? As you might have noticed, we are trying to
remove stuff from arch/ and move as much as possible to drivers/ , but
S10 is doing the exact opposite :(

Not all PSCI code fit in DM (drivers/). There should be a good place to keep the PSCI code for our platform. Can you advise us where should we place those PSCI implementation other than arch/ ?

#7 lore raw

cover Enable PSCI services for booting Linux

Quoted 35 lines · Chee Hong
Quoted 26 lines · Marek Vasut
Quoted 20 lines · Chee Hong
Quoted 11 lines · chee.hong.ang at intel.com

From: "Ang, Chee Hong" <[email protected]>

Add "SYTEM_RESET" (cold reset) and "CPU_ON" (SMP) PSCI support for booting Linux on Stratix 10 platform.

Ang, Chee Hong (3):
  ARM: socfpga: stratix10: Enable PSCI system reset
  ARM: socfpga: stratix10: Enable PSCI CPU_ON
  ARM: socfpga: stratix10: Enable PSCI support for Stratix 10

Quoted 7 lines

 arch/arm/mach-socfpga/Kconfig  |  9 ++++++-
 arch/arm/mach-socfpga/Makefile |  3 +++
 arch/arm/mach-socfpga/psci.c   | 56
++++++++++++++++++++++++++++++++++++++++++

 3 files changed, 67 insertions(+), 1 deletion(-)

 create mode 100644 arch/arm/mach-socfpga/psci.c

Quoted 5 lines

Hi Marek,

Any comment on this ? These PSCI patches are needed for booting Linux
on our S10 platform.

Quoted 8 lines

Same questions as in Re: [PATCH v1 0/3] Enable HPS execution stage notification , can we stop adding more and more stuff to arch/ and instead add it to drivers/ ? As you might have noticed, we are trying to
remove stuff from arch/ and move as much as possible to drivers/ , but
S10 is doing the exact opposite :(

Quoted 3 lines

Not all PSCI code fit in DM (drivers/). There should be a good place to keep the PSCI code for our platform. Can you advise us where should we place those PSCI implementation other than arch/ ?

Look through this discussion:
https://www.mail-archive.com/u-boot at lists.denx.de/msg319458.html and possibly follow up on it.

Signature · 2 lines
Best regards,
Marek Vasut