xref: /linux/include/linux/soc/mediatek/mtk-mutex.h (revision be239684b18e1cdcafcf8c7face4a2f562c745ad)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (c) 2015 MediaTek Inc.
4  */
5 
6 #ifndef MTK_MUTEX_H
7 #define MTK_MUTEX_H
8 
9 struct regmap;
10 struct device;
11 struct mtk_mutex;
12 
13 enum mtk_mutex_mod_index {
14 	/* MDP table index */
15 	MUTEX_MOD_IDX_MDP_RDMA0,
16 	MUTEX_MOD_IDX_MDP_RSZ0,
17 	MUTEX_MOD_IDX_MDP_RSZ1,
18 	MUTEX_MOD_IDX_MDP_TDSHP0,
19 	MUTEX_MOD_IDX_MDP_WROT0,
20 	MUTEX_MOD_IDX_MDP_WDMA,
21 	MUTEX_MOD_IDX_MDP_AAL0,
22 	MUTEX_MOD_IDX_MDP_CCORR0,
23 	MUTEX_MOD_IDX_MDP_HDR0,
24 	MUTEX_MOD_IDX_MDP_COLOR0,
25 	MUTEX_MOD_IDX_MDP_RDMA1,
26 	MUTEX_MOD_IDX_MDP_RDMA2,
27 	MUTEX_MOD_IDX_MDP_RDMA3,
28 	MUTEX_MOD_IDX_MDP_STITCH0,
29 	MUTEX_MOD_IDX_MDP_FG0,
30 	MUTEX_MOD_IDX_MDP_FG1,
31 	MUTEX_MOD_IDX_MDP_FG2,
32 	MUTEX_MOD_IDX_MDP_FG3,
33 	MUTEX_MOD_IDX_MDP_HDR1,
34 	MUTEX_MOD_IDX_MDP_HDR2,
35 	MUTEX_MOD_IDX_MDP_HDR3,
36 	MUTEX_MOD_IDX_MDP_AAL1,
37 	MUTEX_MOD_IDX_MDP_AAL2,
38 	MUTEX_MOD_IDX_MDP_AAL3,
39 	MUTEX_MOD_IDX_MDP_RSZ2,
40 	MUTEX_MOD_IDX_MDP_RSZ3,
41 	MUTEX_MOD_IDX_MDP_MERGE2,
42 	MUTEX_MOD_IDX_MDP_MERGE3,
43 	MUTEX_MOD_IDX_MDP_TDSHP1,
44 	MUTEX_MOD_IDX_MDP_TDSHP2,
45 	MUTEX_MOD_IDX_MDP_TDSHP3,
46 	MUTEX_MOD_IDX_MDP_COLOR1,
47 	MUTEX_MOD_IDX_MDP_COLOR2,
48 	MUTEX_MOD_IDX_MDP_COLOR3,
49 	MUTEX_MOD_IDX_MDP_OVL0,
50 	MUTEX_MOD_IDX_MDP_OVL1,
51 	MUTEX_MOD_IDX_MDP_PAD0,
52 	MUTEX_MOD_IDX_MDP_PAD1,
53 	MUTEX_MOD_IDX_MDP_PAD2,
54 	MUTEX_MOD_IDX_MDP_PAD3,
55 	MUTEX_MOD_IDX_MDP_TCC0,
56 	MUTEX_MOD_IDX_MDP_TCC1,
57 	MUTEX_MOD_IDX_MDP_WROT1,
58 	MUTEX_MOD_IDX_MDP_WROT2,
59 	MUTEX_MOD_IDX_MDP_WROT3,
60 
61 	MUTEX_MOD_IDX_MAX		/* ALWAYS keep at the end */
62 };
63 
64 enum mtk_mutex_sof_index {
65 	MUTEX_SOF_IDX_SINGLE_MODE,
66 
67 	MUTEX_SOF_IDX_MAX		/* ALWAYS keep at the end */
68 };
69 
70 struct mtk_mutex *mtk_mutex_get(struct device *dev);
71 int mtk_mutex_prepare(struct mtk_mutex *mutex);
72 void mtk_mutex_add_comp(struct mtk_mutex *mutex,
73 			enum mtk_ddp_comp_id id);
74 void mtk_mutex_enable(struct mtk_mutex *mutex);
75 int mtk_mutex_enable_by_cmdq(struct mtk_mutex *mutex,
76 			     void *pkt);
77 void mtk_mutex_disable(struct mtk_mutex *mutex);
78 void mtk_mutex_remove_comp(struct mtk_mutex *mutex,
79 			   enum mtk_ddp_comp_id id);
80 void mtk_mutex_unprepare(struct mtk_mutex *mutex);
81 void mtk_mutex_put(struct mtk_mutex *mutex);
82 void mtk_mutex_acquire(struct mtk_mutex *mutex);
83 void mtk_mutex_release(struct mtk_mutex *mutex);
84 int mtk_mutex_write_mod(struct mtk_mutex *mutex,
85 			enum mtk_mutex_mod_index idx,
86 			bool clear);
87 int mtk_mutex_write_sof(struct mtk_mutex *mutex,
88 			enum mtk_mutex_sof_index idx);
89 
90 #endif /* MTK_MUTEX_H */
91