1 /*
2  * Copyright (c) 2020, MediaTek Inc. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef MT_SPM_CONDIT_H
8 #define MT_SPM_CONDIT_H
9 
10 #include <mt_lp_rm.h>
11 
12 enum PLAT_SPM_COND {
13 	PLAT_SPM_COND_MTCMOS1 = 0,
14 	PLAT_SPM_COND_CG_INFRA_0,
15 	PLAT_SPM_COND_CG_INFRA_1,
16 	PLAT_SPM_COND_CG_INFRA_2,
17 	PLAT_SPM_COND_CG_INFRA_3,
18 	PLAT_SPM_COND_CG_INFRA_4,
19 	PLAT_SPM_COND_CG_INFRA_5,
20 	PLAT_SPM_COND_CG_MMSYS_0,
21 	PLAT_SPM_COND_CG_MMSYS_1,
22 	PLAT_SPM_COND_CG_MMSYS_2,
23 	PLAT_SPM_COND_MAX,
24 };
25 
26 #define PLL_BIT_UNIVPLL	BIT(0)
27 #define PLL_BIT_MFGPLL	BIT(1)
28 #define PLL_BIT_MSDCPLL	BIT(2)
29 #define PLL_BIT_TVDPLL	BIT(3)
30 #define PLL_BIT_MMPLL	BIT(4)
31 
32 /* Definition about SPM_COND_CHECK_BLOCKED
33  * bit [00 ~ 15]: cg blocking index
34  * bit [16 ~ 29]: pll blocking index
35  * bit [30]     : pll blocking information
36  * bit [31]	: idle condition check fail
37  */
38 #define SPM_COND_BLOCKED_CG_IDX		U(0)
39 #define SPM_COND_BLOCKED_PLL_IDX	U(16)
40 #define SPM_COND_CHECK_BLOCKED_PLL	BIT(30)
41 #define SPM_COND_CHECK_FAIL		BIT(31)
42 
43 struct mt_spm_cond_tables {
44 	char *name;
45 	unsigned int table_cg[PLAT_SPM_COND_MAX];
46 	unsigned int table_pll;
47 	void *priv;
48 };
49 
50 extern unsigned int mt_spm_cond_check(int state_id,
51 				      const struct mt_spm_cond_tables *src,
52 				      const struct mt_spm_cond_tables *dest,
53 				      struct mt_spm_cond_tables *res);
54 extern int mt_spm_cond_update(struct mt_resource_constraint **con,
55 			      int stateid, void *priv);
56 #endif /* MT_SPM_CONDIT_H */
57