developer | 7d46db6 | 2020-12-14 16:53:22 +0800 | [diff] [blame] | 1 | /* |
developer | 91bb08d | 2022-09-07 18:41:59 +0800 | [diff] [blame] | 2 | * Copyright (c) 2020-2023, MediaTek Inc. All rights reserved. |
developer | 7d46db6 | 2020-12-14 16:53:22 +0800 | [diff] [blame] | 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 | |
developer | 91bb08d | 2022-09-07 18:41:59 +0800 | [diff] [blame] | 12 | #define MT_RM_STATUS_OK (0) |
| 13 | #define MT_RM_STATUS_BAD (-1) |
| 14 | #define MT_RM_STATUS_STOP (-2) |
developer | 7d46db6 | 2020-12-14 16:53:22 +0800 | [diff] [blame] | 15 | |
| 16 | enum PLAT_MT_LPM_RC_TYPE { |
| 17 | PLAT_RC_UPDATE_CONDITION, |
developer | 91bb08d | 2022-09-07 18:41:59 +0800 | [diff] [blame] | 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, |
developer | 7d46db6 | 2020-12-14 16:53:22 +0800 | [diff] [blame] | 28 | }; |
| 29 | |
developer | 91bb08d | 2022-09-07 18:41:59 +0800 | [diff] [blame] | 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 | |
developer | 7d46db6 | 2020-12-14 16:53:22 +0800 | [diff] [blame] | 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); |
developer | 91bb08d | 2022-09-07 18:41:59 +0800 | [diff] [blame] | 47 | int (*get_status)(unsigned int type, void *priv); |
developer | 7d46db6 | 2020-12-14 16:53:22 +0800 | [diff] [blame] | 48 | unsigned int (*allow)(int stateid); |
| 49 | }; |
| 50 | |
| 51 | struct mt_resource_manager { |
developer | fbc1ea9 | 2023-01-06 15:50:33 +0800 | [diff] [blame] | 52 | int (*update)(struct mt_resource_constraint **con, unsigned int num, |
developer | 7d46db6 | 2020-12-14 16:53:22 +0800 | [diff] [blame] | 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); |
developer | d0c3bab | 2023-01-06 19:57:15 +0800 | [diff] [blame] | 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, |
developer | 7d46db6 | 2020-12-14 16:53:22 +0800 | [diff] [blame] | 62 | int stateid, void *priv); |
developer | d0c3bab | 2023-01-06 19:57:15 +0800 | [diff] [blame] | 63 | extern int mt_lp_rm_reset_constraint(unsigned int idx, unsigned int cpuid, int stateid); |
developer | 7d46db6 | 2020-12-14 16:53:22 +0800 | [diff] [blame] | 64 | extern int mt_lp_rm_do_update(int stateid, int type, void const *p); |
developer | 91bb08d | 2022-09-07 18:41:59 +0800 | [diff] [blame] | 65 | extern int mt_lp_rm_get_status(unsigned int type, void *priv); |
| 66 | |
developer | 7d46db6 | 2020-12-14 16:53:22 +0800 | [diff] [blame] | 67 | #endif /* MT_LP_RM_H */ |