2 * Copyright (c) 2017 Theobroma Systems Design und Consulting GmbH
4 * SPDX-License-Identifier: GPL-2.0+
17 #include <asm/arch/clock.h>
18 #include <asm/arch/hardware.h>
19 #include <asm/arch/grf_rk3399.h>
20 #include <power/regulator.h>
23 static int rk3399_hdmi_enable(struct udevice *dev, int panel_bpp,
24 const struct display_timing *edid)
26 struct rk_hdmi_priv *priv = dev_get_priv(dev);
27 struct display_plat *uc_plat = dev_get_uclass_platdata(dev);
28 int vop_id = uc_plat->source_id;
29 struct rk3399_grf_regs *grf = priv->grf;
31 /* select the hdmi encoder input data from our source_id */
32 rk_clrsetreg(&grf->soc_con20, GRF_RK3399_HDMI_VOP_SEL_MASK,
33 (vop_id == 1) ? GRF_RK3399_HDMI_VOP_SEL_L : 0);
35 return dw_hdmi_enable(&priv->hdmi, edid);
38 static int rk3399_hdmi_ofdata_to_platdata(struct udevice *dev)
40 struct rk_hdmi_priv *priv = dev_get_priv(dev);
41 struct dw_hdmi *hdmi = &priv->hdmi;
43 hdmi->i2c_clk_high = 0x7a;
44 hdmi->i2c_clk_low = 0x8d;
46 return rk_hdmi_ofdata_to_platdata(dev);
49 static const char * const rk3399_regulator_names[] = {
54 static int rk3399_hdmi_probe(struct udevice *dev)
56 /* Enable regulators required for HDMI */
57 rk_hdmi_probe_regulators(dev, rk3399_regulator_names,
58 ARRAY_SIZE(rk3399_regulator_names));
60 return rk_hdmi_probe(dev);
63 static const struct dm_display_ops rk3399_hdmi_ops = {
64 .read_edid = rk_hdmi_read_edid,
65 .enable = rk3399_hdmi_enable,
68 static const struct udevice_id rk3399_hdmi_ids[] = {
69 { .compatible = "rockchip,rk3399-dw-hdmi" },
73 U_BOOT_DRIVER(rk3399_hdmi_rockchip) = {
74 .name = "rk3399_hdmi_rockchip",
76 .of_match = rk3399_hdmi_ids,
77 .ops = &rk3399_hdmi_ops,
78 .ofdata_to_platdata = rk3399_hdmi_ofdata_to_platdata,
79 .probe = rk3399_hdmi_probe,
80 .priv_auto_alloc_size = sizeof(struct rk_hdmi_priv),