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