1 #include <kernel/thread.h> 2 #include <sm/sm.h> 3 #include <stdint.h> 4 5 #define PSCI_VERSION_0_2 U(0x00000002) 6 #define PSCI_VERSION_1_0 U(0x00010000) 7 #define PSCI_VERSION U(0x84000000) 8 #define PSCI_CPU_SUSPEND U(0x84000001) 9 #define PSCI_CPU_OFF U(0x84000002) 10 #define PSCI_CPU_ON U(0x84000003) 11 #define PSCI_CPU_ON_SMC64 (PSCI_CPU_ON | U(0x40000000)) 12 #define PSCI_AFFINITY_INFO U(0x84000004) 13 #define PSCI_MIGRATE U(0x84000005) 14 #define PSCI_MIGRATE_INFO_TYPE U(0x84000006) 15 #define PSCI_MIGRATE_INFO_UP_CPU U(0x84000007) 16 #define PSCI_SYSTEM_OFF U(0x84000008) 17 #define PSCI_SYSTEM_RESET U(0x84000009) 18 #define PSCI_PSCI_FEATURES U(0x8400000a) 19 #define PSCI_CPU_FREEZE U(0x8400000b) 20 #define PSCI_CPU_DEFAULT_SUSPEND U(0x8400000c) 21 #define PSCI_NODE_HW_STATE U(0x8400000d) 22 #define PSCI_SYSTEM_SUSPEND U(0x8400000e) 23 #define PSCI_PSCI_SET_SUSPEND_MODE U(0x8400000f) 24 #define PSCI_FN_STAT_RESIDENCY U(0x84000010) 25 #define PSCI_FN_STAT_COUNT U(0x84000011) 26 27 #define PSCI_NUM_CALLS U(18) 28 29 #define PSCI_AFFINITY_LEVEL_ON U(0) 30 #define PSCI_AFFINITY_LEVEL_OFF U(1) 31 #define PSCI_AFFINITY_LEVEL_ON_PENDING U(2) 32 33 #define PSCI_POWER_STATE_ID_MASK U(0xffff) 34 #define PSCI_POWER_STATE_ID_SHIFT U(0) 35 #define PSCI_POWER_STATE_TYPE_SHIFT U(16) 36 #define PSCI_POWER_STATE_TYPE_MASK BIT32(PSCI_POWER_STATE_TYPE_SHIFT) 37 #define PSCI_POWER_STATE_AFFL_SHIFT U(24) 38 #define PSCI_POWER_STATE_AFFL_MASK SHIFT_U32(0x3, \ 39 PSCI_POWER_STATE_AFFL_SHIFT) 40 41 #define PSCI_POWER_STATE_TYPE_STANDBY U(0) 42 #define PSCI_POWER_STATE_TYPE_POWER_DOWN U(1) 43 44 #define PSCI_RET_SUCCESS (0) 45 #define PSCI_RET_NOT_SUPPORTED (-1) 46 #define PSCI_RET_INVALID_PARAMETERS (-2) 47 #define PSCI_RET_DENIED (-3) 48 #define PSCI_RET_ALREADY_ON (-4) 49 #define PSCI_RET_ON_PENDING (-5) 50 #define PSCI_RET_INTERNAL_FAILURE (-6) 51 #define PSCI_RET_NOT_PRESENT (-7) 52 #define PSCI_RET_DISABLED (-8) 53 #define PSCI_RET_INVALID_ADDRESS (-9) 54 55 uint32_t psci_version(void); 56 int psci_cpu_suspend(uint32_t power_state, uintptr_t entry, 57 uint32_t context_id, struct sm_nsec_ctx *nsec); 58 int psci_cpu_off(void); 59 int psci_cpu_on(uint32_t cpu_id, uint32_t entry, uint32_t context_id); 60 int psci_affinity_info(uint32_t affinity, uint32_t lowest_affnity_level); 61 int psci_migrate(uint32_t cpu_id); 62 int psci_migrate_info_type(void); 63 int psci_migrate_info_up_cpu(void); 64 void psci_system_off(void); 65 void psci_system_reset(void); 66 int psci_features(uint32_t psci_fid); 67 int psci_node_hw_state(uint32_t cpu_id, uint32_t power_level); 68 int psci_system_suspend(uintptr_t entry, uint32_t context_id, 69 struct sm_nsec_ctx *nsec); 70 int psci_stat_residency(uint32_t cpu_id, uint32_t power_state); 71 int psci_stat_count(uint32_t cpu_id, uint32_t power_state); 72 void tee_psci_handler(struct thread_smc_args *args, struct sm_nsec_ctx *nsec); 73 74 void psci_armv7_cpu_off(void); 75