1 /*
2  * Copyright (c) 2020, 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 
15 enum PLAT_MT_LPM_RC_TYPE {
16 	PLAT_RC_UPDATE_CONDITION,
17 	PLAT_RC_UPDATE_REMAIN_IRQS
18 };
19 
20 struct mt_resource_constraint {
21 	int level;
22 	int (*init)(void);
23 	bool (*is_valid)(unsigned int cpu, int stateid);
24 	int (*update)(int stateid, int type, const void *p);
25 	int (*run)(unsigned int cpu, int stateid);
26 	int (*reset)(unsigned int cpu, int stateid);
27 	unsigned int (*allow)(int stateid);
28 };
29 
30 struct mt_resource_manager {
31 	int (*update)(struct mt_resource_constraint **con,
32 		      int stateid, void *priv);
33 	struct mt_resource_constraint **consts;
34 };
35 
36 extern int mt_lp_rm_register(struct mt_resource_manager *rm);
37 extern int mt_lp_rm_find_and_run_constraint(int idx, unsigned int cpuid,
38 					    int stateid, void *priv);
39 extern int mt_lp_rm_reset_constraint(int constraint_id, unsigned int cpuid,
40 				     int stateid);
41 extern int mt_lp_rm_do_update(int stateid, int type, void const *p);
42 #endif /* MT_LP_RM_H */
43