firmware: psci: Export functions to manage the OSI mode
authorUlf Hansson <ulf.hansson@linaro.org>
Thu, 10 Oct 2019 10:01:48 +0000 (12:01 +0200)
committerUlf Hansson <ulf.hansson@linaro.org>
Thu, 2 Jan 2020 15:49:59 +0000 (16:49 +0100)
To allow subsequent changes to implement support for OSI mode through the
cpuidle-psci driver, export the existing psci_has_osi_support(). Export
also a new function, psci_set_osi_mode(), that allows its caller to enable
the OS-initiated CPU-suspend mode in the PSCI FW.

To deal with backwards compatibility for a kernel started through a kexec
call, default to set the CPU-suspend mode to the Platform Coordinated mode
during boot.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
drivers/firmware/psci/psci.c
include/linux/psci.h

index b3b6c15..2937d44 100644 (file)
@@ -97,7 +97,7 @@ static inline bool psci_has_ext_power_state(void)
                                PSCI_1_0_FEATURES_CPU_SUSPEND_PF_MASK;
 }
 
-static inline bool psci_has_osi_support(void)
+bool psci_has_osi_support(void)
 {
        return psci_cpu_suspend_feature & PSCI_1_0_OS_INITIATED;
 }
@@ -162,6 +162,15 @@ static u32 psci_get_version(void)
        return invoke_psci_fn(PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0);
 }
 
+int psci_set_osi_mode(void)
+{
+       int err;
+
+       err = invoke_psci_fn(PSCI_1_0_FN_SET_SUSPEND_MODE,
+                            PSCI_1_0_SUSPEND_MODE_OSI, 0, 0);
+       return psci_to_linux_errno(err);
+}
+
 static int psci_cpu_suspend(u32 state, unsigned long entry_point)
 {
        int err;
@@ -544,9 +553,14 @@ static int __init psci_1_0_init(struct device_node *np)
        if (err)
                return err;
 
-       if (psci_has_osi_support())
+       if (psci_has_osi_support()) {
                pr_info("OSI mode supported.\n");
 
+               /* Default to PC mode. */
+               invoke_psci_fn(PSCI_1_0_FN_SET_SUSPEND_MODE,
+                              PSCI_1_0_SUSPEND_MODE_PC, 0, 0);
+       }
+
        return 0;
 }
 
index ebe0a88..a67712b 100644 (file)
@@ -18,6 +18,8 @@ bool psci_tos_resident_on(int cpu);
 
 int psci_cpu_suspend_enter(u32 state);
 bool psci_power_state_is_valid(u32 state);
+int psci_set_osi_mode(void);
+bool psci_has_osi_support(void);
 
 enum smccc_version {
        SMCCC_VERSION_1_0,