.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. |
---|
2 | | - * |
---|
3 | | - * This program is free software; you can redistribute it and/or modify |
---|
4 | | - * it under the terms of the GNU General Public License version 2 and |
---|
5 | | - * only version 2 as published by the Free Software Foundation. |
---|
6 | | - * |
---|
7 | | - * This program is distributed in the hope that it will be useful, |
---|
8 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
9 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
10 | | - * GNU General Public License for more details. |
---|
11 | 3 | */ |
---|
12 | 4 | |
---|
13 | 5 | #include "dpu_hwio.h" |
---|
14 | 6 | #include "dpu_hw_catalog.h" |
---|
15 | 7 | #include "dpu_hw_intf.h" |
---|
16 | | -#include "dpu_dbg.h" |
---|
17 | 8 | #include "dpu_kms.h" |
---|
18 | 9 | |
---|
19 | 10 | #define INTF_TIMING_ENGINE_EN 0x000 |
---|
.. | .. |
---|
65 | 56 | #define INTF_FRAME_COUNT 0x0AC |
---|
66 | 57 | #define INTF_LINE_COUNT 0x0B0 |
---|
67 | 58 | |
---|
68 | | -#define INTF_MISR_CTRL 0x180 |
---|
69 | | -#define INTF_MISR_SIGNATURE 0x184 |
---|
| 59 | +#define INTF_MUX 0x25C |
---|
70 | 60 | |
---|
71 | | -static struct dpu_intf_cfg *_intf_offset(enum dpu_intf intf, |
---|
72 | | - struct dpu_mdss_cfg *m, |
---|
| 61 | +static const struct dpu_intf_cfg *_intf_offset(enum dpu_intf intf, |
---|
| 62 | + const struct dpu_mdss_cfg *m, |
---|
73 | 63 | void __iomem *addr, |
---|
74 | 64 | struct dpu_hw_blk_reg_map *b) |
---|
75 | 65 | { |
---|
.. | .. |
---|
117 | 107 | display_v_end = ((vsync_period - p->v_front_porch) * hsync_period) + |
---|
118 | 108 | p->hsync_skew - 1; |
---|
119 | 109 | |
---|
120 | | - if (ctx->cap->type == INTF_EDP || ctx->cap->type == INTF_DP) { |
---|
121 | | - display_v_start += p->hsync_pulse_width + p->h_back_porch; |
---|
122 | | - display_v_end -= p->h_front_porch; |
---|
123 | | - } |
---|
124 | | - |
---|
125 | 110 | hsync_start_x = p->h_back_porch + p->hsync_pulse_width; |
---|
126 | 111 | hsync_end_x = hsync_period - p->h_front_porch - 1; |
---|
127 | 112 | |
---|
.. | .. |
---|
154 | 139 | hsync_ctl = (hsync_period << 16) | p->hsync_pulse_width; |
---|
155 | 140 | display_hctl = (hsync_end_x << 16) | hsync_start_x; |
---|
156 | 141 | |
---|
| 142 | + if (ctx->cap->type == INTF_EDP || ctx->cap->type == INTF_DP) { |
---|
| 143 | + active_h_start = hsync_start_x; |
---|
| 144 | + active_h_end = active_h_start + p->xres - 1; |
---|
| 145 | + active_v_start = display_v_start; |
---|
| 146 | + active_v_end = active_v_start + (p->yres * hsync_period) - 1; |
---|
| 147 | + |
---|
| 148 | + display_v_start += p->hsync_pulse_width + p->h_back_porch; |
---|
| 149 | + display_v_end -= p->h_front_porch; |
---|
| 150 | + |
---|
| 151 | + active_hctl = (active_h_end << 16) | active_h_start; |
---|
| 152 | + display_hctl = active_hctl; |
---|
| 153 | + } |
---|
| 154 | + |
---|
157 | 155 | den_polarity = 0; |
---|
158 | 156 | if (ctx->cap->type == INTF_HDMI) { |
---|
159 | 157 | hsync_polarity = p->yres >= 720 ? 0 : 1; |
---|
160 | 158 | vsync_polarity = p->yres >= 720 ? 0 : 1; |
---|
| 159 | + } else if (ctx->cap->type == INTF_DP) { |
---|
| 160 | + hsync_polarity = p->hsync_polarity; |
---|
| 161 | + vsync_polarity = p->vsync_polarity; |
---|
161 | 162 | } else { |
---|
162 | 163 | hsync_polarity = 0; |
---|
163 | 164 | vsync_polarity = 0; |
---|
.. | .. |
---|
230 | 231 | DPU_REG_WRITE(c, INTF_CONFIG, fetch_enable); |
---|
231 | 232 | } |
---|
232 | 233 | |
---|
| 234 | +static void dpu_hw_intf_bind_pingpong_blk( |
---|
| 235 | + struct dpu_hw_intf *intf, |
---|
| 236 | + bool enable, |
---|
| 237 | + const enum dpu_pingpong pp) |
---|
| 238 | +{ |
---|
| 239 | + struct dpu_hw_blk_reg_map *c = &intf->hw; |
---|
| 240 | + u32 mux_cfg; |
---|
| 241 | + |
---|
| 242 | + mux_cfg = DPU_REG_READ(c, INTF_MUX); |
---|
| 243 | + mux_cfg &= ~0xf; |
---|
| 244 | + |
---|
| 245 | + if (enable) |
---|
| 246 | + mux_cfg |= (pp - PINGPONG_0) & 0x7; |
---|
| 247 | + else |
---|
| 248 | + mux_cfg |= 0xf; |
---|
| 249 | + |
---|
| 250 | + DPU_REG_WRITE(c, INTF_MUX, mux_cfg); |
---|
| 251 | +} |
---|
| 252 | + |
---|
233 | 253 | static void dpu_hw_intf_get_status( |
---|
234 | 254 | struct dpu_hw_intf *intf, |
---|
235 | 255 | struct intf_status *s) |
---|
.. | .. |
---|
244 | 264 | s->line_count = 0; |
---|
245 | 265 | s->frame_count = 0; |
---|
246 | 266 | } |
---|
247 | | -} |
---|
248 | | - |
---|
249 | | -static void dpu_hw_intf_setup_misr(struct dpu_hw_intf *intf, |
---|
250 | | - bool enable, u32 frame_count) |
---|
251 | | -{ |
---|
252 | | - struct dpu_hw_blk_reg_map *c = &intf->hw; |
---|
253 | | - u32 config = 0; |
---|
254 | | - |
---|
255 | | - DPU_REG_WRITE(c, INTF_MISR_CTRL, MISR_CTRL_STATUS_CLEAR); |
---|
256 | | - /* clear misr data */ |
---|
257 | | - wmb(); |
---|
258 | | - |
---|
259 | | - if (enable) |
---|
260 | | - config = (frame_count & MISR_FRAME_COUNT_MASK) | |
---|
261 | | - MISR_CTRL_ENABLE | INTF_MISR_CTRL_FREE_RUN_MASK; |
---|
262 | | - |
---|
263 | | - DPU_REG_WRITE(c, INTF_MISR_CTRL, config); |
---|
264 | | -} |
---|
265 | | - |
---|
266 | | -static u32 dpu_hw_intf_collect_misr(struct dpu_hw_intf *intf) |
---|
267 | | -{ |
---|
268 | | - struct dpu_hw_blk_reg_map *c = &intf->hw; |
---|
269 | | - |
---|
270 | | - return DPU_REG_READ(c, INTF_MISR_SIGNATURE); |
---|
271 | 267 | } |
---|
272 | 268 | |
---|
273 | 269 | static u32 dpu_hw_intf_get_line_count(struct dpu_hw_intf *intf) |
---|
.. | .. |
---|
289 | 285 | ops->setup_prg_fetch = dpu_hw_intf_setup_prg_fetch; |
---|
290 | 286 | ops->get_status = dpu_hw_intf_get_status; |
---|
291 | 287 | ops->enable_timing = dpu_hw_intf_enable_timing_engine; |
---|
292 | | - ops->setup_misr = dpu_hw_intf_setup_misr; |
---|
293 | | - ops->collect_misr = dpu_hw_intf_collect_misr; |
---|
294 | 288 | ops->get_line_count = dpu_hw_intf_get_line_count; |
---|
| 289 | + if (cap & BIT(DPU_INTF_INPUT_CTRL)) |
---|
| 290 | + ops->bind_pingpong_blk = dpu_hw_intf_bind_pingpong_blk; |
---|
295 | 291 | } |
---|
296 | 292 | |
---|
297 | | -static struct dpu_hw_blk_ops dpu_hw_ops = { |
---|
298 | | - .start = NULL, |
---|
299 | | - .stop = NULL, |
---|
300 | | -}; |
---|
| 293 | +static struct dpu_hw_blk_ops dpu_hw_ops; |
---|
301 | 294 | |
---|
302 | 295 | struct dpu_hw_intf *dpu_hw_intf_init(enum dpu_intf idx, |
---|
303 | 296 | void __iomem *addr, |
---|
304 | | - struct dpu_mdss_cfg *m) |
---|
| 297 | + const struct dpu_mdss_cfg *m) |
---|
305 | 298 | { |
---|
306 | 299 | struct dpu_hw_intf *c; |
---|
307 | | - struct dpu_intf_cfg *cfg; |
---|
308 | | - int rc; |
---|
| 300 | + const struct dpu_intf_cfg *cfg; |
---|
309 | 301 | |
---|
310 | 302 | c = kzalloc(sizeof(*c), GFP_KERNEL); |
---|
311 | 303 | if (!c) |
---|
.. | .. |
---|
326 | 318 | c->mdss = m; |
---|
327 | 319 | _setup_intf_ops(&c->ops, c->cap->features); |
---|
328 | 320 | |
---|
329 | | - rc = dpu_hw_blk_init(&c->base, DPU_HW_BLK_INTF, idx, &dpu_hw_ops); |
---|
330 | | - if (rc) { |
---|
331 | | - DPU_ERROR("failed to init hw blk %d\n", rc); |
---|
332 | | - goto blk_init_error; |
---|
333 | | - } |
---|
| 321 | + dpu_hw_blk_init(&c->base, DPU_HW_BLK_INTF, idx, &dpu_hw_ops); |
---|
334 | 322 | |
---|
335 | 323 | return c; |
---|
336 | | - |
---|
337 | | -blk_init_error: |
---|
338 | | - kzfree(c); |
---|
339 | | - |
---|
340 | | - return ERR_PTR(rc); |
---|
341 | 324 | } |
---|
342 | 325 | |
---|
343 | 326 | void dpu_hw_intf_destroy(struct dpu_hw_intf *intf) |
---|