u-boot/drivers/video/rockchip/rk3399_vop.c
Jagan Teki e67243f1a3 video: rockchip: Fix vop modes for rk3399
VOP display endpoint pipeline configuration differs
between rk3288 vs rk3399.

These VOP pipeline configuration depends on how the
different display interfaces connected in sequence to
IN and OUT ports like for,

RK3288:

vopb_out: port {
	#address-cells = <1>;
	#size-cells = <0>;
	vopb_out_edp: endpoint@0 {
		reg = <0>;
		remote-endpoint = <&edp_in_vopb>;
	};
	vopb_out_hdmi: endpoint@1 {
		reg = <1>;
                remote-endpoint = <&hdmi_in_vopb>;
        };
        vopb_out_lvds: endpoint@2 {
                reg = <2>;
                remote-endpoint = <&lvds_in_vopb>;
        };
        vopb_out_mipi: endpoint@3 {
                reg = <3>;
                remote-endpoint = <&mipi_in_vopb>;
        };
};

RK3399:

vopb_out: port {
         #address-cells = <1>;
         #size-cells = <0>;
         vopb_out_edp: endpoint@0 {
                reg = <0>;
                remote-endpoint = <&edp_in_vopb>;
         };
         vopb_out_mipi: endpoint@1 {
                reg = <1>;
                remote-endpoint = <&mipi_in_vopb>;
         };
         vopb_out_hdmi: endpoint@2 {
                reg = <2>;
                remote-endpoint = <&hdmi_in_vopb>;
         };
         vopb_out_mipi1: endpoint@3 {
                reg = <3>;
                remote-endpoint = <&mipi1_in_vopb>;
         };
         vopb_out_dp: endpoint@4 {
                reg = <4>;
                remote-endpoint = <&dp_in_vopb>;
         };
};

here, HDMI interface has endpoint 1 in rk3288 and 2 in rk3399.

The rockchip vop driver often depends on this determined endpoint
number and stored in vop_mode. So based on this vop_mode the bpp
and pin polarity would configure on detected display interface.

Since, the existing driver using rk3288 vop mode settings enabling
the same will result wrong display interface configuration for rk3399.

Add the patch for fixing these vop modes for rk3399.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
2020-04-02 15:47:35 +02:00

102 lines
2.4 KiB
C

// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (c) 2017 Theobroma Systems Design und Consulting GmbH
* Copyright (c) 2015 Google, Inc
* Copyright 2014 Rockchip Inc.
*/
#include <common.h>
#include <display.h>
#include <dm.h>
#include <regmap.h>
#include <video.h>
#include <asm/arch-rockchip/hardware.h>
#include <asm/io.h>
#include "rk_vop.h"
DECLARE_GLOBAL_DATA_PTR;
static void rk3399_set_pin_polarity(struct udevice *dev,
enum vop_modes mode, u32 polarity)
{
struct rk_vop_priv *priv = dev_get_priv(dev);
struct rk3288_vop *regs = priv->regs;
/*
* The RK3399 VOPs (v3.5 and v3.6) require a per-mode setting of
* the polarity configuration (in ctrl1).
*/
switch (mode) {
case VOP_MODE_HDMI:
clrsetbits_le32(&regs->dsp_ctrl1,
M_RK3399_DSP_HDMI_POL,
V_RK3399_DSP_HDMI_POL(polarity));
break;
case VOP_MODE_EDP:
clrsetbits_le32(&regs->dsp_ctrl1,
M_RK3399_DSP_EDP_POL,
V_RK3399_DSP_EDP_POL(polarity));
break;
case VOP_MODE_MIPI:
clrsetbits_le32(&regs->dsp_ctrl1,
M_RK3399_DSP_MIPI_POL,
V_RK3399_DSP_MIPI_POL(polarity));
break;
default:
debug("%s: unsupported output mode %x\n", __func__, mode);
}
}
/*
* Try some common regulators. We should really get these from the
* device tree somehow.
*/
static const char * const rk3399_regulator_names[] = {
"vcc33_lcd"
};
static int rk3399_vop_probe(struct udevice *dev)
{
/* Before relocation we don't need to do anything */
if (!(gd->flags & GD_FLG_RELOC))
return 0;
/* Probe regulators required for the RK3399 VOP */
rk_vop_probe_regulators(dev, rk3399_regulator_names,
ARRAY_SIZE(rk3399_regulator_names));
return rk_vop_probe(dev);
}
struct rkvop_driverdata rk3399_lit_driverdata = {
.set_pin_polarity = rk3399_set_pin_polarity,
};
struct rkvop_driverdata rk3399_big_driverdata = {
.features = VOP_FEATURE_OUTPUT_10BIT,
.set_pin_polarity = rk3399_set_pin_polarity,
};
static const struct udevice_id rk3399_vop_ids[] = {
{ .compatible = "rockchip,rk3399-vop-big",
.data = (ulong)&rk3399_big_driverdata },
{ .compatible = "rockchip,rk3399-vop-lit",
.data = (ulong)&rk3399_lit_driverdata },
{ }
};
static const struct video_ops rk3399_vop_ops = {
};
U_BOOT_DRIVER(rk3399_vop) = {
.name = "rk3399_vop",
.id = UCLASS_VIDEO,
.of_match = rk3399_vop_ids,
.ops = &rk3399_vop_ops,
.bind = rk_vop_bind,
.probe = rk3399_vop_probe,
.priv_auto_alloc_size = sizeof(struct rk_vop_priv),
};