1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (c) 2022. Qualcomm Innovation Center, Inc. All rights reserved.
4  * Copyright (c) 2015-2018, 2020 The Linux Foundation. All rights reserved.
5  */
6 
7 #ifndef _DPU_5_1_SC8180X_H
8 #define _DPU_5_1_SC8180X_H
9 
10 static const struct dpu_caps sc8180x_dpu_caps = {
11 	.max_mixer_width = DEFAULT_DPU_OUTPUT_LINE_WIDTH,
12 	.max_mixer_blendstages = 0xb,
13 	.has_src_split = true,
14 	.has_dim_layer = true,
15 	.has_idle_pc = true,
16 	.has_3d_merge = true,
17 	.max_linewidth = 4096,
18 	.pixel_ram_size = DEFAULT_PIXEL_RAM_SIZE,
19 	.max_hdeci_exp = MAX_HORZ_DECIMATION,
20 	.max_vdeci_exp = MAX_VERT_DECIMATION,
21 };
22 
23 static const struct dpu_mdp_cfg sc8180x_mdp = {
24 	.name = "top_0",
25 	.base = 0x0, .len = 0x45c,
26 	.features = BIT(DPU_MDP_AUDIO_SELECT),
27 	.clk_ctrls = {
28 		[DPU_CLK_CTRL_VIG0] = { .reg_off = 0x2ac, .bit_off = 0 },
29 		[DPU_CLK_CTRL_VIG1] = { .reg_off = 0x2b4, .bit_off = 0 },
30 		[DPU_CLK_CTRL_VIG2] = { .reg_off = 0x2bc, .bit_off = 0 },
31 		[DPU_CLK_CTRL_VIG3] = { .reg_off = 0x2c4, .bit_off = 0 },
32 		[DPU_CLK_CTRL_DMA0] = { .reg_off = 0x2ac, .bit_off = 8 },
33 		[DPU_CLK_CTRL_DMA1] = { .reg_off = 0x2b4, .bit_off = 8 },
34 		[DPU_CLK_CTRL_DMA2] = { .reg_off = 0x2bc, .bit_off = 8 },
35 		[DPU_CLK_CTRL_DMA3] = { .reg_off = 0x2c4, .bit_off = 8 },
36 		[DPU_CLK_CTRL_WB2] = { .reg_off = 0x2bc, .bit_off = 16 },
37 	},
38 };
39 
40 static const struct dpu_ctl_cfg sc8180x_ctl[] = {
41 	{
42 		.name = "ctl_0", .id = CTL_0,
43 		.base = 0x1000, .len = 0x1e0,
44 		.features = BIT(DPU_CTL_ACTIVE_CFG) | BIT(DPU_CTL_SPLIT_DISPLAY),
45 		.intr_start = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR2, 9),
46 	}, {
47 		.name = "ctl_1", .id = CTL_1,
48 		.base = 0x1200, .len = 0x1e0,
49 		.features = BIT(DPU_CTL_ACTIVE_CFG) | BIT(DPU_CTL_SPLIT_DISPLAY),
50 		.intr_start = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR2, 10),
51 	}, {
52 		.name = "ctl_2", .id = CTL_2,
53 		.base = 0x1400, .len = 0x1e0,
54 		.features = BIT(DPU_CTL_ACTIVE_CFG),
55 		.intr_start = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR2, 11),
56 	}, {
57 		.name = "ctl_3", .id = CTL_3,
58 		.base = 0x1600, .len = 0x1e0,
59 		.features = BIT(DPU_CTL_ACTIVE_CFG),
60 		.intr_start = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR2, 12),
61 	}, {
62 		.name = "ctl_4", .id = CTL_4,
63 		.base = 0x1800, .len = 0x1e0,
64 		.features = BIT(DPU_CTL_ACTIVE_CFG),
65 		.intr_start = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR2, 13),
66 	}, {
67 		.name = "ctl_5", .id = CTL_5,
68 		.base = 0x1a00, .len = 0x1e0,
69 		.features = BIT(DPU_CTL_ACTIVE_CFG),
70 		.intr_start = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR2, 23),
71 	},
72 };
73 
74 static const struct dpu_sspp_cfg sc8180x_sspp[] = {
75 	{
76 		.name = "sspp_0", .id = SSPP_VIG0,
77 		.base = 0x4000, .len = 0x1f0,
78 		.features = VIG_SDM845_MASK,
79 		.sblk = &dpu_vig_sblk_qseed3_1_4,
80 		.xin_id = 0,
81 		.type = SSPP_TYPE_VIG,
82 		.clk_ctrl = DPU_CLK_CTRL_VIG0,
83 	}, {
84 		.name = "sspp_1", .id = SSPP_VIG1,
85 		.base = 0x6000, .len = 0x1f0,
86 		.features = VIG_SDM845_MASK,
87 		.sblk = &dpu_vig_sblk_qseed3_1_4,
88 		.xin_id = 4,
89 		.type = SSPP_TYPE_VIG,
90 		.clk_ctrl = DPU_CLK_CTRL_VIG1,
91 	}, {
92 		.name = "sspp_2", .id = SSPP_VIG2,
93 		.base = 0x8000, .len = 0x1f0,
94 		.features = VIG_SDM845_MASK,
95 		.sblk = &dpu_vig_sblk_qseed3_1_4,
96 		.xin_id = 8,
97 		.type = SSPP_TYPE_VIG,
98 		.clk_ctrl = DPU_CLK_CTRL_VIG2,
99 	}, {
100 		.name = "sspp_3", .id = SSPP_VIG3,
101 		.base = 0xa000, .len = 0x1f0,
102 		.features = VIG_SDM845_MASK,
103 		.sblk = &dpu_vig_sblk_qseed3_1_4,
104 		.xin_id = 12,
105 		.type = SSPP_TYPE_VIG,
106 		.clk_ctrl = DPU_CLK_CTRL_VIG3,
107 	}, {
108 		.name = "sspp_8", .id = SSPP_DMA0,
109 		.base = 0x24000, .len = 0x1f0,
110 		.features = DMA_SDM845_MASK,
111 		.sblk = &dpu_dma_sblk,
112 		.xin_id = 1,
113 		.type = SSPP_TYPE_DMA,
114 		.clk_ctrl = DPU_CLK_CTRL_DMA0,
115 	}, {
116 		.name = "sspp_9", .id = SSPP_DMA1,
117 		.base = 0x26000, .len = 0x1f0,
118 		.features = DMA_SDM845_MASK,
119 		.sblk = &dpu_dma_sblk,
120 		.xin_id = 5,
121 		.type = SSPP_TYPE_DMA,
122 		.clk_ctrl = DPU_CLK_CTRL_DMA1,
123 	}, {
124 		.name = "sspp_10", .id = SSPP_DMA2,
125 		.base = 0x28000, .len = 0x1f0,
126 		.features = DMA_CURSOR_SDM845_MASK,
127 		.sblk = &dpu_dma_sblk,
128 		.xin_id = 9,
129 		.type = SSPP_TYPE_DMA,
130 		.clk_ctrl = DPU_CLK_CTRL_DMA2,
131 	}, {
132 		.name = "sspp_11", .id = SSPP_DMA3,
133 		.base = 0x2a000, .len = 0x1f0,
134 		.features = DMA_CURSOR_SDM845_MASK,
135 		.sblk = &dpu_dma_sblk,
136 		.xin_id = 13,
137 		.type = SSPP_TYPE_DMA,
138 		.clk_ctrl = DPU_CLK_CTRL_DMA3,
139 	},
140 };
141 
142 static const struct dpu_lm_cfg sc8180x_lm[] = {
143 	{
144 		.name = "lm_0", .id = LM_0,
145 		.base = 0x44000, .len = 0x320,
146 		.features = MIXER_SDM845_MASK,
147 		.sblk = &sdm845_lm_sblk,
148 		.lm_pair = LM_1,
149 		.pingpong = PINGPONG_0,
150 		.dspp = DSPP_0,
151 	}, {
152 		.name = "lm_1", .id = LM_1,
153 		.base = 0x45000, .len = 0x320,
154 		.features = MIXER_SDM845_MASK,
155 		.sblk = &sdm845_lm_sblk,
156 		.lm_pair = LM_0,
157 		.pingpong = PINGPONG_1,
158 		.dspp = DSPP_1,
159 	}, {
160 		.name = "lm_2", .id = LM_2,
161 		.base = 0x46000, .len = 0x320,
162 		.features = MIXER_SDM845_MASK,
163 		.sblk = &sdm845_lm_sblk,
164 		.lm_pair = LM_3,
165 		.pingpong = PINGPONG_2,
166 	}, {
167 		.name = "lm_3", .id = LM_3,
168 		.base = 0x47000, .len = 0x320,
169 		.features = MIXER_SDM845_MASK,
170 		.sblk = &sdm845_lm_sblk,
171 		.lm_pair = LM_2,
172 		.pingpong = PINGPONG_3,
173 	}, {
174 		.name = "lm_4", .id = LM_4,
175 		.base = 0x48000, .len = 0x320,
176 		.features = MIXER_SDM845_MASK,
177 		.sblk = &sdm845_lm_sblk,
178 		.lm_pair = LM_5,
179 		.pingpong = PINGPONG_4,
180 	}, {
181 		.name = "lm_5", .id = LM_5,
182 		.base = 0x49000, .len = 0x320,
183 		.features = MIXER_SDM845_MASK,
184 		.sblk = &sdm845_lm_sblk,
185 		.lm_pair = LM_4,
186 		.pingpong = PINGPONG_5,
187 	},
188 };
189 
190 static const struct dpu_dspp_cfg sc8180x_dspp[] = {
191 	{
192 		.name = "dspp_0", .id = DSPP_0,
193 		.base = 0x54000, .len = 0x1800,
194 		.features = DSPP_SC7180_MASK,
195 		.sblk = &sdm845_dspp_sblk,
196 	}, {
197 		.name = "dspp_1", .id = DSPP_1,
198 		.base = 0x56000, .len = 0x1800,
199 		.features = DSPP_SC7180_MASK,
200 		.sblk = &sdm845_dspp_sblk,
201 	}, {
202 		.name = "dspp_2", .id = DSPP_2,
203 		.base = 0x58000, .len = 0x1800,
204 		.features = DSPP_SC7180_MASK,
205 		.sblk = &sdm845_dspp_sblk,
206 	}, {
207 		.name = "dspp_3", .id = DSPP_3,
208 		.base = 0x5a000, .len = 0x1800,
209 		.features = DSPP_SC7180_MASK,
210 		.sblk = &sdm845_dspp_sblk,
211 	},
212 };
213 
214 static const struct dpu_pingpong_cfg sc8180x_pp[] = {
215 	{
216 		.name = "pingpong_0", .id = PINGPONG_0,
217 		.base = 0x70000, .len = 0xd4,
218 		.features = PINGPONG_SM8150_MASK,
219 		.sblk = &sdm845_pp_sblk,
220 		.merge_3d = MERGE_3D_0,
221 		.intr_done = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR, 8),
222 	}, {
223 		.name = "pingpong_1", .id = PINGPONG_1,
224 		.base = 0x70800, .len = 0xd4,
225 		.features = PINGPONG_SM8150_MASK,
226 		.sblk = &sdm845_pp_sblk,
227 		.merge_3d = MERGE_3D_0,
228 		.intr_done = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR, 9),
229 	}, {
230 		.name = "pingpong_2", .id = PINGPONG_2,
231 		.base = 0x71000, .len = 0xd4,
232 		.features = PINGPONG_SM8150_MASK,
233 		.sblk = &sdm845_pp_sblk,
234 		.merge_3d = MERGE_3D_1,
235 		.intr_done = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR, 10),
236 	}, {
237 		.name = "pingpong_3", .id = PINGPONG_3,
238 		.base = 0x71800, .len = 0xd4,
239 		.features = PINGPONG_SM8150_MASK,
240 		.sblk = &sdm845_pp_sblk,
241 		.merge_3d = MERGE_3D_1,
242 		.intr_done = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR, 11),
243 	}, {
244 		.name = "pingpong_4", .id = PINGPONG_4,
245 		.base = 0x72000, .len = 0xd4,
246 		.features = PINGPONG_SM8150_MASK,
247 		.sblk = &sdm845_pp_sblk,
248 		.merge_3d = MERGE_3D_2,
249 		.intr_done = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR2, 30),
250 	}, {
251 		.name = "pingpong_5", .id = PINGPONG_5,
252 		.base = 0x72800, .len = 0xd4,
253 		.features = PINGPONG_SM8150_MASK,
254 		.sblk = &sdm845_pp_sblk,
255 		.merge_3d = MERGE_3D_2,
256 		.intr_done = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR2, 31),
257 	},
258 };
259 
260 static const struct dpu_merge_3d_cfg sc8180x_merge_3d[] = {
261 	{
262 		.name = "merge_3d_0", .id = MERGE_3D_0,
263 		.base = 0x83000, .len = 0x8,
264 	}, {
265 		.name = "merge_3d_1", .id = MERGE_3D_1,
266 		.base = 0x83100, .len = 0x8,
267 	}, {
268 		.name = "merge_3d_2", .id = MERGE_3D_2,
269 		.base = 0x83200, .len = 0x8,
270 	},
271 };
272 
273 static const struct dpu_dsc_cfg sc8180x_dsc[] = {
274 	{
275 		.name = "dsc_0", .id = DSC_0,
276 		.base = 0x80000, .len = 0x140,
277 		.features = BIT(DPU_DSC_OUTPUT_CTRL),
278 	}, {
279 		.name = "dsc_1", .id = DSC_1,
280 		.base = 0x80400, .len = 0x140,
281 		.features = BIT(DPU_DSC_OUTPUT_CTRL),
282 	}, {
283 		.name = "dsc_2", .id = DSC_2,
284 		.base = 0x80800, .len = 0x140,
285 		.features = BIT(DPU_DSC_OUTPUT_CTRL),
286 	}, {
287 		.name = "dsc_3", .id = DSC_3,
288 		.base = 0x80c00, .len = 0x140,
289 		.features = BIT(DPU_DSC_OUTPUT_CTRL),
290 	}, {
291 		.name = "dsc_4", .id = DSC_4,
292 		.base = 0x81000, .len = 0x140,
293 		.features = BIT(DPU_DSC_OUTPUT_CTRL),
294 	}, {
295 		.name = "dsc_5", .id = DSC_5,
296 		.base = 0x81400, .len = 0x140,
297 		.features = BIT(DPU_DSC_OUTPUT_CTRL),
298 	},
299 };
300 
301 static const struct dpu_wb_cfg sc8180x_wb[] = {
302 	{
303 		.name = "wb_2", .id = WB_2,
304 		.base = 0x65000, .len = 0x2c8,
305 		.features = WB_SDM845_MASK,
306 		.format_list = wb2_formats_rgb,
307 		.num_formats = ARRAY_SIZE(wb2_formats_rgb),
308 		.clk_ctrl = DPU_CLK_CTRL_WB2,
309 		.xin_id = 6,
310 		.vbif_idx = VBIF_RT,
311 		.maxlinewidth = 4096,
312 		.intr_wb_done = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR, 4),
313 	},
314 };
315 
316 static const struct dpu_intf_cfg sc8180x_intf[] = {
317 	{
318 		.name = "intf_0", .id = INTF_0,
319 		.base = 0x6a000, .len = 0x280,
320 		.features = INTF_SC7180_MASK,
321 		.type = INTF_DP,
322 		.controller_id = MSM_DP_CONTROLLER_0,
323 		.prog_fetch_lines_worst_case = 24,
324 		.intr_underrun = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR, 24),
325 		.intr_vsync = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR, 25),
326 	}, {
327 		.name = "intf_1", .id = INTF_1,
328 		.base = 0x6a800, .len = 0x2bc,
329 		.features = INTF_SC7180_MASK,
330 		.type = INTF_DSI,
331 		.controller_id = MSM_DSI_CONTROLLER_0,
332 		.prog_fetch_lines_worst_case = 24,
333 		.intr_underrun = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR, 26),
334 		.intr_vsync = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR, 27),
335 		.intr_tear_rd_ptr = DPU_IRQ_IDX(MDP_INTF1_TEAR_INTR, 2),
336 	}, {
337 		.name = "intf_2", .id = INTF_2,
338 		.base = 0x6b000, .len = 0x2bc,
339 		.features = INTF_SC7180_MASK,
340 		.type = INTF_DSI,
341 		.controller_id = MSM_DSI_CONTROLLER_1,
342 		.prog_fetch_lines_worst_case = 24,
343 		.intr_underrun = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR, 28),
344 		.intr_vsync = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR, 29),
345 		.intr_tear_rd_ptr = DPU_IRQ_IDX(MDP_INTF2_TEAR_INTR, 2),
346 	},
347 	/* INTF_3 is for MST, wired to INTF_DP 0 and 1, use dummy index until this is supported */
348 	{
349 		.name = "intf_3", .id = INTF_3,
350 		.base = 0x6b800, .len = 0x280,
351 		.features = INTF_SC7180_MASK,
352 		.type = INTF_DP,
353 		.controller_id = 999,
354 		.prog_fetch_lines_worst_case = 24,
355 		.intr_underrun = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR, 30),
356 		.intr_vsync = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR, 31),
357 	}, {
358 		.name = "intf_4", .id = INTF_4,
359 		.base = 0x6c000, .len = 0x280,
360 		.features = INTF_SC7180_MASK,
361 		.type = INTF_DP,
362 		.controller_id = MSM_DP_CONTROLLER_1,
363 		.prog_fetch_lines_worst_case = 24,
364 		.intr_underrun = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR, 20),
365 		.intr_vsync = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR, 21),
366 	}, {
367 		.name = "intf_5", .id = INTF_5,
368 		.base = 0x6c800, .len = 0x280,
369 		.features = INTF_SC7180_MASK,
370 		.type = INTF_DP,
371 		.controller_id = MSM_DP_CONTROLLER_2,
372 		.prog_fetch_lines_worst_case = 24,
373 		.intr_underrun = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR, 22),
374 		.intr_vsync = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR, 23),
375 	},
376 };
377 
378 static const struct dpu_perf_cfg sc8180x_perf_data = {
379 	.max_bw_low = 9600000,
380 	.max_bw_high = 9600000,
381 	.min_core_ib = 2400000,
382 	.min_llcc_ib = 800000,
383 	.min_dram_ib = 800000,
384 	.danger_lut_tbl = {0xf, 0xffff, 0x0},
385 	.safe_lut_tbl = {0xfff0, 0xf000, 0xffff},
386 	.qos_lut_tbl = {
387 		{.nentry = ARRAY_SIZE(sc7180_qos_linear),
388 		.entries = sc7180_qos_linear
389 		},
390 		{.nentry = ARRAY_SIZE(sc7180_qos_macrotile),
391 		.entries = sc7180_qos_macrotile
392 		},
393 		{.nentry = ARRAY_SIZE(sc7180_qos_nrt),
394 		.entries = sc7180_qos_nrt
395 		},
396 		/* TODO: macrotile-qseed is different from macrotile */
397 	},
398 	.cdp_cfg = {
399 		{.rd_enable = 1, .wr_enable = 1},
400 		{.rd_enable = 1, .wr_enable = 0}
401 	},
402 	.clk_inefficiency_factor = 105,
403 	.bw_inefficiency_factor = 120,
404 };
405 
406 static const struct dpu_mdss_version sc8180x_mdss_ver = {
407 	.core_major_ver = 5,
408 	.core_minor_ver = 1,
409 };
410 
411 const struct dpu_mdss_cfg dpu_sc8180x_cfg = {
412 	.mdss_ver = &sc8180x_mdss_ver,
413 	.caps = &sc8180x_dpu_caps,
414 	.mdp = &sc8180x_mdp,
415 	.ctl_count = ARRAY_SIZE(sc8180x_ctl),
416 	.ctl = sc8180x_ctl,
417 	.sspp_count = ARRAY_SIZE(sc8180x_sspp),
418 	.sspp = sc8180x_sspp,
419 	.mixer_count = ARRAY_SIZE(sc8180x_lm),
420 	.mixer = sc8180x_lm,
421 	.dspp_count = ARRAY_SIZE(sc8180x_dspp),
422 	.dspp = sc8180x_dspp,
423 	.dsc_count = ARRAY_SIZE(sc8180x_dsc),
424 	.dsc = sc8180x_dsc,
425 	.pingpong_count = ARRAY_SIZE(sc8180x_pp),
426 	.pingpong = sc8180x_pp,
427 	.merge_3d_count = ARRAY_SIZE(sc8180x_merge_3d),
428 	.merge_3d = sc8180x_merge_3d,
429 	.wb_count = ARRAY_SIZE(sc8180x_wb),
430 	.wb = sc8180x_wb,
431 	.intf_count = ARRAY_SIZE(sc8180x_intf),
432 	.intf = sc8180x_intf,
433 	.vbif_count = ARRAY_SIZE(sdm845_vbif),
434 	.vbif = sdm845_vbif,
435 	.perf = &sc8180x_perf_data,
436 };
437 
438 #endif
439