blob: c7630ccf55588ce9d5c41f429cceeb67e3e57b69 [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
Philipp Tomsichdf48c792017-05-31 17:59:34 +02006#include <clk.h>
7#include <display.h>
8#include <dm.h>
9#include <dw_hdmi.h>
10#include <edid.h>
11#include <regmap.h>
12#include <syscon.h>
13#include <asm/gpio.h>
Kever Yang9fbe17c2019-03-28 11:01:23 +080014#include <asm/arch-rockchip/clock.h>
15#include <asm/arch-rockchip/hardware.h>
16#include <asm/arch-rockchip/grf_rk3399.h>
Philipp Tomsichdf48c792017-05-31 17:59:34 +020017#include <power/regulator.h>
18#include "rk_hdmi.h"
19
20static int rk3399_hdmi_enable(struct udevice *dev, int panel_bpp,
21 const struct display_timing *edid)
22{
23 struct rk_hdmi_priv *priv = dev_get_priv(dev);
Simon Glass71fa5b42020-12-03 16:55:18 -070024 struct display_plat *uc_plat = dev_get_uclass_plat(dev);
Philipp Tomsichdf48c792017-05-31 17:59:34 +020025 int vop_id = uc_plat->source_id;
26 struct rk3399_grf_regs *grf = priv->grf;
27
28 /* select the hdmi encoder input data from our source_id */
29 rk_clrsetreg(&grf->soc_con20, GRF_RK3399_HDMI_VOP_SEL_MASK,
30 (vop_id == 1) ? GRF_RK3399_HDMI_VOP_SEL_L : 0);
31
32 return dw_hdmi_enable(&priv->hdmi, edid);
33}
34
Simon Glassaad29ae2020-12-03 16:55:21 -070035static int rk3399_hdmi_of_to_plat(struct udevice *dev)
Philipp Tomsichdf48c792017-05-31 17:59:34 +020036{
37 struct rk_hdmi_priv *priv = dev_get_priv(dev);
38 struct dw_hdmi *hdmi = &priv->hdmi;
39
40 hdmi->i2c_clk_high = 0x7a;
41 hdmi->i2c_clk_low = 0x8d;
42
Simon Glassaad29ae2020-12-03 16:55:21 -070043 return rk_hdmi_of_to_plat(dev);
Philipp Tomsichdf48c792017-05-31 17:59:34 +020044}
45
46static const char * const rk3399_regulator_names[] = {
47 "vcc1v8_hdmi",
48 "vcc0v9_hdmi"
49};
50
51static int rk3399_hdmi_probe(struct udevice *dev)
52{
53 /* Enable regulators required for HDMI */
54 rk_hdmi_probe_regulators(dev, rk3399_regulator_names,
55 ARRAY_SIZE(rk3399_regulator_names));
56
57 return rk_hdmi_probe(dev);
58}
59
60static const struct dm_display_ops rk3399_hdmi_ops = {
61 .read_edid = rk_hdmi_read_edid,
62 .enable = rk3399_hdmi_enable,
63};
64
65static const struct udevice_id rk3399_hdmi_ids[] = {
66 { .compatible = "rockchip,rk3399-dw-hdmi" },
67 { }
68};
69
70U_BOOT_DRIVER(rk3399_hdmi_rockchip) = {
71 .name = "rk3399_hdmi_rockchip",
72 .id = UCLASS_DISPLAY,
73 .of_match = rk3399_hdmi_ids,
74 .ops = &rk3399_hdmi_ops,
Simon Glassaad29ae2020-12-03 16:55:21 -070075 .of_to_plat = rk3399_hdmi_of_to_plat,
Philipp Tomsichdf48c792017-05-31 17:59:34 +020076 .probe = rk3399_hdmi_probe,
Simon Glass8a2b47f2020-12-03 16:55:17 -070077 .priv_auto = sizeof(struct rk_hdmi_priv),
Philipp Tomsichdf48c792017-05-31 17:59:34 +020078};