]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
video: dw_hdmi: Add support for ddc-i2c-bus property
authorNiklas Schulze <me@jns.io>
Sat, 27 Jul 2019 12:07:13 +0000 (12:07 +0000)
committerAnatolij Gustschin <agust@denx.de>
Sun, 28 Jul 2019 22:32:59 +0000 (00:32 +0200)
Add support for the ddc-i2c-bus device tree property which allows
for using an external i2c master for reading the display's EDID.

Signed-off-by: Niklas Schulze <me@jns.io>
drivers/video/dw_hdmi.c
drivers/video/meson/meson_dw_hdmi.c
drivers/video/rockchip/rk_hdmi.c
drivers/video/sunxi/sunxi_dw_hdmi.c
include/dw_hdmi.h

index 463436edf3ea90b7eb6ee8f2e62e086b4b73557b..bf74d6adf204053930c7d8c0a7251ca1dddc8724 100644 (file)
@@ -8,6 +8,7 @@
 #include <common.h>
 #include <fdtdec.h>
 #include <asm/io.h>
+#include <i2c.h>
 #include <media_bus_format.h>
 #include "dw_hdmi.h"
 
@@ -812,6 +813,18 @@ static int hdmi_read_edid(struct dw_hdmi *hdmi, int block, u8 *buff)
        u32 trytime = 5;
        u32 n;
 
+       if (CONFIG_IS_ENABLED(DM_I2C) && hdmi->ddc_bus) {
+               struct udevice *chip;
+
+               edid_read_err = i2c_get_chip(hdmi->ddc_bus,
+                                            HDMI_I2CM_SLAVE_DDC_ADDR,
+                                            1, &chip);
+               if (edid_read_err)
+                       return edid_read_err;
+
+               return dm_i2c_read(chip, shift, buff, HDMI_EDID_BLOCK_SIZE);
+       }
+
        /* set ddc i2c clk which devided from ddc_clk to 100khz */
        hdmi_write(hdmi, hdmi->i2c_clk_high, HDMI_I2CM_SS_SCL_HCNT_0_ADDR);
        hdmi_write(hdmi, hdmi->i2c_clk_low, HDMI_I2CM_SS_SCL_LCNT_0_ADDR);
index 617f75724b544163095ed5fbe87fcfbc49ad5231..9831d978fca4834e92d1211f89032edcf5cbb5c1 100644 (file)
@@ -375,6 +375,9 @@ static int meson_dw_hdmi_probe(struct udevice *dev)
        }
 #endif
 
+       uclass_get_device_by_phandle(UCLASS_I2C, dev, "ddc-i2c-bus",
+                                    &priv->hdmi.ddc_bus);
+
        ret = reset_get_bulk(dev, &resets);
        if (ret)
                return ret;
index 51931ceefae35cf3e64622f20f6a876a70ec32f5..5b44a7e8c97d76a756d38d86bae651ec956cf27e 100644 (file)
@@ -93,6 +93,9 @@ int rk_hdmi_ofdata_to_platdata(struct udevice *dev)
 
        priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
 
+       uclass_get_device_by_phandle(UCLASS_I2C, dev, "ddc-i2c-bus",
+                                    &hdmi->ddc_bus);
+
        return 0;
 }
 
index 6fe1aa7ee469590e67b7be513d7755f1ceb67456..cec23295b5cb2069437b30ee731233e69ceddb14 100644 (file)
@@ -373,6 +373,9 @@ static int sunxi_dw_hdmi_probe(struct udevice *dev)
        priv->hdmi.phy_set = sunxi_dw_hdmi_phy_cfg;
        priv->mux = uc_plat->source_id;
 
+       uclass_get_device_by_phandle(UCLASS_I2C, dev, "ddc-i2c-bus",
+                                    &priv->hdmi.ddc_bus);
+
        dw_hdmi_init(&priv->hdmi);
 
        return 0;
index 90fb64bc9988df4aff89607406e61383de5352b1..8acae3839fb3efb7ed97e01cc08292928baacbb1 100644 (file)
@@ -542,6 +542,7 @@ struct dw_hdmi {
        u8 i2c_clk_low;
        u8 reg_io_width;
        struct hdmi_data_info hdmi_data;
+       struct udevice *ddc_bus;
 
        int (*phy_set)(struct dw_hdmi *hdmi, uint mpixelclock);
        void (*write_reg)(struct dw_hdmi *hdmi, u8 val, int offset);