video: dw_hdmi: Add support for ddc-i2c-bus property

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>
diff --git a/drivers/video/dw_hdmi.c b/drivers/video/dw_hdmi.c
index 463436e..bf74d6a 100644
--- a/drivers/video/dw_hdmi.c
+++ b/drivers/video/dw_hdmi.c
@@ -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 @@
 	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);