blob: 3041360c6ed978831fb28cd3a6f015fe8adab853 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Philipp Tomsichdf48c792017-05-31 17:59:34 +02002/*
3 * Copyright (c) 2017 Theobroma Systems Design und Consulting GmbH
Philipp Tomsichdf48c792017-05-31 17:59:34 +02004 */
5
6#include <common.h>
7#include <clk.h>
8#include <display.h>
9#include <dm.h>
10#include <dw_hdmi.h>
11#include <edid.h>
12#include <regmap.h>
13#include <syscon.h>
14#include <asm/gpio.h>
15#include <asm/io.h>
Kever Yang9fbe17c2019-03-28 11:01:23 +080016#include <asm/arch-rockchip/clock.h>
17#include <asm/arch-rockchip/hardware.h>
18#include <asm/arch-rockchip/grf_rk3399.h>
Philipp Tomsichdf48c792017-05-31 17:59:34 +020019#include <power/regulator.h>
20#include "rk_hdmi.h"
21
22static int rk3399_hdmi_enable(struct udevice *dev, int panel_bpp,
23 const struct display_timing *edid)
24{
25 struct rk_hdmi_priv *priv = dev_get_priv(dev);
Simon Glass71fa5b42020-12-03 16:55:18 -070026 struct display_plat *uc_plat = dev_get_uclass_plat(dev);
Philipp Tomsichdf48c792017-05-31 17:59:34 +020027 int vop_id = uc_plat->source_id;
28 struct rk3399_grf_regs *grf = priv->grf;
29
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);
33
34 return dw_hdmi_enable(&priv->hdmi, edid);
35}
36
Simon Glassaad29ae2020-12-03 16:55:21 -070037static int rk3399_hdmi_of_to_plat(struct udevice *dev)
Philipp Tomsichdf48c792017-05-31 17:59:34 +020038{
39 struct rk_hdmi_priv *priv = dev_get_priv(dev);
40 struct dw_hdmi *hdmi = &priv->hdmi;
41
42 hdmi->i2c_clk_high = 0x7a;
43 hdmi->i2c_clk_low = 0x8d;
44
Simon Glassaad29ae2020-12-03 16:55:21 -070045 return rk_hdmi_of_to_plat(dev);
Philipp Tomsichdf48c792017-05-31 17:59:34 +020046}
47
48static const char * const rk3399_regulator_names[] = {
49 "vcc1v8_hdmi",
50 "vcc0v9_hdmi"
51};
52
53static int rk3399_hdmi_probe(struct udevice *dev)
54{
55 /* Enable regulators required for HDMI */
56 rk_hdmi_probe_regulators(dev, rk3399_regulator_names,
57 ARRAY_SIZE(rk3399_regulator_names));
58
59 return rk_hdmi_probe(dev);
60}
61
62static const struct dm_display_ops rk3399_hdmi_ops = {
63 .read_edid = rk_hdmi_read_edid,
64 .enable = rk3399_hdmi_enable,
65};
66
67static const struct udevice_id rk3399_hdmi_ids[] = {
68 { .compatible = "rockchip,rk3399-dw-hdmi" },
69 { }
70};
71
72U_BOOT_DRIVER(rk3399_hdmi_rockchip) = {
73 .name = "rk3399_hdmi_rockchip",
74 .id = UCLASS_DISPLAY,
75 .of_match = rk3399_hdmi_ids,
76 .ops = &rk3399_hdmi_ops,
Simon Glassaad29ae2020-12-03 16:55:21 -070077 .of_to_plat = rk3399_hdmi_of_to_plat,
Philipp Tomsichdf48c792017-05-31 17:59:34 +020078 .probe = rk3399_hdmi_probe,
Simon Glass8a2b47f2020-12-03 16:55:17 -070079 .priv_auto = sizeof(struct rk_hdmi_priv),
Philipp Tomsichdf48c792017-05-31 17:59:34 +020080};