blob: bf99489bd357ff67d4822b4eb123c3292d9d27a0 [file] [log] [blame]
developer7d46db62020-12-14 16:53:22 +08001/*
developer91bb08d2022-09-07 18:41:59 +08002 * Copyright (c) 2020-2023, MediaTek Inc. All rights reserved.
developer7d46db62020-12-14 16:53:22 +08003 *
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
developer91bb08d2022-09-07 18:41:59 +080012#define MT_RM_STATUS_OK (0)
13#define MT_RM_STATUS_BAD (-1)
14#define MT_RM_STATUS_STOP (-2)
developer7d46db62020-12-14 16:53:22 +080015
16enum PLAT_MT_LPM_RC_TYPE {
17 PLAT_RC_UPDATE_CONDITION,
developer91bb08d2022-09-07 18:41:59 +080018 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,
developer7d46db62020-12-14 16:53:22 +080028};
29
developer91bb08d2022-09-07 18:41:59 +080030enum 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
developer7d46db62020-12-14 16:53:22 +080040struct 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);
developer91bb08d2022-09-07 18:41:59 +080047 int (*get_status)(unsigned int type, void *priv);
developer7d46db62020-12-14 16:53:22 +080048 unsigned int (*allow)(int stateid);
49};
50
51struct mt_resource_manager {
developerfbc1ea92023-01-06 15:50:33 +080052 int (*update)(struct mt_resource_constraint **con, unsigned int num,
developer7d46db62020-12-14 16:53:22 +080053 int stateid, void *priv);
54 struct mt_resource_constraint **consts;
55};
56
57extern int mt_lp_rm_register(struct mt_resource_manager *rm);
developerd0c3bab2023-01-06 19:57:15 +080058extern int mt_lp_rm_do_constraint(unsigned int constraint_id, unsigned int cpuid, int stateid);
59extern int mt_lp_rm_find_constraint(unsigned int idx, unsigned int cpuid,
60 int stateid, void *priv);
61extern int mt_lp_rm_find_and_run_constraint(unsigned int idx, unsigned int cpuid,
developer7d46db62020-12-14 16:53:22 +080062 int stateid, void *priv);
developerd0c3bab2023-01-06 19:57:15 +080063extern int mt_lp_rm_reset_constraint(unsigned int idx, unsigned int cpuid, int stateid);
developer7d46db62020-12-14 16:53:22 +080064extern int mt_lp_rm_do_update(int stateid, int type, void const *p);
developer91bb08d2022-09-07 18:41:59 +080065extern int mt_lp_rm_get_status(unsigned int type, void *priv);
66
developer7d46db62020-12-14 16:53:22 +080067#endif /* MT_LP_RM_H */