Add ARMv8 PSCI framework
v2 cover Add ARMv8 PSCI framework
From: Hongbo Zhang <[email protected]>
v1-v2 changes:
- The new config options are introduced in Kconfig when used for first time
- Introduce new config options in armv8/Kconfig instead of LS1043 platform
- Move previous patch 5/6 to current 2/6 place
v1 notes:
This patch set introduces ARMv8 PSCI framework, all the PSCI functions are implemented a default dummy one, it is up to each platform to implement their own specific ones.
The first 1/6 patch is a prepare clean up for adding ARMv8 PSCI. Patches 2/6 to 5/6 introduce new ARMv8 framework and set it up. The last 6/6 adds a most simple implementation on NXP LS1043 platform, to verify this framework.
This patch set mainly introduces ARMv8 PSCI framework, for easier review and merge, further PSCI implementation on LS1043 is coming later.
Hongbo Zhang (6):
ARMv8: LS1043A: change macro CONFIG_ARMV8_PSCI definition
ARMv8: Enable SMC instruction
ARMv8: Add secure sections for PSCI text and data
ARMv8: Add basic PSCI framework
ARMv8: Setup PSCI memory and dt
ARMv8: LS1043A: Enable LS1043A default PSCI support
arch/arm/config.mk | 3 +- arch/arm/cpu/armv8/Kconfig | 44 ++++ arch/arm/cpu/armv8/Makefile | 1 + arch/arm/cpu/armv8/cpu-dt.c | 12 +- arch/arm/cpu/armv8/cpu.c | 22 ++ arch/arm/cpu/armv8/fsl-layerscape/Makefile | 1 + arch/arm/cpu/armv8/fsl-layerscape/cpu.c | 3 +- arch/arm/cpu/armv8/fsl-layerscape/fdt.c | 3 +- arch/arm/cpu/armv8/fsl-layerscape/ls1043a_psci.S | 20 ++ arch/arm/cpu/armv8/psci.S | 286 +++++++++++++++++++++++ arch/arm/cpu/armv8/sec_firmware.c | 2 +- arch/arm/cpu/armv8/sec_firmware_asm.S | 2 +- arch/arm/cpu/armv8/u-boot.lds | 57 +++++ arch/arm/include/asm/armv8/sec_firmware.h | 2 +- arch/arm/include/asm/macro.h | 2 +- arch/arm/include/asm/psci.h | 15 ++ arch/arm/include/asm/secure.h | 2 +- arch/arm/include/asm/system.h | 11 + arch/arm/lib/bootm-fdt.c | 3 +- arch/arm/lib/bootm.c | 3 + arch/arm/lib/psci-dt.c | 5 +- board/freescale/ls1043ardb/Kconfig | 9 + configs/ls1043ardb_defconfig | 1 + include/configs/ls1043ardb.h | 2 +- 24 files changed, 498 insertions(+), 13 deletions(-) create mode 100644 arch/arm/cpu/armv8/fsl-layerscape/ls1043a_psci.S create mode 100644 arch/arm/cpu/armv8/psci.S
Signature · 1 line
2.1.4
PATCH v2 1/6 ARMv8: LS1043A: change macro CONFIG_ARMV8_PSCI definition
From: Hongbo Zhang <[email protected]>
NXP/Freescale uses macro CONFIG_ARMV8_PSCI to enable their private PSCI implementation in PPA firmware, but this macro naming too generic, so this patch replaces it with a specic one CONFIG_FSL_PPA_ARMV8_PSCI. And this macro CONFIG_ARMV8_PSCI will be used for a generic PSCI for ARMv8 which will be added in following patchs.
--- arch/arm/cpu/armv8/cpu-dt.c | 2 +- arch/arm/cpu/armv8/fsl-layerscape/cpu.c | 3 ++- arch/arm/cpu/armv8/fsl-layerscape/fdt.c | 3 ++- arch/arm/cpu/armv8/sec_firmware.c | 2 +- arch/arm/cpu/armv8/sec_firmware_asm.S | 2 +- arch/arm/include/asm/armv8/sec_firmware.h | 2 +- arch/arm/lib/bootm-fdt.c | 2 +- arch/arm/lib/psci-dt.c | 2 +- include/configs/ls1043ardb.h | 2 +- 9 files changed, 11 insertions(+), 9 deletions(-)
arch/arm/cpu/armv8/cpu-dt.c +1 -1
@@ -13,7 +13,7 @@int psci_update_dt (void *fdt) {#ifdef CONFIG_MP -#if defined(CONFIG_ARMV8_PSCI ) +#if defined(CONFIG_FSL_PPA_ARMV8_PSCI )#ifdef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT /* * If the PSCI in SEC Firmware didn't work, avoid to update the
arch/arm/cpu/armv8/fsl-layerscape/cpu.c +2 -1
@@ -402,7 +402,8 @@ int arch_early_init_r(void)#endif #ifdef CONFIG_MP -#if defined(CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT ) && defined(CONFIG_ARMV8_PSCI ) +#if defined(CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT ) && \ + defined(CONFIG_FSL_PPA_ARMV8_PSCI )/* Check the psci version to determine if the psci is supported */ psci_ver =sec_firmware_support_psci_version ();#endif
arch/arm/cpu/armv8/fsl-layerscape/fdt.c +2 -1
@@ -41,7 +41,8 @@ void ft_fixup_cpu(void *blob)int addr_cells;u64 val, core_id;size_t *boot_code_size = &(__secondary_boot_code_size); -#if defined(CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT ) && defined(CONFIG_ARMV8_PSCI ) +#if defined(CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT ) && \ + defined(CONFIG_FSL_PPA_ARMV8_PSCI )int node;u32 psci_ver;
arch/arm/cpu/armv8/sec_firmware.c +1 -1
@@ -209,7 +209,7 @@ __weak bool sec_firmware_is_valid(const void *sec_firmware_img)return true; } -#ifdef CONFIG_ARMV8_PSCI +#ifdef CONFIG_FSL_PPA_ARMV8_PSCI /* * The PSCI_VERSION function is added from PSCI v0.2. When the PSCI * v0.1 received this function, the NOT_SUPPORTED (0xffff_ffff) error
arch/arm/cpu/armv8/sec_firmware_asm.S +1 -1
@@ -41,7 +41,7 @@ WEAK(_sec_firmware_entry) ret ENDPROC(_sec_firmware_entry) -#ifdef CONFIG_ARMV8_PSCI +#ifdef CONFIG_FSL_PPA_ARMV8_PSCI ENTRY(_sec_firmware_support_psci_version) mov x0, 0x84000000 mov x1, 0x0
arch/arm/include/asm/armv8/sec_firmware.h +1 -1
@@ -14,7 +14,7 @@int sec_firmware_init (const void *,u32 *,u32 *);int _sec_firmware_entry (const void *,u32 *,u32 *);bool sec_firmware_is_valid (const void *); -#ifdef CONFIG_ARMV8_PSCI +#ifdef CONFIG_FSL_PPA_ARMV8_PSCI unsigned int sec_firmware_support_psci_version (void );unsigned int _sec_firmware_support_psci_version (void );#endif
arch/arm/lib/bootm-fdt.c +1 -1
@@ -53,7 +53,7 @@ int arch_fixup_fdt(void *blob)return ret;#endif -#if defined(CONFIG_ARMV7_NONSEC ) || defined(CONFIG_ARMV8_PSCI ) +#if defined(CONFIG_ARMV7_NONSEC ) || defined(CONFIG_FSL_PPA_ARMV8_PSCI ) ret =psci_update_dt (blob);if (ret)return ret;
arch/arm/lib/psci-dt.c +1 -1
@@ -16,7 +16,7 @@int fdt_psci (void *fdt) { -#if defined(CONFIG_ARMV8_PSCI ) || defined(CONFIG_ARMV7_PSCI ) +#if defined(CONFIG_FSL_PPA_ARMV8_PSCI ) || defined(CONFIG_ARMV7_PSCI )int nodeoff;unsigned int psci_ver =0 ;int tmp;
include/configs/ls1043ardb.h +1 -1
@@ -12,7 +12,7 @@#if defined(CONFIG_FSL_LS_PPA )#define CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT #define SEC_FIRMWARE_ERET_ADDR_REVERT -#define CONFIG_ARMV8_PSCI +#define CONFIG_FSL_PPA_ARMV8_PSCI #define CONFIG_SYS_LS_PPA_FW_IN_XIP #ifdef CONFIG_SYS_LS_PPA_FW_IN_XIP
Signature · 1 line
2.1.4
PATCH v2 1/6 ARMv8: LS1043A: change macro CONFIG_ARMV8_PSCI definition
Quoted 9 lines · macro.wave.z at gmail.com
From: Hongbo Zhang <[email protected]>
NXP/Freescale uses macro
CONFIG_ARMV8_PSCIto enable their private PSCI implementation in PPA firmware, but this macro naming too generic, so this patch replaces it with a specic oneCONFIG_FSL_PPA_ARMV8_PSCI. And this macroCONFIG_ARMV8_PSCIwill be used for a generic PSCI for ARMv8 which will be added in following patchs.Signed-off-by Hongbo Zhang <[email protected]>
[snip]
include/configs/ls1043ardb.h line 18
Quoted 13 lines
include/configs/ls1043ardb.h +1
-1@@ -12,7 +12,7 @@#if defined(CONFIG_FSL_LS_PPA )#define CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT #define SEC_FIRMWARE_ERET_ADDR_REVERT -#define CONFIG_ARMV8_PSCI +#define CONFIG_FSL_PPA_ARMV8_PSCI #define CONFIG_SYS_LS_PPA_FW_IN_XIP #ifdef CONFIG_SYS_LS_PPA_FW_IN_XIP
This will trip-up the whitelist check, please move the new symbol to Kconfig and select it from LS1043ARDB + FSL_LS_PPA. Thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161102/8ae87eb0/attachment.sig>
PATCH v2 1/6 ARMv8: LS1043A: change macro CONFIG_ARMV8_PSCI definition
Quoted 23 lines · Tom Rini
Quoted 9 lines · macro.wave.z at gmail.com
From: Hongbo Zhang <[email protected]>
NXP/Freescale uses macro
CONFIG_ARMV8_PSCIto enable their private PSCI implementation in PPA firmware, but this macro naming too generic, so this patch replaces it with a specic oneCONFIG_FSL_PPA_ARMV8_PSCI. And this macroCONFIG_ARMV8_PSCIwill be used for a generic PSCI for ARMv8 which will be added in following patchs.Signed-off-by Hongbo Zhang <[email protected]>[snip]
Quoted 11 lines
include/configs/ls1043ardb.h +1
-1@@ -12,7 +12,7 @@#if defined(CONFIG_FSL_LS_PPA )#define CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT #define SEC_FIRMWARE_ERET_ADDR_REVERT -#define CONFIG_ARMV8_PSCI +#define CONFIG_FSL_PPA_ARMV8_PSCI
Quoted 6 lines
include/configs/ls1043ardb.h line 18
Quoted 2 lines
include/configs/ls1043ardb.h +0
-0#define CONFIG_SYS_LS_PPA_FW_IN_XIP #ifdef CONFIG_SYS_LS_PPA_FW_IN_XIP This will trip-up the whitelist check, please move the new symbol to
Kconfigand select it from LS1043ARDB +FSL_LS_PPA. Thanks!
Payed much attention to the config options I introduced in the common framework, but neglected this legacy one.
Yes will update this.
Quoted 2 lines
--
Tom
PATCH v2 1/6 ARMv8: LS1043A: change macro CONFIG_ARMV8_PSCI definition
Talked to the author Zhiqiang Hou who introduced the previous CONFIG_ARMV8_PSCI, although this config was introduced due to FSL PPA, codes covered by it in the armv8/cpu-dt.c, bootm-dt.c, psci-dt.c also work for the coming generic ARMv8 PSCI framework, what's more, Zhiqiang is sending patches to clean up PPA related configs to Kconfig, so I don't need to send this 1/6 patch any more, I'll send the other updated 5 patches in v3.
Quoted 37 lines · Hongbo Zhang
Quoted 23 lines · Tom Rini
Quoted 9 lines · macro.wave.z at gmail.com
From: Hongbo Zhang <[email protected]>
NXP/Freescale uses macro
CONFIG_ARMV8_PSCIto enable their private PSCI implementation in PPA firmware, but this macro naming too generic, so this patch replaces it with a specic oneCONFIG_FSL_PPA_ARMV8_PSCI. And this macroCONFIG_ARMV8_PSCIwill be used for a generic PSCI for ARMv8 which will be added in following patchs.Signed-off-by Hongbo Zhang <[email protected]>[snip]
Quoted 11 lines
include/configs/ls1043ardb.h +1
-1@@ -12,7 +12,7 @@#if defined(CONFIG_FSL_LS_PPA )#define CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT #define SEC_FIRMWARE_ERET_ADDR_REVERT -#define CONFIG_ARMV8_PSCI +#define CONFIG_FSL_PPA_ARMV8_PSCI Quoted 6 lines
include/configs/ls1043ardb.h line 18
Quoted 2 lines
include/configs/ls1043ardb.h +0
-0#define CONFIG_SYS_LS_PPA_FW_IN_XIP #ifdef CONFIG_SYS_LS_PPA_FW_IN_XIP This will trip-up the whitelist check, please move the new symbol to
Kconfigand select it from LS1043ARDB +FSL_LS_PPA. Thanks!Payed much attention to the config options I introduced in the common framework, but neglected this legacy one.
Yes will update this.Quoted 2 lines
--
Tom
PATCH v2 2/6 ARMv8: Enable SMC instruction
In reply to macro.wave.z at gmail.comFrom: Hongbo Zhang <[email protected]>
PSCI implementation needs the SMC instruction to be enabled. Following the legacy codes pattern, no bit macro definition and bit operation are used, only the immediate data used in line is changed.
--- arch/arm/include/asm/macro.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/include/asm/macro.h +1 -1
@@ -137,7 +137,7 @@ lr .req x30 .macro armv8_switch_to_el2_m, xreg1 /* 64bit EL2 | HCE | SMD | RES1 (Bits[5:4]) | Non-secure EL0/EL1 */ - mov \xreg1, #0x5b1 + mov \xreg1, #0x531 msr scr_el3, \xreg1 msr cptr_el3, xzr /* Disable coprocessor traps to EL3 */ mov \xreg1, #0x33ff
Signature · 1 line
2.1.4
PATCH v2 2/6 ARMv8: Enable SMC instruction
Quoted 7 lines · macro.wave.z at gmail.com
From: Hongbo Zhang <[email protected]>
PSCI implementation needs the SMC instruction to be enabled. Following the legacy codes pattern, no bit macro definition and bit operation are used, only the immediate data used in line is changed.
Signed-off-by Hongbo Zhang <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161102/0660621a/attachment.sig>
PATCH v2 3/6 ARMv8: Add secure sections for PSCI text and data
In reply to macro.wave.z at gmail.comFrom: Hongbo Zhang <[email protected]>
This patch adds secure_text, secure_data and secure_stack sections for ARMv8 to hold PSCI text and data, and it is based on the legacy implementation of ARMv7.
--- arch/arm/config.mk | 3 ++- arch/arm/cpu/armv8/Kconfig | 31 +++++++++++++++++++++++ arch/arm/cpu/armv8/u-boot.lds | 57 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+), 1 deletion(-)
arch/arm/config.mk +2 -1
@@ -118,7 +118,8 @@ endif # limit ourselves to the sections we want in the .bin. ifdef CONFIG_ARM64 -OBJCOPYFLAGS += -j .text -j .rodata -j .data -j .u_boot_list -j .rela.dyn +OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata -j .data \ + -j .u_boot_list -j .rela.dyn else OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata -j .hash \ -j .data -j .got -j .got.plt -j .u_boot_list -j .rel.dyn
arch/arm/cpu/armv8/Kconfig +31 -0
@@ -39,4 +39,35 @@ config PSCI_RESET Select Y here to make use of PSCI calls for system reset +config ARMV8_PSCI + bool "Enable PSCI support" if EXPERT + default n + help + PSCI is Power State Coordination Interface defined by ARM. + The PSCI in U-boot provides a general framework and each platform + can implement their own specific PSCI functions. + Say Y here to enable PSCI support on ARMv8 platform. + +config ARMV8_PSCI_NR_CPUS + int "Maximum supported CPUs for PSCI" + depends on ARMV8_PSCI + default 4 + help + The maximum number of CPUs supported in the PSCI firmware. + It is no problem to set a larger value than the number of CPUs in + the actual hardware implementation. + +if SYS_HAS_ARMV8_SECURE_BASE + +config ARMV8_SECURE_BASE + hex "Secure address for PSCI image" + depends on ARMV8_PSCI + help + Address for placing the PSCI text, data and stack sections. + If not defined, the PSCI sections are placed together with the u-boot + but platform can choose to place PSCI code image separately in other + places such as some secure RAM built-in SOC etc. + +endif + endif
arch/arm/cpu/armv8/u-boot.lds +57 -0
74 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v2 3/6 ARMv8: Add secure sections for PSCI text and data
Quoted 6 lines · macro.wave.z at gmail.com
From: Hongbo Zhang <[email protected]>
This patch adds
secure_text,secure_dataandsecure_stacksections for ARMv8 to hold PSCI text and data, and it is based on the legacy implementation of ARMv7.Signed-off-by Hongbo Zhang <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161102/a5fb4d77/attachment.sig>
PATCH v2 4/6 ARMv8: Add basic PSCI framework
In reply to macro.wave.z at gmail.comFrom: Hongbo Zhang <[email protected]>
This patch introduces a generic ARMv8 PSCI framework, with all functions returning a dummy ARM_PSCI_RET_NI (Not Implemented), then it is up to each platform to implement their own functions based on this framework.
--- arch/arm/cpu/armv8/Kconfig | 10 ++ arch/arm/cpu/armv8/Makefile | 1 + arch/arm/cpu/armv8/psci.S | 286 ++++++++++++++++++++++++++++++++++++++++++++ arch/arm/include/asm/psci.h | 15 +++ 4 files changed, 312 insertions(+) create mode 100644 arch/arm/cpu/armv8/psci.S
arch/arm/cpu/armv8/Kconfig +10 -0
@@ -57,6 +57,16 @@ config ARMV8_PSCI_NR_CPUS It is no problem to set a larger value than the number of CPUs in the actual hardware implementation. +config ARMV8_PSCI_CPUS_PER_CLUSTER + int "Number of CPUs per cluster" + depends on ARMV8_PSCI + default 0 + help + The number of CPUs per cluster, suppose each cluster has same number + of CPU cores, platforms with asymmetric clusters don't apply here. + A value 0 or no definition of it works for single cluster system. + System with multi-cluster should difine their own exact value. + if SYS_HAS_ARMV8_SECURE_BASE config ARMV8_SECURE_BASE
arch/arm/cpu/armv8/Makefile +1 -0
@@ -25,3 +25,4 @@ obj-$(CONFIG_FSL_LAYERSCAPE) += fsl-layerscape/ obj-$(CONFIG_S32V234) += s32v234/ obj-$(CONFIG_ARCH_ZYNQMP) += zynqmp/ obj-$(CONFIG_TARGET_HIKEY) += hisilicon/ +obj-$(CONFIG_ARMV8_PSCI) += psci.o
arch/arm/cpu/armv8/psci.S new file +286 -0
286 lines not on this page · raw message
arch/arm/include/asm/psci.h +15 -0
@@ -45,6 +45,9 @@#define ARM_PSCI_0_2_FN_BASE 0x84000000#define ARM_PSCI_0_2_FN (n) (ARM_PSCI_0_2_FN_BASE + (n)) +#define ARM_PSCI_0_2_FN64_BASE 0xC4000000 +#define ARM_PSCI_0_2_FN64 (n) (ARM_PSCI_0_2_FN64_BASE + (n)) +#define ARM_PSCI_0_2_FN_PSCI_VERSION ARM_PSCI_0_2_FN(0)#define ARM_PSCI_0_2_FN_CPU_SUSPEND ARM_PSCI_0_2_FN(1)#define ARM_PSCI_0_2_FN_CPU_OFF ARM_PSCI_0_2_FN(2)
@@ -56,6 +59,12 @@#define ARM_PSCI_0_2_FN_SYSTEM_OFF ARM_PSCI_0_2_FN(8)#define ARM_PSCI_0_2_FN_SYSTEM_RESET ARM_PSCI_0_2_FN(9) +#define ARM_PSCI_0_2_FN64_CPU_SUSPEND ARM_PSCI_0_2_FN64(1) +#define ARM_PSCI_0_2_FN64_CPU_ON ARM_PSCI_0_2_FN64(3) +#define ARM_PSCI_0_2_FN64_AFFINITY_INFO ARM_PSCI_0_2_FN64(4) +#define ARM_PSCI_0_2_FN64_MIGRATE ARM_PSCI_0_2_FN64(5) +#define ARM_PSCI_0_2_FN64_MIGRATE_INFO_UP_CPU ARM_PSCI_0_2_FN64(7) +/* PSCI 1.0 interface */ #define ARM_PSCI_1_0_FN_PSCI_FEATURES ARM_PSCI_0_2_FN(10)#define ARM_PSCI_1_0_FN_CPU_FREEZE ARM_PSCI_0_2_FN(11)
@@ -66,6 +75,12 @@#define ARM_PSCI_1_0_FN_STAT_RESIDENCY ARM_PSCI_0_2_FN(16)#define ARM_PSCI_1_0_FN_STAT_COUNT ARM_PSCI_0_2_FN(17) +#define ARM_PSCI_1_0_FN64_CPU_DEFAULT_SUSPEND ARM_PSCI_0_2_FN64(12) +#define ARM_PSCI_1_0_FN64_NODE_HW_STATE ARM_PSCI_0_2_FN64(13) +#define ARM_PSCI_1_0_FN64_SYSTEM_SUSPEND ARM_PSCI_0_2_FN64(14) +#define ARM_PSCI_1_0_FN64_STAT_RESIDENCY ARM_PSCI_0_2_FN64(16) +#define ARM_PSCI_1_0_FN64_STAT_COUNT ARM_PSCI_0_2_FN64(17) +/* 1KB stack per core */ #define ARM_PSCI_STACK_SHIFT 10#define ARM_PSCI_STACK_SIZE (1 << ARM_PSCI_STACK_SHIFT)
Signature · 1 line
2.1.4
PATCH v2 5/6 ARMv8: Setup PSCI memory and dt
In reply to macro.wave.z at gmail.comFrom: Hongbo Zhang <[email protected]>
Newly add ARMv8 PSCI needs to be initialized, be copied or reserved in right place, this patch does all the setup steps.
--- arch/arm/cpu/armv8/cpu-dt.c | 10 ++++++++++ arch/arm/cpu/armv8/cpu.c | 22 ++++++++++++++++++++++ arch/arm/include/asm/secure.h | 2 +- arch/arm/include/asm/system.h | 11 +++++++++++ arch/arm/lib/bootm-fdt.c | 3 ++- arch/arm/lib/bootm.c | 3 +++ arch/arm/lib/psci-dt.c | 5 +++-- 7 files changed, 52 insertions(+), 4 deletions(-)
arch/arm/cpu/armv8/cpu-dt.c +10 -0
@@ -6,6 +6,7 @@#include <common.h> #include <asm/psci.h> +#include <asm/system.h> #ifdef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT #include <asm/armv8/sec_firmware.h> #endif
@@ -27,5 +28,14 @@ int psci_update_dt(void *fdt)fdt_psci (fdt);#endif #endif + +#ifdef CONFIG_ARMV8_PSCI +fdt_psci (fdt); +#ifndef CONFIG_ARMV8_SECURE_BASE +/* secure code lives in RAM, keep it alive */ +fdt_add_mem_rsv (fdt, (unsigned long )__secure_start, + __secure_end - __secure_start); +#endif +#endif return 0 ; }
arch/arm/cpu/armv8/cpu.c +22 -0
@@ -14,6 +14,7 @@#include <common.h> #include <command.h> #include <asm/system.h> +#include <asm/secure.h> #include <linux/compiler.h> int cleanup_before_linux (void )
@@ -41,3 +42,24 @@ int cleanup_before_linux(void)return 0 ; } + +#ifdef CONFIG_ARMV8_PSCI +static void relocate_secure_section (void ) +{ +#ifdef CONFIG_ARMV8_SECURE_BASE +size_t sz = __secure_end - __secure_start; + +memcpy ((void *)CONFIG_ARMV8_SECURE_BASE , __secure_start, sz); +flush_dcache_range (CONFIG_ARMV8_SECURE_BASE , +CONFIG_ARMV8_SECURE_BASE + sz +1 ); +invalidate_icache_all (); +#endif +} + +void armv8_setup_psci (void ) +{ +relocate_secure_section (); +secure_ram_addr (psci_setup_vectors)(); +secure_ram_addr (psci_arch_init)(); +} +#endif
arch/arm/include/asm/secure.h +1 -1
@@ -6,7 +6,7 @@#define __secure __attribute__ ((section ("._secure.text")))#define __secure_data __attribute__ ((section ("._secure.data"))) -#ifdef CONFIG_ARMV7_SECURE_BASE +#if defined(CONFIG_ARMV7_SECURE_BASE ) || defined(CONFIG_ARMV8_SECURE_BASE )/* * Warning, horror ahead. *
arch/arm/include/asm/system.h +11 -0
@@ -118,6 +118,17 @@ void smc_call(struct pt_regs *args);void __noreturn psci_system_reset (void );void __noreturn psci_system_off (void ); +#ifdef CONFIG_ARMV8_PSCI +extern char __secure_start[]; +extern char __secure_end[]; +extern char __secure_stack_start[]; +extern char __secure_stack_end[]; + +void armv8_setup_psci (void ); +void psci_setup_vectors (void ); +void psci_arch_init (void ); +#endif +#endif /* __ASSEMBLY__ */ #else /* CONFIG_ARM64 */
arch/arm/lib/bootm-fdt.c +2 -1
@@ -53,7 +53,8 @@ int arch_fixup_fdt(void *blob)return ret;#endif -#if defined(CONFIG_ARMV7_NONSEC ) || defined(CONFIG_FSL_PPA_ARMV8_PSCI ) +#if defined(CONFIG_ARMV7_NONSEC ) || defined(CONFIG_FSL_PPA_ARMV8_PSCI ) || \ + defined(CONFIG_ARMV8_PSCI ) ret =psci_update_dt (blob);if (ret)return ret;
arch/arm/lib/bootm.c +3 -0
@@ -291,6 +291,9 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)announce_and_cleanup (fake);if (!fake) { +#ifdef CONFIG_ARMV8_PSCI +armv8_setup_psci (); +#endif do_nonsec_virt_switch ();kernel_entry (images->ft_addr,NULL ,NULL ,NULL ); }
arch/arm/lib/psci-dt.c +3 -2
@@ -16,7 +16,8 @@int fdt_psci (void *fdt) { -#if defined(CONFIG_FSL_PPA_ARMV8_PSCI ) || defined(CONFIG_ARMV7_PSCI ) +#if defined(CONFIG_FSL_PPA_ARMV8_PSCI ) || defined(CONFIG_ARMV7_PSCI ) || \ + defined(CONFIG_ARMV8_PSCI )int nodeoff;unsigned int psci_ver =0 ;int tmp;
@@ -65,7 +66,7 @@ int fdt_psci(void *fdt) init_psci_node: #ifdef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT psci_ver =sec_firmware_support_psci_version (); -#elif defined(CONFIG_ARMV7_PSCI_1_0) +#elif defined(CONFIG_ARMV7_PSCI_1_0) || defined(CONFIG_ARMV8_PSCI) psci_ver =ARM_PSCI_VER_1_0 ;#endif switch (psci_ver) {
Signature · 1 line
2.1.4
PATCH v2 5/6 ARMv8: Setup PSCI memory and dt
Quoted 6 lines · macro.wave.z at gmail.com
From: Hongbo Zhang <[email protected]>
Newly add ARMv8 PSCI needs to be initialized, be copied or reserved in right place, this patch does all the setup steps.
Signed-off-by Hongbo Zhang <[email protected]>
[snip]
Quoted 16 lines
arch/arm/cpu/armv8/cpu-dt.c +1
-0@@ -6,6 +6,7 @@#include <common.h> #include <asm/psci.h> +#include <asm/system.h> #ifdef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT #include <asm/armv8/sec_firmware.h> #endif @@ -27,5 +28,14 @@ int psci_update_dt(void *fdt)fdt_psci (fdt);#endif #endif
arch/arm/cpu/armv8/cpu-dt.c int psci_update_dt(void *fdt) · line 40
Quoted 10 lines
arch/arm/cpu/armv8/cpu-dt.c +9
-0+ +#ifdef CONFIG_ARMV8_PSCI +fdt_psci (fdt); +#ifndef CONFIG_ARMV8_SECURE_BASE +/* secure code lives in RAM, keep it alive */ +fdt_add_mem_rsv (fdt, (unsigned long )__secure_start, + __secure_end - __secure_start); +#endif +#endif return 0 ;
Looking just above this context, I think we need to re-work the #if tests now when adding this in.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161102/0353e89b/attachment.sig>
PATCH v2 5/6 ARMv8: Setup PSCI memory and dt
Quoted 29 lines · Tom Rini
Quoted 6 lines · macro.wave.z at gmail.com
From: Hongbo Zhang <[email protected]>
Newly add ARMv8 PSCI needs to be initialized, be copied or reserved in right place, this patch does all the setup steps.
Signed-off-by Hongbo Zhang <[email protected]>[snip]
Quoted 21 lines
arch/arm/cpu/armv8/cpu-dt.c +6
-0@@ -6,6 +6,7 @@#include <common.h> #include <asm/psci.h> +#include <asm/system.h> #ifdef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT #include <asm/armv8/sec_firmware.h> #endif @@ -27,5 +28,14 @@ int psci_update_dt(void *fdt)fdt_psci (fdt);#endif #endif + +#ifdef CONFIG_ARMV8_PSCI +fdt_psci (fdt); +#ifndef CONFIG_ARMV8_SECURE_BASE +/* secure code lives in RAM, keep it alive */
Quoted 9 lines
arch/arm/cpu/armv8/cpu-dt.c int psci_update_dt(void *fdt) · line 40
Quoted 5 lines
arch/arm/cpu/armv8/cpu-dt.c +4
-0+fdt_add_mem_rsv (fdt, (unsigned long )__secure_start, + __secure_end - __secure_start); +#endif +#endif return 0 ;Looking just above this context, I think we need to re-work the #if tests now when adding this in.
Yes, when the CONFIG_FSL_PPA_ARMV8_PSCI moved to Kconfig, there should be less #if #else in the function psci_update_dt(), so I can add my codes neatly.
Quoted 2 lines
--
Tom
PATCH v2 6/6 ARMv8: LS1043A: Enable LS1043A default PSCI support
In reply to macro.wave.z at gmail.comFrom: Hongbo Zhang <[email protected]>
A most basic PSCI implementation with only one psci_version is added for LS1043A, this can verify the generic PSCI framework, and more platform specific implementation will be added later.
--- arch/arm/cpu/armv8/Kconfig | 3 +++ arch/arm/cpu/armv8/fsl-layerscape/Makefile | 1 + arch/arm/cpu/armv8/fsl-layerscape/ls1043a_psci.S | 20 ++++++++++++++++++++ board/freescale/ls1043ardb/Kconfig | 9 +++++++++ configs/ls1043ardb_defconfig | 1 + 5 files changed, 34 insertions(+) create mode 100644 arch/arm/cpu/armv8/fsl-layerscape/ls1043a_psci.S
arch/arm/cpu/armv8/Kconfig +3 -0
@@ -51,6 +51,7 @@ config ARMV8_PSCI config ARMV8_PSCI_NR_CPUS int "Maximum supported CPUs for PSCI" depends on ARMV8_PSCI + default 4 if TARGET_LS1043ARDB default 4 help The maximum number of CPUs supported in the PSCI firmware.
@@ -60,6 +61,7 @@ config ARMV8_PSCI_NR_CPUS config ARMV8_PSCI_CPUS_PER_CLUSTER int "Number of CPUs per cluster" depends on ARMV8_PSCI + default 4 if TARGET_LS1043ARDB default 0 help The number of CPUs per cluster, suppose each cluster has same number
@@ -72,6 +74,7 @@ if SYS_HAS_ARMV8_SECURE_BASE config ARMV8_SECURE_BASE hex "Secure address for PSCI image" depends on ARMV8_PSCI + default 0x10010000 if TARGET_LS1043ARDB help Address for placing the PSCI text, data and stack sections. If not defined, the PSCI sections are placed together with the u-boot
arch/arm/cpu/armv8/fsl-layerscape/Makefile +1 -0
@@ -28,6 +28,7 @@ endif ifneq ($(CONFIG_LS1043A),) obj-$(CONFIG_SYS_HAS_SERDES) += ls1043a_serdes.o +obj-$(CONFIG_ARMV8_PSCI) += ls1043a_psci.o endif ifneq ($(CONFIG_ARCH_LS1012A),)
arch/arm/cpu/armv8/fsl-layerscape/ls1043a_psci.S new file +20 -0
@@ -0,0 +1,20 @@ +/* + * Copyright 2016 Freescale Semiconductor, Inc. + * Author: Hongbo Zhang <[email protected]> + * + * SPDX-License-Identifier: GPL-2.0+ + * This file implements LS102X platform PSCI SYSTEM-SUSPEND function + */ + +#include <config.h> +#include <linux/linkage.h> +#include <asm/psci.h> + + .pushsection ._secure.text, "ax" + +.globl psci_version +psci_version: + ldr w0, =0x00010000 /* PSCI v1.0 */ + ret + + .popsection
board/freescale/ls1043ardb/Kconfig +9 -0
@@ -13,4 +13,13 @@ config SYS_SOC config SYS_CONFIG_NAME default "ls1043ardb" +config SYS_HAS_ARMV8_SECURE_BASE + bool "Enable secure RAM for PSCI image" + depends on ARMV8_PSCI + default y + help + PSCI image can be re-located to secure RAM. + If enabled, please also define the value for ARMV8_SECURE_BASE, + for LS1043ARDB, it is address in OCRAM. + endif
configs/ls1043ardb_defconfig +1 -0
@@ -27,3 +27,4 @@ CONFIG_DM_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y CONFIG_USB_STORAGE=y +CONFIG_ARMV8_PSCI=y
Signature · 1 line
2.1.4
PATCH v2 6/6 ARMv8: LS1043A: Enable LS1043A default PSCI support
Quoted 21 lines · macro.wave.z at gmail.com
From: Hongbo Zhang <[email protected]>
A most basic PSCI implementation with only one
psci_versionis added for LS1043A, this can verify the generic PSCI framework, and more platform specific implementation will be added later.Signed-off-by Hongbo Zhang <[email protected]>--- arch/arm/cpu/armv8/Kconfig | 3 +++ arch/arm/cpu/armv8/fsl-layerscape/Makefile | 1 + arch/arm/cpu/armv8/fsl-layerscape/ls1043a_psci.S | 20 ++++++++++++++++++++ board/freescale/ls1043ardb/Kconfig | 9 +++++++++ configs/ls1043ardb_defconfig | 1 + 5 files changed, 34 insertions(+) create mode 100644 arch/arm/cpu/armv8/fsl-layerscape/ls1043a_psci.Sarch/arm/cpu/armv8/Kconfig +0
-0
arch/arm/cpu/armv8/Kconfig config ARMV8_PSCI · line 55
Quoted 5 lines
arch/arm/cpu/armv8/Kconfig +1
-0@@ -51,6 +51,7 @@ config ARMV8_PSCI config ARMV8_PSCI_NR_CPUS int "Maximum supported CPUs for PSCI" depends on ARMV8_PSCI + default 4 if TARGET_LS1043ARDB default 4
Since 4 is the default we don't need to add in a line here.
Quoted 9 lines
arch/arm/cpu/armv8/Kconfig +1
-0@@ -60,6 +61,7 @@ config ARMV8_PSCI_NR_CPUS config ARMV8_PSCI_CPUS_PER_CLUSTER int "Number of CPUs per cluster" depends on ARMV8_PSCI + default 4 if TARGET_LS1043ARDB default 0 help The number of CPUs per cluster, suppose each cluster has same number
arch/arm/cpu/armv8/Kconfig if SYS_HAS_ARMV8_SECURE_BASE · line 80
Quoted 7 lines
arch/arm/cpu/armv8/Kconfig +1
-0@@ -72,6 +74,7 @@ if SYS_HAS_ARMV8_SECURE_BASE config ARMV8_SECURE_BASE hex "Secure address for PSCI image" depends on ARMV8_PSCI + default 0x10010000 if TARGET_LS1043ARDB help Address for placing the PSCI text, data and stack sections. If not defined, the PSCI sections are placed together with the u-boot
I think we should put those of these into the defconfig and once we add more targets we can see if there's good reason, and non-TARGET_xxx we can key off of to provide default values.
Thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161102/999c3939/attachment.sig>
PATCH v2 6/6 ARMv8: LS1043A: Enable LS1043A default PSCI support
Quoted 42 lines · Tom Rini
Quoted 21 lines · macro.wave.z at gmail.com
From: Hongbo Zhang <[email protected]>
A most basic PSCI implementation with only one
psci_versionis added for LS1043A, this can verify the generic PSCI framework, and more platform specific implementation will be added later.Signed-off-by Hongbo Zhang <[email protected]>--- arch/arm/cpu/armv8/Kconfig | 3 +++ arch/arm/cpu/armv8/fsl-layerscape/Makefile | 1 + arch/arm/cpu/armv8/fsl-layerscape/ls1043a_psci.S | 20 ++++++++++++++++++++ board/freescale/ls1043ardb/Kconfig | 9 +++++++++ configs/ls1043ardb_defconfig | 1 + 5 files changed, 34 insertions(+) create mode 100644 arch/arm/cpu/armv8/fsl-layerscape/ls1043a_psci.Sarch/arm/cpu/armv8/Kconfig +0
-0arch/arm/cpu/armv8/Kconfig config ARMV8_PSCI · line 55
Quoted 5 lines
arch/arm/cpu/armv8/Kconfig +1
-0@@ -51,6 +51,7 @@ config ARMV8_PSCI config ARMV8_PSCI_NR_CPUS int "Maximum supported CPUs for PSCI" depends on ARMV8_PSCI + default 4 if TARGET_LS1043ARDB default 4Since 4 is the default we don't need to add in a line here.
Quoted 12 lines
arch/arm/cpu/armv8/Kconfig +1
-0@@ -60,6 +61,7 @@ config ARMV8_PSCI_NR_CPUS config ARMV8_PSCI_CPUS_PER_CLUSTER int "Number of CPUs per cluster" depends on ARMV8_PSCI + default 4 if TARGET_LS1043ARDB default 0 help The number of CPUs per cluster, suppose each cluster has same number@@ -72,6 +74,7 @@ if SYS_HAS_ARMV8_SECURE_BASE config ARMV8_SECURE_BASE hex "Secure address for PSCI image" depends on ARMV8_PSCI
Quoted 9 lines
arch/arm/cpu/armv8/Kconfig if SYS_HAS_ARMV8_SECURE_BASE · line 80
Quoted 4 lines
arch/arm/cpu/armv8/Kconfig +1
-0+ default 0x10010000 if TARGET_LS1043ARDB help Address for placing the PSCI text, data and stack sections. If not defined, the PSCI sections are placed together with the u-bootI think we should put those of these into the defconfig and once we add more targets we can see if there's good reason, and non-TARGET_xxx we can key off of to provide default values.
I knew when more targets added there will be mess here, I always tried to follow your suggestion to move these three configs here, and forgot to use platform defconfig.
Yes I'll move these three configs to our platform defconfig.
Quoted 4 lines
Thanks!
--
Tom