gma panel config: Turn `internal display type` into a `panel port`

Instead of querying for the type of the internal display (LVDS vs. DP),
make it a choice of the port that has a panel hooked up. As some plat-
forms actually have support for two panels, we prepare for that by
naming it `Panel_1_Port`.

We still need to call into the panel logic, when the respective port
is enabled. This will be done in the next commit.

Change-Id: Id3c78441857d07fb34274b9abd3ae6ea42909ff6
Signed-off-by: Nico Huber <nico.huber@secunet.com>
Reviewed-on: https://review.coreboot.org/c/libgfxinit/+/38242
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Tested-by: Nico Huber <nico.h@gmx.de>
diff --git a/common/Makefile.inc b/common/Makefile.inc
index 4cbdaaa..9378f41 100644
--- a/common/Makefile.inc
+++ b/common/Makefile.inc
@@ -50,7 +50,7 @@
 CONFIG_GFX_GMA_GENERATION	:= $(call strip_quotes,$(CONFIG_GFX_GMA_GENERATION))
 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_PANEL_1_PORT	:= $(call strip_quotes,$(CONFIG_GFX_GMA_PANEL_1_PORT))
 CONFIG_GFX_GMA_ANALOG_I2C_PORT	:= $(call strip_quotes,$(CONFIG_GFX_GMA_ANALOG_I2C_PORT))
 
 _GEN_NONCONST := $(strip \
@@ -72,7 +72,7 @@
 $(hw-gfx-gma-config-ads): $(dir)/hw-gfx-gma-config.ads.template $(cnf)
 	printf "    GENERATE   $(patsubst /%,%,$(subst $(obj)/,,$@))\n"
 	sed -e's/<<GEN>>/$(CONFIG_GFX_GMA_GENERATION)/' \
-	    -e's/<<INTERNAL_PORT>>/$(CONFIG_GFX_GMA_INTERNAL_PORT)/' \
+	    -e's/<<PANEL_1_PORT>>/$(CONFIG_GFX_GMA_PANEL_1_PORT)/' \
 	    -e's/<<ANALOG_I2C_PORT>>/$(CONFIG_GFX_GMA_ANALOG_I2C_PORT)/' \
 	    -e's/<<DEFAULT_MMIO_BASE>>/$(CONFIG_GFX_GMA_DEFAULT_MMIO)/' \
 	    -e'/constant Gen_CPU\(_Var\)\?/d' \
@@ -90,7 +90,7 @@
 	sed -e's/<<GEN>>/$(CONFIG_GFX_GMA_GENERATION)/' \
 	    -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/<<PANEL_1_PORT>>/$(CONFIG_GFX_GMA_PANEL_1_PORT)/' \
 	    -e's/<<ANALOG_I2C_PORT>>/$(CONFIG_GFX_GMA_ANALOG_I2C_PORT)/' \
 	    -e's/<<DEFAULT_MMIO_BASE>>/$(CONFIG_GFX_GMA_DEFAULT_MMIO)/' \
 	    -e":s$$(printf '\n ')/,$$/{N;s/,\n.*Dyn_CPU\(_Var\)\?[^,)]*//;ts$$(printf '\n ')P;D;}" \
diff --git a/common/hw-gfx-gma-config.ads.template b/common/hw-gfx-gma-config.ads.template
index db03a07..2467440 100644
--- a/common/hw-gfx-gma-config.ads.template
+++ b/common/hw-gfx-gma-config.ads.template
@@ -43,7 +43,7 @@
 
    CPU_Var : constant Gen_CPU_Variant := <<CPU_VARIANT>>;
 
-   Internal_Display : constant Internal_Type := <<INTERNAL_PORT>>;
+   Panel_1_Port : constant Port_Type := <<PANEL_1_PORT>>;
 
    Analog_I2C_Port : constant PCH_Port := <<ANALOG_I2C_PORT>>;
 
@@ -146,7 +146,6 @@
    Have_HDMI_Buf_Override  : constant Boolean := DDI_HDMI_Buffer_Translation >= 0;
    Default_MMIO_Base_Set   : constant Boolean := Default_MMIO_Base /= 0;
 
-   Internal_Is_EDP         : constant Boolean := Internal_Display = DP;
    Have_DVI_I              : constant Boolean := Analog_I2C_Port /= PCH_DAC;
 
    Has_Presence_Straps           : <genbool> := not Gen_Broxton;
diff --git a/common/hw-gfx-gma-panel.adb b/common/hw-gfx-gma-panel.adb
index 968fbbe..b40689b 100644
--- a/common/hw-gfx-gma-panel.adb
+++ b/common/hw-gfx-gma-panel.adb
@@ -217,11 +217,13 @@
 
       if Override_Delays then
          if Config.Has_PP_Port_Select then
-            if Config.Internal_Is_EDP then
-               Port_Select := PCH_PP_ON_DELAYS_PORT_SELECT_DP_A;
-            else
-               Port_Select := PCH_PP_ON_DELAYS_PORT_SELECT_LVDS;
-            end if;
+            Port_Select :=
+              (case Config.Panel_1_Port is
+                  when LVDS         => PCH_PP_ON_DELAYS_PORT_SELECT_LVDS,
+                  when eDP          => PCH_PP_ON_DELAYS_PORT_SELECT_DP_A,
+                  when DP2 | HDMI2  => PCH_PP_ON_DELAYS_PORT_SELECT_DP_C,
+                  when DP3 | HDMI3  => PCH_PP_ON_DELAYS_PORT_SELECT_DP_D,
+                  when others       => 0);
          else
             Port_Select := 0;
          end if;
diff --git a/configs/broxton b/configs/broxton
index 5006125..35a6f6c 100644
--- a/configs/broxton
+++ b/configs/broxton
@@ -2,6 +2,6 @@
 CONFIG_GFX_GMA_GENERATION	= Broxton
 CONFIG_GFX_GMA_CPU		= Broxton
 CONFIG_GFX_GMA_CPU_VARIANT	= Normal	# N/A
-CONFIG_GFX_GMA_INTERNAL_PORT	= DP
+CONFIG_GFX_GMA_PANEL_1_PORT	= eDP
 CONFIG_GFX_GMA_ANALOG_I2C_PORT	= PCH_DAC	# N/A
 CONFIG_GFX_GMA_DEFAULT_MMIO	= 16\#e000_0000\#
diff --git a/configs/g45 b/configs/g45
index 44404b9..2f0f679 100644
--- a/configs/g45
+++ b/configs/g45
@@ -1,5 +1,5 @@
 CONFIG_GFX_GMA_DYN_CPU		= y
 CONFIG_GFX_GMA_GENERATION	= G45
-CONFIG_GFX_GMA_INTERNAL_PORT	= LVDS
+CONFIG_GFX_GMA_PANEL_1_PORT	= LVDS
 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 8adaafc..3924572 100644
--- a/configs/haswell
+++ b/configs/haswell
@@ -1,5 +1,5 @@
 CONFIG_GFX_GMA_DYN_CPU		= y
 CONFIG_GFX_GMA_GENERATION	= Haswell
-CONFIG_GFX_GMA_INTERNAL_PORT	= DP
+CONFIG_GFX_GMA_PANEL_1_PORT	= eDP
 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 20b33a7..494b505 100644
--- a/configs/ironlake
+++ b/configs/ironlake
@@ -1,5 +1,5 @@
 CONFIG_GFX_GMA_DYN_CPU		= y
 CONFIG_GFX_GMA_GENERATION	= Ironlake
-CONFIG_GFX_GMA_INTERNAL_PORT	= LVDS
+CONFIG_GFX_GMA_PANEL_1_PORT	= LVDS
 CONFIG_GFX_GMA_ANALOG_I2C_PORT	= PCH_DAC
 CONFIG_GFX_GMA_DEFAULT_MMIO	= 16\#e000_0000\#
diff --git a/configs/ironlake_edp b/configs/ironlake_edp
index 9bc56c3..90804c2 100644
--- a/configs/ironlake_edp
+++ b/configs/ironlake_edp
@@ -1,5 +1,5 @@
 CONFIG_GFX_GMA_DYN_CPU		= y
 CONFIG_GFX_GMA_GENERATION	= Ironlake
-CONFIG_GFX_GMA_INTERNAL_PORT	= DP
+CONFIG_GFX_GMA_PANEL_1_PORT	= eDP
 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 7ae760a..773e7cf 100644
--- a/configs/skylake
+++ b/configs/skylake
@@ -1,5 +1,5 @@
 CONFIG_GFX_GMA_DYN_CPU		= y
 CONFIG_GFX_GMA_GENERATION	= Skylake
-CONFIG_GFX_GMA_INTERNAL_PORT	= DP
+CONFIG_GFX_GMA_PANEL_1_PORT	= eDP
 CONFIG_GFX_GMA_ANALOG_I2C_PORT	= PCH_DAC
 CONFIG_GFX_GMA_DEFAULT_MMIO	= 16\#e000_0000\#