xref: /rk3399_ARM-atf/plat/xilinx/common/include/pm_api_sys.h (revision 06f3c7058c42a9f1a9f7df75ea2de71a000855e8)
1 /*
2  * Copyright (c) 2019-2022, Xilinx, Inc. All rights reserved.
3  * Copyright (c) 2022-2025, Advanced Micro Devices, Inc. All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  */
7 
8 #ifndef PM_API_SYS_H
9 #define PM_API_SYS_H
10 
11 #include <stdint.h>
12 #include "pm_defs.h"
13 
14 /*********************************************************************
15  * Target module IDs macros
16  ********************************************************************/
17 #define LIBPM_MODULE_ID		0x2U
18 #define LOADER_MODULE_ID	0x7U
19 
20 #define MODULE_ID_MASK		0x0000ff00U
21 /**********************************************************
22  * PM API function declarations
23  **********************************************************/
24 
25 enum pm_ret_status pm_handle_eemi_call(uint32_t flag, uint32_t x0, uint32_t x1,
26 				       uint32_t x2, uint32_t x3, uint32_t x4,
27 				       uint32_t x5, uint32_t *result);
28 enum pm_ret_status pm_self_suspend(uint32_t nid,
29 				   uint32_t latency,
30 				   uint32_t state,
31 				   uintptr_t address, uint32_t flag);
32 enum pm_ret_status pm_abort_suspend(enum pm_abort_reason reason, uint32_t flag);
33 enum pm_ret_status pm_req_suspend(uint32_t target,
34 				  uint8_t ack,
35 				  uint32_t latency,
36 				  uint32_t state, uint32_t flag);
37 enum pm_ret_status pm_req_wakeup(uint32_t target, uint32_t set_address,
38 				 uintptr_t address, uint8_t ack, uint32_t flag);
39 enum pm_ret_status pm_set_wakeup_source(uint32_t target, uint32_t wkup_device,
40 					uint8_t enable, uint32_t flag);
41 enum pm_ret_status pm_get_callbackdata(uint32_t *data, size_t count, uint32_t flag,
42 			 uint32_t ack);
43 void pm_client_set_wakeup_sources(uint32_t node_id);
44 enum pm_ret_status pm_force_powerdown(uint32_t target, uint8_t ack,
45 				      uint32_t flag);
46 enum pm_ret_status pm_system_shutdown(uint32_t type, uint32_t subtype,
47 				      uint32_t flag);
48 uint32_t pm_get_shutdown_scope(void);
49 enum pm_ret_status pm_feature_check(uint32_t api_id, uint32_t *ret_payload,
50 				    uint32_t flag);
51 enum pm_ret_status pm_load_pdi(uint32_t src, uint32_t address_low,
52 			       uint32_t address_high, uint32_t flag);
53 enum pm_ret_status pm_register_notifier(uint32_t device_id, uint32_t event,
54 					uint32_t wake, uint32_t enable,
55 					uint32_t flag);
56 enum pm_ret_status pm_get_chipid(uint32_t *value);
57 enum pm_ret_status eemi_feature_check(uint32_t api_id, uint32_t *ret_payload);
58 
59 /*
60  * Assigning of argument values into array elements.
61  */
62 #define PM_PACK_PAYLOAD1(pl, mid, flag, arg0) {	\
63 	pl[0] = (uint32_t)(((uint32_t)(arg0) & 0xFFU) | \
64 		((uint32_t)(mid) << 8U) | ((uint32_t)(flag) << 24U)); \
65 }
66 
67 #define PM_PACK_PAYLOAD2(pl, mid, flag, arg0, arg1) {		\
68 	pl[1] = (uint32_t)(arg1);				\
69 	PM_PACK_PAYLOAD1(pl, (mid), (flag), (arg0));			\
70 }
71 
72 #define PM_PACK_PAYLOAD3(pl, mid, flag, arg0, arg1, arg2) {	\
73 	pl[2] = (uint32_t)(arg2);				\
74 	PM_PACK_PAYLOAD2(pl, (mid), (flag), (arg0), (arg1));		\
75 }
76 
77 #define PM_PACK_PAYLOAD4(pl, mid, flag, arg0, arg1, arg2, arg3) {	\
78 	pl[3] = (uint32_t)(arg3);					\
79 	PM_PACK_PAYLOAD3(pl, (mid), (flag), (arg0), (arg1), (arg2));		\
80 }
81 
82 #define PM_PACK_PAYLOAD5(pl, mid, flag, arg0, arg1, arg2, arg3, arg4) {	\
83 	pl[4] = (uint32_t)(arg4);					\
84 	PM_PACK_PAYLOAD4(pl, (mid), (flag), (arg0), (arg1), (arg2), (arg3));	\
85 }
86 
87 #define PM_PACK_PAYLOAD6(pl, mid, flag, arg0, arg1, arg2, arg3, arg4, arg5) {	\
88 	pl[5] = (uint32_t)(arg5);						\
89 	PM_PACK_PAYLOAD5(pl, (mid), (flag), (arg0), (arg1), (arg2), (arg3), (arg4));		\
90 }
91 
92 #define PM_PACK_PAYLOAD7(pl, mid, flag, arg0, arg1, arg2, arg3, arg4, arg5, arg6) {	\
93 	pl[6] = (uint32_t)(arg6);							\
94 	PM_PACK_PAYLOAD6(pl, (mid), (flag), (arg0), (arg1), (arg2), (arg3), (arg4), (arg5));	\
95 }
96 
97 #endif /* PM_API_SYS_H */
98