1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Xilinx Zynq MPSoC Firmware layer
5 * Copyright (C) 2014-2019 Xilinx
7 * Michal Simek <michal.simek@xilinx.com>
8 * Davorin Mista <davorin.mista@aggios.com>
9 * Jolly Shah <jollys@xilinx.com>
10 * Rajan Vaja <rajanv@xilinx.com>
13 #ifndef __FIRMWARE_ZYNQMP_H__
14 #define __FIRMWARE_ZYNQMP_H__
16 #include <linux/err.h>
18 #define ZYNQMP_PM_VERSION_MAJOR 1
19 #define ZYNQMP_PM_VERSION_MINOR 0
21 #define ZYNQMP_PM_VERSION ((ZYNQMP_PM_VERSION_MAJOR << 16) | \
22 ZYNQMP_PM_VERSION_MINOR)
24 #define ZYNQMP_TZ_VERSION_MAJOR 1
25 #define ZYNQMP_TZ_VERSION_MINOR 0
27 #define ZYNQMP_TZ_VERSION ((ZYNQMP_TZ_VERSION_MAJOR << 16) | \
28 ZYNQMP_TZ_VERSION_MINOR)
30 /* SMC SIP service Call Function Identifier Prefix */
31 #define PM_SIP_SVC 0xC2000000
32 #define PM_GET_TRUSTZONE_VERSION 0xa03
33 #define PM_SET_SUSPEND_MODE 0xa02
34 #define GET_CALLBACK_DATA 0xa01
36 /* Number of 32bits values in payload */
37 #define PAYLOAD_ARG_CNT 4U
39 /* Number of arguments for a callback */
42 /* Payload size (consists of callback API ID + arguments) */
43 #define CB_PAYLOAD_SIZE (CB_ARG_CNT + 1)
45 #define ZYNQMP_PM_MAX_QOS 100U
47 #define GSS_NUM_REGS (4)
49 /* Node capabilities */
50 #define ZYNQMP_PM_CAPABILITY_ACCESS 0x1U
51 #define ZYNQMP_PM_CAPABILITY_CONTEXT 0x2U
52 #define ZYNQMP_PM_CAPABILITY_WAKEUP 0x4U
53 #define ZYNQMP_PM_CAPABILITY_UNUSABLE 0x8U
56 * Firmware FPGA Manager flags
57 * XILINX_ZYNQMP_PM_FPGA_FULL: FPGA full reconfiguration
58 * XILINX_ZYNQMP_PM_FPGA_PARTIAL: FPGA partial reconfiguration
60 #define XILINX_ZYNQMP_PM_FPGA_FULL 0x0U
61 #define XILINX_ZYNQMP_PM_FPGA_PARTIAL BIT(0)
64 PM_GET_API_VERSION = 1,
65 PM_SYSTEM_SHUTDOWN = 12,
71 PM_PM_INIT_FINALIZE = 21,
87 PM_FEATURE_CHECK = 63,
91 /* PMU-FW return status codes */
94 XST_PM_NO_FEATURE = 19,
95 XST_PM_INTERNAL = 2000,
100 XST_PM_ABORT_SUSPEND,
101 XST_PM_MULT_USER = 2008,
105 IOCTL_SD_DLL_RESET = 6,
106 IOCTL_SET_SD_TAPDELAY,
107 IOCTL_SET_PLL_FRAC_MODE,
108 IOCTL_GET_PLL_FRAC_MODE,
109 IOCTL_SET_PLL_FRAC_DATA,
110 IOCTL_GET_PLL_FRAC_DATA,
111 IOCTL_WRITE_GGS = 12,
113 IOCTL_WRITE_PGGS = 14,
114 IOCTL_READ_PGGS = 15,
115 /* Set healthy bit value */
116 IOCTL_SET_BOOT_HEALTH_STATUS = 17,
121 PM_QID_CLOCK_GET_NAME,
122 PM_QID_CLOCK_GET_TOPOLOGY,
123 PM_QID_CLOCK_GET_FIXEDFACTOR_PARAMS,
124 PM_QID_CLOCK_GET_PARENTS,
125 PM_QID_CLOCK_GET_ATTRIBUTES,
126 PM_QID_CLOCK_GET_NUM_CLOCKS = 12,
127 PM_QID_CLOCK_GET_MAX_DIVISOR,
130 enum zynqmp_pm_reset_action {
131 PM_RESET_ACTION_RELEASE,
132 PM_RESET_ACTION_ASSERT,
133 PM_RESET_ACTION_PULSE,
136 enum zynqmp_pm_reset {
137 ZYNQMP_PM_RESET_START = 1000,
138 ZYNQMP_PM_RESET_PCIE_CFG = ZYNQMP_PM_RESET_START,
139 ZYNQMP_PM_RESET_PCIE_BRIDGE,
140 ZYNQMP_PM_RESET_PCIE_CTRL,
142 ZYNQMP_PM_RESET_SWDT_CRF,
143 ZYNQMP_PM_RESET_AFI_FM5,
144 ZYNQMP_PM_RESET_AFI_FM4,
145 ZYNQMP_PM_RESET_AFI_FM3,
146 ZYNQMP_PM_RESET_AFI_FM2,
147 ZYNQMP_PM_RESET_AFI_FM1,
148 ZYNQMP_PM_RESET_AFI_FM0,
149 ZYNQMP_PM_RESET_GDMA,
150 ZYNQMP_PM_RESET_GPU_PP1,
151 ZYNQMP_PM_RESET_GPU_PP0,
154 ZYNQMP_PM_RESET_SATA,
155 ZYNQMP_PM_RESET_ACPU3_PWRON,
156 ZYNQMP_PM_RESET_ACPU2_PWRON,
157 ZYNQMP_PM_RESET_ACPU1_PWRON,
158 ZYNQMP_PM_RESET_ACPU0_PWRON,
159 ZYNQMP_PM_RESET_APU_L2,
160 ZYNQMP_PM_RESET_ACPU3,
161 ZYNQMP_PM_RESET_ACPU2,
162 ZYNQMP_PM_RESET_ACPU1,
163 ZYNQMP_PM_RESET_ACPU0,
165 ZYNQMP_PM_RESET_APM_FPD,
166 ZYNQMP_PM_RESET_SOFT,
167 ZYNQMP_PM_RESET_GEM0,
168 ZYNQMP_PM_RESET_GEM1,
169 ZYNQMP_PM_RESET_GEM2,
170 ZYNQMP_PM_RESET_GEM3,
171 ZYNQMP_PM_RESET_QSPI,
172 ZYNQMP_PM_RESET_UART0,
173 ZYNQMP_PM_RESET_UART1,
174 ZYNQMP_PM_RESET_SPI0,
175 ZYNQMP_PM_RESET_SPI1,
176 ZYNQMP_PM_RESET_SDIO0,
177 ZYNQMP_PM_RESET_SDIO1,
178 ZYNQMP_PM_RESET_CAN0,
179 ZYNQMP_PM_RESET_CAN1,
180 ZYNQMP_PM_RESET_I2C0,
181 ZYNQMP_PM_RESET_I2C1,
182 ZYNQMP_PM_RESET_TTC0,
183 ZYNQMP_PM_RESET_TTC1,
184 ZYNQMP_PM_RESET_TTC2,
185 ZYNQMP_PM_RESET_TTC3,
186 ZYNQMP_PM_RESET_SWDT_CRL,
187 ZYNQMP_PM_RESET_NAND,
188 ZYNQMP_PM_RESET_ADMA,
189 ZYNQMP_PM_RESET_GPIO,
190 ZYNQMP_PM_RESET_IOU_CC,
191 ZYNQMP_PM_RESET_TIMESTAMP,
192 ZYNQMP_PM_RESET_RPU_R50,
193 ZYNQMP_PM_RESET_RPU_R51,
194 ZYNQMP_PM_RESET_RPU_AMBA,
196 ZYNQMP_PM_RESET_RPU_PGE,
197 ZYNQMP_PM_RESET_USB0_CORERESET,
198 ZYNQMP_PM_RESET_USB1_CORERESET,
199 ZYNQMP_PM_RESET_USB0_HIBERRESET,
200 ZYNQMP_PM_RESET_USB1_HIBERRESET,
201 ZYNQMP_PM_RESET_USB0_APB,
202 ZYNQMP_PM_RESET_USB1_APB,
204 ZYNQMP_PM_RESET_APM_LPD,
206 ZYNQMP_PM_RESET_SYSMON,
207 ZYNQMP_PM_RESET_AFI_FM6,
208 ZYNQMP_PM_RESET_LPD_SWDT,
210 ZYNQMP_PM_RESET_RPU_DBG1,
211 ZYNQMP_PM_RESET_RPU_DBG0,
212 ZYNQMP_PM_RESET_DBG_LPD,
213 ZYNQMP_PM_RESET_DBG_FPD,
214 ZYNQMP_PM_RESET_APLL,
215 ZYNQMP_PM_RESET_DPLL,
216 ZYNQMP_PM_RESET_VPLL,
217 ZYNQMP_PM_RESET_IOPLL,
218 ZYNQMP_PM_RESET_RPLL,
219 ZYNQMP_PM_RESET_GPO3_PL_0,
220 ZYNQMP_PM_RESET_GPO3_PL_1,
221 ZYNQMP_PM_RESET_GPO3_PL_2,
222 ZYNQMP_PM_RESET_GPO3_PL_3,
223 ZYNQMP_PM_RESET_GPO3_PL_4,
224 ZYNQMP_PM_RESET_GPO3_PL_5,
225 ZYNQMP_PM_RESET_GPO3_PL_6,
226 ZYNQMP_PM_RESET_GPO3_PL_7,
227 ZYNQMP_PM_RESET_GPO3_PL_8,
228 ZYNQMP_PM_RESET_GPO3_PL_9,
229 ZYNQMP_PM_RESET_GPO3_PL_10,
230 ZYNQMP_PM_RESET_GPO3_PL_11,
231 ZYNQMP_PM_RESET_GPO3_PL_12,
232 ZYNQMP_PM_RESET_GPO3_PL_13,
233 ZYNQMP_PM_RESET_GPO3_PL_14,
234 ZYNQMP_PM_RESET_GPO3_PL_15,
235 ZYNQMP_PM_RESET_GPO3_PL_16,
236 ZYNQMP_PM_RESET_GPO3_PL_17,
237 ZYNQMP_PM_RESET_GPO3_PL_18,
238 ZYNQMP_PM_RESET_GPO3_PL_19,
239 ZYNQMP_PM_RESET_GPO3_PL_20,
240 ZYNQMP_PM_RESET_GPO3_PL_21,
241 ZYNQMP_PM_RESET_GPO3_PL_22,
242 ZYNQMP_PM_RESET_GPO3_PL_23,
243 ZYNQMP_PM_RESET_GPO3_PL_24,
244 ZYNQMP_PM_RESET_GPO3_PL_25,
245 ZYNQMP_PM_RESET_GPO3_PL_26,
246 ZYNQMP_PM_RESET_GPO3_PL_27,
247 ZYNQMP_PM_RESET_GPO3_PL_28,
248 ZYNQMP_PM_RESET_GPO3_PL_29,
249 ZYNQMP_PM_RESET_GPO3_PL_30,
250 ZYNQMP_PM_RESET_GPO3_PL_31,
251 ZYNQMP_PM_RESET_RPU_LS,
252 ZYNQMP_PM_RESET_PS_ONLY,
254 ZYNQMP_PM_RESET_PS_PL0,
255 ZYNQMP_PM_RESET_PS_PL1,
256 ZYNQMP_PM_RESET_PS_PL2,
257 ZYNQMP_PM_RESET_PS_PL3,
258 ZYNQMP_PM_RESET_END = ZYNQMP_PM_RESET_PS_PL3
261 enum zynqmp_pm_suspend_reason {
262 SUSPEND_POWER_REQUEST = 201,
264 SUSPEND_SYSTEM_SHUTDOWN,
267 enum zynqmp_pm_request_ack {
268 ZYNQMP_PM_REQUEST_ACK_NO = 1,
269 ZYNQMP_PM_REQUEST_ACK_BLOCKING,
270 ZYNQMP_PM_REQUEST_ACK_NON_BLOCKING,
278 enum tap_delay_type {
279 PM_TAPDELAY_INPUT = 0,
283 enum dll_reset_type {
285 PM_DLL_RESET_RELEASE,
289 enum zynqmp_pm_shutdown_type {
290 ZYNQMP_PM_SHUTDOWN_TYPE_SHUTDOWN,
291 ZYNQMP_PM_SHUTDOWN_TYPE_RESET,
292 ZYNQMP_PM_SHUTDOWN_TYPE_SETSCOPE_ONLY,
295 enum zynqmp_pm_shutdown_subtype {
296 ZYNQMP_PM_SHUTDOWN_SUBTYPE_SUBSYSTEM,
297 ZYNQMP_PM_SHUTDOWN_SUBTYPE_PS_ONLY,
298 ZYNQMP_PM_SHUTDOWN_SUBTYPE_SYSTEM,
302 * struct zynqmp_pm_query_data - PM query data
304 * @arg1: Argument 1 of query data
305 * @arg2: Argument 2 of query data
306 * @arg3: Argument 3 of query data
308 struct zynqmp_pm_query_data {
315 int zynqmp_pm_invoke_fn(u32 pm_api_id, u32 arg0, u32 arg1,
316 u32 arg2, u32 arg3, u32 *ret_payload);
318 #if IS_REACHABLE(CONFIG_ZYNQMP_FIRMWARE)
319 int zynqmp_pm_get_api_version(u32 *version);
320 int zynqmp_pm_get_chipid(u32 *idcode, u32 *version);
321 int zynqmp_pm_query_data(struct zynqmp_pm_query_data qdata, u32 *out);
322 int zynqmp_pm_clock_enable(u32 clock_id);
323 int zynqmp_pm_clock_disable(u32 clock_id);
324 int zynqmp_pm_clock_getstate(u32 clock_id, u32 *state);
325 int zynqmp_pm_clock_setdivider(u32 clock_id, u32 divider);
326 int zynqmp_pm_clock_getdivider(u32 clock_id, u32 *divider);
327 int zynqmp_pm_clock_setrate(u32 clock_id, u64 rate);
328 int zynqmp_pm_clock_getrate(u32 clock_id, u64 *rate);
329 int zynqmp_pm_clock_setparent(u32 clock_id, u32 parent_id);
330 int zynqmp_pm_clock_getparent(u32 clock_id, u32 *parent_id);
331 int zynqmp_pm_set_pll_frac_mode(u32 clk_id, u32 mode);
332 int zynqmp_pm_get_pll_frac_mode(u32 clk_id, u32 *mode);
333 int zynqmp_pm_set_pll_frac_data(u32 clk_id, u32 data);
334 int zynqmp_pm_get_pll_frac_data(u32 clk_id, u32 *data);
335 int zynqmp_pm_set_sd_tapdelay(u32 node_id, u32 type, u32 value);
336 int zynqmp_pm_sd_dll_reset(u32 node_id, u32 type);
337 int zynqmp_pm_reset_assert(const enum zynqmp_pm_reset reset,
338 const enum zynqmp_pm_reset_action assert_flag);
339 int zynqmp_pm_reset_get_status(const enum zynqmp_pm_reset reset, u32 *status);
340 int zynqmp_pm_init_finalize(void);
341 int zynqmp_pm_set_suspend_mode(u32 mode);
342 int zynqmp_pm_request_node(const u32 node, const u32 capabilities,
343 const u32 qos, const enum zynqmp_pm_request_ack ack);
344 int zynqmp_pm_release_node(const u32 node);
345 int zynqmp_pm_set_requirement(const u32 node, const u32 capabilities,
347 const enum zynqmp_pm_request_ack ack);
348 int zynqmp_pm_aes_engine(const u64 address, u32 *out);
349 int zynqmp_pm_fpga_load(const u64 address, const u32 size, const u32 flags);
350 int zynqmp_pm_fpga_get_status(u32 *value);
351 int zynqmp_pm_write_ggs(u32 index, u32 value);
352 int zynqmp_pm_read_ggs(u32 index, u32 *value);
353 int zynqmp_pm_write_pggs(u32 index, u32 value);
354 int zynqmp_pm_read_pggs(u32 index, u32 *value);
355 int zynqmp_pm_system_shutdown(const u32 type, const u32 subtype);
356 int zynqmp_pm_set_boot_health_status(u32 value);
358 static inline struct zynqmp_eemi_ops *zynqmp_pm_get_eemi_ops(void)
360 return ERR_PTR(-ENODEV);
363 static inline int zynqmp_pm_get_api_version(u32 *version)
368 static inline int zynqmp_pm_get_chipid(u32 *idcode, u32 *version)
373 static inline int zynqmp_pm_query_data(struct zynqmp_pm_query_data qdata,
379 static inline int zynqmp_pm_clock_enable(u32 clock_id)
384 static inline int zynqmp_pm_clock_disable(u32 clock_id)
389 static inline int zynqmp_pm_clock_getstate(u32 clock_id, u32 *state)
394 static inline int zynqmp_pm_clock_setdivider(u32 clock_id, u32 divider)
399 static inline int zynqmp_pm_clock_getdivider(u32 clock_id, u32 *divider)
404 static inline int zynqmp_pm_clock_setrate(u32 clock_id, u64 rate)
409 static inline int zynqmp_pm_clock_getrate(u32 clock_id, u64 *rate)
414 static inline int zynqmp_pm_clock_setparent(u32 clock_id, u32 parent_id)
419 static inline int zynqmp_pm_clock_getparent(u32 clock_id, u32 *parent_id)
424 static inline int zynqmp_pm_set_pll_frac_mode(u32 clk_id, u32 mode)
429 static inline int zynqmp_pm_get_pll_frac_mode(u32 clk_id, u32 *mode)
434 static inline int zynqmp_pm_set_pll_frac_data(u32 clk_id, u32 data)
439 static inline int zynqmp_pm_get_pll_frac_data(u32 clk_id, u32 *data)
444 static inline int zynqmp_pm_set_sd_tapdelay(u32 node_id, u32 type, u32 value)
449 static inline int zynqmp_pm_sd_dll_reset(u32 node_id, u32 type)
454 static inline int zynqmp_pm_reset_assert(const enum zynqmp_pm_reset reset,
455 const enum zynqmp_pm_reset_action assert_flag)
460 static inline int zynqmp_pm_reset_get_status(const enum zynqmp_pm_reset reset,
466 static inline int zynqmp_pm_init_finalize(void)
471 static inline int zynqmp_pm_set_suspend_mode(u32 mode)
476 static inline int zynqmp_pm_request_node(const u32 node, const u32 capabilities,
478 const enum zynqmp_pm_request_ack ack)
483 static inline int zynqmp_pm_release_node(const u32 node)
488 static inline int zynqmp_pm_set_requirement(const u32 node,
489 const u32 capabilities,
491 const enum zynqmp_pm_request_ack ack)
496 static inline int zynqmp_pm_aes_engine(const u64 address, u32 *out)
501 static inline int zynqmp_pm_fpga_load(const u64 address, const u32 size,
507 static inline int zynqmp_pm_fpga_get_status(u32 *value)
512 static inline int zynqmp_pm_write_ggs(u32 index, u32 value)
517 static inline int zynqmp_pm_read_ggs(u32 index, u32 *value)
522 static inline int zynqmp_pm_write_pggs(u32 index, u32 value)
527 static inline int zynqmp_pm_read_pggs(u32 index, u32 *value)
532 static inline int zynqmp_pm_system_shutdown(const u32 type, const u32 subtype)
537 static inline int zynqmp_pm_set_boot_health_status(u32 value)
543 #endif /* __FIRMWARE_ZYNQMP_H__ */