From: Wang Dongsheng
Add the PSCI v1.0 API to U-Boot:
PSCI_VERSION,
AFFINITY_INFO,
MIGRATE_INFO_TYPE,
MIGRATE_INFO_UP_CPU,
SYSTEM_OFF,
SYSTEM_RESET,
PSCI_FEATURES,
SYSTEM_SUSPEND.
In order to be compatible with PSCI v0.1 version, introduce
CONFIG_ARMV7_PSCI_GTE_1_0 macro to add the PSCI v1.0 compatible to
the dtb.
U-Boot currently uses the "arm,psci" compatible, which means PSCI
v0.1. PSCI v1.0 imposes additional requirements, so the
"arm,psci-1.0" property will only be added if the platform defines
CONFIG_ARMV7_PSCI_GTE_1_0."
Signed-off-by: Wang Dongsheng
---
arch/arm/cpu/armv7/psci.S| 36 +++
arch/arm/cpu/armv7/virt-dt.c | 45 +---
arch/arm/include/asm/psci.h | 27 ++
3 files changed, 97 insertions(+), 11 deletions(-)
diff --git a/arch/arm/cpu/armv7/psci.S b/arch/arm/cpu/armv7/psci.S
index a83fa67..68304bf 100644
--- a/arch/arm/cpu/armv7/psci.S
+++ b/arch/arm/cpu/armv7/psci.S
@@ -53,8 +53,18 @@ ENTRY(psci_cpu_suspend)
ENTRY(psci_cpu_off)
ENTRY(psci_cpu_on)
ENTRY(psci_migrate)
+#ifdef CONFIG_ARMV7_PSCI_GTE_1_0
+ENTRY(psci_migrate_info_type)
+ENTRY(psci_migrate_info_up_cpu)
+ENTRY(psci_system_suspend)
+#endif
mov r0, #PSCI_RET_NOT_SUPPORTED @ Return -1 (Not Implemented)
mov pc, lr
+#ifdef CONFIG_ARMV7_PSCI_GTE_1_0
+ENDPROC(psci_system_suspend)
+ENDPROC(psci_migrate_info_up_cpu)
+ENDPROC(psci_migrate_info_type)
+#endif
ENDPROC(psci_migrate)
ENDPROC(psci_cpu_on)
ENDPROC(psci_cpu_off)
@@ -63,8 +73,14 @@ ENDPROC(psci_cpu_suspend)
.weak psci_cpu_off
.weak psci_cpu_on
.weak psci_migrate
+#ifdef CONFIG_ARMV7_PSCI_GTE_1_0
+.weak psci_migrate_info_type
+.weak psci_migrate_info_up_cpu
+.weak psci_system_suspend
+#endif
_psci_table:
+ /* PSCI v0.1 */
.word PSCI_FN_CPU_SUSPEND
.word psci_cpu_suspend
.word PSCI_FN_CPU_OFF
@@ -73,6 +89,26 @@ _psci_table:
.word psci_cpu_on_common
.word PSCI_FN_MIGRATE
.word psci_migrate
+#ifdef CONFIG_ARMV7_PSCI_GTE_1_0
+ /* PSCI v0.2 */
+ .word PSCI_FN_PSCI_VERSION
+ .word psci_version
+ .word PSCI_FN_AFFINITY_INFO
+ .word psci_affinity_info
+ .word PSCI_FN_MIGRATE_INFO_TYPE
+ .word psci_migrate_info_type
+ .word PSCI_FN_MIGRATE_INFO_UP_CPU
+ .word psci_migrate_info_up_cpu
+ .word PSCI_FN_SYSTEM_OFF
+ .word psci_system_off
+ .word PSCI_FN_SYSTEM_RESET
+ .word psci_system_reset
+ /* PSCI v1.0 */
+ .word PSCI_FN_PSCI_FEATURES
+ .word psci_features
+ .word PSCI_FN_SYSTEM_SUSPEND
+ .word psci_system_suspend
+#endif
.word 0
.word 0
diff --git a/arch/arm/cpu/armv7/virt-dt.c b/arch/arm/cpu/armv7/virt-dt.c
index 5ca353c..2865169 100644
--- a/arch/arm/cpu/armv7/virt-dt.c
+++ b/arch/arm/cpu/armv7/virt-dt.c
@@ -26,6 +26,35 @@
#include
#include
+#ifdef CONFIG_ARMV7_PSCI
+#ifdef CONFIG_ARMV7_PSCI_GTE_1_0
+static int fdt_psci_gte_1_0_fixup(void *fdt, int nodeoff)
+{
+ return fdt_setprop_string(fdt, nodeoff, "compatible", "arm,psci-1.0");
+}
+#endif
+
+static int fdt_psci_0_1_fixup(void *fdt, int nodeoff)
+{
+ int ret;
+
+ ret = fdt_appendprop_string(fdt, nodeoff, "compatible", "arm,psci");
+ if (ret)
+ return ret;
+ ret = fdt_setprop_u32(fdt, nodeoff, "cpu_suspend", PSCI_FN_CPU_SUSPEND);
+ if (ret)
+ return ret;
+ ret = fdt_setprop_u32(fdt, nodeoff, "cpu_off", PSCI_FN_CPU_OFF);
+ if (ret)
+ return ret;
+ ret = fdt_setprop_u32(fdt, nodeoff, "cpu_on", PSCI_FN_CPU_ON);
+ if (ret)
+ return ret;
+
+ return fdt_setprop_u32(fdt, nodeoff, "migrate", PSCI_FN_MIGRATE);
+}
+#endif
+
static int fdt_psci(void *fdt)
{
#ifdef CONFIG_ARMV7_PSCI
@@ -67,22 +96,16 @@ static int fdt_psci(void *fdt)
return nodeoff;
}
- tmp = fdt_setprop_string(fdt, nodeoff, "compatible", "arm,psci");
- if (tmp)
- return tmp;
tmp = fdt_setprop_string(fdt, nodeoff, "method", "smc");
if (tmp)
return tmp;
- tmp = fdt_setprop_u32(fdt, nodeoff, "cpu_suspend", PSCI_FN_CPU_SUSPEND);
- if (tmp)
- return tmp;
- tmp = fdt_setprop_u32(fdt, nodeoff, "cpu_off", PSCI_FN_CPU_OFF);
- if (tmp)
- return tmp;
- tmp = fdt_setprop_u32(fdt, nodeoff, "cpu_on", PSCI_FN_CPU_ON);
+
+#ifdef CONFIG_ARMV7_PSCI_GTE_1_0
+ tmp = fdt_psci_gte_1_0_fixup(fdt, nodeoff);
if (tmp)
return tmp;
- tmp = fdt_setprop_u32(fdt, nodeoff, "migrate", PSCI_FN_MIGRATE);
+#endif
+ tmp = fdt_psci_0_1_fixup(fdt, nodeoff);
if (tmp)
return tmp;
#endif
diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
index 274dbda..71cd193 100644
--- a/arch/arm/include/