1 /* 2 * Copyright (c) 2013-2022, 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 * Assigning of argument values into array elements. 38 */ 39 #define PM_PACK_PAYLOAD1(pl, arg0) { \ 40 pl[0] = (uint32_t)(arg0); \ 41 } 42 43 #define PM_PACK_PAYLOAD2(pl, arg0, arg1) { \ 44 pl[1] = (uint32_t)(arg1); \ 45 PM_PACK_PAYLOAD1(pl, arg0); \ 46 } 47 48 #define PM_PACK_PAYLOAD3(pl, arg0, arg1, arg2) { \ 49 pl[2] = (uint32_t)(arg2); \ 50 PM_PACK_PAYLOAD2(pl, arg0, arg1); \ 51 } 52 53 #define PM_PACK_PAYLOAD4(pl, arg0, arg1, arg2, arg3) { \ 54 pl[3] = (uint32_t)(arg3); \ 55 PM_PACK_PAYLOAD3(pl, arg0, arg1, arg2); \ 56 } 57 58 #define PM_PACK_PAYLOAD5(pl, arg0, arg1, arg2, arg3, arg4) { \ 59 pl[4] = (uint32_t)(arg4); \ 60 PM_PACK_PAYLOAD4(pl, arg0, arg1, arg2, arg3); \ 61 } 62 63 #define PM_PACK_PAYLOAD6(pl, arg0, arg1, arg2, arg3, arg4, arg5) { \ 64 pl[5] = (uint32_t)(arg5); \ 65 PM_PACK_PAYLOAD5(pl, arg0, arg1, arg2, arg3, arg4); \ 66 } 67 68 /********************************************************** 69 * System-level API function declarations 70 **********************************************************/ 71 enum pm_ret_status pm_req_suspend(enum pm_node_id target, 72 enum pm_request_ack ack, 73 uint32_t latency, 74 uint32_t state); 75 76 enum pm_ret_status pm_self_suspend(enum pm_node_id nid, 77 uint32_t latency, 78 uint32_t state, 79 uintptr_t address); 80 81 enum pm_ret_status pm_force_powerdown(enum pm_node_id target, 82 enum pm_request_ack ack); 83 84 enum pm_ret_status pm_abort_suspend(enum pm_abort_reason reason); 85 86 enum pm_ret_status pm_req_wakeup(enum pm_node_id target, 87 uint32_t set_address, 88 uintptr_t address, 89 enum pm_request_ack ack); 90 91 enum pm_ret_status pm_set_wakeup_source(enum pm_node_id target, 92 enum pm_node_id wkup_node, 93 uint32_t enable); 94 95 enum pm_ret_status pm_system_shutdown(uint32_t type, uint32_t subtype); 96 97 /* API functions for managing PM Slaves */ 98 enum pm_ret_status pm_req_node(enum pm_node_id nid, 99 uint32_t capabilities, 100 uint32_t qos, 101 enum pm_request_ack ack); 102 103 enum pm_ret_status pm_set_requirement(enum pm_node_id nid, 104 uint32_t capabilities, 105 uint32_t qos, 106 enum pm_request_ack ack); 107 108 /* Miscellaneous API functions */ 109 enum pm_ret_status pm_get_api_version(uint32_t *version); 110 enum pm_ret_status pm_get_node_status(enum pm_node_id nid, 111 uint32_t *ret_buff); 112 113 /* Direct-Control API functions */ 114 enum pm_ret_status pm_mmio_write(uintptr_t address, 115 uint32_t mask, 116 uint32_t value); 117 enum pm_ret_status pm_mmio_read(uintptr_t address, uint32_t *value); 118 enum pm_ret_status pm_fpga_load(uint32_t address_low, 119 uint32_t address_high, 120 uint32_t size, 121 uint32_t flags); 122 enum pm_ret_status pm_fpga_get_status(uint32_t *value); 123 124 enum pm_ret_status pm_get_chipid(uint32_t *value); 125 enum pm_ret_status pm_secure_rsaaes(uint32_t address_low, 126 uint32_t address_high, 127 uint32_t size, 128 uint32_t flags); 129 unsigned int pm_get_shutdown_scope(void); 130 void pm_get_callbackdata(uint32_t *data, size_t count); 131 enum pm_ret_status pm_ioctl(enum pm_node_id nid, 132 uint32_t ioctl_id, 133 uint32_t arg1, 134 uint32_t arg2, 135 uint32_t *value); 136 enum pm_ret_status pm_clock_enable(uint32_t clock_id); 137 enum pm_ret_status pm_clock_disable(uint32_t clock_id); 138 enum pm_ret_status pm_clock_getstate(uint32_t clock_id, 139 uint32_t *state); 140 enum pm_ret_status pm_clock_setdivider(uint32_t clock_id, 141 uint32_t divider); 142 enum pm_ret_status pm_clock_getdivider(uint32_t clock_id, 143 uint32_t *divider); 144 enum pm_ret_status pm_clock_setrate(uint32_t clock_id, 145 uint64_t rate); 146 enum pm_ret_status pm_clock_getrate(uint32_t clock_id, 147 uint64_t *rate); 148 enum pm_ret_status pm_clock_setparent(uint32_t clock_id, 149 uint32_t parent_index); 150 enum pm_ret_status pm_clock_getparent(uint32_t clock_id, 151 uint32_t *parent_index); 152 void pm_query_data(enum pm_query_id qid, uint32_t arg1, uint32_t arg2, 153 uint32_t arg3, uint32_t *data); 154 enum pm_ret_status pm_sha_hash(uint32_t address_high, 155 uint32_t address_low, 156 uint32_t size, 157 uint32_t flags); 158 enum pm_ret_status pm_rsa_core(uint32_t address_high, 159 uint32_t address_low, 160 uint32_t size, 161 uint32_t flags); 162 enum pm_ret_status pm_secure_image(uint32_t address_low, 163 uint32_t address_high, 164 uint32_t key_lo, 165 uint32_t key_hi, 166 uint32_t *value); 167 enum pm_ret_status pm_fpga_read(uint32_t reg_numframes, 168 uint32_t address_low, 169 uint32_t address_high, 170 uint32_t readback_type, 171 uint32_t *value); 172 enum pm_ret_status pm_aes_engine(uint32_t address_high, 173 uint32_t address_low, 174 uint32_t *value); 175 enum pm_ret_status pm_register_access(uint32_t register_access_id, 176 uint32_t address, 177 uint32_t mask, 178 uint32_t value, 179 uint32_t *out); 180 enum pm_ret_status pm_pll_set_parameter(enum pm_node_id nid, 181 enum pm_pll_param param_id, 182 uint32_t value); 183 enum pm_ret_status pm_pll_get_parameter(enum pm_node_id nid, 184 enum pm_pll_param param_id, 185 uint32_t *value); 186 enum pm_ret_status pm_pll_set_mode(enum pm_node_id nid, enum pm_pll_mode mode); 187 enum pm_ret_status pm_pll_get_mode(enum pm_node_id nid, enum pm_pll_mode *mode); 188 enum pm_ret_status pm_efuse_access(uint32_t address_high, 189 uint32_t address_low, uint32_t *value); 190 enum pm_ret_status em_set_action(uint32_t *value); 191 enum pm_ret_status em_remove_action(uint32_t *value); 192 enum pm_ret_status em_send_errors(uint32_t *value); 193 enum pm_ret_status pm_feature_check(uint32_t api_id, uint32_t *version, 194 uint32_t *bit_mask, uint8_t len); 195 enum pm_ret_status check_api_dependency(uint8_t id); 196 197 #endif /* PM_API_SYS_H */ 198