]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
video: rockchip: Add rk3328 hdmi support
authorJagan Teki <jagan@edgeble.ai>
Wed, 17 Jan 2024 07:51:49 +0000 (13:21 +0530)
committerAnatolij Gustschin <agust@denx.de>
Sun, 21 Apr 2024 07:07:00 +0000 (09:07 +0200)
Add Rockchip RK3328 HDMI Out driver.

Signed-off-by: Jagan Teki <jagan@edgeble.ai>
drivers/video/rockchip/Makefile
drivers/video/rockchip/rk3328_hdmi.c [new file with mode: 0644]
drivers/video/rockchip/rk_hdmi.h

index 8128289cc8209079ec2bdbb521bac9fba797eccb..4991303c737d8ef7dd577ae5ec836f829d5d9f7d 100644 (file)
@@ -10,6 +10,7 @@ obj-$(CONFIG_ROCKCHIP_RK3399) += rk3399_vop.o
 obj-$(CONFIG_DISPLAY_ROCKCHIP_EDP) += rk_edp.o
 obj-$(CONFIG_DISPLAY_ROCKCHIP_LVDS) += rk_lvds.o
 obj-hdmi-$(CONFIG_ROCKCHIP_RK3288) += rk3288_hdmi.o
+obj-hdmi-$(CONFIG_ROCKCHIP_RK3328) += rk3328_hdmi.o
 obj-hdmi-$(CONFIG_ROCKCHIP_RK3399) += rk3399_hdmi.o
 obj-$(CONFIG_DISPLAY_ROCKCHIP_HDMI) += rk_hdmi.o $(obj-hdmi-y)
 obj-mipi-$(CONFIG_ROCKCHIP_RK3288) += rk3288_mipi.o
diff --git a/drivers/video/rockchip/rk3328_hdmi.c b/drivers/video/rockchip/rk3328_hdmi.c
new file mode 100644 (file)
index 0000000..763669c
--- /dev/null
@@ -0,0 +1,126 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2023 Edgeble AI Technologies Pvt. Ltd.
+ */
+
+#include <clk.h>
+#include <display.h>
+#include <dm.h>
+#include <dw_hdmi.h>
+#include <asm/io.h>
+#include <asm/arch-rockchip/grf_rk3328.h>
+#include "rk_hdmi.h"
+
+#define RK3328_IO_3V_DOMAIN              (7 << (9 + 16))
+#define RK3328_IO_5V_DOMAIN              ((7 << 9) | (3 << (9 + 16)))
+#define RK3328_IO_DDC_IN_MSK             ((3 << 10) | (3 << (10 + 16)))
+#define RK3328_IO_CTRL_BY_HDMI           ((1 << 13) | (1 << (13 + 16)))
+
+static int rk3328_hdmi_enable(struct udevice *dev, int panel_bpp,
+                             const struct display_timing *edid)
+{
+       struct rk_hdmi_priv *priv = dev_get_priv(dev);
+
+       return dw_hdmi_enable(&priv->hdmi, edid);
+}
+
+static int rk3328_dw_hdmi_phy_cfg(struct dw_hdmi *hdmi, uint pixclock)
+{
+       struct rk_hdmi_priv *priv = container_of(hdmi, struct rk_hdmi_priv, hdmi);
+       int ret;
+
+       ret = generic_phy_init(&priv->phy);
+       if (ret) {
+               printf("failed to init phy (ret=%d)\n", ret);
+               return ret;
+       }
+
+       ret = generic_phy_power_on(&priv->phy);
+       if (ret) {
+               printf("failed to power on phy (ret=%d)\n", ret);
+               return ret;
+       }
+
+       return 0;
+}
+
+static void rk3328_dw_hdmi_setup_hpd(struct dw_hdmi *hdmi)
+{
+       struct rk_hdmi_priv *priv = container_of(hdmi, struct rk_hdmi_priv, hdmi);
+       struct rk3328_grf_regs *grf = priv->grf;
+
+       writel(RK3328_IO_DDC_IN_MSK, &grf->soc_con[2]);
+       writel(RK3328_IO_CTRL_BY_HDMI, &grf->soc_con[3]);
+}
+
+static void rk3328_dw_hdmi_read_hpd(struct dw_hdmi *hdmi, bool hpd_status)
+{
+       struct rk_hdmi_priv *priv = container_of(hdmi, struct rk_hdmi_priv, hdmi);
+       struct rk3328_grf_regs *grf = priv->grf;
+
+       if (hpd_status)
+               writel(RK3328_IO_5V_DOMAIN, &grf->soc_con[4]);
+       else
+               writel(RK3328_IO_3V_DOMAIN, &grf->soc_con[4]);
+}
+
+static const struct dw_hdmi_phy_ops dw_hdmi_rk3328_phy_ops = {
+       .phy_set = rk3328_dw_hdmi_phy_cfg,
+       .setup_hpd = rk3328_dw_hdmi_setup_hpd,
+       .read_hpd = rk3328_dw_hdmi_read_hpd,
+};
+
+static int rk3328_hdmi_of_to_plat(struct udevice *dev)
+{
+       struct rk_hdmi_priv *priv = dev_get_priv(dev);
+       struct dw_hdmi *hdmi = &priv->hdmi;
+
+       hdmi->i2c_clk_high = 0x71;
+       hdmi->i2c_clk_low = 0x76;
+
+       rk_hdmi_of_to_plat(dev);
+
+       hdmi->ops = &dw_hdmi_rk3328_phy_ops;
+
+       return 0;
+}
+
+static int rk3328_hdmi_probe(struct udevice *dev)
+{
+       struct rk_hdmi_priv *priv = dev_get_priv(dev);
+       int ret;
+
+       ret = generic_phy_get_by_name(dev, "hdmi", &priv->phy);
+       if (ret) {
+               printf("failed to get hdmi phy\n");
+               return ret;
+       };
+
+       ret = rk_hdmi_probe(dev);
+       if (ret) {
+               printf("failed to probe rk hdmi\n");
+               return ret;
+       }
+
+       return 0;
+}
+
+static const struct dm_display_ops rk3328_hdmi_ops = {
+       .read_edid = rk_hdmi_read_edid,
+       .enable = rk3328_hdmi_enable,
+};
+
+static const struct udevice_id rk3328_hdmi_ids[] = {
+       { .compatible = "rockchip,rk3328-dw-hdmi" },
+       { }
+};
+
+U_BOOT_DRIVER(rk3328_hdmi_rockchip) = {
+       .name = "rk3328_hdmi_rockchip",
+       .id = UCLASS_DISPLAY,
+       .of_match = rk3328_hdmi_ids,
+       .ops = &rk3328_hdmi_ops,
+       .of_to_plat = rk3328_hdmi_of_to_plat,
+       .probe = rk3328_hdmi_probe,
+       .priv_auto      = sizeof(struct rk_hdmi_priv),
+};
index 200dbaea740fc89a9f9d47d49bffe2591f621e53..dcfba3d3d7e9228b591837d4a46e7e21c760d57b 100644 (file)
@@ -6,6 +6,8 @@
 #ifndef __RK_HDMI_H__
 #define __RK_HDMI_H__
 
+#include <generic-phy.h>
+
 struct rkhdmi_driverdata {
        /* configuration */
        u8 i2c_clk_high;
@@ -19,6 +21,7 @@ struct rkhdmi_driverdata {
 
 struct rk_hdmi_priv {
        struct dw_hdmi hdmi;
+       struct phy phy;
        void *grf;
 };