192f7de1eSJay Buddhabhatti /* 292f7de1eSJay Buddhabhatti * Copyright (c) 2019-2022, Xilinx, Inc. All rights reserved. 3*924f8ce2SRonak Jain * Copyright (c) 2022-2024, Advanced Micro Devices, Inc. All rights reserved. 492f7de1eSJay Buddhabhatti * 592f7de1eSJay Buddhabhatti * SPDX-License-Identifier: BSD-3-Clause 692f7de1eSJay Buddhabhatti */ 792f7de1eSJay Buddhabhatti 892f7de1eSJay Buddhabhatti /* Versal power management enums and defines */ 992f7de1eSJay Buddhabhatti 1092f7de1eSJay Buddhabhatti #ifndef PM_DEFS_H 1192f7de1eSJay Buddhabhatti #define PM_DEFS_H 1292f7de1eSJay Buddhabhatti 1392f7de1eSJay Buddhabhatti #include "pm_node.h" 1492f7de1eSJay Buddhabhatti 1592f7de1eSJay Buddhabhatti /********************************************************************* 1692f7de1eSJay Buddhabhatti * Macro definitions 1792f7de1eSJay Buddhabhatti ********************************************************************/ 1892f7de1eSJay Buddhabhatti 1992f7de1eSJay Buddhabhatti /* State arguments of the self suspend */ 2092f7de1eSJay Buddhabhatti #define PM_STATE_CPU_IDLE 0x0U 2159497016SJay Buddhabhatti #define PM_STATE_CPU_OFF 0x1U 2292f7de1eSJay Buddhabhatti #define PM_STATE_SUSPEND_TO_RAM 0xFU 2392f7de1eSJay Buddhabhatti 2492f7de1eSJay Buddhabhatti #define MAX_LATENCY (~0U) 2592f7de1eSJay Buddhabhatti #define MAX_QOS 100U 2692f7de1eSJay Buddhabhatti 2792f7de1eSJay Buddhabhatti /* Processor core device IDs */ 2892f7de1eSJay Buddhabhatti #define APU_DEVID(IDX) NODEID(XPM_NODECLASS_DEVICE, XPM_NODESUBCL_DEV_CORE, \ 2992f7de1eSJay Buddhabhatti XPM_NODETYPE_DEV_CORE_APU, (IDX)) 3092f7de1eSJay Buddhabhatti 3192f7de1eSJay Buddhabhatti #define XPM_DEVID_ACPU_0 APU_DEVID(XPM_NODEIDX_DEV_ACPU_0) 3292f7de1eSJay Buddhabhatti #define XPM_DEVID_ACPU_1 APU_DEVID(XPM_NODEIDX_DEV_ACPU_1) 3392f7de1eSJay Buddhabhatti 34964e5592SJay Buddhabhatti #define PERIPH_DEVID(IDX) NODEID((uint32_t)XPM_NODECLASS_DEVICE, \ 35964e5592SJay Buddhabhatti (uint32_t)XPM_NODESUBCL_DEV_PERIPH, \ 36964e5592SJay Buddhabhatti (uint32_t)XPM_NODETYPE_DEV_PERIPH, (IDX)) 3792f7de1eSJay Buddhabhatti 3892f7de1eSJay Buddhabhatti #define PM_GET_CALLBACK_DATA 0xa01U 3992f7de1eSJay Buddhabhatti #define PM_GET_TRUSTZONE_VERSION 0xa03U 4092f7de1eSJay Buddhabhatti #define TF_A_PM_REGISTER_SGI 0xa04U 4192f7de1eSJay Buddhabhatti 4292f7de1eSJay Buddhabhatti /* PM API Versions */ 4392f7de1eSJay Buddhabhatti #define PM_API_BASE_VERSION 1U 4492f7de1eSJay Buddhabhatti #define PM_API_VERSION_2 2U 4592f7de1eSJay Buddhabhatti 4692f7de1eSJay Buddhabhatti /* Loader API ids */ 4792f7de1eSJay Buddhabhatti #define PM_LOAD_PDI 0x701U 4892f7de1eSJay Buddhabhatti #define PM_LOAD_GET_HANDOFF_PARAMS 0x70BU 4992f7de1eSJay Buddhabhatti 5092f7de1eSJay Buddhabhatti /* System shutdown macros */ 5192f7de1eSJay Buddhabhatti #define XPM_SHUTDOWN_TYPE_SHUTDOWN 0U 5292f7de1eSJay Buddhabhatti #define XPM_SHUTDOWN_TYPE_RESET 1U 5392f7de1eSJay Buddhabhatti #define XPM_SHUTDOWN_TYPE_SETSCOPE_ONLY 2U 5492f7de1eSJay Buddhabhatti 5592f7de1eSJay Buddhabhatti #define XPM_SHUTDOWN_SUBTYPE_RST_SUBSYSTEM 0U 5692f7de1eSJay Buddhabhatti #define XPM_SHUTDOWN_SUBTYPE_RST_PS_ONLY 1U 5792f7de1eSJay Buddhabhatti #define XPM_SHUTDOWN_SUBTYPE_RST_SYSTEM 2U 5892f7de1eSJay Buddhabhatti 5992f7de1eSJay Buddhabhatti /********************************************************************* 6092f7de1eSJay Buddhabhatti * Enum definitions 6192f7de1eSJay Buddhabhatti ********************************************************************/ 6292f7de1eSJay Buddhabhatti 63de7ed953SPrasad Kummari /* 64de7ed953SPrasad Kummari * ioctl id 65de7ed953SPrasad Kummari */ 66c90f4abfSJay Buddhabhatti enum { 67c90f4abfSJay Buddhabhatti IOCTL_GET_RPU_OPER_MODE = 0, 68c90f4abfSJay Buddhabhatti IOCTL_SET_RPU_OPER_MODE = 1, 69c90f4abfSJay Buddhabhatti IOCTL_RPU_BOOT_ADDR_CONFIG = 2, 70c90f4abfSJay Buddhabhatti IOCTL_TCM_COMB_CONFIG = 3, 71c90f4abfSJay Buddhabhatti IOCTL_SET_TAPDELAY_BYPASS = 4, 72c90f4abfSJay Buddhabhatti IOCTL_SD_DLL_RESET = 6, 73c90f4abfSJay Buddhabhatti IOCTL_SET_SD_TAPDELAY = 7, 74c90f4abfSJay Buddhabhatti /* Ioctl for clock driver */ 75c90f4abfSJay Buddhabhatti IOCTL_SET_PLL_FRAC_MODE = 8, 76c90f4abfSJay Buddhabhatti IOCTL_GET_PLL_FRAC_MODE = 9, 77c90f4abfSJay Buddhabhatti IOCTL_SET_PLL_FRAC_DATA = 10, 78c90f4abfSJay Buddhabhatti IOCTL_GET_PLL_FRAC_DATA = 11, 79c90f4abfSJay Buddhabhatti IOCTL_WRITE_GGS = 12, 80c90f4abfSJay Buddhabhatti IOCTL_READ_GGS = 13, 81c90f4abfSJay Buddhabhatti IOCTL_WRITE_PGGS = 14, 82c90f4abfSJay Buddhabhatti IOCTL_READ_PGGS = 15, 83c90f4abfSJay Buddhabhatti /* IOCTL for ULPI reset */ 84c90f4abfSJay Buddhabhatti IOCTL_ULPI_RESET = 16, 85c90f4abfSJay Buddhabhatti /* Set healthy bit value */ 86c90f4abfSJay Buddhabhatti IOCTL_SET_BOOT_HEALTH_STATUS = 17, 87c90f4abfSJay Buddhabhatti IOCTL_AFI = 18, 88c90f4abfSJay Buddhabhatti /* Probe counter read/write */ 89c90f4abfSJay Buddhabhatti IOCTL_PROBE_COUNTER_READ = 19, 90c90f4abfSJay Buddhabhatti IOCTL_PROBE_COUNTER_WRITE = 20, 91c90f4abfSJay Buddhabhatti IOCTL_OSPI_MUX_SELECT = 21, 92c90f4abfSJay Buddhabhatti /* IOCTL for USB power request */ 93c90f4abfSJay Buddhabhatti IOCTL_USB_SET_STATE = 22, 94c90f4abfSJay Buddhabhatti /* IOCTL to get last reset reason */ 95c90f4abfSJay Buddhabhatti IOCTL_GET_LAST_RESET_REASON = 23, 96c90f4abfSJay Buddhabhatti /* AI engine NPI ISR clear */ 97c90f4abfSJay Buddhabhatti IOCTL_AIE_ISR_CLEAR = 24, 98c90f4abfSJay Buddhabhatti }; 99c90f4abfSJay Buddhabhatti 10092f7de1eSJay Buddhabhatti /** 101de7ed953SPrasad Kummari * enum pm_pll_param - enum represents the parameters for a phase-locked loop. 102de7ed953SPrasad Kummari * @PM_PLL_PARAM_DIV2: Enable for divide by 2 function inside the PLL. 103de7ed953SPrasad Kummari * @PM_PLL_PARAM_FBDIV: Feedback divisor integer portion for the PLL. 104de7ed953SPrasad Kummari * @PM_PLL_PARAM_DATA: Feedback divisor fractional portion for the PLL. 105de7ed953SPrasad Kummari * @PM_PLL_PARAM_PRE_SRC: Clock source for PLL input. 106de7ed953SPrasad Kummari * @PM_PLL_PARAM_POST_SRC: Clock source for PLL Bypass mode. 107de7ed953SPrasad Kummari * @PM_PLL_PARAM_LOCK_DLY: Lock circuit config settings for lock windowsize. 108de7ed953SPrasad Kummari * @PM_PLL_PARAM_LOCK_CNT: Lock circuit counter setting. 109de7ed953SPrasad Kummari * @PM_PLL_PARAM_LFHF: PLL loop filter high frequency capacitor control. 110de7ed953SPrasad Kummari * @PM_PLL_PARAM_CP: PLL charge pump control. 111de7ed953SPrasad Kummari * @PM_PLL_PARAM_RES: PLL loop filter resistor control. 112de7ed953SPrasad Kummari * @PM_PLL_PARAM_MAX: Represents the maximum parameter value for the PLL 11392f7de1eSJay Buddhabhatti */ 11492f7de1eSJay Buddhabhatti enum pm_pll_param { 11592f7de1eSJay Buddhabhatti PM_PLL_PARAM_DIV2, 11692f7de1eSJay Buddhabhatti PM_PLL_PARAM_FBDIV, 11792f7de1eSJay Buddhabhatti PM_PLL_PARAM_DATA, 11892f7de1eSJay Buddhabhatti PM_PLL_PARAM_PRE_SRC, 11992f7de1eSJay Buddhabhatti PM_PLL_PARAM_POST_SRC, 12092f7de1eSJay Buddhabhatti PM_PLL_PARAM_LOCK_DLY, 12192f7de1eSJay Buddhabhatti PM_PLL_PARAM_LOCK_CNT, 12292f7de1eSJay Buddhabhatti PM_PLL_PARAM_LFHF, 12392f7de1eSJay Buddhabhatti PM_PLL_PARAM_CP, 12492f7de1eSJay Buddhabhatti PM_PLL_PARAM_RES, 12592f7de1eSJay Buddhabhatti PM_PLL_PARAM_MAX, 12692f7de1eSJay Buddhabhatti }; 12792f7de1eSJay Buddhabhatti 12892f7de1eSJay Buddhabhatti enum pm_api_id { 12992f7de1eSJay Buddhabhatti /* Miscellaneous API functions: */ 13092f7de1eSJay Buddhabhatti PM_GET_API_VERSION = 1, /* Do not change or move */ 13192f7de1eSJay Buddhabhatti PM_SET_CONFIGURATION, 13292f7de1eSJay Buddhabhatti PM_GET_NODE_STATUS, 13392f7de1eSJay Buddhabhatti PM_GET_OP_CHARACTERISTIC, 13492f7de1eSJay Buddhabhatti PM_REGISTER_NOTIFIER, 13592f7de1eSJay Buddhabhatti /* API for suspending of PUs: */ 13692f7de1eSJay Buddhabhatti PM_REQ_SUSPEND, 13792f7de1eSJay Buddhabhatti PM_SELF_SUSPEND, 13892f7de1eSJay Buddhabhatti PM_FORCE_POWERDOWN, 13992f7de1eSJay Buddhabhatti PM_ABORT_SUSPEND, 14092f7de1eSJay Buddhabhatti PM_REQ_WAKEUP, 14192f7de1eSJay Buddhabhatti PM_SET_WAKEUP_SOURCE, 14292f7de1eSJay Buddhabhatti PM_SYSTEM_SHUTDOWN, 14392f7de1eSJay Buddhabhatti /* API for managing PM slaves: */ 14492f7de1eSJay Buddhabhatti PM_REQ_NODE, 14592f7de1eSJay Buddhabhatti PM_RELEASE_NODE, 14692f7de1eSJay Buddhabhatti PM_SET_REQUIREMENT, 14792f7de1eSJay Buddhabhatti PM_SET_MAX_LATENCY, 14892f7de1eSJay Buddhabhatti /* Direct control API functions: */ 14992f7de1eSJay Buddhabhatti PM_RESET_ASSERT, 15092f7de1eSJay Buddhabhatti PM_RESET_GET_STATUS, 15192f7de1eSJay Buddhabhatti PM_MMIO_WRITE, 15292f7de1eSJay Buddhabhatti PM_MMIO_READ, 15392f7de1eSJay Buddhabhatti PM_INIT_FINALIZE, 15492f7de1eSJay Buddhabhatti PM_FPGA_LOAD, 15592f7de1eSJay Buddhabhatti PM_FPGA_GET_STATUS, 15692f7de1eSJay Buddhabhatti PM_GET_CHIPID, 15792f7de1eSJay Buddhabhatti PM_SECURE_RSA_AES, 15892f7de1eSJay Buddhabhatti PM_SECURE_SHA, 15992f7de1eSJay Buddhabhatti PM_SECURE_RSA, 16092f7de1eSJay Buddhabhatti PM_PINCTRL_REQUEST, 16192f7de1eSJay Buddhabhatti PM_PINCTRL_RELEASE, 16292f7de1eSJay Buddhabhatti PM_PINCTRL_GET_FUNCTION, 16392f7de1eSJay Buddhabhatti PM_PINCTRL_SET_FUNCTION, 16492f7de1eSJay Buddhabhatti PM_PINCTRL_CONFIG_PARAM_GET, 16592f7de1eSJay Buddhabhatti PM_PINCTRL_CONFIG_PARAM_SET, 16692f7de1eSJay Buddhabhatti PM_IOCTL, 16792f7de1eSJay Buddhabhatti /* API to query information from firmware */ 16892f7de1eSJay Buddhabhatti PM_QUERY_DATA, 16992f7de1eSJay Buddhabhatti /* Clock control API functions */ 17092f7de1eSJay Buddhabhatti PM_CLOCK_ENABLE, 17192f7de1eSJay Buddhabhatti PM_CLOCK_DISABLE, 17292f7de1eSJay Buddhabhatti PM_CLOCK_GETSTATE, 17392f7de1eSJay Buddhabhatti PM_CLOCK_SETDIVIDER, 17492f7de1eSJay Buddhabhatti PM_CLOCK_GETDIVIDER, 175e5955d7cSRonak Jain PM_CLOCK_SETPARENT = 43, 17692f7de1eSJay Buddhabhatti PM_CLOCK_GETPARENT, 17792f7de1eSJay Buddhabhatti PM_SECURE_IMAGE, 17892f7de1eSJay Buddhabhatti /* FPGA PL Readback */ 17992f7de1eSJay Buddhabhatti PM_FPGA_READ, 18092f7de1eSJay Buddhabhatti PM_SECURE_AES, 18192f7de1eSJay Buddhabhatti /* PLL control API functions */ 18292f7de1eSJay Buddhabhatti PM_PLL_SET_PARAMETER, 18392f7de1eSJay Buddhabhatti PM_PLL_GET_PARAMETER, 18492f7de1eSJay Buddhabhatti PM_PLL_SET_MODE, 18592f7de1eSJay Buddhabhatti PM_PLL_GET_MODE, 18692f7de1eSJay Buddhabhatti /* PM Register Access API */ 18792f7de1eSJay Buddhabhatti PM_REGISTER_ACCESS, 18892f7de1eSJay Buddhabhatti PM_EFUSE_ACCESS, 18992f7de1eSJay Buddhabhatti PM_FPGA_GET_VERSION, 19092f7de1eSJay Buddhabhatti PM_FPGA_GET_FEATURE_LIST, 19192f7de1eSJay Buddhabhatti PM_FEATURE_CHECK = 63, 19292f7de1eSJay Buddhabhatti PM_API_MAX = 74 19392f7de1eSJay Buddhabhatti }; 19492f7de1eSJay Buddhabhatti 19592f7de1eSJay Buddhabhatti enum pm_abort_reason { 19692f7de1eSJay Buddhabhatti ABORT_REASON_WKUP_EVENT = 100, 19792f7de1eSJay Buddhabhatti ABORT_REASON_PU_BUSY, 19892f7de1eSJay Buddhabhatti ABORT_REASON_NO_PWRDN, 19992f7de1eSJay Buddhabhatti ABORT_REASON_UNKNOWN, 20092f7de1eSJay Buddhabhatti }; 20192f7de1eSJay Buddhabhatti 20292f7de1eSJay Buddhabhatti enum pm_opchar_type { 20392f7de1eSJay Buddhabhatti PM_OPCHAR_TYPE_POWER = 1, 20492f7de1eSJay Buddhabhatti PM_OPCHAR_TYPE_TEMP, 20592f7de1eSJay Buddhabhatti PM_OPCHAR_TYPE_LATENCY, 20692f7de1eSJay Buddhabhatti }; 20792f7de1eSJay Buddhabhatti 208de7ed953SPrasad Kummari /* 20992f7de1eSJay Buddhabhatti * Subsystem IDs 21092f7de1eSJay Buddhabhatti */ 21192f7de1eSJay Buddhabhatti typedef enum { 21292f7de1eSJay Buddhabhatti XPM_SUBSYSID_PMC, 21392f7de1eSJay Buddhabhatti XPM_SUBSYSID_PSM, 21492f7de1eSJay Buddhabhatti XPM_SUBSYSID_APU, 21592f7de1eSJay Buddhabhatti XPM_SUBSYSID_RPU0_LOCK, 21692f7de1eSJay Buddhabhatti XPM_SUBSYSID_RPU0_0, 21792f7de1eSJay Buddhabhatti XPM_SUBSYSID_RPU0_1, 21892f7de1eSJay Buddhabhatti XPM_SUBSYSID_DDR0, 21992f7de1eSJay Buddhabhatti XPM_SUBSYSID_ME, 22092f7de1eSJay Buddhabhatti XPM_SUBSYSID_PL, 22192f7de1eSJay Buddhabhatti XPM_SUBSYSID_MAX, 22292f7de1eSJay Buddhabhatti } XPm_SubsystemId; 22392f7de1eSJay Buddhabhatti 22492f7de1eSJay Buddhabhatti /* TODO: move pm_ret_status from device specific location to common location */ 22592f7de1eSJay Buddhabhatti /** 226de7ed953SPrasad Kummari * enum pm_ret_status - enum represents the return status codes for a PM 227de7ed953SPrasad Kummari * operation. 228de7ed953SPrasad Kummari * @PM_RET_SUCCESS: success. 229de7ed953SPrasad Kummari * @PM_RET_ERROR_ARGS: illegal arguments provided (deprecated). 230de7ed953SPrasad Kummari * @PM_RET_ERROR_NOTSUPPORTED: feature not supported (deprecated). 231de7ed953SPrasad Kummari * @PM_RET_ERROR_NOFEATURE: feature is not available. 232de7ed953SPrasad Kummari * @PM_RET_ERROR_INVALID_CRC: invalid crc in IPI communication. 233de7ed953SPrasad Kummari * @PM_RET_ERROR_NOT_ENABLED: feature is not enabled. 234de7ed953SPrasad Kummari * @PM_RET_ERROR_INTERNAL: internal error. 235de7ed953SPrasad Kummari * @PM_RET_ERROR_CONFLICT: conflict. 236de7ed953SPrasad Kummari * @PM_RET_ERROR_ACCESS: access rights violation. 237de7ed953SPrasad Kummari * @PM_RET_ERROR_INVALID_NODE: invalid node. 238de7ed953SPrasad Kummari * @PM_RET_ERROR_DOUBLE_REQ: duplicate request for same node. 239de7ed953SPrasad Kummari * @PM_RET_ERROR_ABORT_SUSPEND: suspend procedure has been aborted. 240de7ed953SPrasad Kummari * @PM_RET_ERROR_TIMEOUT: timeout in communication with PMU. 241de7ed953SPrasad Kummari * @PM_RET_ERROR_NODE_USED: node is already in use. 242de7ed953SPrasad Kummari * @PM_RET_ERROR_NO_FEATURE: indicates that the requested feature is not 243de7ed953SPrasad Kummari * supported. 24492f7de1eSJay Buddhabhatti */ 24592f7de1eSJay Buddhabhatti enum pm_ret_status { 24692f7de1eSJay Buddhabhatti PM_RET_SUCCESS, 24792f7de1eSJay Buddhabhatti PM_RET_ERROR_ARGS = 1, 24892f7de1eSJay Buddhabhatti PM_RET_ERROR_NOTSUPPORTED = 4, 24992f7de1eSJay Buddhabhatti PM_RET_ERROR_NOFEATURE = 19, 25092f7de1eSJay Buddhabhatti PM_RET_ERROR_INVALID_CRC = 301, 25192f7de1eSJay Buddhabhatti PM_RET_ERROR_NOT_ENABLED = 29, 25292f7de1eSJay Buddhabhatti PM_RET_ERROR_INTERNAL = 2000, 25392f7de1eSJay Buddhabhatti PM_RET_ERROR_CONFLICT = 2001, 25492f7de1eSJay Buddhabhatti PM_RET_ERROR_ACCESS = 2002, 25592f7de1eSJay Buddhabhatti PM_RET_ERROR_INVALID_NODE = 2003, 25692f7de1eSJay Buddhabhatti PM_RET_ERROR_DOUBLE_REQ = 2004, 25792f7de1eSJay Buddhabhatti PM_RET_ERROR_ABORT_SUSPEND = 2005, 25892f7de1eSJay Buddhabhatti PM_RET_ERROR_TIMEOUT = 2006, 25992f7de1eSJay Buddhabhatti PM_RET_ERROR_NODE_USED = 2007, 26092f7de1eSJay Buddhabhatti PM_RET_ERROR_NO_FEATURE = 2008 26192f7de1eSJay Buddhabhatti }; 26292f7de1eSJay Buddhabhatti 263de7ed953SPrasad Kummari /* 26492f7de1eSJay Buddhabhatti * Qids 26592f7de1eSJay Buddhabhatti */ 26692f7de1eSJay Buddhabhatti enum pm_query_id { 26792f7de1eSJay Buddhabhatti XPM_QID_INVALID, 26892f7de1eSJay Buddhabhatti XPM_QID_CLOCK_GET_NAME, 26992f7de1eSJay Buddhabhatti XPM_QID_CLOCK_GET_TOPOLOGY, 27092f7de1eSJay Buddhabhatti XPM_QID_CLOCK_GET_FIXEDFACTOR_PARAMS, 27192f7de1eSJay Buddhabhatti XPM_QID_CLOCK_GET_MUXSOURCES, 27292f7de1eSJay Buddhabhatti XPM_QID_CLOCK_GET_ATTRIBUTES, 27392f7de1eSJay Buddhabhatti XPM_QID_PINCTRL_GET_NUM_PINS, 27492f7de1eSJay Buddhabhatti XPM_QID_PINCTRL_GET_NUM_FUNCTIONS, 27592f7de1eSJay Buddhabhatti XPM_QID_PINCTRL_GET_NUM_FUNCTION_GROUPS, 27692f7de1eSJay Buddhabhatti XPM_QID_PINCTRL_GET_FUNCTION_NAME, 27792f7de1eSJay Buddhabhatti XPM_QID_PINCTRL_GET_FUNCTION_GROUPS, 27892f7de1eSJay Buddhabhatti XPM_QID_PINCTRL_GET_PIN_GROUPS, 27992f7de1eSJay Buddhabhatti XPM_QID_CLOCK_GET_NUM_CLOCKS, 28092f7de1eSJay Buddhabhatti XPM_QID_CLOCK_GET_MAX_DIVISOR, 28192f7de1eSJay Buddhabhatti XPM_QID_PLD_GET_PARENT, 28292f7de1eSJay Buddhabhatti }; 28392f7de1eSJay Buddhabhatti #endif /* PM_DEFS_H */ 284