xref: /arm-trusted-firmware/plat/xilinx/common/include/pm_defs.h (revision 91f16700b400a8c0651d24a598fc48ee2997a0d7)
1*91f16700Schasinglulu /*
2*91f16700Schasinglulu  * Copyright (c) 2019-2022, Xilinx, Inc. All rights reserved.
3*91f16700Schasinglulu  * Copyright (c) 2022-2023, Advanced Micro Devices, Inc. All rights reserved.
4*91f16700Schasinglulu  *
5*91f16700Schasinglulu  * SPDX-License-Identifier: BSD-3-Clause
6*91f16700Schasinglulu  */
7*91f16700Schasinglulu 
8*91f16700Schasinglulu /* Versal power management enums and defines */
9*91f16700Schasinglulu 
10*91f16700Schasinglulu #ifndef PM_DEFS_H
11*91f16700Schasinglulu #define PM_DEFS_H
12*91f16700Schasinglulu 
13*91f16700Schasinglulu #include "pm_node.h"
14*91f16700Schasinglulu 
15*91f16700Schasinglulu /*********************************************************************
16*91f16700Schasinglulu  * Macro definitions
17*91f16700Schasinglulu  ********************************************************************/
18*91f16700Schasinglulu 
19*91f16700Schasinglulu /* State arguments of the self suspend */
20*91f16700Schasinglulu #define PM_STATE_CPU_IDLE	0x0U
21*91f16700Schasinglulu #define PM_STATE_SUSPEND_TO_RAM	0xFU
22*91f16700Schasinglulu 
23*91f16700Schasinglulu #define MAX_LATENCY		(~0U)
24*91f16700Schasinglulu #define MAX_QOS			100U
25*91f16700Schasinglulu 
26*91f16700Schasinglulu /* Processor core device IDs */
27*91f16700Schasinglulu #define APU_DEVID(IDX)	NODEID(XPM_NODECLASS_DEVICE, XPM_NODESUBCL_DEV_CORE, \
28*91f16700Schasinglulu 			       XPM_NODETYPE_DEV_CORE_APU, (IDX))
29*91f16700Schasinglulu 
30*91f16700Schasinglulu #define XPM_DEVID_ACPU_0	APU_DEVID(XPM_NODEIDX_DEV_ACPU_0)
31*91f16700Schasinglulu #define XPM_DEVID_ACPU_1	APU_DEVID(XPM_NODEIDX_DEV_ACPU_1)
32*91f16700Schasinglulu 
33*91f16700Schasinglulu #define PERIPH_DEVID(IDX)	NODEID((uint32_t)XPM_NODECLASS_DEVICE, \
34*91f16700Schasinglulu 				       (uint32_t)XPM_NODESUBCL_DEV_PERIPH, \
35*91f16700Schasinglulu 				       (uint32_t)XPM_NODETYPE_DEV_PERIPH, (IDX))
36*91f16700Schasinglulu 
37*91f16700Schasinglulu #define PM_GET_CALLBACK_DATA		0xa01U
38*91f16700Schasinglulu #define PM_GET_TRUSTZONE_VERSION	0xa03U
39*91f16700Schasinglulu #define TF_A_PM_REGISTER_SGI		0xa04U
40*91f16700Schasinglulu 
41*91f16700Schasinglulu /* PM API Versions */
42*91f16700Schasinglulu #define PM_API_BASE_VERSION		1U
43*91f16700Schasinglulu #define PM_API_VERSION_2		2U
44*91f16700Schasinglulu 
45*91f16700Schasinglulu /* Loader API ids */
46*91f16700Schasinglulu #define PM_LOAD_PDI			0x701U
47*91f16700Schasinglulu #define PM_LOAD_GET_HANDOFF_PARAMS	0x70BU
48*91f16700Schasinglulu 
49*91f16700Schasinglulu /* System shutdown macros */
50*91f16700Schasinglulu #define	XPM_SHUTDOWN_TYPE_SHUTDOWN	0U
51*91f16700Schasinglulu #define	XPM_SHUTDOWN_TYPE_RESET		1U
52*91f16700Schasinglulu #define	XPM_SHUTDOWN_TYPE_SETSCOPE_ONLY	2U
53*91f16700Schasinglulu 
54*91f16700Schasinglulu #define	XPM_SHUTDOWN_SUBTYPE_RST_SUBSYSTEM	0U
55*91f16700Schasinglulu #define	XPM_SHUTDOWN_SUBTYPE_RST_PS_ONLY	1U
56*91f16700Schasinglulu #define	XPM_SHUTDOWN_SUBTYPE_RST_SYSTEM		2U
57*91f16700Schasinglulu 
58*91f16700Schasinglulu /*********************************************************************
59*91f16700Schasinglulu  * Enum definitions
60*91f16700Schasinglulu  ********************************************************************/
61*91f16700Schasinglulu 
62*91f16700Schasinglulu /*
63*91f16700Schasinglulu  * ioctl id
64*91f16700Schasinglulu  */
65*91f16700Schasinglulu enum {
66*91f16700Schasinglulu 	IOCTL_GET_RPU_OPER_MODE = 0,
67*91f16700Schasinglulu 	IOCTL_SET_RPU_OPER_MODE = 1,
68*91f16700Schasinglulu 	IOCTL_RPU_BOOT_ADDR_CONFIG = 2,
69*91f16700Schasinglulu 	IOCTL_TCM_COMB_CONFIG = 3,
70*91f16700Schasinglulu 	IOCTL_SET_TAPDELAY_BYPASS = 4,
71*91f16700Schasinglulu 	IOCTL_SD_DLL_RESET = 6,
72*91f16700Schasinglulu 	IOCTL_SET_SD_TAPDELAY = 7,
73*91f16700Schasinglulu 	 /* Ioctl for clock driver */
74*91f16700Schasinglulu 	IOCTL_SET_PLL_FRAC_MODE = 8,
75*91f16700Schasinglulu 	IOCTL_GET_PLL_FRAC_MODE = 9,
76*91f16700Schasinglulu 	IOCTL_SET_PLL_FRAC_DATA = 10,
77*91f16700Schasinglulu 	IOCTL_GET_PLL_FRAC_DATA = 11,
78*91f16700Schasinglulu 	IOCTL_WRITE_GGS = 12,
79*91f16700Schasinglulu 	IOCTL_READ_GGS = 13,
80*91f16700Schasinglulu 	IOCTL_WRITE_PGGS = 14,
81*91f16700Schasinglulu 	IOCTL_READ_PGGS = 15,
82*91f16700Schasinglulu 	/* IOCTL for ULPI reset */
83*91f16700Schasinglulu 	IOCTL_ULPI_RESET = 16,
84*91f16700Schasinglulu 	/* Set healthy bit value */
85*91f16700Schasinglulu 	IOCTL_SET_BOOT_HEALTH_STATUS = 17,
86*91f16700Schasinglulu 	IOCTL_AFI = 18,
87*91f16700Schasinglulu 	/* Probe counter read/write */
88*91f16700Schasinglulu 	IOCTL_PROBE_COUNTER_READ = 19,
89*91f16700Schasinglulu 	IOCTL_PROBE_COUNTER_WRITE = 20,
90*91f16700Schasinglulu 	IOCTL_OSPI_MUX_SELECT = 21,
91*91f16700Schasinglulu 	/* IOCTL for USB power request */
92*91f16700Schasinglulu 	IOCTL_USB_SET_STATE = 22,
93*91f16700Schasinglulu 	/* IOCTL to get last reset reason */
94*91f16700Schasinglulu 	IOCTL_GET_LAST_RESET_REASON = 23,
95*91f16700Schasinglulu 	/* AI engine NPI ISR clear */
96*91f16700Schasinglulu 	IOCTL_AIE_ISR_CLEAR = 24,
97*91f16700Schasinglulu 	/* Register SGI to TF-A */
98*91f16700Schasinglulu 	IOCTL_SET_SGI = 25,
99*91f16700Schasinglulu };
100*91f16700Schasinglulu 
101*91f16700Schasinglulu /**
102*91f16700Schasinglulu  * enum pm_pll_param - enum represents the parameters for a phase-locked loop.
103*91f16700Schasinglulu  * @PM_PLL_PARAM_DIV2: Enable for divide by 2 function inside the PLL.
104*91f16700Schasinglulu  * @PM_PLL_PARAM_FBDIV: Feedback divisor integer portion for the PLL.
105*91f16700Schasinglulu  * @PM_PLL_PARAM_DATA: Feedback divisor fractional portion for the PLL.
106*91f16700Schasinglulu  * @PM_PLL_PARAM_PRE_SRC: Clock source for PLL input.
107*91f16700Schasinglulu  * @PM_PLL_PARAM_POST_SRC: Clock source for PLL Bypass mode.
108*91f16700Schasinglulu  * @PM_PLL_PARAM_LOCK_DLY: Lock circuit config settings for lock windowsize.
109*91f16700Schasinglulu  * @PM_PLL_PARAM_LOCK_CNT: Lock circuit counter setting.
110*91f16700Schasinglulu  * @PM_PLL_PARAM_LFHF: PLL loop filter high frequency capacitor control.
111*91f16700Schasinglulu  * @PM_PLL_PARAM_CP: PLL charge pump control.
112*91f16700Schasinglulu  * @PM_PLL_PARAM_RES: PLL loop filter resistor control.
113*91f16700Schasinglulu  * @PM_PLL_PARAM_MAX: Represents the maximum parameter value for the PLL
114*91f16700Schasinglulu  */
115*91f16700Schasinglulu enum pm_pll_param {
116*91f16700Schasinglulu 	PM_PLL_PARAM_DIV2,
117*91f16700Schasinglulu 	PM_PLL_PARAM_FBDIV,
118*91f16700Schasinglulu 	PM_PLL_PARAM_DATA,
119*91f16700Schasinglulu 	PM_PLL_PARAM_PRE_SRC,
120*91f16700Schasinglulu 	PM_PLL_PARAM_POST_SRC,
121*91f16700Schasinglulu 	PM_PLL_PARAM_LOCK_DLY,
122*91f16700Schasinglulu 	PM_PLL_PARAM_LOCK_CNT,
123*91f16700Schasinglulu 	PM_PLL_PARAM_LFHF,
124*91f16700Schasinglulu 	PM_PLL_PARAM_CP,
125*91f16700Schasinglulu 	PM_PLL_PARAM_RES,
126*91f16700Schasinglulu 	PM_PLL_PARAM_MAX,
127*91f16700Schasinglulu };
128*91f16700Schasinglulu 
129*91f16700Schasinglulu enum pm_api_id {
130*91f16700Schasinglulu 	/* Miscellaneous API functions: */
131*91f16700Schasinglulu 	PM_GET_API_VERSION = 1, /* Do not change or move */
132*91f16700Schasinglulu 	PM_SET_CONFIGURATION,
133*91f16700Schasinglulu 	PM_GET_NODE_STATUS,
134*91f16700Schasinglulu 	PM_GET_OP_CHARACTERISTIC,
135*91f16700Schasinglulu 	PM_REGISTER_NOTIFIER,
136*91f16700Schasinglulu 	/* API for suspending of PUs: */
137*91f16700Schasinglulu 	PM_REQ_SUSPEND,
138*91f16700Schasinglulu 	PM_SELF_SUSPEND,
139*91f16700Schasinglulu 	PM_FORCE_POWERDOWN,
140*91f16700Schasinglulu 	PM_ABORT_SUSPEND,
141*91f16700Schasinglulu 	PM_REQ_WAKEUP,
142*91f16700Schasinglulu 	PM_SET_WAKEUP_SOURCE,
143*91f16700Schasinglulu 	PM_SYSTEM_SHUTDOWN,
144*91f16700Schasinglulu 	/* API for managing PM slaves: */
145*91f16700Schasinglulu 	PM_REQ_NODE,
146*91f16700Schasinglulu 	PM_RELEASE_NODE,
147*91f16700Schasinglulu 	PM_SET_REQUIREMENT,
148*91f16700Schasinglulu 	PM_SET_MAX_LATENCY,
149*91f16700Schasinglulu 	/* Direct control API functions: */
150*91f16700Schasinglulu 	PM_RESET_ASSERT,
151*91f16700Schasinglulu 	PM_RESET_GET_STATUS,
152*91f16700Schasinglulu 	PM_MMIO_WRITE,
153*91f16700Schasinglulu 	PM_MMIO_READ,
154*91f16700Schasinglulu 	PM_INIT_FINALIZE,
155*91f16700Schasinglulu 	PM_FPGA_LOAD,
156*91f16700Schasinglulu 	PM_FPGA_GET_STATUS,
157*91f16700Schasinglulu 	PM_GET_CHIPID,
158*91f16700Schasinglulu 	PM_SECURE_RSA_AES,
159*91f16700Schasinglulu 	PM_SECURE_SHA,
160*91f16700Schasinglulu 	PM_SECURE_RSA,
161*91f16700Schasinglulu 	PM_PINCTRL_REQUEST,
162*91f16700Schasinglulu 	PM_PINCTRL_RELEASE,
163*91f16700Schasinglulu 	PM_PINCTRL_GET_FUNCTION,
164*91f16700Schasinglulu 	PM_PINCTRL_SET_FUNCTION,
165*91f16700Schasinglulu 	PM_PINCTRL_CONFIG_PARAM_GET,
166*91f16700Schasinglulu 	PM_PINCTRL_CONFIG_PARAM_SET,
167*91f16700Schasinglulu 	PM_IOCTL,
168*91f16700Schasinglulu 	/* API to query information from firmware */
169*91f16700Schasinglulu 	PM_QUERY_DATA,
170*91f16700Schasinglulu 	/* Clock control API functions */
171*91f16700Schasinglulu 	PM_CLOCK_ENABLE,
172*91f16700Schasinglulu 	PM_CLOCK_DISABLE,
173*91f16700Schasinglulu 	PM_CLOCK_GETSTATE,
174*91f16700Schasinglulu 	PM_CLOCK_SETDIVIDER,
175*91f16700Schasinglulu 	PM_CLOCK_GETDIVIDER,
176*91f16700Schasinglulu 	PM_CLOCK_SETPARENT = 43,
177*91f16700Schasinglulu 	PM_CLOCK_GETPARENT,
178*91f16700Schasinglulu 	PM_SECURE_IMAGE,
179*91f16700Schasinglulu 	/* FPGA PL Readback */
180*91f16700Schasinglulu 	PM_FPGA_READ,
181*91f16700Schasinglulu 	PM_SECURE_AES,
182*91f16700Schasinglulu 	/* PLL control API functions */
183*91f16700Schasinglulu 	PM_PLL_SET_PARAMETER,
184*91f16700Schasinglulu 	PM_PLL_GET_PARAMETER,
185*91f16700Schasinglulu 	PM_PLL_SET_MODE,
186*91f16700Schasinglulu 	PM_PLL_GET_MODE,
187*91f16700Schasinglulu 	/* PM Register Access API */
188*91f16700Schasinglulu 	PM_REGISTER_ACCESS,
189*91f16700Schasinglulu 	PM_EFUSE_ACCESS,
190*91f16700Schasinglulu 	PM_FPGA_GET_VERSION,
191*91f16700Schasinglulu 	PM_FPGA_GET_FEATURE_LIST,
192*91f16700Schasinglulu 	PM_FEATURE_CHECK = 63,
193*91f16700Schasinglulu 	PM_API_MAX = 74
194*91f16700Schasinglulu };
195*91f16700Schasinglulu 
196*91f16700Schasinglulu enum pm_abort_reason {
197*91f16700Schasinglulu 	ABORT_REASON_WKUP_EVENT = 100,
198*91f16700Schasinglulu 	ABORT_REASON_PU_BUSY,
199*91f16700Schasinglulu 	ABORT_REASON_NO_PWRDN,
200*91f16700Schasinglulu 	ABORT_REASON_UNKNOWN,
201*91f16700Schasinglulu };
202*91f16700Schasinglulu 
203*91f16700Schasinglulu enum pm_opchar_type {
204*91f16700Schasinglulu 	PM_OPCHAR_TYPE_POWER = 1,
205*91f16700Schasinglulu 	PM_OPCHAR_TYPE_TEMP,
206*91f16700Schasinglulu 	PM_OPCHAR_TYPE_LATENCY,
207*91f16700Schasinglulu };
208*91f16700Schasinglulu 
209*91f16700Schasinglulu /*
210*91f16700Schasinglulu  * Subsystem IDs
211*91f16700Schasinglulu  */
212*91f16700Schasinglulu typedef enum {
213*91f16700Schasinglulu 	XPM_SUBSYSID_PMC,
214*91f16700Schasinglulu 	XPM_SUBSYSID_PSM,
215*91f16700Schasinglulu 	XPM_SUBSYSID_APU,
216*91f16700Schasinglulu 	XPM_SUBSYSID_RPU0_LOCK,
217*91f16700Schasinglulu 	XPM_SUBSYSID_RPU0_0,
218*91f16700Schasinglulu 	XPM_SUBSYSID_RPU0_1,
219*91f16700Schasinglulu 	XPM_SUBSYSID_DDR0,
220*91f16700Schasinglulu 	XPM_SUBSYSID_ME,
221*91f16700Schasinglulu 	XPM_SUBSYSID_PL,
222*91f16700Schasinglulu 	XPM_SUBSYSID_MAX,
223*91f16700Schasinglulu } XPm_SubsystemId;
224*91f16700Schasinglulu 
225*91f16700Schasinglulu /* TODO: move pm_ret_status from device specific location to common location */
226*91f16700Schasinglulu /**
227*91f16700Schasinglulu  * enum pm_ret_status - enum represents the return status codes for a PM
228*91f16700Schasinglulu  *                      operation.
229*91f16700Schasinglulu  * @PM_RET_SUCCESS: success.
230*91f16700Schasinglulu  * @PM_RET_ERROR_ARGS: illegal arguments provided (deprecated).
231*91f16700Schasinglulu  * @PM_RET_ERROR_NOTSUPPORTED: feature not supported  (deprecated).
232*91f16700Schasinglulu  * @PM_RET_ERROR_NOFEATURE: feature is not available.
233*91f16700Schasinglulu  * @PM_RET_ERROR_INVALID_CRC: invalid crc in IPI communication.
234*91f16700Schasinglulu  * @PM_RET_ERROR_NOT_ENABLED: feature is not enabled.
235*91f16700Schasinglulu  * @PM_RET_ERROR_INTERNAL: internal error.
236*91f16700Schasinglulu  * @PM_RET_ERROR_CONFLICT: conflict.
237*91f16700Schasinglulu  * @PM_RET_ERROR_ACCESS: access rights violation.
238*91f16700Schasinglulu  * @PM_RET_ERROR_INVALID_NODE: invalid node.
239*91f16700Schasinglulu  * @PM_RET_ERROR_DOUBLE_REQ: duplicate request for same node.
240*91f16700Schasinglulu  * @PM_RET_ERROR_ABORT_SUSPEND: suspend procedure has been aborted.
241*91f16700Schasinglulu  * @PM_RET_ERROR_TIMEOUT: timeout in communication with PMU.
242*91f16700Schasinglulu  * @PM_RET_ERROR_NODE_USED: node is already in use.
243*91f16700Schasinglulu  * @PM_RET_ERROR_NO_FEATURE: indicates that the requested feature is not
244*91f16700Schasinglulu  *                           supported.
245*91f16700Schasinglulu  */
246*91f16700Schasinglulu enum pm_ret_status {
247*91f16700Schasinglulu 	PM_RET_SUCCESS,
248*91f16700Schasinglulu 	PM_RET_ERROR_ARGS = 1,
249*91f16700Schasinglulu 	PM_RET_ERROR_NOTSUPPORTED = 4,
250*91f16700Schasinglulu 	PM_RET_ERROR_NOFEATURE = 19,
251*91f16700Schasinglulu 	PM_RET_ERROR_INVALID_CRC = 301,
252*91f16700Schasinglulu 	PM_RET_ERROR_NOT_ENABLED = 29,
253*91f16700Schasinglulu 	PM_RET_ERROR_INTERNAL = 2000,
254*91f16700Schasinglulu 	PM_RET_ERROR_CONFLICT = 2001,
255*91f16700Schasinglulu 	PM_RET_ERROR_ACCESS = 2002,
256*91f16700Schasinglulu 	PM_RET_ERROR_INVALID_NODE = 2003,
257*91f16700Schasinglulu 	PM_RET_ERROR_DOUBLE_REQ = 2004,
258*91f16700Schasinglulu 	PM_RET_ERROR_ABORT_SUSPEND = 2005,
259*91f16700Schasinglulu 	PM_RET_ERROR_TIMEOUT = 2006,
260*91f16700Schasinglulu 	PM_RET_ERROR_NODE_USED = 2007,
261*91f16700Schasinglulu 	PM_RET_ERROR_NO_FEATURE = 2008
262*91f16700Schasinglulu };
263*91f16700Schasinglulu 
264*91f16700Schasinglulu /*
265*91f16700Schasinglulu  * Qids
266*91f16700Schasinglulu  */
267*91f16700Schasinglulu enum pm_query_id {
268*91f16700Schasinglulu 	XPM_QID_INVALID,
269*91f16700Schasinglulu 	XPM_QID_CLOCK_GET_NAME,
270*91f16700Schasinglulu 	XPM_QID_CLOCK_GET_TOPOLOGY,
271*91f16700Schasinglulu 	XPM_QID_CLOCK_GET_FIXEDFACTOR_PARAMS,
272*91f16700Schasinglulu 	XPM_QID_CLOCK_GET_MUXSOURCES,
273*91f16700Schasinglulu 	XPM_QID_CLOCK_GET_ATTRIBUTES,
274*91f16700Schasinglulu 	XPM_QID_PINCTRL_GET_NUM_PINS,
275*91f16700Schasinglulu 	XPM_QID_PINCTRL_GET_NUM_FUNCTIONS,
276*91f16700Schasinglulu 	XPM_QID_PINCTRL_GET_NUM_FUNCTION_GROUPS,
277*91f16700Schasinglulu 	XPM_QID_PINCTRL_GET_FUNCTION_NAME,
278*91f16700Schasinglulu 	XPM_QID_PINCTRL_GET_FUNCTION_GROUPS,
279*91f16700Schasinglulu 	XPM_QID_PINCTRL_GET_PIN_GROUPS,
280*91f16700Schasinglulu 	XPM_QID_CLOCK_GET_NUM_CLOCKS,
281*91f16700Schasinglulu 	XPM_QID_CLOCK_GET_MAX_DIVISOR,
282*91f16700Schasinglulu 	XPM_QID_PLD_GET_PARENT,
283*91f16700Schasinglulu };
284*91f16700Schasinglulu #endif /* PM_DEFS_H */
285