psci: change customized PSCI to support bit operation
authorPark Bumgyu <bumgyu.park@samsung.com>
Wed, 31 Jan 2018 06:38:46 +0000 (15:38 +0900)
committerChungwoo Park <cww.park@samsung.com>
Mon, 21 May 2018 08:30:28 +0000 (17:30 +0900)
Change-Id: I8cf40dbe290e56d6d93fb2c193342eda166b3857
Signed-off-by: Park Bumgyu <bumgyu.park@samsung.com>
Signed-off-by: Soohyun Kim <soohyuni.kim@samsung.com>
drivers/firmware/psci.c
include/linux/psci.h

index 2d7557c77e4b4e8c7a54b900302db2e8ed40af93..8d60b4cd1df460fef283800716edda6dcaf89f2e 100644 (file)
@@ -431,28 +431,21 @@ static u32 psci_power_state_pack(u32 id, u32 type, u32 affinity_level)
 static int psci_suspend_customized_finisher(unsigned long index)
 {
        u32 state;
+       u32 id = 0, type = 0, affinity_level = 0;
 
-       switch (index) {
-       case PSCI_CLUSTER_SLEEP:
-               state = psci_power_state_pack(0, 0, 1);
-               break;
-       case PSCI_SYSTEM_IDLE:
-       case PSCI_SYSTEM_IDLE_AUDIO:
-               state = psci_power_state_pack(1, 0, 0);
-               break;
-       case PSCI_SYSTEM_IDLE_CLUSTER_SLEEP:
-               state = psci_power_state_pack(1, 0, 1);
-               break;
-       case PSCI_CP_CALL:
-               state = psci_power_state_pack(0, 0, 2);
-               break;
-       case PSCI_SYSTEM_SLEEP:
-               state = psci_power_state_pack(0, 0, 3);
-               break;
-       default:
-               panic("Unsupported psci state, index = %ld\n", index);
-               break;
-       };
+       if (index & PSCI_SYSTEM_IDLE)
+               id = 1;
+
+       if (index & PSCI_CLUSTER_SLEEP)
+               affinity_level = 1;
+
+       if (index & PSCI_CP_CALL)
+               affinity_level = 2;
+
+       if (index & PSCI_SYSTEM_SLEEP)
+               affinity_level = 3;
+
+       state = psci_power_state_pack(id, type, affinity_level);
 
        return psci_ops.cpu_suspend(state, virt_to_phys(cpu_resume));
 }
@@ -468,7 +461,7 @@ int psci_cpu_suspend_enter(unsigned long index)
        if (WARN_ON_ONCE(!index))
                return -EINVAL;
 
-       if (unlikely(index >= PSCI_UNUSED_INDEX))
+       if (unlikely(index >= PSCI_CUSTOMIZED_INDEX))
                return cpu_suspend(index, psci_suspend_customized_finisher);
 
        if (!psci_power_state_loses_context(state[index - 1]))
index 99095024eb869e68549d3bc358aefea1791e0f63..577d037f1650b477292f93807c20631c1738c389 100644 (file)
 #include <linux/init.h>
 #include <linux/types.h>
 
-#define PSCI_UNUSED_INDEX              128
-#define PSCI_CLUSTER_SLEEP             (PSCI_UNUSED_INDEX)
-#define PSCI_SYSTEM_IDLE               (PSCI_UNUSED_INDEX + 1)
-#define PSCI_SYSTEM_IDLE_CLUSTER_SLEEP (PSCI_UNUSED_INDEX + 2)
-#define PSCI_SYSTEM_IDLE_AUDIO         (PSCI_UNUSED_INDEX + 3)
-#define PSCI_CP_CALL                   (PSCI_UNUSED_INDEX + 4)
-#define PSCI_SYSTEM_SLEEP              (PSCI_UNUSED_INDEX + 5)
+#define PSCI_CUSTOMIZED_INDEX          (1 << 7)
+#define PSCI_CLUSTER_SLEEP             (PSCI_CUSTOMIZED_INDEX)
+#define PSCI_SYSTEM_IDLE               (1 << 8)
+#define PSCI_CP_CALL                   (1 << 9)
+#define PSCI_SYSTEM_SLEEP              (1 << 10)
 
 #define PSCI_POWER_STATE_TYPE_STANDBY          0
 #define PSCI_POWER_STATE_TYPE_POWER_DOWN       1