192f7de1eSJay Buddhabhatti /* 292f7de1eSJay Buddhabhatti * Copyright (c) 2019-2022, Xilinx, Inc. All rights reserved. 3924f8ce2SRonak 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, 98*b9c20e5dSAmit Nagal IOCTL_UFS_TXRX_CFGRDY_GET = 40, 99*b9c20e5dSAmit Nagal IOCTL_UFS_SRAM_CSR_SEL = 41, 100c90f4abfSJay Buddhabhatti }; 101c90f4abfSJay Buddhabhatti 10292f7de1eSJay Buddhabhatti /** 103de7ed953SPrasad Kummari * enum pm_pll_param - enum represents the parameters for a phase-locked loop. 104de7ed953SPrasad Kummari * @PM_PLL_PARAM_DIV2: Enable for divide by 2 function inside the PLL. 105de7ed953SPrasad Kummari * @PM_PLL_PARAM_FBDIV: Feedback divisor integer portion for the PLL. 106de7ed953SPrasad Kummari * @PM_PLL_PARAM_DATA: Feedback divisor fractional portion for the PLL. 107de7ed953SPrasad Kummari * @PM_PLL_PARAM_PRE_SRC: Clock source for PLL input. 108de7ed953SPrasad Kummari * @PM_PLL_PARAM_POST_SRC: Clock source for PLL Bypass mode. 109de7ed953SPrasad Kummari * @PM_PLL_PARAM_LOCK_DLY: Lock circuit config settings for lock windowsize. 110de7ed953SPrasad Kummari * @PM_PLL_PARAM_LOCK_CNT: Lock circuit counter setting. 111de7ed953SPrasad Kummari * @PM_PLL_PARAM_LFHF: PLL loop filter high frequency capacitor control. 112de7ed953SPrasad Kummari * @PM_PLL_PARAM_CP: PLL charge pump control. 113de7ed953SPrasad Kummari * @PM_PLL_PARAM_RES: PLL loop filter resistor control. 114de7ed953SPrasad Kummari * @PM_PLL_PARAM_MAX: Represents the maximum parameter value for the PLL 11592f7de1eSJay Buddhabhatti */ 11692f7de1eSJay Buddhabhatti enum pm_pll_param { 11792f7de1eSJay Buddhabhatti PM_PLL_PARAM_DIV2, 11892f7de1eSJay Buddhabhatti PM_PLL_PARAM_FBDIV, 11992f7de1eSJay Buddhabhatti PM_PLL_PARAM_DATA, 12092f7de1eSJay Buddhabhatti PM_PLL_PARAM_PRE_SRC, 12192f7de1eSJay Buddhabhatti PM_PLL_PARAM_POST_SRC, 12292f7de1eSJay Buddhabhatti PM_PLL_PARAM_LOCK_DLY, 12392f7de1eSJay Buddhabhatti PM_PLL_PARAM_LOCK_CNT, 12492f7de1eSJay Buddhabhatti PM_PLL_PARAM_LFHF, 12592f7de1eSJay Buddhabhatti PM_PLL_PARAM_CP, 12692f7de1eSJay Buddhabhatti PM_PLL_PARAM_RES, 12792f7de1eSJay Buddhabhatti PM_PLL_PARAM_MAX, 12892f7de1eSJay Buddhabhatti }; 12992f7de1eSJay Buddhabhatti 13092f7de1eSJay Buddhabhatti enum pm_api_id { 13192f7de1eSJay Buddhabhatti /* Miscellaneous API functions: */ 13292f7de1eSJay Buddhabhatti PM_GET_API_VERSION = 1, /* Do not change or move */ 13392f7de1eSJay Buddhabhatti PM_SET_CONFIGURATION, 13492f7de1eSJay Buddhabhatti PM_GET_NODE_STATUS, 13592f7de1eSJay Buddhabhatti PM_GET_OP_CHARACTERISTIC, 13692f7de1eSJay Buddhabhatti PM_REGISTER_NOTIFIER, 13792f7de1eSJay Buddhabhatti /* API for suspending of PUs: */ 13892f7de1eSJay Buddhabhatti PM_REQ_SUSPEND, 13992f7de1eSJay Buddhabhatti PM_SELF_SUSPEND, 14092f7de1eSJay Buddhabhatti PM_FORCE_POWERDOWN, 14192f7de1eSJay Buddhabhatti PM_ABORT_SUSPEND, 14292f7de1eSJay Buddhabhatti PM_REQ_WAKEUP, 14392f7de1eSJay Buddhabhatti PM_SET_WAKEUP_SOURCE, 14492f7de1eSJay Buddhabhatti PM_SYSTEM_SHUTDOWN, 14592f7de1eSJay Buddhabhatti /* API for managing PM slaves: */ 14692f7de1eSJay Buddhabhatti PM_REQ_NODE, 14792f7de1eSJay Buddhabhatti PM_RELEASE_NODE, 14892f7de1eSJay Buddhabhatti PM_SET_REQUIREMENT, 14992f7de1eSJay Buddhabhatti PM_SET_MAX_LATENCY, 15092f7de1eSJay Buddhabhatti /* Direct control API functions: */ 15192f7de1eSJay Buddhabhatti PM_RESET_ASSERT, 15292f7de1eSJay Buddhabhatti PM_RESET_GET_STATUS, 15392f7de1eSJay Buddhabhatti PM_MMIO_WRITE, 15492f7de1eSJay Buddhabhatti PM_MMIO_READ, 15592f7de1eSJay Buddhabhatti PM_INIT_FINALIZE, 15692f7de1eSJay Buddhabhatti PM_FPGA_LOAD, 15792f7de1eSJay Buddhabhatti PM_FPGA_GET_STATUS, 15892f7de1eSJay Buddhabhatti PM_GET_CHIPID, 15992f7de1eSJay Buddhabhatti PM_SECURE_RSA_AES, 16092f7de1eSJay Buddhabhatti PM_SECURE_SHA, 16192f7de1eSJay Buddhabhatti PM_SECURE_RSA, 16292f7de1eSJay Buddhabhatti PM_PINCTRL_REQUEST, 16392f7de1eSJay Buddhabhatti PM_PINCTRL_RELEASE, 16492f7de1eSJay Buddhabhatti PM_PINCTRL_GET_FUNCTION, 16592f7de1eSJay Buddhabhatti PM_PINCTRL_SET_FUNCTION, 16692f7de1eSJay Buddhabhatti PM_PINCTRL_CONFIG_PARAM_GET, 16792f7de1eSJay Buddhabhatti PM_PINCTRL_CONFIG_PARAM_SET, 16892f7de1eSJay Buddhabhatti PM_IOCTL, 16992f7de1eSJay Buddhabhatti /* API to query information from firmware */ 17092f7de1eSJay Buddhabhatti PM_QUERY_DATA, 17192f7de1eSJay Buddhabhatti /* Clock control API functions */ 17292f7de1eSJay Buddhabhatti PM_CLOCK_ENABLE, 17392f7de1eSJay Buddhabhatti PM_CLOCK_DISABLE, 17492f7de1eSJay Buddhabhatti PM_CLOCK_GETSTATE, 17592f7de1eSJay Buddhabhatti PM_CLOCK_SETDIVIDER, 17692f7de1eSJay Buddhabhatti PM_CLOCK_GETDIVIDER, 177e5955d7cSRonak Jain PM_CLOCK_SETPARENT = 43, 17892f7de1eSJay Buddhabhatti PM_CLOCK_GETPARENT, 17992f7de1eSJay Buddhabhatti PM_SECURE_IMAGE, 18092f7de1eSJay Buddhabhatti /* FPGA PL Readback */ 18192f7de1eSJay Buddhabhatti PM_FPGA_READ, 18292f7de1eSJay Buddhabhatti PM_SECURE_AES, 18392f7de1eSJay Buddhabhatti /* PLL control API functions */ 18492f7de1eSJay Buddhabhatti PM_PLL_SET_PARAMETER, 18592f7de1eSJay Buddhabhatti PM_PLL_GET_PARAMETER, 18692f7de1eSJay Buddhabhatti PM_PLL_SET_MODE, 18792f7de1eSJay Buddhabhatti PM_PLL_GET_MODE, 18892f7de1eSJay Buddhabhatti /* PM Register Access API */ 18992f7de1eSJay Buddhabhatti PM_REGISTER_ACCESS, 19092f7de1eSJay Buddhabhatti PM_EFUSE_ACCESS, 19192f7de1eSJay Buddhabhatti PM_FPGA_GET_VERSION, 19292f7de1eSJay Buddhabhatti PM_FPGA_GET_FEATURE_LIST, 19392f7de1eSJay Buddhabhatti PM_FEATURE_CHECK = 63, 19492f7de1eSJay Buddhabhatti PM_API_MAX = 74 19592f7de1eSJay Buddhabhatti }; 19692f7de1eSJay Buddhabhatti 19792f7de1eSJay Buddhabhatti enum pm_abort_reason { 19892f7de1eSJay Buddhabhatti ABORT_REASON_WKUP_EVENT = 100, 19992f7de1eSJay Buddhabhatti ABORT_REASON_PU_BUSY, 20092f7de1eSJay Buddhabhatti ABORT_REASON_NO_PWRDN, 20192f7de1eSJay Buddhabhatti ABORT_REASON_UNKNOWN, 20292f7de1eSJay Buddhabhatti }; 20392f7de1eSJay Buddhabhatti 20492f7de1eSJay Buddhabhatti enum pm_opchar_type { 20592f7de1eSJay Buddhabhatti PM_OPCHAR_TYPE_POWER = 1, 20692f7de1eSJay Buddhabhatti PM_OPCHAR_TYPE_TEMP, 20792f7de1eSJay Buddhabhatti PM_OPCHAR_TYPE_LATENCY, 20892f7de1eSJay Buddhabhatti }; 20992f7de1eSJay Buddhabhatti 210de7ed953SPrasad Kummari /* 21192f7de1eSJay Buddhabhatti * Subsystem IDs 21292f7de1eSJay Buddhabhatti */ 21392f7de1eSJay Buddhabhatti typedef enum { 21492f7de1eSJay Buddhabhatti XPM_SUBSYSID_PMC, 21592f7de1eSJay Buddhabhatti XPM_SUBSYSID_PSM, 21692f7de1eSJay Buddhabhatti XPM_SUBSYSID_APU, 21792f7de1eSJay Buddhabhatti XPM_SUBSYSID_RPU0_LOCK, 21892f7de1eSJay Buddhabhatti XPM_SUBSYSID_RPU0_0, 21992f7de1eSJay Buddhabhatti XPM_SUBSYSID_RPU0_1, 22092f7de1eSJay Buddhabhatti XPM_SUBSYSID_DDR0, 22192f7de1eSJay Buddhabhatti XPM_SUBSYSID_ME, 22292f7de1eSJay Buddhabhatti XPM_SUBSYSID_PL, 22392f7de1eSJay Buddhabhatti XPM_SUBSYSID_MAX, 22492f7de1eSJay Buddhabhatti } XPm_SubsystemId; 22592f7de1eSJay Buddhabhatti 22692f7de1eSJay Buddhabhatti /* TODO: move pm_ret_status from device specific location to common location */ 22792f7de1eSJay Buddhabhatti /** 228de7ed953SPrasad Kummari * enum pm_ret_status - enum represents the return status codes for a PM 229de7ed953SPrasad Kummari * operation. 230de7ed953SPrasad Kummari * @PM_RET_SUCCESS: success. 231de7ed953SPrasad Kummari * @PM_RET_ERROR_ARGS: illegal arguments provided (deprecated). 232de7ed953SPrasad Kummari * @PM_RET_ERROR_NOTSUPPORTED: feature not supported (deprecated). 233de7ed953SPrasad Kummari * @PM_RET_ERROR_NOFEATURE: feature is not available. 234de7ed953SPrasad Kummari * @PM_RET_ERROR_INVALID_CRC: invalid crc in IPI communication. 235de7ed953SPrasad Kummari * @PM_RET_ERROR_NOT_ENABLED: feature is not enabled. 236de7ed953SPrasad Kummari * @PM_RET_ERROR_INTERNAL: internal error. 237de7ed953SPrasad Kummari * @PM_RET_ERROR_CONFLICT: conflict. 238de7ed953SPrasad Kummari * @PM_RET_ERROR_ACCESS: access rights violation. 239de7ed953SPrasad Kummari * @PM_RET_ERROR_INVALID_NODE: invalid node. 240de7ed953SPrasad Kummari * @PM_RET_ERROR_DOUBLE_REQ: duplicate request for same node. 241de7ed953SPrasad Kummari * @PM_RET_ERROR_ABORT_SUSPEND: suspend procedure has been aborted. 242de7ed953SPrasad Kummari * @PM_RET_ERROR_TIMEOUT: timeout in communication with PMU. 243de7ed953SPrasad Kummari * @PM_RET_ERROR_NODE_USED: node is already in use. 244de7ed953SPrasad Kummari * @PM_RET_ERROR_NO_FEATURE: indicates that the requested feature is not 245de7ed953SPrasad Kummari * supported. 24692f7de1eSJay Buddhabhatti */ 24792f7de1eSJay Buddhabhatti enum pm_ret_status { 24892f7de1eSJay Buddhabhatti PM_RET_SUCCESS, 24992f7de1eSJay Buddhabhatti PM_RET_ERROR_ARGS = 1, 25092f7de1eSJay Buddhabhatti PM_RET_ERROR_NOTSUPPORTED = 4, 25192f7de1eSJay Buddhabhatti PM_RET_ERROR_NOFEATURE = 19, 25292f7de1eSJay Buddhabhatti PM_RET_ERROR_INVALID_CRC = 301, 25392f7de1eSJay Buddhabhatti PM_RET_ERROR_NOT_ENABLED = 29, 25492f7de1eSJay Buddhabhatti PM_RET_ERROR_INTERNAL = 2000, 25592f7de1eSJay Buddhabhatti PM_RET_ERROR_CONFLICT = 2001, 25692f7de1eSJay Buddhabhatti PM_RET_ERROR_ACCESS = 2002, 25792f7de1eSJay Buddhabhatti PM_RET_ERROR_INVALID_NODE = 2003, 25892f7de1eSJay Buddhabhatti PM_RET_ERROR_DOUBLE_REQ = 2004, 25992f7de1eSJay Buddhabhatti PM_RET_ERROR_ABORT_SUSPEND = 2005, 26092f7de1eSJay Buddhabhatti PM_RET_ERROR_TIMEOUT = 2006, 26192f7de1eSJay Buddhabhatti PM_RET_ERROR_NODE_USED = 2007, 26292f7de1eSJay Buddhabhatti PM_RET_ERROR_NO_FEATURE = 2008 26392f7de1eSJay Buddhabhatti }; 26492f7de1eSJay Buddhabhatti 265de7ed953SPrasad Kummari /* 26692f7de1eSJay Buddhabhatti * Qids 26792f7de1eSJay Buddhabhatti */ 26892f7de1eSJay Buddhabhatti enum pm_query_id { 26992f7de1eSJay Buddhabhatti XPM_QID_INVALID, 27092f7de1eSJay Buddhabhatti XPM_QID_CLOCK_GET_NAME, 27192f7de1eSJay Buddhabhatti XPM_QID_CLOCK_GET_TOPOLOGY, 27292f7de1eSJay Buddhabhatti XPM_QID_CLOCK_GET_FIXEDFACTOR_PARAMS, 27392f7de1eSJay Buddhabhatti XPM_QID_CLOCK_GET_MUXSOURCES, 27492f7de1eSJay Buddhabhatti XPM_QID_CLOCK_GET_ATTRIBUTES, 27592f7de1eSJay Buddhabhatti XPM_QID_PINCTRL_GET_NUM_PINS, 27692f7de1eSJay Buddhabhatti XPM_QID_PINCTRL_GET_NUM_FUNCTIONS, 27792f7de1eSJay Buddhabhatti XPM_QID_PINCTRL_GET_NUM_FUNCTION_GROUPS, 27892f7de1eSJay Buddhabhatti XPM_QID_PINCTRL_GET_FUNCTION_NAME, 27992f7de1eSJay Buddhabhatti XPM_QID_PINCTRL_GET_FUNCTION_GROUPS, 28092f7de1eSJay Buddhabhatti XPM_QID_PINCTRL_GET_PIN_GROUPS, 28192f7de1eSJay Buddhabhatti XPM_QID_CLOCK_GET_NUM_CLOCKS, 28292f7de1eSJay Buddhabhatti XPM_QID_CLOCK_GET_MAX_DIVISOR, 28392f7de1eSJay Buddhabhatti XPM_QID_PLD_GET_PARENT, 28492f7de1eSJay Buddhabhatti }; 28592f7de1eSJay Buddhabhatti #endif /* PM_DEFS_H */ 286