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