Skip to content

Commit c2b587f

Browse files
sandy-huangrkhuangtao
authored andcommitted
drm/rockchip: vop: config dclk invert from grf register
Some platform like rk3288,rk3368,px30, we need to config grf register to invert dclk polarity when connector is rgb or lvds. Change-Id: I9ef9ce09f050ee42c0543d415a9baac1f50a0848 Signed-off-by: Sandy Huang <hjc@rock-chips.com>
1 parent 04e6e5c commit c2b587f

4 files changed

Lines changed: 57 additions & 0 deletions

File tree

drivers/gpu/drm/rockchip/rockchip_drm_vop.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
#include <linux/of_device.h>
3535
#include <linux/pm_runtime.h>
3636
#include <linux/component.h>
37+
#include <linux/regmap.h>
38+
#include <linux/mfd/syscon.h>
3739

3840
#include <linux/reset.h>
3941
#include <linux/delay.h>
@@ -134,6 +136,12 @@
134136

135137
#define VOP_WIN_GET_YRGBADDR(vop, win) \
136138
vop_readl(vop, win->offset + VOP_WIN_NAME(win, yrgb_mst).offset)
139+
#define VOP_GRF_SET(vop, reg, v) \
140+
do { \
141+
if (vop->data->grf_ctrl) { \
142+
vop_grf_writel(vop, vop->data->grf_ctrl->reg, v); \
143+
} \
144+
} while (0)
137145

