1 /* 2 * Copyright (c) 2025, 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_IS_USB_HEADSET, 28 PLAT_RC_MAX, 29 }; 30 31 enum plat_mt_lpm_hw_ctrl_type { 32 PLAT_AP_MDSRC_REQ, 33 PLAT_AP_MDSRC_ACK, 34 PLAT_AP_IS_MD_SLEEP, 35 PLAT_AP_MDSRC_SETTLE, 36 PLAT_AP_GPUEB_PLL_CONTROL, 37 PLAT_AP_GPUEB_PWR_STATUS, 38 PLAT_AP_GPUEB_MFG0_PWR_CON, 39 PLAT_AP_ASSERT_SPM_IRQ, 40 PLAT_AP_SPM_RESOURCE_REQUEST_UPDATE, 41 PLAT_AP_SPM_WDT_TRIGGER, 42 PLAT_AP_HW_CTRL_MAX, 43 }; 44 45 struct mt_resource_constraint { 46 int level; 47 int (*init)(void); 48 bool (*is_valid)(unsigned int cpu, int stateid); 49 int (*update)(int stateid, int type, const void *p); 50 int (*run)(unsigned int cpu, int stateid); 51 int (*reset)(unsigned int cpu, int stateid); 52 int (*get_status)(unsigned int type, void *priv); 53 unsigned int (*allow)(int stateid); 54 }; 55 56 struct mt_resource_manager { 57 int (*update)(struct mt_resource_constraint **con, unsigned int num, 58 int stateid, void *priv); 59 struct mt_resource_constraint **consts; 60 int (*hwctrl)(unsigned int type, int set, void *priv); 61 }; 62 63 extern int mt_lp_rm_register(struct mt_resource_manager *rm); 64 extern int mt_lp_rm_do_constraint(unsigned int constraint_id, 65 unsigned int cpuid, int stateid); 66 extern int mt_lp_rm_find_constraint(unsigned int idx, unsigned int cpuid, 67 int stateid, void *priv); 68 extern int mt_lp_rm_find_and_run_constraint(unsigned int idx, 69 unsigned int cpuid, 70 int stateid, void *priv); 71 extern int mt_lp_rm_reset_constraint(unsigned int idx, 72 unsigned int cpuid, int stateid); 73 extern int mt_lp_rm_do_update(int stateid, int type, void const *p); 74 extern int mt_lp_rm_get_status(unsigned int type, void *priv); 75 extern int mt_lp_rm_do_hwctrl(unsigned int type, int set, void *priv); 76 77 #endif /* MT_LP_RM_H */ 78