Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 1 | /* |
Michal Simek | 2a47faa | 2023-04-14 08:43:51 +0200 | [diff] [blame] | 2 | * Copyright (c) 2013-2022, Arm Limited and Contributors. All rights reserved. |
Michal Simek | 7c819f1 | 2023-02-27 09:28:20 +0100 | [diff] [blame] | 3 | * Copyright (c) 2023, Advanced Micro Devices Inc. All rights reserved. |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 4 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 5 | * SPDX-License-Identifier: BSD-3-Clause |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 6 | */ |
| 7 | |
Jay Buddhabhatti | 26e138a | 2022-12-21 23:03:35 -0800 | [diff] [blame] | 8 | #ifndef ZYNQMP_PM_API_SYS_H |
| 9 | #define ZYNQMP_PM_API_SYS_H |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 10 | |
| 11 | #include <stdint.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 12 | |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 13 | #include "pm_defs.h" |
Jay Buddhabhatti | 5b9f391 | 2023-02-02 22:34:03 -0800 | [diff] [blame] | 14 | #include "zynqmp_pm_defs.h" |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 15 | |
Jay Buddhabhatti | 5b9f391 | 2023-02-02 22:34:03 -0800 | [diff] [blame] | 16 | enum pm_query_ids { |
Rajan Vaja | 3511613 | 2018-01-17 02:39:25 -0800 | [diff] [blame] | 17 | PM_QID_INVALID, |
| 18 | PM_QID_CLOCK_GET_NAME, |
| 19 | PM_QID_CLOCK_GET_TOPOLOGY, |
| 20 | PM_QID_CLOCK_GET_FIXEDFACTOR_PARAMS, |
| 21 | PM_QID_CLOCK_GET_PARENTS, |
| 22 | PM_QID_CLOCK_GET_ATTRIBUTES, |
Rajan Vaja | d5dd836 | 2018-01-30 04:16:31 -0800 | [diff] [blame] | 23 | PM_QID_PINCTRL_GET_NUM_PINS, |
| 24 | PM_QID_PINCTRL_GET_NUM_FUNCTIONS, |
| 25 | PM_QID_PINCTRL_GET_NUM_FUNCTION_GROUPS, |
| 26 | PM_QID_PINCTRL_GET_FUNCTION_NAME, |
| 27 | PM_QID_PINCTRL_GET_FUNCTION_GROUPS, |
| 28 | PM_QID_PINCTRL_GET_PIN_GROUPS, |
Rajan Vaja | da95940 | 2018-07-20 03:16:27 -0700 | [diff] [blame] | 29 | PM_QID_CLOCK_GET_NUM_CLOCKS, |
Rajan Vaja | b34deca | 2019-03-20 01:13:21 +0530 | [diff] [blame] | 30 | PM_QID_CLOCK_GET_MAX_DIVISOR, |
Rajan Vaja | 3511613 | 2018-01-17 02:39:25 -0800 | [diff] [blame] | 31 | }; |
| 32 | |
Kalyani Akula | 6ebe483 | 2020-11-22 22:42:10 -0800 | [diff] [blame] | 33 | enum pm_register_access_id { |
| 34 | CONFIG_REG_WRITE, |
| 35 | CONFIG_REG_READ, |
| 36 | }; |
| 37 | |
Rajan Vaja | 0c0615a | 2021-10-12 03:30:09 -0700 | [diff] [blame] | 38 | /** |
| 39 | * Assigning of argument values into array elements. |
| 40 | */ |
| 41 | #define PM_PACK_PAYLOAD1(pl, arg0) { \ |
| 42 | pl[0] = (uint32_t)(arg0); \ |
| 43 | } |
| 44 | |
| 45 | #define PM_PACK_PAYLOAD2(pl, arg0, arg1) { \ |
| 46 | pl[1] = (uint32_t)(arg1); \ |
| 47 | PM_PACK_PAYLOAD1(pl, arg0); \ |
| 48 | } |
| 49 | |
| 50 | #define PM_PACK_PAYLOAD3(pl, arg0, arg1, arg2) { \ |
| 51 | pl[2] = (uint32_t)(arg2); \ |
| 52 | PM_PACK_PAYLOAD2(pl, arg0, arg1); \ |
| 53 | } |
| 54 | |
| 55 | #define PM_PACK_PAYLOAD4(pl, arg0, arg1, arg2, arg3) { \ |
| 56 | pl[3] = (uint32_t)(arg3); \ |
| 57 | PM_PACK_PAYLOAD3(pl, arg0, arg1, arg2); \ |
| 58 | } |
| 59 | |
| 60 | #define PM_PACK_PAYLOAD5(pl, arg0, arg1, arg2, arg3, arg4) { \ |
| 61 | pl[4] = (uint32_t)(arg4); \ |
| 62 | PM_PACK_PAYLOAD4(pl, arg0, arg1, arg2, arg3); \ |
| 63 | } |
| 64 | |
| 65 | #define PM_PACK_PAYLOAD6(pl, arg0, arg1, arg2, arg3, arg4, arg5) { \ |
| 66 | pl[5] = (uint32_t)(arg5); \ |
| 67 | PM_PACK_PAYLOAD5(pl, arg0, arg1, arg2, arg3, arg4); \ |
| 68 | } |
| 69 | |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 70 | /********************************************************** |
| 71 | * System-level API function declarations |
| 72 | **********************************************************/ |
Venkatesh Yadav Abbarapu | c70726f | 2022-05-16 17:44:33 +0530 | [diff] [blame] | 73 | enum pm_ret_status pm_req_suspend(enum pm_node_id target, |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 74 | enum pm_request_ack ack, |
Venkatesh Yadav Abbarapu | e7c4538 | 2022-05-19 14:49:49 +0530 | [diff] [blame] | 75 | uint32_t latency, |
| 76 | uint32_t state); |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 77 | |
| 78 | enum pm_ret_status pm_self_suspend(enum pm_node_id nid, |
Venkatesh Yadav Abbarapu | e7c4538 | 2022-05-19 14:49:49 +0530 | [diff] [blame] | 79 | uint32_t latency, |
| 80 | uint32_t state, |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 81 | uintptr_t address); |
| 82 | |
Venkatesh Yadav Abbarapu | c70726f | 2022-05-16 17:44:33 +0530 | [diff] [blame] | 83 | enum pm_ret_status pm_force_powerdown(enum pm_node_id target, |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 84 | enum pm_request_ack ack); |
| 85 | |
| 86 | enum pm_ret_status pm_abort_suspend(enum pm_abort_reason reason); |
| 87 | |
Venkatesh Yadav Abbarapu | c70726f | 2022-05-16 17:44:33 +0530 | [diff] [blame] | 88 | enum pm_ret_status pm_req_wakeup(enum pm_node_id target, |
Venkatesh Yadav Abbarapu | e7c4538 | 2022-05-19 14:49:49 +0530 | [diff] [blame] | 89 | uint32_t set_address, |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 90 | uintptr_t address, |
| 91 | enum pm_request_ack ack); |
| 92 | |
| 93 | enum pm_ret_status pm_set_wakeup_source(enum pm_node_id target, |
| 94 | enum pm_node_id wkup_node, |
Venkatesh Yadav Abbarapu | e7c4538 | 2022-05-19 14:49:49 +0530 | [diff] [blame] | 95 | uint32_t enable); |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 96 | |
Venkatesh Yadav Abbarapu | e7c4538 | 2022-05-19 14:49:49 +0530 | [diff] [blame] | 97 | enum pm_ret_status pm_system_shutdown(uint32_t type, uint32_t subtype); |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 98 | |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 99 | /* API functions for managing PM Slaves */ |
| 100 | enum pm_ret_status pm_req_node(enum pm_node_id nid, |
Venkatesh Yadav Abbarapu | e7c4538 | 2022-05-19 14:49:49 +0530 | [diff] [blame] | 101 | uint32_t capabilities, |
| 102 | uint32_t qos, |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 103 | enum pm_request_ack ack); |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 104 | |
| 105 | enum pm_ret_status pm_set_requirement(enum pm_node_id nid, |
Venkatesh Yadav Abbarapu | e7c4538 | 2022-05-19 14:49:49 +0530 | [diff] [blame] | 106 | uint32_t capabilities, |
| 107 | uint32_t qos, |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 108 | enum pm_request_ack ack); |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 109 | |
| 110 | /* Miscellaneous API functions */ |
Venkatesh Yadav Abbarapu | e7c4538 | 2022-05-19 14:49:49 +0530 | [diff] [blame] | 111 | enum pm_ret_status pm_get_api_version(uint32_t *version); |
Venkatesh Yadav Abbarapu | c70726f | 2022-05-16 17:44:33 +0530 | [diff] [blame] | 112 | enum pm_ret_status pm_get_node_status(enum pm_node_id nid, |
Anes Hadziahmetagic | 1caf88e | 2017-01-27 18:42:44 +0100 | [diff] [blame] | 113 | uint32_t *ret_buff); |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 114 | |
| 115 | /* Direct-Control API functions */ |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 116 | enum pm_ret_status pm_mmio_write(uintptr_t address, |
Venkatesh Yadav Abbarapu | e7c4538 | 2022-05-19 14:49:49 +0530 | [diff] [blame] | 117 | uint32_t mask, |
| 118 | uint32_t value); |
| 119 | enum pm_ret_status pm_mmio_read(uintptr_t address, uint32_t *value); |
Soren Brinkmann | 881788d | 2017-09-18 09:13:17 -0700 | [diff] [blame] | 120 | enum pm_ret_status pm_fpga_load(uint32_t address_low, |
| 121 | uint32_t address_high, |
Nava kishore Manne | 68d460c | 2016-08-20 23:18:09 +0530 | [diff] [blame] | 122 | uint32_t size, |
| 123 | uint32_t flags); |
Venkatesh Yadav Abbarapu | e7c4538 | 2022-05-19 14:49:49 +0530 | [diff] [blame] | 124 | enum pm_ret_status pm_fpga_get_status(uint32_t *value); |
Nava kishore Manne | 68d460c | 2016-08-20 23:18:09 +0530 | [diff] [blame] | 125 | |
Soren Brinkmann | cb36681 | 2016-09-22 12:21:11 -0700 | [diff] [blame] | 126 | enum pm_ret_status pm_get_chipid(uint32_t *value); |
Venkatesh Yadav Abbarapu | c70726f | 2022-05-16 17:44:33 +0530 | [diff] [blame] | 127 | enum pm_ret_status pm_secure_rsaaes(uint32_t address_low, |
| 128 | uint32_t address_high, |
Siva Durga Prasad Paladugu | de93d98 | 2018-04-30 15:49:27 +0530 | [diff] [blame] | 129 | uint32_t size, |
| 130 | uint32_t flags); |
HariBabu Gattem | 6535f86 | 2022-09-22 02:45:16 -0700 | [diff] [blame] | 131 | uint32_t pm_get_shutdown_scope(void); |
Naman Trivedi Manojbhai | beec83f | 2023-03-07 12:41:12 +0530 | [diff] [blame] | 132 | enum pm_ret_status pm_get_callbackdata(uint32_t *data, size_t count); |
Rajan Vaja | 5529a01 | 2018-01-17 02:39:23 -0800 | [diff] [blame] | 133 | enum pm_ret_status pm_ioctl(enum pm_node_id nid, |
Venkatesh Yadav Abbarapu | e7c4538 | 2022-05-19 14:49:49 +0530 | [diff] [blame] | 134 | uint32_t ioctl_id, |
| 135 | uint32_t arg1, |
| 136 | uint32_t arg2, |
| 137 | uint32_t *value); |
| 138 | enum pm_ret_status pm_clock_enable(uint32_t clock_id); |
| 139 | enum pm_ret_status pm_clock_disable(uint32_t clock_id); |
| 140 | enum pm_ret_status pm_clock_getstate(uint32_t clock_id, |
| 141 | uint32_t *state); |
| 142 | enum pm_ret_status pm_clock_setdivider(uint32_t clock_id, |
| 143 | uint32_t divider); |
| 144 | enum pm_ret_status pm_clock_getdivider(uint32_t clock_id, |
| 145 | uint32_t *divider); |
| 146 | enum pm_ret_status pm_clock_setrate(uint32_t clock_id, |
Rajan Vaja | 3511613 | 2018-01-17 02:39:25 -0800 | [diff] [blame] | 147 | uint64_t rate); |
Venkatesh Yadav Abbarapu | e7c4538 | 2022-05-19 14:49:49 +0530 | [diff] [blame] | 148 | enum pm_ret_status pm_clock_getrate(uint32_t clock_id, |
Rajan Vaja | 3511613 | 2018-01-17 02:39:25 -0800 | [diff] [blame] | 149 | uint64_t *rate); |
Venkatesh Yadav Abbarapu | e7c4538 | 2022-05-19 14:49:49 +0530 | [diff] [blame] | 150 | enum pm_ret_status pm_clock_setparent(uint32_t clock_id, |
| 151 | uint32_t parent_index); |
| 152 | enum pm_ret_status pm_clock_getparent(uint32_t clock_id, |
| 153 | uint32_t *parent_index); |
Jay Buddhabhatti | 5b9f391 | 2023-02-02 22:34:03 -0800 | [diff] [blame] | 154 | void pm_query_data(enum pm_query_ids qid, uint32_t arg1, uint32_t arg2, |
Venkatesh Yadav Abbarapu | e7c4538 | 2022-05-19 14:49:49 +0530 | [diff] [blame] | 155 | uint32_t arg3, uint32_t *data); |
Siva Durga Prasad Paladugu | f3994cc | 2018-05-01 11:12:55 +0530 | [diff] [blame] | 156 | enum pm_ret_status pm_sha_hash(uint32_t address_high, |
| 157 | uint32_t address_low, |
| 158 | uint32_t size, |
| 159 | uint32_t flags); |
| 160 | enum pm_ret_status pm_rsa_core(uint32_t address_high, |
| 161 | uint32_t address_low, |
| 162 | uint32_t size, |
| 163 | uint32_t flags); |
Siva Durga Prasad Paladugu | a4ed4b2 | 2018-04-30 20:06:58 +0530 | [diff] [blame] | 164 | enum pm_ret_status pm_secure_image(uint32_t address_low, |
| 165 | uint32_t address_high, |
| 166 | uint32_t key_lo, |
| 167 | uint32_t key_hi, |
| 168 | uint32_t *value); |
Siva Durga Prasad Paladugu | 7c6516a | 2018-09-04 17:41:34 +0530 | [diff] [blame] | 169 | enum pm_ret_status pm_fpga_read(uint32_t reg_numframes, |
| 170 | uint32_t address_low, |
| 171 | uint32_t address_high, |
| 172 | uint32_t readback_type, |
| 173 | uint32_t *value); |
Siva Durga Prasad Paladugu | 8bd905b | 2018-09-04 18:05:50 +0530 | [diff] [blame] | 174 | enum pm_ret_status pm_aes_engine(uint32_t address_high, |
| 175 | uint32_t address_low, |
| 176 | uint32_t *value); |
Venkatesh Yadav Abbarapu | e7c4538 | 2022-05-19 14:49:49 +0530 | [diff] [blame] | 177 | enum pm_ret_status pm_register_access(uint32_t register_access_id, |
| 178 | uint32_t address, |
| 179 | uint32_t mask, |
| 180 | uint32_t value, |
| 181 | uint32_t *out); |
Jolly Shah | a7cc5ee | 2019-01-02 12:27:00 -0800 | [diff] [blame] | 182 | enum pm_ret_status pm_pll_set_parameter(enum pm_node_id nid, |
Michal Simek | 08341b7 | 2022-03-09 08:53:20 +0100 | [diff] [blame] | 183 | enum pm_pll_param param_id, |
Venkatesh Yadav Abbarapu | e7c4538 | 2022-05-19 14:49:49 +0530 | [diff] [blame] | 184 | uint32_t value); |
Jolly Shah | cb2f45d | 2019-01-04 11:28:38 -0800 | [diff] [blame] | 185 | enum pm_ret_status pm_pll_get_parameter(enum pm_node_id nid, |
Michal Simek | 08341b7 | 2022-03-09 08:53:20 +0100 | [diff] [blame] | 186 | enum pm_pll_param param_id, |
Venkatesh Yadav Abbarapu | e7c4538 | 2022-05-19 14:49:49 +0530 | [diff] [blame] | 187 | uint32_t *value); |
Jolly Shah | 1f0d585 | 2019-01-04 11:32:31 -0800 | [diff] [blame] | 188 | enum pm_ret_status pm_pll_set_mode(enum pm_node_id nid, enum pm_pll_mode mode); |
Jolly Shah | 141421e | 2019-01-04 11:35:48 -0800 | [diff] [blame] | 189 | enum pm_ret_status pm_pll_get_mode(enum pm_node_id nid, enum pm_pll_mode *mode); |
VNSL Durga | deb1a36 | 2020-11-23 04:46:04 -0800 | [diff] [blame] | 190 | enum pm_ret_status pm_efuse_access(uint32_t address_high, |
| 191 | uint32_t address_low, uint32_t *value); |
Ronak Jain | 325bad1 | 2021-12-21 01:39:59 -0800 | [diff] [blame] | 192 | enum pm_ret_status pm_feature_check(uint32_t api_id, uint32_t *version, |
| 193 | uint32_t *bit_mask, uint8_t len); |
| 194 | enum pm_ret_status check_api_dependency(uint8_t id); |
Ronak Jain | 42d6f39 | 2021-08-11 00:26:28 -0700 | [diff] [blame] | 195 | |
Jay Buddhabhatti | 26e138a | 2022-12-21 23:03:35 -0800 | [diff] [blame] | 196 | #endif /* ZYNQMP_PM_API_SYS_H */ |