1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 2017 Theobroma Systems Design und Consulting GmbH
16 #include <asm/arch/clock.h>
17 #include <asm/arch/hardware.h>
18 #include <asm/arch/grf_rk3399.h>
19 #include <power/regulator.h>
22 static int rk3399_hdmi_enable(struct udevice *dev, int panel_bpp,
23 const struct display_timing *edid)
25 struct rk_hdmi_priv *priv = dev_get_priv(dev);
26 struct display_plat *uc_plat = dev_get_uclass_platdata(dev);
27 int vop_id = uc_plat->source_id;
28 struct rk3399_grf_regs *grf = priv->grf;
30 /* select the hdmi encoder input data from our source_id */
31 rk_clrsetreg(&grf->soc_con20, GRF_RK3399_HDMI_VOP_SEL_MASK,
32 (vop_id == 1) ? GRF_RK3399_HDMI_VOP_SEL_L : 0);
34 return dw_hdmi_enable(&priv->hdmi, edid);
37 static int rk3399_hdmi_ofdata_to_platdata(struct udevice *dev)
39 struct rk_hdmi_priv *priv = dev_get_priv(dev);
40 struct dw_hdmi *hdmi = &priv->hdmi;
42 hdmi->i2c_clk_high = 0x7a;
43 hdmi->i2c_clk_low = 0x8d;
45 return rk_hdmi_ofdata_to_platdata(dev);
48 static const char * const rk3399_regulator_names[] = {
53 static int rk3399_hdmi_probe(struct udevice *dev)
55 /* Enable regulators required for HDMI */
56 rk_hdmi_probe_regulators(dev, rk3399_regulator_names,
57 ARRAY_SIZE(rk3399_regulator_names));
59 return rk_hdmi_probe(dev);
62 static const struct dm_display_ops rk3399_hdmi_ops = {
63 .read_edid = rk_hdmi_read_edid,
64 .enable = rk3399_hdmi_enable,
67 static const struct udevice_id rk3399_hdmi_ids[] = {
68 { .compatible = "rockchip,rk3399-dw-hdmi" },
72 U_BOOT_DRIVER(rk3399_hdmi_rockchip) = {
73 .name = "rk3399_hdmi_rockchip",
75 .of_match = rk3399_hdmi_ids,
76 .ops = &rk3399_hdmi_ops,
77 .ofdata_to_platdata = rk3399_hdmi_ofdata_to_platdata,
78 .probe = rk3399_hdmi_probe,
79 .priv_auto_alloc_size = sizeof(struct rk_hdmi_priv),