gma i2c: Make I2C port for VGA displays a config option

Boards with a DVI-I connector share the I2C pins for both analog and
digital displays. In that case, the EDID for a VGA display has to be
read over the I2C interface of the coupled digital port.

TEST=Booted kontron/ktqm77 with DVI-I to VGA cable. Display is detected
     and enabled (but doesn't show anything, yet?).

Change-Id: I5c4f77d5ad1927f075877a3719361ed2193f4c39
Signed-off-by: Nico Huber <nico.huber@secunet.com>
Reviewed-on: https://review.coreboot.org/17086
Tested-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
diff --git a/common/Makefile.inc b/common/Makefile.inc
index 31020a9..9745eb6 100644
--- a/common/Makefile.inc
+++ b/common/Makefile.inc
@@ -42,6 +42,7 @@
 CONFIG_GFX_GMA_CPU		:= $(call strip_quotes,$(CONFIG_GFX_GMA_CPU))
 CONFIG_GFX_GMA_CPU_VARIANT	:= $(call strip_quotes,$(CONFIG_GFX_GMA_CPU_VARIANT))
 CONFIG_GFX_GMA_INTERNAL_PORT	:= $(call strip_quotes,$(CONFIG_GFX_GMA_INTERNAL_PORT))
+CONFIG_GFX_GMA_ANALOG_I2C_PORT	:= $(call strip_quotes,$(CONFIG_GFX_GMA_ANALOG_I2C_PORT))
 
 hw-gfx-gma-config-ads := $(subst //,/,$(call src-to-obj,,$(dir)/hw-gfx-gma-config).ads)
 
@@ -50,6 +51,7 @@
 	sed -e's/<<CPU>>/$(CONFIG_GFX_GMA_CPU)/' \
 	    -e's/<<CPU_VARIANT>>/$(CONFIG_GFX_GMA_CPU_VARIANT)/' \
 	    -e's/<<INTERNAL_PORT>>/$(CONFIG_GFX_GMA_INTERNAL_PORT)/' \
+	    -e's/<<ANALOG_I2C_PORT>>/$(CONFIG_GFX_GMA_ANALOG_I2C_PORT)/' \
 	    -e's/<<DEFAULT_MMIO_BASE>>/$(CONFIG_GFX_GMA_DEFAULT_MMIO)/' \
 	    $< >$@
 gfxinit-gen-y += $(hw-gfx-gma-config-ads)
diff --git a/common/hw-gfx-gma-config.ads.template b/common/hw-gfx-gma-config.ads.template
index c3a5152..1ba66a2 100644
--- a/common/hw-gfx-gma-config.ads.template
+++ b/common/hw-gfx-gma-config.ads.template
@@ -23,6 +23,8 @@
 
    Internal_Display : constant Internal_Type := <<INTERNAL_PORT>>;
 
+   Analog_I2C_Port : constant PCH_Port := <<ANALOG_I2C_PORT>>;
+
    EDP_Low_Voltage_Swing : constant Boolean := False;
 
    Default_MMIO_Base : constant := <<DEFAULT_MMIO_BASE>>;
diff --git a/common/hw-gfx-gma-connector_info.adb b/common/hw-gfx-gma-connector_info.adb
index 2ee0c05..c5dcad2 100644
--- a/common/hw-gfx-gma-connector_info.adb
+++ b/common/hw-gfx-gma-connector_info.adb
@@ -59,7 +59,9 @@
                Success  => Success);
          else
             I2C.I2C_Read
-              (Port     => Port_Cfg.PCH_Port,
+              (Port     => (if Port_Cfg.Display = VGA
+                            then Config.Analog_I2C_Port
+                            else Port_Cfg.PCH_Port),
                Address  => 16#50#,
                Length   => Raw_EDID_Length,
                Data     => Raw_EDID,
diff --git a/configs/broadwell b/configs/broadwell
index 51b9df7..9921ff8 100644
--- a/configs/broadwell
+++ b/configs/broadwell
@@ -1,4 +1,5 @@
 CONFIG_GFX_GMA_CPU		= Broadwell
 CONFIG_GFX_GMA_CPU_VARIANT	= Normal
 CONFIG_GFX_GMA_INTERNAL_PORT	= DP
+CONFIG_GFX_GMA_ANALOG_I2C_PORT	= PCH_DAC
 CONFIG_GFX_GMA_DEFAULT_MMIO	= 16#e000_0000#
diff --git a/configs/broadwell_ult b/configs/broadwell_ult
index f209293..0860a1c 100644
--- a/configs/broadwell_ult
+++ b/configs/broadwell_ult
@@ -1,4 +1,5 @@
 CONFIG_GFX_GMA_CPU		= Broadwell
 CONFIG_GFX_GMA_CPU_VARIANT	= ULT
 CONFIG_GFX_GMA_INTERNAL_PORT	= DP
+CONFIG_GFX_GMA_ANALOG_I2C_PORT	= PCH_DAC
 CONFIG_GFX_GMA_DEFAULT_MMIO	= 16#e000_0000#
diff --git a/configs/haswell b/configs/haswell
index 724d651..e4a5c04 100644
--- a/configs/haswell
+++ b/configs/haswell
@@ -1,4 +1,5 @@
 CONFIG_GFX_GMA_CPU		= Haswell
 CONFIG_GFX_GMA_CPU_VARIANT	= Normal
 CONFIG_GFX_GMA_INTERNAL_PORT	= DP
+CONFIG_GFX_GMA_ANALOG_I2C_PORT	= PCH_DAC
 CONFIG_GFX_GMA_DEFAULT_MMIO	= 16#e000_0000#
diff --git a/configs/haswell_ult b/configs/haswell_ult
index f3deac5..d9c483e 100644
--- a/configs/haswell_ult
+++ b/configs/haswell_ult
@@ -1,4 +1,5 @@
 CONFIG_GFX_GMA_CPU		= Haswell
 CONFIG_GFX_GMA_CPU_VARIANT	= ULT
 CONFIG_GFX_GMA_INTERNAL_PORT	= DP
+CONFIG_GFX_GMA_ANALOG_I2C_PORT	= PCH_DAC
 CONFIG_GFX_GMA_DEFAULT_MMIO	= 16#e000_0000#
diff --git a/configs/ironlake b/configs/ironlake
index 7450d35..8a4e66a 100644
--- a/configs/ironlake
+++ b/configs/ironlake
@@ -1,4 +1,5 @@
 CONFIG_GFX_GMA_CPU		= Ironlake
 CONFIG_GFX_GMA_CPU_VARIANT	= Normal
 CONFIG_GFX_GMA_INTERNAL_PORT	= LVDS
+CONFIG_GFX_GMA_ANALOG_I2C_PORT	= PCH_DAC
 CONFIG_GFX_GMA_DEFAULT_MMIO	= 16#e000_0000#
diff --git a/configs/ivybridge_edp b/configs/ivybridge_edp
index 53907a0..32ce3d6 100644
--- a/configs/ivybridge_edp
+++ b/configs/ivybridge_edp
@@ -1,4 +1,5 @@
 CONFIG_GFX_GMA_CPU		= Ivybridge
 CONFIG_GFX_GMA_CPU_VARIANT	= Normal
 CONFIG_GFX_GMA_INTERNAL_PORT	= DP
+CONFIG_GFX_GMA_ANALOG_I2C_PORT	= PCH_DAC
 CONFIG_GFX_GMA_DEFAULT_MMIO	= 16#e000_0000#
diff --git a/configs/ivybridge_lvds b/configs/ivybridge_lvds
index 6a77aea..930a009 100644
--- a/configs/ivybridge_lvds
+++ b/configs/ivybridge_lvds
@@ -1,4 +1,5 @@
 CONFIG_GFX_GMA_CPU		= Ivybridge
 CONFIG_GFX_GMA_CPU_VARIANT	= Normal
 CONFIG_GFX_GMA_INTERNAL_PORT	= LVDS
+CONFIG_GFX_GMA_ANALOG_I2C_PORT	= PCH_DAC
 CONFIG_GFX_GMA_DEFAULT_MMIO	= 16#e000_0000#
diff --git a/configs/sandybridge b/configs/sandybridge
index 50a6c61..7d8075f 100644
--- a/configs/sandybridge
+++ b/configs/sandybridge
@@ -1,4 +1,5 @@
 CONFIG_GFX_GMA_CPU		= Sandybridge
 CONFIG_GFX_GMA_CPU_VARIANT	= Normal
 CONFIG_GFX_GMA_INTERNAL_PORT	= LVDS
+CONFIG_GFX_GMA_ANALOG_I2C_PORT	= PCH_DAC
 CONFIG_GFX_GMA_DEFAULT_MMIO	= 16#e000_0000#
diff --git a/configs/skylake b/configs/skylake
index 7867f79..4577c84 100644
--- a/configs/skylake
+++ b/configs/skylake
@@ -1,4 +1,5 @@
 CONFIG_GFX_GMA_CPU		= Skylake
 CONFIG_GFX_GMA_CPU_VARIANT	= Normal
 CONFIG_GFX_GMA_INTERNAL_PORT	= DP
+CONFIG_GFX_GMA_ANALOG_I2C_PORT	= PCH_DAC
 CONFIG_GFX_GMA_DEFAULT_MMIO	= 16#e000_0000#
diff --git a/configs/skylake_ult b/configs/skylake_ult
index 8c386db..5e67484 100644
--- a/configs/skylake_ult
+++ b/configs/skylake_ult
@@ -1,4 +1,5 @@
 CONFIG_GFX_GMA_CPU		= Skylake
 CONFIG_GFX_GMA_CPU_VARIANT	= ULT
 CONFIG_GFX_GMA_INTERNAL_PORT	= DP
+CONFIG_GFX_GMA_ANALOG_I2C_PORT	= PCH_DAC
 CONFIG_GFX_GMA_DEFAULT_MMIO	= 16#e000_0000#