blob: e93dac3d7fa96720344912abb381a1c8b1d24803 [file] [log] [blame]
developer7d46db62020-12-14 16:53:22 +08001/*
developerfe14b9f2022-09-05 11:18:04 +08002 * Copyright (c) 2020-2022, 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
12#define MT_RM_STATUS_OK 0
13#define MT_RM_STATUS_BAD -1
14
15enum PLAT_MT_LPM_RC_TYPE {
16 PLAT_RC_UPDATE_CONDITION,
17 PLAT_RC_UPDATE_REMAIN_IRQS
18};
19
20struct 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
30struct mt_resource_manager {
31 int (*update)(struct mt_resource_constraint **con,
32 int stateid, void *priv);
33 struct mt_resource_constraint **consts;
34};
35
36extern int mt_lp_rm_register(struct mt_resource_manager *rm);
37extern int mt_lp_rm_find_and_run_constraint(int idx, unsigned int cpuid,
38 int stateid, void *priv);
39extern int mt_lp_rm_reset_constraint(int constraint_id, unsigned int cpuid,
40 int stateid);
41extern int mt_lp_rm_do_update(int stateid, int type, void const *p);
42#endif /* MT_LP_RM_H */