1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 2017 Theobroma Systems Design und Consulting GmbH
4 * Copyright (c) 2015 Google, Inc
5 * Copyright 2014 Rockchip Inc.
13 #include <asm/arch-rockchip/hardware.h>
17 DECLARE_GLOBAL_DATA_PTR;
19 static void rk3399_set_pin_polarity(struct udevice *dev,
20 enum vop_modes mode, u32 polarity)
22 struct rk_vop_priv *priv = dev_get_priv(dev);
23 struct rk3288_vop *regs = priv->regs;
26 * The RK3399 VOPs (v3.5 and v3.6) require a per-mode setting of
27 * the polarity configuration (in ctrl1).
31 clrsetbits_le32(®s->dsp_ctrl1,
32 M_RK3399_DSP_HDMI_POL,
33 V_RK3399_DSP_HDMI_POL(polarity));
37 clrsetbits_le32(®s->dsp_ctrl1,
39 V_RK3399_DSP_EDP_POL(polarity));
43 clrsetbits_le32(®s->dsp_ctrl1,
44 M_RK3399_DSP_MIPI_POL,
45 V_RK3399_DSP_MIPI_POL(polarity));
49 /* The RK3399 has neither parallel RGB nor LVDS output. */
51 debug("%s: unsupported output mode %x\n", __func__, mode);
56 * Try some common regulators. We should really get these from the
57 * device tree somehow.
59 static const char * const rk3399_regulator_names[] = {
63 static int rk3399_vop_probe(struct udevice *dev)
65 /* Before relocation we don't need to do anything */
66 if (!(gd->flags & GD_FLG_RELOC))
69 /* Probe regulators required for the RK3399 VOP */
70 rk_vop_probe_regulators(dev, rk3399_regulator_names,
71 ARRAY_SIZE(rk3399_regulator_names));
73 return rk_vop_probe(dev);
76 struct rkvop_driverdata rk3399_lit_driverdata = {
77 .set_pin_polarity = rk3399_set_pin_polarity,
80 struct rkvop_driverdata rk3399_big_driverdata = {
81 .features = VOP_FEATURE_OUTPUT_10BIT,
82 .set_pin_polarity = rk3399_set_pin_polarity,
85 static const struct udevice_id rk3399_vop_ids[] = {
86 { .compatible = "rockchip,rk3399-vop-big",
87 .data = (ulong)&rk3399_big_driverdata },
88 { .compatible = "rockchip,rk3399-vop-lit",
89 .data = (ulong)&rk3399_lit_driverdata },
93 static const struct video_ops rk3399_vop_ops = {
96 U_BOOT_DRIVER(rk3399_vop) = {
99 .of_match = rk3399_vop_ids,
100 .ops = &rk3399_vop_ops,
102 .probe = rk3399_vop_probe,
103 .priv_auto_alloc_size = sizeof(struct rk_vop_priv),