gma ilk: Handle Ibex Peak DP correctly

We missed some bits specific to Ibex Peak DPs. Namely, the training
pattern selection moved and we have to select the transcoder in the
`DP_CTL` register as there is no separate DP transcoder register.

The latter is quirky, however. If a port (DP or HDMI) is disabled
with the second transcoder selected. This selection sticks and the
sibling port (e.g. DP2 to HDMI2) can't be enabled with the first
transcoder. As a workaround, we are supposed to enable a port that
was using the second transcoder with the first transcoder selected
again.

Change-Id: I0c1fafc2ba113aeeaf4ace750b333cc270bca37c
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/libgfxinit/+/35740
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
diff --git a/common/ironlake/hw-gfx-gma-pch-hdmi.adb b/common/ironlake/hw-gfx-gma-pch-hdmi.adb
index aaf7951..9426a86 100644
--- a/common/ironlake/hw-gfx-gma-pch-hdmi.adb
+++ b/common/ironlake/hw-gfx-gma-pch-hdmi.adb
@@ -72,14 +72,35 @@
 
    procedure Off (Port : PCH_HDMI_Port)
    is
+      With_Transcoder_B_Enabled : Boolean := False;
    begin
       pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
 
+      if not Config.Has_Trans_DP_Ctl then
+         -- Ensure transcoder select isn't set to B,
+         -- disabled HDMI may block DP otherwise.
+         Registers.Is_Set_Mask
+           (Register => PCH_HDMI (Port),
+            Mask     => PCH_HDMI_ENABLE or
+                        PCH_TRANSCODER_SELECT (FDI_B),
+            Result   => With_Transcoder_B_Enabled);
+      end if;
+
       Registers.Unset_And_Set_Mask
          (Register   => PCH_HDMI (Port),
           Mask_Unset => PCH_HDMI_MASK,
           Mask_Set   => PCH_HDMI_HSYNC_ACTIVE_HIGH or
                         PCH_HDMI_VSYNC_ACTIVE_HIGH);
+      Registers.Posting_Read (PCH_HDMI (Port));
+
+      if not Config.Has_Trans_DP_Ctl and then With_Transcoder_B_Enabled then
+         -- Reenable with transcoder A selected to switch.
+         Registers.Set_Mask (PCH_HDMI (Port), PCH_HDMI_ENABLE);
+         Registers.Posting_Read (PCH_HDMI (Port));
+         Registers.Unset_Mask (PCH_HDMI (Port), PCH_HDMI_ENABLE);
+         Registers.Posting_Read (PCH_HDMI (Port));
+      end if;
+
    end Off;
 
    procedure All_Off