192f7de1eSJay Buddhabhatti /* 292f7de1eSJay Buddhabhatti * Copyright (c) 2019-2022, Xilinx, Inc. All rights reserved. 392f7de1eSJay Buddhabhatti * Copyright (c) 2022-2023, 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 2192f7de1eSJay Buddhabhatti #define PM_STATE_SUSPEND_TO_RAM 0xFU 2292f7de1eSJay Buddhabhatti 2392f7de1eSJay Buddhabhatti #define MAX_LATENCY (~0U) 2492f7de1eSJay Buddhabhatti #define MAX_QOS 100U 2592f7de1eSJay Buddhabhatti 2692f7de1eSJay Buddhabhatti /* Processor core device IDs */ 2792f7de1eSJay Buddhabhatti #define APU_DEVID(IDX) NODEID(XPM_NODECLASS_DEVICE, XPM_NODESUBCL_DEV_CORE, \ 2892f7de1eSJay Buddhabhatti XPM_NODETYPE_DEV_CORE_APU, (IDX)) 2992f7de1eSJay Buddhabhatti 3092f7de1eSJay Buddhabhatti #define XPM_DEVID_ACPU_0 APU_DEVID(XPM_NODEIDX_DEV_ACPU_0) 3192f7de1eSJay Buddhabhatti #define XPM_DEVID_ACPU_1 APU_DEVID(XPM_NODEIDX_DEV_ACPU_1) 3292f7de1eSJay Buddhabhatti 33964e5592SJay Buddhabhatti #define PERIPH_DEVID(IDX) NODEID((uint32_t)XPM_NODECLASS_DEVICE, \ 34964e5592SJay Buddhabhatti (uint32_t)XPM_NODESUBCL_DEV_PERIPH, \ 35964e5592SJay Buddhabhatti (uint32_t)XPM_NODETYPE_DEV_PERIPH, (IDX)) 3692f7de1eSJay Buddhabhatti 3792f7de1eSJay Buddhabhatti #define PM_GET_CALLBACK_DATA 0xa01U 3892f7de1eSJay Buddhabhatti #define PM_GET_TRUSTZONE_VERSION 0xa03U 3992f7de1eSJay Buddhabhatti #define TF_A_PM_REGISTER_SGI 0xa04U 4092f7de1eSJay Buddhabhatti 4192f7de1eSJay Buddhabhatti /* PM API Versions */ 4292f7de1eSJay Buddhabhatti #define PM_API_BASE_VERSION 1U 4392f7de1eSJay Buddhabhatti #define PM_API_VERSION_2 2U 4492f7de1eSJay Buddhabhatti 4592f7de1eSJay Buddhabhatti /* Loader API ids */ 4692f7de1eSJay Buddhabhatti #define PM_LOAD_PDI 0x701U 4792f7de1eSJay Buddhabhatti #define PM_LOAD_GET_HANDOFF_PARAMS 0x70BU 4892f7de1eSJay Buddhabhatti 4992f7de1eSJay Buddhabhatti /* System shutdown macros */ 5092f7de1eSJay Buddhabhatti #define XPM_SHUTDOWN_TYPE_SHUTDOWN 0U 5192f7de1eSJay Buddhabhatti #define XPM_SHUTDOWN_TYPE_RESET 1U 5292f7de1eSJay Buddhabhatti #define XPM_SHUTDOWN_TYPE_SETSCOPE_ONLY 2U 5392f7de1eSJay Buddhabhatti 5492f7de1eSJay Buddhabhatti #define XPM_SHUTDOWN_SUBTYPE_RST_SUBSYSTEM 0U 5592f7de1eSJay Buddhabhatti #define XPM_SHUTDOWN_SUBTYPE_RST_PS_ONLY 1U 5692f7de1eSJay Buddhabhatti #define XPM_SHUTDOWN_SUBTYPE_RST_SYSTEM 2U 5792f7de1eSJay Buddhabhatti 5892f7de1eSJay Buddhabhatti /********************************************************************* 5992f7de1eSJay Buddhabhatti * Enum definitions 6092f7de1eSJay Buddhabhatti ********************************************************************/ 6192f7de1eSJay Buddhabhatti 62*c90f4abfSJay Buddhabhatti //ioctl id 63*c90f4abfSJay Buddhabhatti enum { 64*c90f4abfSJay Buddhabhatti IOCTL_GET_RPU_OPER_MODE = 0, 65*c90f4abfSJay Buddhabhatti IOCTL_SET_RPU_OPER_MODE = 1, 66*c90f4abfSJay Buddhabhatti IOCTL_RPU_BOOT_ADDR_CONFIG = 2, 67*c90f4abfSJay Buddhabhatti IOCTL_TCM_COMB_CONFIG = 3, 68*c90f4abfSJay Buddhabhatti IOCTL_SET_TAPDELAY_BYPASS = 4, 69*c90f4abfSJay Buddhabhatti IOCTL_SET_SGMII_MODE = 5, 70*c90f4abfSJay Buddhabhatti IOCTL_SD_DLL_RESET = 6, 71*c90f4abfSJay Buddhabhatti IOCTL_SET_SD_TAPDELAY = 7, 72*c90f4abfSJay Buddhabhatti /* Ioctl for clock driver */ 73*c90f4abfSJay Buddhabhatti IOCTL_SET_PLL_FRAC_MODE = 8, 74*c90f4abfSJay Buddhabhatti IOCTL_GET_PLL_FRAC_MODE = 9, 75*c90f4abfSJay Buddhabhatti IOCTL_SET_PLL_FRAC_DATA = 10, 76*c90f4abfSJay Buddhabhatti IOCTL_GET_PLL_FRAC_DATA = 11, 77*c90f4abfSJay Buddhabhatti IOCTL_WRITE_GGS = 12, 78*c90f4abfSJay Buddhabhatti IOCTL_READ_GGS = 13, 79*c90f4abfSJay Buddhabhatti IOCTL_WRITE_PGGS = 14, 80*c90f4abfSJay Buddhabhatti IOCTL_READ_PGGS = 15, 81*c90f4abfSJay Buddhabhatti /* IOCTL for ULPI reset */ 82*c90f4abfSJay Buddhabhatti IOCTL_ULPI_RESET = 16, 83*c90f4abfSJay Buddhabhatti /* Set healthy bit value */ 84*c90f4abfSJay Buddhabhatti IOCTL_SET_BOOT_HEALTH_STATUS = 17, 85*c90f4abfSJay Buddhabhatti IOCTL_AFI = 18, 86*c90f4abfSJay Buddhabhatti /* Probe counter read/write */ 87*c90f4abfSJay Buddhabhatti IOCTL_PROBE_COUNTER_READ = 19, 88*c90f4abfSJay Buddhabhatti IOCTL_PROBE_COUNTER_WRITE = 20, 89*c90f4abfSJay Buddhabhatti IOCTL_OSPI_MUX_SELECT = 21, 90*c90f4abfSJay Buddhabhatti /* IOCTL for USB power request */ 91*c90f4abfSJay Buddhabhatti IOCTL_USB_SET_STATE = 22, 92*c90f4abfSJay Buddhabhatti /* IOCTL to get last reset reason */ 93*c90f4abfSJay Buddhabhatti IOCTL_GET_LAST_RESET_REASON = 23, 94*c90f4abfSJay Buddhabhatti /* AI engine NPI ISR clear */ 95*c90f4abfSJay Buddhabhatti IOCTL_AIE_ISR_CLEAR = 24, 96*c90f4abfSJay Buddhabhatti /* Register SGI to TF-A */ 97*c90f4abfSJay Buddhabhatti IOCTL_SET_SGI = 25, 98*c90f4abfSJay Buddhabhatti }; 99*c90f4abfSJay Buddhabhatti 10092f7de1eSJay Buddhabhatti /** 10192f7de1eSJay Buddhabhatti * @PM_PLL_PARAM_DIV2: Enable for divide by 2 function inside the PLL 10292f7de1eSJay Buddhabhatti * @PM_PLL_PARAM_FBDIV: Feedback divisor integer portion for the PLL 10392f7de1eSJay Buddhabhatti * @PM_PLL_PARAM_DATA: Feedback divisor fractional portion for the PLL 10492f7de1eSJay Buddhabhatti * @PM_PLL_PARAM_PRE_SRC: Clock source for PLL input 10592f7de1eSJay Buddhabhatti * @PM_PLL_PARAM_POST_SRC: Clock source for PLL Bypass mode 10692f7de1eSJay Buddhabhatti * @PM_PLL_PARAM_LOCK_DLY: Lock circuit config settings for lock windowsize 10792f7de1eSJay Buddhabhatti * @PM_PLL_PARAM_LOCK_CNT: Lock circuit counter setting 10892f7de1eSJay Buddhabhatti * @PM_PLL_PARAM_LFHF: PLL loop filter high frequency capacitor control 10992f7de1eSJay Buddhabhatti * @PM_PLL_PARAM_CP: PLL charge pump control 11092f7de1eSJay Buddhabhatti * @PM_PLL_PARAM_RES: PLL loop filter resistor control 11192f7de1eSJay Buddhabhatti */ 11292f7de1eSJay Buddhabhatti enum pm_pll_param { 11392f7de1eSJay Buddhabhatti PM_PLL_PARAM_DIV2, 11492f7de1eSJay Buddhabhatti PM_PLL_PARAM_FBDIV, 11592f7de1eSJay Buddhabhatti PM_PLL_PARAM_DATA, 11692f7de1eSJay Buddhabhatti PM_PLL_PARAM_PRE_SRC, 11792f7de1eSJay Buddhabhatti PM_PLL_PARAM_POST_SRC, 11892f7de1eSJay Buddhabhatti PM_PLL_PARAM_LOCK_DLY, 11992f7de1eSJay Buddhabhatti PM_PLL_PARAM_LOCK_CNT, 12092f7de1eSJay Buddhabhatti PM_PLL_PARAM_LFHF, 12192f7de1eSJay Buddhabhatti PM_PLL_PARAM_CP, 12292f7de1eSJay Buddhabhatti PM_PLL_PARAM_RES, 12392f7de1eSJay Buddhabhatti PM_PLL_PARAM_MAX, 12492f7de1eSJay Buddhabhatti }; 12592f7de1eSJay Buddhabhatti 12692f7de1eSJay Buddhabhatti enum pm_api_id { 12792f7de1eSJay Buddhabhatti /* Miscellaneous API functions: */ 12892f7de1eSJay Buddhabhatti PM_GET_API_VERSION = 1, /* Do not change or move */ 12992f7de1eSJay Buddhabhatti PM_SET_CONFIGURATION, 13092f7de1eSJay Buddhabhatti PM_GET_NODE_STATUS, 13192f7de1eSJay Buddhabhatti PM_GET_OP_CHARACTERISTIC, 13292f7de1eSJay Buddhabhatti PM_REGISTER_NOTIFIER, 13392f7de1eSJay Buddhabhatti /* API for suspending of PUs: */ 13492f7de1eSJay Buddhabhatti PM_REQ_SUSPEND, 13592f7de1eSJay Buddhabhatti PM_SELF_SUSPEND, 13692f7de1eSJay Buddhabhatti PM_FORCE_POWERDOWN, 13792f7de1eSJay Buddhabhatti PM_ABORT_SUSPEND, 13892f7de1eSJay Buddhabhatti PM_REQ_WAKEUP, 13992f7de1eSJay Buddhabhatti PM_SET_WAKEUP_SOURCE, 14092f7de1eSJay Buddhabhatti PM_SYSTEM_SHUTDOWN, 14192f7de1eSJay Buddhabhatti /* API for managing PM slaves: */ 14292f7de1eSJay Buddhabhatti PM_REQ_NODE, 14392f7de1eSJay Buddhabhatti PM_RELEASE_NODE, 14492f7de1eSJay Buddhabhatti PM_SET_REQUIREMENT, 14592f7de1eSJay Buddhabhatti PM_SET_MAX_LATENCY, 14692f7de1eSJay Buddhabhatti /* Direct control API functions: */ 14792f7de1eSJay Buddhabhatti PM_RESET_ASSERT, 14892f7de1eSJay Buddhabhatti PM_RESET_GET_STATUS, 14992f7de1eSJay Buddhabhatti PM_MMIO_WRITE, 15092f7de1eSJay Buddhabhatti PM_MMIO_READ, 15192f7de1eSJay Buddhabhatti PM_INIT_FINALIZE, 15292f7de1eSJay Buddhabhatti PM_FPGA_LOAD, 15392f7de1eSJay Buddhabhatti PM_FPGA_GET_STATUS, 15492f7de1eSJay Buddhabhatti PM_GET_CHIPID, 15592f7de1eSJay Buddhabhatti PM_SECURE_RSA_AES, 15692f7de1eSJay Buddhabhatti PM_SECURE_SHA, 15792f7de1eSJay Buddhabhatti PM_SECURE_RSA, 15892f7de1eSJay Buddhabhatti PM_PINCTRL_REQUEST, 15992f7de1eSJay Buddhabhatti PM_PINCTRL_RELEASE, 16092f7de1eSJay Buddhabhatti PM_PINCTRL_GET_FUNCTION, 16192f7de1eSJay Buddhabhatti PM_PINCTRL_SET_FUNCTION, 16292f7de1eSJay Buddhabhatti PM_PINCTRL_CONFIG_PARAM_GET, 16392f7de1eSJay Buddhabhatti PM_PINCTRL_CONFIG_PARAM_SET, 16492f7de1eSJay Buddhabhatti PM_IOCTL, 16592f7de1eSJay Buddhabhatti /* API to query information from firmware */ 16692f7de1eSJay Buddhabhatti PM_QUERY_DATA, 16792f7de1eSJay Buddhabhatti /* Clock control API functions */ 16892f7de1eSJay Buddhabhatti PM_CLOCK_ENABLE, 16992f7de1eSJay Buddhabhatti PM_CLOCK_DISABLE, 17092f7de1eSJay Buddhabhatti PM_CLOCK_GETSTATE, 17192f7de1eSJay Buddhabhatti PM_CLOCK_SETDIVIDER, 17292f7de1eSJay Buddhabhatti PM_CLOCK_GETDIVIDER, 17392f7de1eSJay Buddhabhatti PM_CLOCK_SETRATE, 17492f7de1eSJay Buddhabhatti PM_CLOCK_GETRATE, 17592f7de1eSJay Buddhabhatti PM_CLOCK_SETPARENT, 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 20892f7de1eSJay Buddhabhatti /** 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 /** 22692f7de1eSJay Buddhabhatti * @PM_RET_SUCCESS: success 22792f7de1eSJay Buddhabhatti * @PM_RET_ERROR_ARGS: illegal arguments provided (deprecated) 22892f7de1eSJay Buddhabhatti * @PM_RET_ERROR_NOTSUPPORTED: feature not supported (deprecated) 22992f7de1eSJay Buddhabhatti * @PM_RET_ERROR_NOFEATURE: feature is not available 23092f7de1eSJay Buddhabhatti * @PM_RET_ERROR_INVALID_CRC: invalid crc in IPI communication 23192f7de1eSJay Buddhabhatti * @PM_RET_ERROR_NOT_ENABLED: feature is not enabled 23292f7de1eSJay Buddhabhatti * @PM_RET_ERROR_INTERNAL: internal error 23392f7de1eSJay Buddhabhatti * @PM_RET_ERROR_CONFLICT: conflict 23492f7de1eSJay Buddhabhatti * @PM_RET_ERROR_ACCESS: access rights violation 23592f7de1eSJay Buddhabhatti * @PM_RET_ERROR_INVALID_NODE: invalid node 23692f7de1eSJay Buddhabhatti * @PM_RET_ERROR_DOUBLE_REQ: duplicate request for same node 23792f7de1eSJay Buddhabhatti * @PM_RET_ERROR_ABORT_SUSPEND: suspend procedure has been aborted 23892f7de1eSJay Buddhabhatti * @PM_RET_ERROR_TIMEOUT: timeout in communication with PMU 23992f7de1eSJay Buddhabhatti * @PM_RET_ERROR_NODE_USED: node is already in use 24092f7de1eSJay Buddhabhatti */ 24192f7de1eSJay Buddhabhatti enum pm_ret_status { 24292f7de1eSJay Buddhabhatti PM_RET_SUCCESS, 24392f7de1eSJay Buddhabhatti PM_RET_ERROR_ARGS = 1, 24492f7de1eSJay Buddhabhatti PM_RET_ERROR_NOTSUPPORTED = 4, 24592f7de1eSJay Buddhabhatti PM_RET_ERROR_NOFEATURE = 19, 24692f7de1eSJay Buddhabhatti PM_RET_ERROR_INVALID_CRC = 301, 24792f7de1eSJay Buddhabhatti PM_RET_ERROR_NOT_ENABLED = 29, 24892f7de1eSJay Buddhabhatti PM_RET_ERROR_INTERNAL = 2000, 24992f7de1eSJay Buddhabhatti PM_RET_ERROR_CONFLICT = 2001, 25092f7de1eSJay Buddhabhatti PM_RET_ERROR_ACCESS = 2002, 25192f7de1eSJay Buddhabhatti PM_RET_ERROR_INVALID_NODE = 2003, 25292f7de1eSJay Buddhabhatti PM_RET_ERROR_DOUBLE_REQ = 2004, 25392f7de1eSJay Buddhabhatti PM_RET_ERROR_ABORT_SUSPEND = 2005, 25492f7de1eSJay Buddhabhatti PM_RET_ERROR_TIMEOUT = 2006, 25592f7de1eSJay Buddhabhatti PM_RET_ERROR_NODE_USED = 2007, 25692f7de1eSJay Buddhabhatti PM_RET_ERROR_NO_FEATURE = 2008 25792f7de1eSJay Buddhabhatti }; 25892f7de1eSJay Buddhabhatti 25992f7de1eSJay Buddhabhatti /** 26092f7de1eSJay Buddhabhatti * Qids 26192f7de1eSJay Buddhabhatti */ 26292f7de1eSJay Buddhabhatti enum pm_query_id { 26392f7de1eSJay Buddhabhatti XPM_QID_INVALID, 26492f7de1eSJay Buddhabhatti XPM_QID_CLOCK_GET_NAME, 26592f7de1eSJay Buddhabhatti XPM_QID_CLOCK_GET_TOPOLOGY, 26692f7de1eSJay Buddhabhatti XPM_QID_CLOCK_GET_FIXEDFACTOR_PARAMS, 26792f7de1eSJay Buddhabhatti XPM_QID_CLOCK_GET_MUXSOURCES, 26892f7de1eSJay Buddhabhatti XPM_QID_CLOCK_GET_ATTRIBUTES, 26992f7de1eSJay Buddhabhatti XPM_QID_PINCTRL_GET_NUM_PINS, 27092f7de1eSJay Buddhabhatti XPM_QID_PINCTRL_GET_NUM_FUNCTIONS, 27192f7de1eSJay Buddhabhatti XPM_QID_PINCTRL_GET_NUM_FUNCTION_GROUPS, 27292f7de1eSJay Buddhabhatti XPM_QID_PINCTRL_GET_FUNCTION_NAME, 27392f7de1eSJay Buddhabhatti XPM_QID_PINCTRL_GET_FUNCTION_GROUPS, 27492f7de1eSJay Buddhabhatti XPM_QID_PINCTRL_GET_PIN_GROUPS, 27592f7de1eSJay Buddhabhatti XPM_QID_CLOCK_GET_NUM_CLOCKS, 27692f7de1eSJay Buddhabhatti XPM_QID_CLOCK_GET_MAX_DIVISOR, 27792f7de1eSJay Buddhabhatti XPM_QID_PLD_GET_PARENT, 27892f7de1eSJay Buddhabhatti }; 27992f7de1eSJay Buddhabhatti #endif /* PM_DEFS_H */ 280