1 /*
2  * Copyright (c) 2013-2020, ARM Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef PM_API_SYS_H
8 #define PM_API_SYS_H
9 
10 #include <stdint.h>
11 
12 #include "pm_defs.h"
13 
14 enum pm_query_id {
15 	PM_QID_INVALID,
16 	PM_QID_CLOCK_GET_NAME,
17 	PM_QID_CLOCK_GET_TOPOLOGY,
18 	PM_QID_CLOCK_GET_FIXEDFACTOR_PARAMS,
19 	PM_QID_CLOCK_GET_PARENTS,
20 	PM_QID_CLOCK_GET_ATTRIBUTES,
21 	PM_QID_PINCTRL_GET_NUM_PINS,
22 	PM_QID_PINCTRL_GET_NUM_FUNCTIONS,
23 	PM_QID_PINCTRL_GET_NUM_FUNCTION_GROUPS,
24 	PM_QID_PINCTRL_GET_FUNCTION_NAME,
25 	PM_QID_PINCTRL_GET_FUNCTION_GROUPS,
26 	PM_QID_PINCTRL_GET_PIN_GROUPS,
27 	PM_QID_CLOCK_GET_NUM_CLOCKS,
28 	PM_QID_CLOCK_GET_MAX_DIVISOR,
29 };
30 
31 enum pm_register_access_id {
32 	CONFIG_REG_WRITE,
33 	CONFIG_REG_READ,
34 };
35 
36 /**********************************************************
37  * System-level API function declarations
38  **********************************************************/
39 enum pm_ret_status pm_req_suspend(enum pm_node_id nid,
40 				  enum pm_request_ack ack,
41 				  unsigned int latency,
42 				  unsigned int state);
43 
44 enum pm_ret_status pm_self_suspend(enum pm_node_id nid,
45 				   unsigned int latency,
46 				   unsigned int state,
47 				   uintptr_t address);
48 
49 enum pm_ret_status pm_force_powerdown(enum pm_node_id nid,
50 				      enum pm_request_ack ack);
51 
52 enum pm_ret_status pm_abort_suspend(enum pm_abort_reason reason);
53 
54 enum pm_ret_status pm_req_wakeup(enum pm_node_id nid,
55 				 unsigned int set_address,
56 				 uintptr_t address,
57 				 enum pm_request_ack ack);
58 
59 enum pm_ret_status pm_set_wakeup_source(enum pm_node_id target,
60 					enum pm_node_id wkup_node,
61 					unsigned int enable);
62 
63 enum pm_ret_status pm_system_shutdown(unsigned int type, unsigned int subtype);
64 
65 enum pm_ret_status pm_init_suspend_cb(enum pm_suspend_reason reason,
66 				      unsigned int latency,
67 				      unsigned int state,
68 				      unsigned int timeout);
69 
70 /* API functions for managing PM Slaves */
71 enum pm_ret_status pm_req_node(enum pm_node_id nid,
72 			       unsigned int capabilities,
73 			       unsigned int qos,
74 			       enum pm_request_ack ack);
75 enum pm_ret_status pm_release_node(enum pm_node_id nid);
76 
77 enum pm_ret_status pm_set_requirement(enum pm_node_id nid,
78 				      unsigned int capabilities,
79 				      unsigned int qos,
80 				      enum pm_request_ack ack);
81 enum pm_ret_status pm_set_max_latency(enum pm_node_id nid,
82 				      unsigned int latency);
83 
84 /* Miscellaneous API functions */
85 enum pm_ret_status pm_get_api_version(unsigned int *version);
86 enum pm_ret_status pm_set_configuration(unsigned int phys_addr);
87 enum pm_ret_status pm_init_finalize(void);
88 enum pm_ret_status pm_get_node_status(enum pm_node_id node,
89 				      uint32_t *ret_buff);
90 enum pm_ret_status pm_register_notifier(enum pm_node_id nid,
91 					unsigned int event,
92 					unsigned int wake,
93 					unsigned int enable);
94 enum pm_ret_status pm_get_op_characteristic(enum pm_node_id nid,
95 					    enum pm_opchar_type type,
96 					    uint32_t *result);
97 enum pm_ret_status pm_acknowledge_cb(enum pm_node_id nid,
98 				     enum pm_ret_status status,
99 				     unsigned int oppoint);
100 enum pm_ret_status pm_notify_cb(enum pm_node_id nid,
101 				unsigned int event,
102 				unsigned int oppoint);
103 
104 /* Direct-Control API functions */
105 enum pm_ret_status pm_reset_assert(unsigned int reset_id,
106 				   unsigned int assert);
107 enum pm_ret_status pm_reset_get_status(unsigned int reset_id,
108 				       unsigned int *reset_status);
109 enum pm_ret_status pm_mmio_write(uintptr_t address,
110 				 unsigned int mask,
111 				 unsigned int value);
112 enum pm_ret_status pm_mmio_read(uintptr_t address, unsigned int *value);
113 enum pm_ret_status pm_fpga_load(uint32_t address_low,
114 				uint32_t address_high,
115 				uint32_t size,
116 				uint32_t flags);
117 enum pm_ret_status pm_fpga_get_status(unsigned int *value);
118 
119 enum pm_ret_status pm_get_chipid(uint32_t *value);
120 enum pm_ret_status pm_secure_rsaaes(uint32_t address_high,
121 				    uint32_t address_low,
122 				    uint32_t size,
123 				    uint32_t flags);
124 unsigned int pm_get_shutdown_scope(void);
125 void pm_get_callbackdata(uint32_t *data, size_t count);
126 enum pm_ret_status pm_pinctrl_request(unsigned int pin);
127 enum pm_ret_status pm_pinctrl_release(unsigned int pin);
128 enum pm_ret_status pm_pinctrl_get_function(unsigned int pin,
129 					   enum pm_node_id *nid);
130 enum pm_ret_status pm_pinctrl_set_function(unsigned int pin,
131 					   enum pm_node_id nid);
132 enum pm_ret_status pm_pinctrl_get_config(unsigned int pin,
133 					 unsigned int param,
134 					 unsigned int *value);
135 enum pm_ret_status pm_pinctrl_set_config(unsigned int pin,
136 					 unsigned int param,
137 					 unsigned int value);
138 enum pm_ret_status pm_ioctl(enum pm_node_id nid,
139 			    unsigned int ioctl_id,
140 			    unsigned int arg1,
141 			    unsigned int arg2,
142 			    unsigned int *value);
143 enum pm_ret_status pm_clock_enable(unsigned int clock_id);
144 enum pm_ret_status pm_clock_disable(unsigned int clock_id);
145 enum pm_ret_status pm_clock_getstate(unsigned int clock_id,
146 				     unsigned int *state);
147 enum pm_ret_status pm_clock_setdivider(unsigned int clock_id,
148 				       unsigned int divider);
149 enum pm_ret_status pm_clock_getdivider(unsigned int clock_id,
150 				       unsigned int *divider);
151 enum pm_ret_status pm_clock_setrate(unsigned int clock_id,
152 				    uint64_t rate);
153 enum pm_ret_status pm_clock_getrate(unsigned int clock_id,
154 				    uint64_t *rate);
155 enum pm_ret_status pm_clock_setparent(unsigned int clock_id,
156 				      unsigned int parent_id);
157 enum pm_ret_status pm_clock_getparent(unsigned int clock_id,
158 				      unsigned int *parent_id);
159 void pm_query_data(enum pm_query_id qid, unsigned int arg1, unsigned int arg2,
160 		   unsigned int arg3, unsigned int *data);
161 enum pm_ret_status pm_sha_hash(uint32_t address_high,
162 				    uint32_t address_low,
163 				    uint32_t size,
164 				    uint32_t flags);
165 enum pm_ret_status pm_rsa_core(uint32_t address_high,
166 				    uint32_t address_low,
167 				    uint32_t size,
168 				    uint32_t flags);
169 enum pm_ret_status pm_secure_image(uint32_t address_low,
170 				   uint32_t address_high,
171 				   uint32_t key_lo,
172 				   uint32_t key_hi,
173 				   uint32_t *value);
174 
175 enum pm_ret_status pm_fpga_read(uint32_t reg_numframes,
176 				uint32_t address_low,
177 				uint32_t address_high,
178 				uint32_t readback_type,
179 				uint32_t *value);
180 enum pm_ret_status pm_aes_engine(uint32_t address_high,
181 				 uint32_t address_low,
182 				 uint32_t  *value);
183 enum pm_ret_status pm_register_access(unsigned int register_access_id,
184 				      unsigned int address,
185 				      unsigned int mask,
186 				      unsigned int value,
187 				      unsigned int *out);
188 
189 enum pm_ret_status pm_pll_set_parameter(enum pm_node_id nid,
190 				enum pm_pll_param param_id,
191 				unsigned int value);
192 
193 enum pm_ret_status pm_pll_get_parameter(enum pm_node_id nid,
194 				enum pm_pll_param param_id,
195 				unsigned int *value);
196 
197 enum pm_ret_status pm_pll_set_mode(enum pm_node_id nid, enum pm_pll_mode mode);
198 enum pm_ret_status pm_pll_get_mode(enum pm_node_id nid, enum pm_pll_mode *mode);
199 enum pm_ret_status pm_efuse_access(uint32_t address_high,
200 				   uint32_t address_low, uint32_t *value);
201 enum pm_ret_status em_set_action(unsigned int *value);
202 enum pm_ret_status em_remove_action(unsigned int *value);
203 enum pm_ret_status em_send_errors(unsigned int *value);
204 
205 enum pm_ret_status pm_feature_config(unsigned int ioctl_id,
206 				     unsigned int config_id,
207 				     unsigned int value,
208 				     unsigned int *response);
209 
210 #endif /* PM_API_SYS_H */
211