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