1*91f16700Schasinglulu /* 2*91f16700Schasinglulu * Copyright (c) 2020-2023, MediaTek Inc. All rights reserved. 3*91f16700Schasinglulu * 4*91f16700Schasinglulu * SPDX-License-Identifier: BSD-3-Clause 5*91f16700Schasinglulu */ 6*91f16700Schasinglulu 7*91f16700Schasinglulu #ifndef MT_LP_RM_H 8*91f16700Schasinglulu #define MT_LP_RM_H 9*91f16700Schasinglulu 10*91f16700Schasinglulu #include <stdbool.h> 11*91f16700Schasinglulu 12*91f16700Schasinglulu #define MT_RM_STATUS_OK (0) 13*91f16700Schasinglulu #define MT_RM_STATUS_BAD (-1) 14*91f16700Schasinglulu #define MT_RM_STATUS_STOP (-2) 15*91f16700Schasinglulu 16*91f16700Schasinglulu enum PLAT_MT_LPM_RC_TYPE { 17*91f16700Schasinglulu PLAT_RC_UPDATE_CONDITION, 18*91f16700Schasinglulu PLAT_RC_STATUS, 19*91f16700Schasinglulu PLAT_RC_UPDATE_REMAIN_IRQS, 20*91f16700Schasinglulu PLAT_RC_IS_FMAUDIO, 21*91f16700Schasinglulu PLAT_RC_IS_ADSP, 22*91f16700Schasinglulu PLAT_RC_ENTER_CNT, 23*91f16700Schasinglulu PLAT_RC_CLKBUF_STATUS, 24*91f16700Schasinglulu PLAT_RC_UFS_STATUS, 25*91f16700Schasinglulu PLAT_RC_IS_USB_PERI, 26*91f16700Schasinglulu PLAT_RC_IS_USB_INFRA, 27*91f16700Schasinglulu PLAT_RC_MAX, 28*91f16700Schasinglulu }; 29*91f16700Schasinglulu 30*91f16700Schasinglulu enum plat_mt_lpm_hw_ctrl_type { 31*91f16700Schasinglulu PLAT_AP_MDSRC_REQ, 32*91f16700Schasinglulu PLAT_AP_MDSRC_ACK, 33*91f16700Schasinglulu PLAT_AP_IS_MD_SLEEP, 34*91f16700Schasinglulu PLAT_AP_MDSRC_SETTLE, 35*91f16700Schasinglulu PLAT_AP_GPUEB_PLL_CONTROL, 36*91f16700Schasinglulu PLAT_AP_GPUEB_GET_PWR_STATUS, 37*91f16700Schasinglulu PLAT_AP_HW_CTRL_MAX, 38*91f16700Schasinglulu }; 39*91f16700Schasinglulu 40*91f16700Schasinglulu struct mt_resource_constraint { 41*91f16700Schasinglulu int level; 42*91f16700Schasinglulu int (*init)(void); 43*91f16700Schasinglulu bool (*is_valid)(unsigned int cpu, int stateid); 44*91f16700Schasinglulu int (*update)(int stateid, int type, const void *p); 45*91f16700Schasinglulu int (*run)(unsigned int cpu, int stateid); 46*91f16700Schasinglulu int (*reset)(unsigned int cpu, int stateid); 47*91f16700Schasinglulu int (*get_status)(unsigned int type, void *priv); 48*91f16700Schasinglulu unsigned int (*allow)(int stateid); 49*91f16700Schasinglulu }; 50*91f16700Schasinglulu 51*91f16700Schasinglulu struct mt_resource_manager { 52*91f16700Schasinglulu int (*update)(struct mt_resource_constraint **con, unsigned int num, 53*91f16700Schasinglulu int stateid, void *priv); 54*91f16700Schasinglulu struct mt_resource_constraint **consts; 55*91f16700Schasinglulu }; 56*91f16700Schasinglulu 57*91f16700Schasinglulu extern int mt_lp_rm_register(struct mt_resource_manager *rm); 58*91f16700Schasinglulu extern int mt_lp_rm_do_constraint(unsigned int constraint_id, unsigned int cpuid, int stateid); 59*91f16700Schasinglulu extern int mt_lp_rm_find_constraint(unsigned int idx, unsigned int cpuid, 60*91f16700Schasinglulu int stateid, void *priv); 61*91f16700Schasinglulu extern int mt_lp_rm_find_and_run_constraint(unsigned int idx, unsigned int cpuid, 62*91f16700Schasinglulu int stateid, void *priv); 63*91f16700Schasinglulu extern int mt_lp_rm_reset_constraint(unsigned int idx, unsigned int cpuid, int stateid); 64*91f16700Schasinglulu extern int mt_lp_rm_do_update(int stateid, int type, void const *p); 65*91f16700Schasinglulu extern int mt_lp_rm_get_status(unsigned int type, void *priv); 66*91f16700Schasinglulu 67*91f16700Schasinglulu #endif /* MT_LP_RM_H */ 68