Merge tag 'u-boot-imx-20200108' of https://gitlab.denx.de/u-boot/custodians/u-boot-imx
[oweals/u-boot.git] / drivers / video / dw_hdmi.c
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);