1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 2017 Theobroma Systems Design und Consulting GmbH
18 #include <asm/arch-rockchip/clock.h>
19 #include <asm/arch-rockchip/hardware.h>
20 #include <asm/arch-rockchip/grf_rk3288.h>
21 #include <power/regulator.h>
24 static int rk3288_hdmi_enable(struct udevice *dev, int panel_bpp,
25 const struct display_timing *edid)
27 struct rk_hdmi_priv *priv = dev_get_priv(dev);
28 struct display_plat *uc_plat = dev_get_uclass_platdata(dev);
29 int vop_id = uc_plat->source_id;
30 struct rk3288_grf *grf = priv->grf;
32 /* hdmi source select hdmi controller */
33 rk_setreg(&grf->soc_con6, 1 << 15);
35 /* hdmi data from vop id */
36 rk_clrsetreg(&grf->soc_con6, 1 << 4, (vop_id == 1) ? (1 << 4) : 0);
38 return dw_hdmi_enable(&priv->hdmi, edid);
41 static int rk3288_hdmi_ofdata_to_platdata(struct udevice *dev)
43 struct rk_hdmi_priv *priv = dev_get_priv(dev);
44 struct dw_hdmi *hdmi = &priv->hdmi;
46 hdmi->i2c_clk_high = 0x7a;
47 hdmi->i2c_clk_low = 0x8d;
50 * TODO(sjg@chromium.org): The above values don't work - these
51 * ones work better, but generate lots of errors in the data.
53 hdmi->i2c_clk_high = 0x0d;
54 hdmi->i2c_clk_low = 0x0d;
56 return rk_hdmi_ofdata_to_platdata(dev);
59 static int rk3288_clk_config(struct udevice *dev)
61 struct display_plat *uc_plat = dev_get_uclass_platdata(dev);
66 * Configure the maximum clock to permit whatever resolution the
69 ret = clk_get_by_index(uc_plat->src_dev, 0, &clk);
71 ret = clk_set_rate(&clk, 384000000);
75 debug("%s: Failed to set clock in source device '%s': ret=%d\n",
76 __func__, uc_plat->src_dev->name, ret);
83 static const char * const rk3288_regulator_names[] = {
87 static int rk3288_hdmi_probe(struct udevice *dev)
89 /* Enable VOP clock for RK3288 */
90 rk3288_clk_config(dev);
92 /* Enable regulators required for HDMI */
93 rk_hdmi_probe_regulators(dev, rk3288_regulator_names,
94 ARRAY_SIZE(rk3288_regulator_names));
96 return rk_hdmi_probe(dev);
99 static const struct dm_display_ops rk3288_hdmi_ops = {
100 .read_edid = rk_hdmi_read_edid,
101 .enable = rk3288_hdmi_enable,
104 static const struct udevice_id rk3288_hdmi_ids[] = {
105 { .compatible = "rockchip,rk3288-dw-hdmi" },
109 U_BOOT_DRIVER(rk3288_hdmi_rockchip) = {
110 .name = "rk3288_hdmi_rockchip",
111 .id = UCLASS_DISPLAY,
112 .of_match = rk3288_hdmi_ids,
113 .ops = &rk3288_hdmi_ops,
114 .ofdata_to_platdata = rk3288_hdmi_ofdata_to_platdata,
115 .probe = rk3288_hdmi_probe,
116 .priv_auto_alloc_size = sizeof(struct rk_hdmi_priv),