Tejas Patel | 354fe57 | 2018-12-14 00:55:37 -0800 | [diff] [blame] | 1 | /* |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 2 | * Copyright (c) 2019-2022, Xilinx, Inc. All rights reserved. |
Naman Trivedi Manojbhai | c0dfba8 | 2023-03-07 12:41:11 +0530 | [diff] [blame] | 3 | * Copyright (c) 2022-2023, Advanced Micro Devices Inc. All rights reserved. |
Tejas Patel | 354fe57 | 2018-12-14 00:55:37 -0800 | [diff] [blame] | 4 | * |
| 5 | * SPDX-License-Identifier: BSD-3-Clause |
| 6 | */ |
| 7 | |
| 8 | /* Versal power management enums and defines */ |
| 9 | |
| 10 | #ifndef PM_DEFS_H |
| 11 | #define PM_DEFS_H |
| 12 | |
| 13 | #include "pm_node.h" |
| 14 | |
| 15 | /********************************************************************* |
| 16 | * Macro definitions |
| 17 | ********************************************************************/ |
| 18 | |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 19 | /* State arguments of the self suspend */ |
| 20 | #define PM_STATE_CPU_IDLE 0x0U |
| 21 | #define PM_STATE_SUSPEND_TO_RAM 0xFU |
| 22 | |
| 23 | #define MAX_LATENCY (~0U) |
| 24 | #define MAX_QOS 100U |
| 25 | |
Tejas Patel | 354fe57 | 2018-12-14 00:55:37 -0800 | [diff] [blame] | 26 | /* Processor core device IDs */ |
| 27 | #define APU_DEVID(IDX) NODEID(XPM_NODECLASS_DEVICE, XPM_NODESUBCL_DEV_CORE, \ |
| 28 | XPM_NODETYPE_DEV_CORE_APU, (IDX)) |
| 29 | |
| 30 | #define XPM_DEVID_ACPU_0 APU_DEVID(XPM_NODEIDX_DEV_ACPU_0) |
| 31 | #define XPM_DEVID_ACPU_1 APU_DEVID(XPM_NODEIDX_DEV_ACPU_1) |
| 32 | |
Tejas Patel | fcb7c16 | 2019-02-27 18:44:56 +0530 | [diff] [blame] | 33 | #define PERIPH_DEVID(IDX) NODEID(XPM_NODECLASS_DEVICE, \ |
| 34 | XPM_NODESUBCL_DEV_PERIPH, \ |
| 35 | XPM_NODETYPE_DEV_PERIPH, (IDX)) |
| 36 | |
Abhyuday Godhasara | edc38ae | 2021-08-04 23:58:46 -0700 | [diff] [blame] | 37 | #define PM_GET_CALLBACK_DATA 0xa01U |
| 38 | #define PM_GET_TRUSTZONE_VERSION 0xa03U |
Tanmay Shah | 0dde16c | 2021-12-14 04:53:40 -0800 | [diff] [blame] | 39 | #define TF_A_PM_REGISTER_SGI 0xa04U |
Ravi Patel | 22b0b49 | 2019-03-06 12:34:46 +0530 | [diff] [blame] | 40 | |
| 41 | /* PM API Versions */ |
| 42 | #define PM_API_BASE_VERSION 1U |
Venkatesh Yadav Abbarapu | d90e47b | 2022-07-28 08:50:30 +0530 | [diff] [blame] | 43 | #define PM_API_VERSION_2 2U |
Rajan Vaja | 030620d | 2020-11-23 04:13:54 -0800 | [diff] [blame] | 44 | |
Tejas Patel | 9d09ff9 | 2019-01-08 01:46:35 -0800 | [diff] [blame] | 45 | /* PM API ids */ |
Tejas Patel | 4201555 | 2020-11-25 01:56:57 -0800 | [diff] [blame] | 46 | #define PM_REGISTER_NOTIFIER 5U |
Tejas Patel | fe0e10a | 2019-12-08 23:29:44 -0800 | [diff] [blame] | 47 | #define PM_REQ_SUSPEND 6U |
| 48 | #define PM_SELF_SUSPEND 7U |
Tejas Patel | 6b28225 | 2019-01-10 03:03:47 -0800 | [diff] [blame] | 49 | #define PM_FORCE_POWERDOWN 8U |
Tejas Patel | fe0e10a | 2019-12-08 23:29:44 -0800 | [diff] [blame] | 50 | #define PM_ABORT_SUSPEND 9U |
Tejas Patel | 49cd871 | 2019-01-23 14:18:51 +0530 | [diff] [blame] | 51 | #define PM_REQ_WAKEUP 10U |
Tejas Patel | db81205 | 2019-01-23 14:18:53 +0530 | [diff] [blame] | 52 | #define PM_SET_WAKEUP_SOURCE 11U |
Tejas Patel | 6b28225 | 2019-01-10 03:03:47 -0800 | [diff] [blame] | 53 | #define PM_SYSTEM_SHUTDOWN 12U |
Tejas Patel | 9141f44 | 2019-01-10 03:03:48 -0800 | [diff] [blame] | 54 | #define PM_IOCTL 34U |
Tejas Patel | a3e34ad | 2019-02-01 17:25:19 +0530 | [diff] [blame] | 55 | #define PM_QUERY_DATA 35U |
Tejas Patel | 023116d | 2019-01-08 01:46:41 -0800 | [diff] [blame] | 56 | #define PM_PLL_SET_PARAMETER 48U |
| 57 | #define PM_PLL_GET_PARAMETER 49U |
| 58 | #define PM_PLL_SET_MODE 50U |
| 59 | #define PM_PLL_GET_MODE 51U |
Ravi Patel | 22b0b49 | 2019-03-06 12:34:46 +0530 | [diff] [blame] | 60 | #define PM_FEATURE_CHECK 63U |
Tejas Patel | 9d09ff9 | 2019-01-08 01:46:35 -0800 | [diff] [blame] | 61 | |
Jolly Shah | ed05a71 | 2019-03-22 05:33:39 +0530 | [diff] [blame] | 62 | /* Loader API ids */ |
| 63 | #define PM_LOAD_PDI 0x701U |
Venkatesh Yadav Abbarapu | 58b24d8 | 2022-07-12 09:19:03 +0530 | [diff] [blame] | 64 | #define PM_LOAD_GET_HANDOFF_PARAMS 0x70BU |
Jolly Shah | ed05a71 | 2019-03-22 05:33:39 +0530 | [diff] [blame] | 65 | |
Tejas Patel | 9141f44 | 2019-01-10 03:03:48 -0800 | [diff] [blame] | 66 | /* IOCTL IDs for clock driver */ |
Abhyuday Godhasara | edc38ae | 2021-08-04 23:58:46 -0700 | [diff] [blame] | 67 | #define IOCTL_SET_PLL_FRAC_MODE 8U |
| 68 | #define IOCTL_GET_PLL_FRAC_MODE 9U |
| 69 | #define IOCTL_SET_PLL_FRAC_DATA 10U |
| 70 | #define IOCTL_GET_PLL_FRAC_DATA 11U |
| 71 | #define IOCTL_SET_SGI 25U |
Tejas Patel | 9141f44 | 2019-01-10 03:03:48 -0800 | [diff] [blame] | 72 | |
| 73 | /* Parameter ID for PLL IOCTLs */ |
| 74 | /* Fractional data portion for PLL */ |
| 75 | #define PM_PLL_PARAM_DATA 2 |
| 76 | |
Saeed Nowshadi | c5a1bda | 2019-12-08 23:35:35 -0800 | [diff] [blame] | 77 | /* System shutdown macros */ |
| 78 | #define XPM_SHUTDOWN_TYPE_SHUTDOWN 0U |
| 79 | #define XPM_SHUTDOWN_TYPE_RESET 1U |
| 80 | #define XPM_SHUTDOWN_TYPE_SETSCOPE_ONLY 2U |
| 81 | |
| 82 | #define XPM_SHUTDOWN_SUBTYPE_RST_SUBSYSTEM 0U |
| 83 | #define XPM_SHUTDOWN_SUBTYPE_RST_PS_ONLY 1U |
| 84 | #define XPM_SHUTDOWN_SUBTYPE_RST_SYSTEM 2U |
| 85 | |
Tejas Patel | 354fe57 | 2018-12-14 00:55:37 -0800 | [diff] [blame] | 86 | /********************************************************************* |
| 87 | * Enum definitions |
| 88 | ********************************************************************/ |
| 89 | |
Tejas Patel | fe0e10a | 2019-12-08 23:29:44 -0800 | [diff] [blame] | 90 | enum pm_abort_reason { |
| 91 | ABORT_REASON_WKUP_EVENT = 100, |
| 92 | ABORT_REASON_PU_BUSY, |
| 93 | ABORT_REASON_NO_PWRDN, |
| 94 | ABORT_REASON_UNKNOWN, |
| 95 | }; |
| 96 | |
Saeed Nowshadi | 2294b42 | 2019-06-03 10:22:35 -0700 | [diff] [blame] | 97 | enum pm_opchar_type { |
| 98 | PM_OPCHAR_TYPE_POWER = 1, |
| 99 | PM_OPCHAR_TYPE_TEMP, |
| 100 | PM_OPCHAR_TYPE_LATENCY, |
| 101 | }; |
| 102 | |
Tejas Patel | 354fe57 | 2018-12-14 00:55:37 -0800 | [diff] [blame] | 103 | /** |
Tejas Patel | 41f3e0b | 2019-01-08 01:46:37 -0800 | [diff] [blame] | 104 | * Subsystem IDs |
| 105 | */ |
| 106 | typedef enum { |
| 107 | XPM_SUBSYSID_PMC, |
| 108 | XPM_SUBSYSID_PSM, |
| 109 | XPM_SUBSYSID_APU, |
| 110 | XPM_SUBSYSID_RPU0_LOCK, |
| 111 | XPM_SUBSYSID_RPU0_0, |
| 112 | XPM_SUBSYSID_RPU0_1, |
| 113 | XPM_SUBSYSID_DDR0, |
| 114 | XPM_SUBSYSID_ME, |
| 115 | XPM_SUBSYSID_PL, |
| 116 | XPM_SUBSYSID_MAX, |
| 117 | } XPm_SubsystemId; |
| 118 | |
Naman Trivedi Manojbhai | c0dfba8 | 2023-03-07 12:41:11 +0530 | [diff] [blame] | 119 | /* TODO: move pm_ret_status from device specific location to common location */ |
Tejas Patel | 41f3e0b | 2019-01-08 01:46:37 -0800 | [diff] [blame] | 120 | /** |
Tejas Patel | 354fe57 | 2018-12-14 00:55:37 -0800 | [diff] [blame] | 121 | * @PM_RET_SUCCESS: success |
| 122 | * @PM_RET_ERROR_ARGS: illegal arguments provided (deprecated) |
| 123 | * @PM_RET_ERROR_NOTSUPPORTED: feature not supported (deprecated) |
Ravi Patel | 22b0b49 | 2019-03-06 12:34:46 +0530 | [diff] [blame] | 124 | * @PM_RET_ERROR_NOFEATURE: feature is not available |
Naman Trivedi Manojbhai | c0dfba8 | 2023-03-07 12:41:11 +0530 | [diff] [blame] | 125 | * @PM_RET_ERROR_INVALID_CRC: invalid crc in IPI communication |
Tejas Patel | 354fe57 | 2018-12-14 00:55:37 -0800 | [diff] [blame] | 126 | * @PM_RET_ERROR_INTERNAL: internal error |
| 127 | * @PM_RET_ERROR_CONFLICT: conflict |
| 128 | * @PM_RET_ERROR_ACCESS: access rights violation |
| 129 | * @PM_RET_ERROR_INVALID_NODE: invalid node |
| 130 | * @PM_RET_ERROR_DOUBLE_REQ: duplicate request for same node |
| 131 | * @PM_RET_ERROR_ABORT_SUSPEND: suspend procedure has been aborted |
| 132 | * @PM_RET_ERROR_TIMEOUT: timeout in communication with PMU |
| 133 | * @PM_RET_ERROR_NODE_USED: node is already in use |
| 134 | */ |
| 135 | enum pm_ret_status { |
| 136 | PM_RET_SUCCESS, |
| 137 | PM_RET_ERROR_ARGS = 1, |
| 138 | PM_RET_ERROR_NOTSUPPORTED = 4, |
Ravi Patel | 22b0b49 | 2019-03-06 12:34:46 +0530 | [diff] [blame] | 139 | PM_RET_ERROR_NOFEATURE = 19, |
Naman Trivedi Manojbhai | c0dfba8 | 2023-03-07 12:41:11 +0530 | [diff] [blame] | 140 | PM_RET_ERROR_INVALID_CRC = 301, |
Tejas Patel | 354fe57 | 2018-12-14 00:55:37 -0800 | [diff] [blame] | 141 | PM_RET_ERROR_INTERNAL = 2000, |
| 142 | PM_RET_ERROR_CONFLICT = 2001, |
| 143 | PM_RET_ERROR_ACCESS = 2002, |
| 144 | PM_RET_ERROR_INVALID_NODE = 2003, |
| 145 | PM_RET_ERROR_DOUBLE_REQ = 2004, |
| 146 | PM_RET_ERROR_ABORT_SUSPEND = 2005, |
| 147 | PM_RET_ERROR_TIMEOUT = 2006, |
| 148 | PM_RET_ERROR_NODE_USED = 2007 |
| 149 | }; |
Rajan Vaja | 030620d | 2020-11-23 04:13:54 -0800 | [diff] [blame] | 150 | |
| 151 | /** |
| 152 | * Qids |
| 153 | */ |
| 154 | enum pm_query_id { |
| 155 | XPM_QID_INVALID, |
| 156 | XPM_QID_CLOCK_GET_NAME, |
| 157 | XPM_QID_CLOCK_GET_TOPOLOGY, |
| 158 | XPM_QID_CLOCK_GET_FIXEDFACTOR_PARAMS, |
| 159 | XPM_QID_CLOCK_GET_MUXSOURCES, |
| 160 | XPM_QID_CLOCK_GET_ATTRIBUTES, |
| 161 | XPM_QID_PINCTRL_GET_NUM_PINS, |
| 162 | XPM_QID_PINCTRL_GET_NUM_FUNCTIONS, |
| 163 | XPM_QID_PINCTRL_GET_NUM_FUNCTION_GROUPS, |
| 164 | XPM_QID_PINCTRL_GET_FUNCTION_NAME, |
| 165 | XPM_QID_PINCTRL_GET_FUNCTION_GROUPS, |
| 166 | XPM_QID_PINCTRL_GET_PIN_GROUPS, |
| 167 | XPM_QID_CLOCK_GET_NUM_CLOCKS, |
| 168 | XPM_QID_CLOCK_GET_MAX_DIVISOR, |
| 169 | XPM_QID_PLD_GET_PARENT, |
| 170 | }; |
Tejas Patel | 354fe57 | 2018-12-14 00:55:37 -0800 | [diff] [blame] | 171 | #endif /* PM_DEFS_H */ |