Commit 49fdcd75 authored by Ulf Hansson's avatar Ulf Hansson

firmware: psci: Export functions to manage the OSI mode

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: default avatarUlf Hansson <ulf.hansson@linaro.org>
Reviewed-by: default avatarSudeep Holla <sudeep.holla@arm.com>
parent a3f048b5
...@@ -97,7 +97,7 @@ static inline bool psci_has_ext_power_state(void) ...@@ -97,7 +97,7 @@ static inline bool psci_has_ext_power_state(void)
PSCI_1_0_FEATURES_CPU_SUSPEND_PF_MASK; 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; return psci_cpu_suspend_feature & PSCI_1_0_OS_INITIATED;
} }
...@@ -162,6 +162,15 @@ static u32 psci_get_version(void) ...@@ -162,6 +162,15 @@ static u32 psci_get_version(void)
return invoke_psci_fn(PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0); 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) static int psci_cpu_suspend(u32 state, unsigned long entry_point)
{ {
int err; int err;
...@@ -544,9 +553,14 @@ static int __init psci_1_0_init(struct device_node *np) ...@@ -544,9 +553,14 @@ static int __init psci_1_0_init(struct device_node *np)
if (err) if (err)
return err; return err;
if (psci_has_osi_support()) if (psci_has_osi_support()) {
pr_info("OSI mode supported.\n"); 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; return 0;
} }
......
...@@ -18,6 +18,8 @@ bool psci_tos_resident_on(int cpu); ...@@ -18,6 +18,8 @@ bool psci_tos_resident_on(int cpu);
int psci_cpu_suspend_enter(u32 state); int psci_cpu_suspend_enter(u32 state);
bool psci_power_state_is_valid(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 { enum smccc_version {
SMCCC_VERSION_1_0, SMCCC_VERSION_1_0,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment