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