xref: /OK3568_Linux_fs/kernel/drivers/video/rockchip/dvbm/rockchip_dvbm.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (c) 2022 Rockchip Electronics Co., Ltd
4  */
5 #ifndef __ROCKCHIP_DVBM_H__
6 #define __ROCKCHIP_DVBM_H__
7 
8 #include <linux/clk.h>
9 #include <linux/reset.h>
10 
11 struct rk_dvbm_base {
12 	/* 0x2c */
13 	u32 ybuf_bot;
14 	/* 0x30 */
15 	u32 ybuf_top;
16 	/* 0x34 */
17 	u32 ybuf_sadr;
18 	/* 0x38 */
19 	u32 ybuf_lstd;
20 	/* 0x3c */
21 	u32 ybuf_fstd;
22 	/* 0x40 */
23 	u32 cbuf_bot;
24 	/* 0x44 */
25 	u32 cbuf_top;
26 	/* 0x48 */
27 	u32 cbuf_sadr;
28 	/* 0x4c */
29 	u32 cbuf_lstd;
30 	/* 0x50 */
31 	u32 cbuf_fstd;
32 	/* 0x54 */
33 	u32 aful_thdy;
34 	/* 0x58 */
35 	u32 aful_thdc;
36 	/* 0x5c */
37 	u32 oful_thdy;
38 	/* 0x60 */
39 	u32 oful_thdc;
40 };
41 
42 struct rk_dvbm_regs {
43 	/* 0x0 */
44 	u32 version;
45 
46 	/* 0x4 */
47 	struct {
48 		u32 isp_cnct : 1;
49 		u32 reserved : 31;
50 	} isp_cnct;
51 
52 	/* 0x8 */
53 	struct {
54 		u32 vepu_cnct : 1;
55 		u32 reserved : 31;
56 	} vepu_cnct;
57 
58 	/* 0xc */
59 	struct {
60 		u32 auto_resyn                  : 1;
61 		u32 ignore_vepu_cnct_ack        : 1;
62 		/*
63 		 * 1’b0                            : the current ISP frame
64 		 * 1’b1                            : the next ISP frame
65 		 */
66 		u32 start_point_after_vepu_cnct : 1;
67 		u32 reserved0                   : 5;
68 		/* only support yuv420sp 4'h0 */
69 		u32 fmt                         : 4;
70 		u32 reserved1                   : 20;
71 	} dvbm_cfg;
72 
73 	/* 0x10 */
74 	struct {
75 		u32 wdg_isp_cnct_timeout        : 22;
76 		u32 reserved                    : 10;
77 	} wdg_cfg0;
78 
79 	/* 0x14 */
80 	struct {
81 		u32 wdg_vepu_cnct_timeout       : 22;
82 		u32 reserved                    : 10;
83 	} wdg_cfg1;
84 
85 	/* 0x18 */
86 	struct {
87 		u32 wdg_vepu_handshake_timeout  : 22;
88 		u32 reserved                    : 10;
89 	} wdg_cfg2;
90 
91 	/* 0x1c */
92 	struct {
93 		u32 buf_ovfl               : 1;
94 		u32 resync_finish          : 1;
95 		u32 isp_cnct_timeout       : 1;
96 		u32 vepu_cnct_timeout      : 1;
97 
98 		u32 vepu_handshake_timeout : 1;
99 		u32 isp_cnct               : 1;
100 		u32 isp_discnct            : 1;
101 		u32 vepu_cnct              : 1;
102 
103 		u32 vepu_discnct           : 1;
104 		u32 reserved               : 23;
105 	} int_en;
106 
107 	/* 0x20 */
108 	struct {
109 		u32 buf_ovfl               : 1;
110 		u32 resync_finish          : 1;
111 		u32 isp_cnct_timeout       : 1;
112 		u32 vepu_cnct_timeout      : 1;
113 
114 		u32 vepu_handshake_timeout : 1;
115 		u32 isp_cnct               : 1;
116 		u32 isp_discnct            : 1;
117 		u32 vepu_cnct              : 1;
118 
119 		u32 vepu_discnct           : 1;
120 		u32 reserved               : 23;
121 	} int_msk;
122 
123 	/* 0x24 */
124 	struct {
125 		u32 buf_ovfl               : 1;
126 		u32 resync_finish          : 1;
127 		u32 isp_cnct_timeout       : 1;
128 		u32 vepu_cnct_timeout      : 1;
129 
130 		u32 vepu_handshake_timeout : 1;
131 		u32 isp_cnct               : 1;
132 		u32 isp_discnct            : 1;
133 		u32 vepu_cnct              : 1;
134 
135 		u32 vepu_discnct           : 1;
136 		u32 reserved               : 23;
137 	} int_clr;
138 
139 	/* 0x28 */
140 	struct {
141 		u32 buf_ovfl               : 1;
142 		u32 resync_finish          : 1;
143 		u32 isp_cnct_timeout       : 1;
144 		u32 vepu_cnct_timeout      : 1;
145 
146 		u32 vepu_handshake_timeout : 1;
147 		u32 isp_cnct               : 1;
148 		u32 isp_discnct            : 1;
149 		u32 vepu_cnct              : 1;
150 
151 		u32 vepu_discnct           : 1;
152 		u32 reserved               : 23;
153 	} int_st;
154 	struct rk_dvbm_base addr_base;
155 	/* 0x64 - 0x7c */
156 	u32 reserved[7];
157 
158 	/* 0x80 */
159 	struct {
160 		u32 isp_connection       : 1;
161 		u32 vepu_connection      : 1;
162 		u32 resynchronization    : 1;
163 		u32 y_buf_ovfl           : 1;
164 
165 		u32 c_buf_ovfl           : 1;
166 		u32 reserved             : 27;
167 	} dvbm_st;
168 
169 	/* 0x84 */
170 	u32 ovfl_st;
171 };
172 
173 struct dvbm_ctx {
174 	struct clk *clk;
175 	struct device *dev;
176 	void __iomem *reg_base;
177 	struct rk_dvbm_regs regs;
178 	struct reset_control *rst;
179 
180 	u32 isp_connet;
181 	u32 vepu_connet;
182 	u32 buf_overflow;
183 	u32 irq_status;
184 	u32 dvbm_status;
185 	int irq;
186 
187 	/* vepu infos */
188 	struct dvbm_port port_vepu;
189 	atomic_t vepu_ref;
190 	atomic_t vepu_link;
191 	struct dvbm_cb	vepu_cb;
192 	struct dvbm_addr_cfg vepu_cfg;
193 
194 	/* isp infos */
195 	struct dvbm_port port_isp;
196 	struct dvbm_cb	isp_cb;
197 	struct dvbm_isp_cfg_t isp_cfg;
198 	struct dvbm_isp_frm_info isp_frm_info;
199 	atomic_t isp_link;
200 	atomic_t isp_ref;
201 	u32 isp_max_lcnt;
202 	u32 isp_frm_start;
203 	u32 isp_frm_end;
204 	ktime_t isp_frm_time;
205 	u32 wrap_line;
206 
207 	/* debug infos */
208 	u32 dump_s;
209 	u32 dump_e;
210 	u32 ignore_ovfl;
211 	u32 loopcnt;
212 };
213 
214 #endif
215