From 09ea44a37017f02ddf3e5b4a4ad765fbf5fd7954 Mon Sep 17 00:00:00 2001 From: wangqinglin <53550140+HelloByeAll@users.noreply.github.com> Date: Mon, 5 Jun 2023 17:31:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=97=A0=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E6=A0=91=E6=A8=A1=E5=BC=8FPSCI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libcpu/aarch64/common/psci.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/libcpu/aarch64/common/psci.c b/libcpu/aarch64/common/psci.c index 5c6ac82b25..b3bf1c50af 100644 --- a/libcpu/aarch64/common/psci.c +++ b/libcpu/aarch64/common/psci.c @@ -43,6 +43,7 @@ struct psci_ops_t psci_ops; #ifdef RT_USING_FDT #include "dtb_node.h" +#endif /* RT_USING_FDT */ #if __SIZE_WIDTH__ == 64 #define PSCI_FN_NATIVE(version, name) PSCI_##version##_FN64_##name @@ -66,13 +67,14 @@ static rt_uint32_t psci_call(unsigned long a0, unsigned long a1, unsigned long a return res.a0; } -static int _psci_probe_version(char *version, int *major, int *minor); static int _psci_init_with_version(int major, int minor); -static struct dtb_node *psci_node; +#ifdef RT_USING_FDT +static int _psci_probe_version(char *version, int *major, int *minor); static int psci_ver_major; static int psci_ver_minor; +static struct dtb_node *psci_node; /** * @brief init psci operations. @@ -81,7 +83,7 @@ static int psci_ver_minor; * * @return int 0 on success */ -int psci_init() +int psci_init(void) { void *root = get_dtb_node_head(); psci_node = dtb_node_get_dtb_node_by_path(root, "/psci"); @@ -158,6 +160,14 @@ static int psci_0_1_init() PROBE_AND_SET(migrate); return 0; } +#else +int psci_init(void) +{ + smccc_call = arm_smccc_smc; + _psci_init_with_version(0, 2); + return 0; +} +#endif /* RT_USING_FDT */ COMMON_PSCI_OPS_TEMPLATE(0_2, PSCI_FN_NATIVE(0_2, CPU_SUSPEND), PSCI_0_2_FN_CPU_OFF, PSCI_FN_NATIVE(0_2, CPU_ON), PSCI_FN_NATIVE(0_2, MIGRATE)); @@ -230,6 +240,7 @@ static int psci_1_0_init() return 0; } +#ifdef RT_USING_FDT /* probe psci version from fdt or SMC call */ static int _psci_probe_version(char *version, int *major, int *minor) { @@ -255,6 +266,7 @@ static int _psci_probe_version(char *version, int *major, int *minor) LOG_D("Using PSCI v%d.%d", *major, *minor); return retval; } +#endif /* RT_USING_FDT */ /* init psci ops with version info */ static int _psci_init_with_version(int major, int minor) @@ -265,7 +277,9 @@ static int _psci_init_with_version(int major, int minor) // for v0.1, psci function id was provided fdt if (minor == 1) { +#ifdef RT_USING_FDT retval = psci_0_1_init(); +#endif } else if (minor == 2) { @@ -284,5 +298,3 @@ static int _psci_init_with_version(int major, int minor) } return retval; } - -#endif /* RT_USING_FDT */ \ No newline at end of file