blob: 9cdb0ba07f7e5f185df0eaf3308e871f282abd5b [file] [log] [blame]
Tejas Patel354fe572018-12-14 00:55:37 -08001/*
Tanmay Shahff34daa2021-08-09 11:00:41 -07002 * Copyright (c) 2019-2022, Xilinx, Inc. All rights reserved.
Michal Simekd4ff2722023-04-20 08:01:03 +02003 * Copyright (c) 2022-2023, Advanced Micro Devices, Inc. All rights reserved.
Tejas Patel354fe572018-12-14 00:55:37 -08004 *
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 Patel54d13192019-02-27 18:44:55 +053019/* 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 Patel354fe572018-12-14 00:55:37 -080026/* 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
Jay Buddhabhattif2f84b32023-02-09 22:56:53 -080033#define PERIPH_DEVID(IDX) NODEID((uint32_t)XPM_NODECLASS_DEVICE, \
34 (uint32_t)XPM_NODESUBCL_DEV_PERIPH, \
35 (uint32_t)XPM_NODETYPE_DEV_PERIPH, (IDX))
Tejas Patelfcb7c162019-02-27 18:44:56 +053036
Abhyuday Godhasaraedc38ae2021-08-04 23:58:46 -070037#define PM_GET_CALLBACK_DATA 0xa01U
38#define PM_GET_TRUSTZONE_VERSION 0xa03U
Tanmay Shah0dde16c2021-12-14 04:53:40 -080039#define TF_A_PM_REGISTER_SGI 0xa04U
Ravi Patel22b0b492019-03-06 12:34:46 +053040
41/* PM API Versions */
42#define PM_API_BASE_VERSION 1U
Venkatesh Yadav Abbarapud90e47b2022-07-28 08:50:30 +053043#define PM_API_VERSION_2 2U
Rajan Vaja030620d2020-11-23 04:13:54 -080044
Jolly Shahed05a712019-03-22 05:33:39 +053045/* Loader API ids */
46#define PM_LOAD_PDI 0x701U
Venkatesh Yadav Abbarapu58b24d82022-07-12 09:19:03 +053047#define PM_LOAD_GET_HANDOFF_PARAMS 0x70BU
Jolly Shahed05a712019-03-22 05:33:39 +053048
Saeed Nowshadic5a1bda2019-12-08 23:35:35 -080049/* System shutdown macros */
50#define XPM_SHUTDOWN_TYPE_SHUTDOWN 0U
51#define XPM_SHUTDOWN_TYPE_RESET 1U
52#define XPM_SHUTDOWN_TYPE_SETSCOPE_ONLY 2U
53
54#define XPM_SHUTDOWN_SUBTYPE_RST_SUBSYSTEM 0U
55#define XPM_SHUTDOWN_SUBTYPE_RST_PS_ONLY 1U
56#define XPM_SHUTDOWN_SUBTYPE_RST_SYSTEM 2U
57
Tejas Patel354fe572018-12-14 00:55:37 -080058/*********************************************************************
59 * Enum definitions
60 ********************************************************************/
61
Prasad Kummari7d0623a2023-06-09 14:32:00 +053062/*
63 * ioctl id
64 */
Jay Buddhabhatti5b672d92023-03-23 05:02:50 -070065enum {
66 IOCTL_GET_RPU_OPER_MODE = 0,
67 IOCTL_SET_RPU_OPER_MODE = 1,
68 IOCTL_RPU_BOOT_ADDR_CONFIG = 2,
69 IOCTL_TCM_COMB_CONFIG = 3,
70 IOCTL_SET_TAPDELAY_BYPASS = 4,
Jay Buddhabhatti5b672d92023-03-23 05:02:50 -070071 IOCTL_SD_DLL_RESET = 6,
72 IOCTL_SET_SD_TAPDELAY = 7,
73 /* Ioctl for clock driver */
74 IOCTL_SET_PLL_FRAC_MODE = 8,
75 IOCTL_GET_PLL_FRAC_MODE = 9,
76 IOCTL_SET_PLL_FRAC_DATA = 10,
77 IOCTL_GET_PLL_FRAC_DATA = 11,
78 IOCTL_WRITE_GGS = 12,
79 IOCTL_READ_GGS = 13,
80 IOCTL_WRITE_PGGS = 14,
81 IOCTL_READ_PGGS = 15,
82 /* IOCTL for ULPI reset */
83 IOCTL_ULPI_RESET = 16,
84 /* Set healthy bit value */
85 IOCTL_SET_BOOT_HEALTH_STATUS = 17,
86 IOCTL_AFI = 18,
87 /* Probe counter read/write */
88 IOCTL_PROBE_COUNTER_READ = 19,
89 IOCTL_PROBE_COUNTER_WRITE = 20,
90 IOCTL_OSPI_MUX_SELECT = 21,
91 /* IOCTL for USB power request */
92 IOCTL_USB_SET_STATE = 22,
93 /* IOCTL to get last reset reason */
94 IOCTL_GET_LAST_RESET_REASON = 23,
95 /* AI engine NPI ISR clear */
96 IOCTL_AIE_ISR_CLEAR = 24,
97 /* Register SGI to TF-A */
98 IOCTL_SET_SGI = 25,
99};
100
Jay Buddhabhatti5b9f3912023-02-02 22:34:03 -0800101/**
Prasad Kummari7d0623a2023-06-09 14:32:00 +0530102 * enum pm_pll_param - enum represents the parameters for a phase-locked loop.
103 * @PM_PLL_PARAM_DIV2: Enable for divide by 2 function inside the PLL.
104 * @PM_PLL_PARAM_FBDIV: Feedback divisor integer portion for the PLL.
105 * @PM_PLL_PARAM_DATA: Feedback divisor fractional portion for the PLL.
106 * @PM_PLL_PARAM_PRE_SRC: Clock source for PLL input.
107 * @PM_PLL_PARAM_POST_SRC: Clock source for PLL Bypass mode.
108 * @PM_PLL_PARAM_LOCK_DLY: Lock circuit config settings for lock windowsize.
109 * @PM_PLL_PARAM_LOCK_CNT: Lock circuit counter setting.
110 * @PM_PLL_PARAM_LFHF: PLL loop filter high frequency capacitor control.
111 * @PM_PLL_PARAM_CP: PLL charge pump control.
112 * @PM_PLL_PARAM_RES: PLL loop filter resistor control.
113 * @PM_PLL_PARAM_MAX: Represents the maximum parameter value for the PLL
Jay Buddhabhatti5b9f3912023-02-02 22:34:03 -0800114 */
115enum pm_pll_param {
116 PM_PLL_PARAM_DIV2,
117 PM_PLL_PARAM_FBDIV,
118 PM_PLL_PARAM_DATA,
119 PM_PLL_PARAM_PRE_SRC,
120 PM_PLL_PARAM_POST_SRC,
121 PM_PLL_PARAM_LOCK_DLY,
122 PM_PLL_PARAM_LOCK_CNT,
123 PM_PLL_PARAM_LFHF,
124 PM_PLL_PARAM_CP,
125 PM_PLL_PARAM_RES,
126 PM_PLL_PARAM_MAX,
127};
128
129enum pm_api_id {
130 /* Miscellaneous API functions: */
131 PM_GET_API_VERSION = 1, /* Do not change or move */
132 PM_SET_CONFIGURATION,
133 PM_GET_NODE_STATUS,
134 PM_GET_OP_CHARACTERISTIC,
135 PM_REGISTER_NOTIFIER,
136 /* API for suspending of PUs: */
137 PM_REQ_SUSPEND,
138 PM_SELF_SUSPEND,
139 PM_FORCE_POWERDOWN,
140 PM_ABORT_SUSPEND,
141 PM_REQ_WAKEUP,
142 PM_SET_WAKEUP_SOURCE,
143 PM_SYSTEM_SHUTDOWN,
144 /* API for managing PM slaves: */
145 PM_REQ_NODE,
146 PM_RELEASE_NODE,
147 PM_SET_REQUIREMENT,
148 PM_SET_MAX_LATENCY,
149 /* Direct control API functions: */
150 PM_RESET_ASSERT,
151 PM_RESET_GET_STATUS,
152 PM_MMIO_WRITE,
153 PM_MMIO_READ,
154 PM_INIT_FINALIZE,
155 PM_FPGA_LOAD,
156 PM_FPGA_GET_STATUS,
157 PM_GET_CHIPID,
158 PM_SECURE_RSA_AES,
159 PM_SECURE_SHA,
160 PM_SECURE_RSA,
161 PM_PINCTRL_REQUEST,
162 PM_PINCTRL_RELEASE,
163 PM_PINCTRL_GET_FUNCTION,
164 PM_PINCTRL_SET_FUNCTION,
165 PM_PINCTRL_CONFIG_PARAM_GET,
166 PM_PINCTRL_CONFIG_PARAM_SET,
167 PM_IOCTL,
168 /* API to query information from firmware */
169 PM_QUERY_DATA,
170 /* Clock control API functions */
171 PM_CLOCK_ENABLE,
172 PM_CLOCK_DISABLE,
173 PM_CLOCK_GETSTATE,
174 PM_CLOCK_SETDIVIDER,
175 PM_CLOCK_GETDIVIDER,
Ronak Jaind5a3eff2023-08-02 01:28:10 -0700176 PM_CLOCK_SETPARENT = 43,
Jay Buddhabhatti5b9f3912023-02-02 22:34:03 -0800177 PM_CLOCK_GETPARENT,
178 PM_SECURE_IMAGE,
179 /* FPGA PL Readback */
180 PM_FPGA_READ,
181 PM_SECURE_AES,
182 /* PLL control API functions */
183 PM_PLL_SET_PARAMETER,
184 PM_PLL_GET_PARAMETER,
185 PM_PLL_SET_MODE,
186 PM_PLL_GET_MODE,
187 /* PM Register Access API */
188 PM_REGISTER_ACCESS,
189 PM_EFUSE_ACCESS,
190 PM_FPGA_GET_VERSION,
191 PM_FPGA_GET_FEATURE_LIST,
192 PM_FEATURE_CHECK = 63,
193 PM_API_MAX = 74
194};
195
Tejas Patelfe0e10a2019-12-08 23:29:44 -0800196enum pm_abort_reason {
197 ABORT_REASON_WKUP_EVENT = 100,
198 ABORT_REASON_PU_BUSY,
199 ABORT_REASON_NO_PWRDN,
200 ABORT_REASON_UNKNOWN,
201};
202
Saeed Nowshadi2294b422019-06-03 10:22:35 -0700203enum pm_opchar_type {
204 PM_OPCHAR_TYPE_POWER = 1,
205 PM_OPCHAR_TYPE_TEMP,
206 PM_OPCHAR_TYPE_LATENCY,
207};
208
Prasad Kummari7d0623a2023-06-09 14:32:00 +0530209/*
Tejas Patel41f3e0b2019-01-08 01:46:37 -0800210 * Subsystem IDs
211 */
212typedef enum {
213 XPM_SUBSYSID_PMC,
214 XPM_SUBSYSID_PSM,
215 XPM_SUBSYSID_APU,
216 XPM_SUBSYSID_RPU0_LOCK,
217 XPM_SUBSYSID_RPU0_0,
218 XPM_SUBSYSID_RPU0_1,
219 XPM_SUBSYSID_DDR0,
220 XPM_SUBSYSID_ME,
221 XPM_SUBSYSID_PL,
222 XPM_SUBSYSID_MAX,
223} XPm_SubsystemId;
224
Naman Trivedi Manojbhaic0dfba82023-03-07 12:41:11 +0530225/* TODO: move pm_ret_status from device specific location to common location */
Tejas Patel41f3e0b2019-01-08 01:46:37 -0800226/**
Prasad Kummari7d0623a2023-06-09 14:32:00 +0530227 * enum pm_ret_status - enum represents the return status codes for a PM
228 * operation.
229 * @PM_RET_SUCCESS: success.
230 * @PM_RET_ERROR_ARGS: illegal arguments provided (deprecated).
231 * @PM_RET_ERROR_NOTSUPPORTED: feature not supported (deprecated).
232 * @PM_RET_ERROR_NOFEATURE: feature is not available.
233 * @PM_RET_ERROR_INVALID_CRC: invalid crc in IPI communication.
234 * @PM_RET_ERROR_NOT_ENABLED: feature is not enabled.
235 * @PM_RET_ERROR_INTERNAL: internal error.
236 * @PM_RET_ERROR_CONFLICT: conflict.
237 * @PM_RET_ERROR_ACCESS: access rights violation.
238 * @PM_RET_ERROR_INVALID_NODE: invalid node.
239 * @PM_RET_ERROR_DOUBLE_REQ: duplicate request for same node.
240 * @PM_RET_ERROR_ABORT_SUSPEND: suspend procedure has been aborted.
241 * @PM_RET_ERROR_TIMEOUT: timeout in communication with PMU.
242 * @PM_RET_ERROR_NODE_USED: node is already in use.
243 * @PM_RET_ERROR_NO_FEATURE: indicates that the requested feature is not
244 * supported.
Tejas Patel354fe572018-12-14 00:55:37 -0800245 */
246enum pm_ret_status {
247 PM_RET_SUCCESS,
248 PM_RET_ERROR_ARGS = 1,
249 PM_RET_ERROR_NOTSUPPORTED = 4,
Ravi Patel22b0b492019-03-06 12:34:46 +0530250 PM_RET_ERROR_NOFEATURE = 19,
Naman Trivedi Manojbhaic0dfba82023-03-07 12:41:11 +0530251 PM_RET_ERROR_INVALID_CRC = 301,
Jay Buddhabhatti5b9f3912023-02-02 22:34:03 -0800252 PM_RET_ERROR_NOT_ENABLED = 29,
Tejas Patel354fe572018-12-14 00:55:37 -0800253 PM_RET_ERROR_INTERNAL = 2000,
254 PM_RET_ERROR_CONFLICT = 2001,
255 PM_RET_ERROR_ACCESS = 2002,
256 PM_RET_ERROR_INVALID_NODE = 2003,
257 PM_RET_ERROR_DOUBLE_REQ = 2004,
258 PM_RET_ERROR_ABORT_SUSPEND = 2005,
259 PM_RET_ERROR_TIMEOUT = 2006,
Jay Buddhabhatti5b9f3912023-02-02 22:34:03 -0800260 PM_RET_ERROR_NODE_USED = 2007,
261 PM_RET_ERROR_NO_FEATURE = 2008
Tejas Patel354fe572018-12-14 00:55:37 -0800262};
Rajan Vaja030620d2020-11-23 04:13:54 -0800263
Prasad Kummari7d0623a2023-06-09 14:32:00 +0530264/*
Rajan Vaja030620d2020-11-23 04:13:54 -0800265 * Qids
266 */
267enum pm_query_id {
268 XPM_QID_INVALID,
269 XPM_QID_CLOCK_GET_NAME,
270 XPM_QID_CLOCK_GET_TOPOLOGY,
271 XPM_QID_CLOCK_GET_FIXEDFACTOR_PARAMS,
272 XPM_QID_CLOCK_GET_MUXSOURCES,
273 XPM_QID_CLOCK_GET_ATTRIBUTES,
274 XPM_QID_PINCTRL_GET_NUM_PINS,
275 XPM_QID_PINCTRL_GET_NUM_FUNCTIONS,
276 XPM_QID_PINCTRL_GET_NUM_FUNCTION_GROUPS,
277 XPM_QID_PINCTRL_GET_FUNCTION_NAME,
278 XPM_QID_PINCTRL_GET_FUNCTION_GROUPS,
279 XPM_QID_PINCTRL_GET_PIN_GROUPS,
280 XPM_QID_CLOCK_GET_NUM_CLOCKS,
281 XPM_QID_CLOCK_GET_MAX_DIVISOR,
282 XPM_QID_PLD_GET_PARENT,
283};
Tejas Patel354fe572018-12-14 00:55:37 -0800284#endif /* PM_DEFS_H */