drivers: firmware: psci: move power_state handling to generic code
authorLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Tue, 26 May 2015 15:49:01 +0000 (16:49 +0100)
committerLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Fri, 2 Oct 2015 13:35:16 +0000 (14:35 +0100)
Functions implemented on arm64 to check if a power_state parameter
is valid and if the power_state implies context loss are not
arm64 specific and should be moved to generic code so that they
can be reused on arm systems too.

This patch moves the functions handling the power_state parameter
to generic PSCI firmware layer code.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Will Deacon <will.deacon@arm.com>
Acked-by: Sudeep Holla <sudeep.holla@arm.com>
Tested-by: Jisheng Zhang <jszhang@marvell.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
arch/arm64/kernel/psci.c
drivers/firmware/psci.c
include/linux/psci.h

index aa94a88f6279963ae7ef0c6477215894859c9aff..f67f35b6edb12e4d34e1db17750b07a0bec72e39 100644 (file)
 #include <asm/smp_plat.h>
 #include <asm/suspend.h>
 
-static bool psci_power_state_loses_context(u32 state)
-{
-       return state & PSCI_0_2_POWER_STATE_TYPE_MASK;
-}
-
-static bool psci_power_state_is_valid(u32 state)
-{
-       const u32 valid_mask = PSCI_0_2_POWER_STATE_ID_MASK |
-                              PSCI_0_2_POWER_STATE_TYPE_MASK |
-                              PSCI_0_2_POWER_STATE_AFFL_MASK;
-
-       return !(state & ~valid_mask);
-}
-
 static DEFINE_PER_CPU_READ_MOSTLY(u32 *, psci_power_state);
 
 static int __maybe_unused cpu_psci_cpu_init_idle(unsigned int cpu)
index 0821e332c85a37cff3197f4dcf11a26a493dcb5d..3157eb0ef3000726e0d58290daba994dcada5bff 100644 (file)
@@ -70,6 +70,21 @@ enum psci_function {
 
 static u32 psci_function_id[PSCI_FN_MAX];
 
+#define PSCI_0_2_POWER_STATE_MASK              \
+                               (PSCI_0_2_POWER_STATE_ID_MASK | \
+                               PSCI_0_2_POWER_STATE_TYPE_MASK | \
+                               PSCI_0_2_POWER_STATE_AFFL_MASK)
+
+bool psci_power_state_loses_context(u32 state)
+{
+       return state & PSCI_0_2_POWER_STATE_TYPE_MASK;
+}
+
+bool psci_power_state_is_valid(u32 state)
+{
+       return !(state & ~PSCI_0_2_POWER_STATE_MASK);
+}
+
 static int psci_to_linux_errno(int errno)
 {
        switch (errno) {
index a682fcc91c3321b386a13313dd9135b590117ee4..12c4865457adc3d0412c573b710feec7d3d6fd81 100644 (file)
@@ -21,6 +21,8 @@
 #define PSCI_POWER_STATE_TYPE_POWER_DOWN       1
 
 bool psci_tos_resident_on(int cpu);
+bool psci_power_state_loses_context(u32 state);
+bool psci_power_state_is_valid(u32 state);
 
 struct psci_operations {
        int (*cpu_suspend)(u32 state, unsigned long entry_point);