138146
#define to_vop(x) container_of(x, struct vop, crtc)
139147
#define to_vop_win(x) container_of(x, struct vop_win, base)
@@ -229,6 +237,7 @@ struct vop {
229237

230238
uint32_t *regsbak;
231239
void __iomem *regs;
240+
struct regmap *grf;
232241

233242
/* physical map length of vop register */
234243
uint32_t len;
@@ -271,6 +280,18 @@ struct vop {
271280
static struct vop *dmc_vop[MAX_VOPS];
272281
static struct devfreq *devfreq_vop;
273282
static DEFINE_MUTEX(register_devfreq_lock);
283+
static inline void vop_grf_writel(struct vop *vop, struct vop_reg reg, u32 v)
284+
{
285+
u32 val = 0;
286+
287+
if (IS_ERR_OR_NULL(vop->grf))
288+
return;
289+
290+
if (VOP_REG_SUPPORT(vop, reg)) {
291+
val = (v << reg.shift) | (reg.mask << (reg.shift + 16));
292+
regmap_write(vop->grf, reg.offset, val);
293+
}
294+
}
274295

275296
static inline void vop_writel(struct vop *vop, uint32_t offset, uint32_t v)
276297
{
@@ -2516,6 +2537,8 @@ static void vop_crtc_enable(struct drm_crtc *crtc)
25162537
VOP_CTRL_SET(vop, lvds_en, 1);
25172538
VOP_CTRL_SET(vop, lvds_pin_pol, val);
25182539
VOP_CTRL_SET(vop, lvds_dclk_pol, dclk_inv);
2540+
2541+
VOP_GRF_SET(vop, grf_dclk_inv, !dclk_inv);
25192542
break;
25202543
case DRM_MODE_CONNECTOR_eDP:
25212544
VOP_CTRL_SET(vop, edp_en, 1);
@@ -4247,6 +4270,11 @@ static int vop_bind(struct device *dev, struct device *master, void *data)
42474270
}
42484271
}
42494272

4273+
vop->grf = syscon_regmap_lookup_by_phandle(dev->of_node,
4274+
"rockchip,grf");
4275+
if (IS_ERR(vop->grf))
4276+
dev_err(dev, "missing rockchip,grf property\n");
4277+
42504278
vop->hclk = devm_clk_get(vop->dev, "hclk_vop");
42514279
if (IS_ERR(vop->hclk)) {
42524280
dev_err(vop->dev, "failed to get hclk source\n");

drivers/gpu/drm/rockchip/rockchip_drm_vop.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,10 @@ struct vop_win_data {
427427
u64 feature;
428428
};
429429

430+
struct vop_grf_ctrl {
431+
struct vop_reg grf_dclk_inv;
432+
};
433+
430434
#define VOP_FEATURE_OUTPUT_10BIT BIT(0)
431435
#define VOP_FEATURE_AFBDC BIT(1)
432436
#define VOP_FEATURE_ALPHA_SCALE BIT(2)
@@ -449,6 +453,7 @@ struct vop_data {
449453
const struct vop_win_data *win;
450454
const struct vop_csc_table *csc_table;
451455
const struct vop_hdr_table *hdr_table;
456+
const struct vop_grf_ctrl *grf_ctrl;
452457
unsigned int win_size;
453458
uint32_t version;
454459
struct vop_rect max_input;

drivers/gpu/drm/rockchip/rockchip_vop_reg.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,12 +322,21 @@ static const struct vop_intr rk3288_vop_intr = {
322322
.clear = VOP_REG(RK3288_INTR_CTRL0, 0xf, 8),
323323
};
324324

325+
static const struct vop_grf_ctrl rk3288_vop_big_grf_ctrl = {
326+
.grf_dclk_inv = VOP_REG(RK3288_GRF_SOC_CON15, 0x1, 12),
327+
};
328+
329+
static const struct vop_grf_ctrl rk3288_vop_lit_grf_ctrl = {
330+
.grf_dclk_inv = VOP_REG(RK3288_GRF_SOC_CON15, 0x1, 14),
331+
};
332+
325333
static const struct vop_data rk3288_vop_big = {
326334
.version = VOP_VERSION(3, 0),
327335
.feature = VOP_FEATURE_OUTPUT_10BIT | VOP_FEATURE_ALPHA_SCALE,
328336
.max_input = {4096, 8192},
329337
.max_output = {3840, 2160},
330338
.intr = &rk3288_vop_intr,
339+
.grf_ctrl = &rk3288_vop_big_grf_ctrl,
331340
.ctrl = &rk3288_ctrl_data,
332341
.win = rk3288_vop_win_data,
333342
.win_size = ARRAY_SIZE(rk3288_vop_win_data),
@@ -339,6 +348,7 @@ static const struct vop_data rk3288_vop_lit = {
339348
.max_input = {4096, 8192},
340349
.max_output = {2560, 1600},
341350
.intr = &rk3288_vop_intr,
351+
.grf_ctrl = &rk3288_vop_lit_grf_ctrl,
342352
.ctrl = &rk3288_ctrl_data,
343353
.win = rk3288_vop_win_data,
344354
.win_size = ARRAY_SIZE(rk3288_vop_win_data),
@@ -460,12 +470,17 @@ static const struct vop_intr rk3366_vop_intr = {
460470
.clear = VOP_REG_MASK(RK3366_INTR_CLEAR0, 0xffff, 0),
461471
};
462472

473+
static const struct vop_grf_ctrl rk3368_vop_grf_ctrl = {
474+
.grf_dclk_inv = VOP_REG(RK3368_GRF_SOC_CON6, 0x1, 5),
475+
};
476+
463477
static const struct vop_data rk3366_vop = {
464478
.version = VOP_VERSION(3, 4),
465479
.feature = VOP_FEATURE_ALPHA_SCALE,
466480
.max_input = {4096, 8192},
467481
.max_output = {4096, 2160},
468482
.intr = &rk3366_vop_intr,
483+
.grf_ctrl = &rk3368_vop_grf_ctrl,
469484
.ctrl = &rk3288_ctrl_data,
470485
.win = rk3368_vop_win_data,
471486
.win_size = ARRAY_SIZE(rk3368_vop_win_data),
@@ -1550,12 +1565,17 @@ static const struct vop_win_data px30_vop_lit_win_data[] = {
15501565
{ .phy = NULL },
15511566
};
15521567

1568+
static const struct vop_grf_ctrl px30_grf_ctrl = {
1569+
.grf_dclk_inv = VOP_REG(PX30_GRF_PD_VO_CON1, 0x1, 4),
1570+
};
1571+
15531572
static const struct vop_data px30_vop_lit = {
15541573
.version = VOP_VERSION(2, 5),
15551574
.max_input = {1920, 8192},
15561575
.max_output = {1920, 1080},
15571576
.ctrl = &px30_ctrl_data,
15581577
.intr = &rk3366_lit_intr,
1578+
.grf_ctrl = &px30_grf_ctrl,
15591579
.win = px30_vop_lit_win_data,
15601580
.win_size = ARRAY_SIZE(px30_vop_lit_win_data),
15611581
};
@@ -1567,6 +1587,7 @@ static const struct vop_data px30_vop_big = {
15671587
.max_output = {1920, 1080},
15681588
.ctrl = &px30_ctrl_data,
15691589
.intr = &rk3366_lit_intr,
1590+
.grf_ctrl = &px30_grf_ctrl,
15701591
.win = px30_vop_big_win_data,
15711592
.win_size = ARRAY_SIZE(px30_vop_big_win_data),
15721593
};

drivers/gpu/drm/rockchip/rockchip_vop_reg.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
#define RK3288_BCSH_COLOR_BAR 0x01b0
126126
#define RK3288_BCSH_BCS 0x01b4
127127
#define RK3288_BCSH_H 0x01b8
128+
#define RK3288_GRF_SOC_CON15 0x03a4
128129
/* register definition end */
129130

130131
/* rk3368 register definition */
@@ -312,6 +313,7 @@
312313
#define RK3368_CABC_GAMMA_LUT_ADDR 0x1800
313314
#define RK3368_MCU_BYPASS_WPORT 0x2200
314315
#define RK3368_MCU_BYPASS_RPORT 0x2300
316+
#define RK3368_GRF_SOC_CON6 0x0418
315317
/* rk3368 register definition end */
316318

317319
#define RK3366_REG_CFG_DONE 0x0000
@@ -1037,6 +1039,7 @@
10371039
#define PX30_AFBCD0_PIC_SIZE 0x00248
10381040
#define PX30_AFBCD0_PIC_OFFSET 0x0024c
10391041
#define PX30_AFBCD0_AXI_CTRL 0x00250
1042+
#define PX30_GRF_PD_VO_CON1 0x00438
10401043
/* px30 register definition end */
10411044

10421045
#endif /* _ROCKCHIP_VOP_REG_H */

0 commit comments

Comments
 (0)