gma hsw+: Treat DDI E and PCH DAC disabling separately

We only use DDI E for analog VGA outputs through the PCH DAC. DDI E
might be configured differently, though, by a previously running dri-
ver, so we have to treat the two entities seperately on the All_Off()
path.

Change-Id: I603ecd29c48af43bc21acaadbedaeae451acbcf3
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/20822
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
diff --git a/common/haswell_shared/hw-gfx-gma-connectors-ddi.adb b/common/haswell_shared/hw-gfx-gma-connectors-ddi.adb
index fa62a98..b6d7284 100644
--- a/common/haswell_shared/hw-gfx-gma-connectors-ddi.adb
+++ b/common/haswell_shared/hw-gfx-gma-connectors-ddi.adb
@@ -732,7 +732,7 @@
    begin
       pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
 
-      if Port = DIGI_E then
+      if Config.Has_PCH_DAC and then Port = DIGI_E then
          PCH.VGA.Off;
          PCH.Transcoder.Off (PCH.FDI_A);
          -- PCH.VGA.Clock_Off; -- Can't tell what Linux does, if anything.
@@ -743,7 +743,9 @@
 
       if Port = DIGI_E then
          SPLL.Off;
-         PCH.FDI.Off (PCH.FDI_A, PCH.FDI.Clock_Off);
+         if Config.Has_PCH_DAC then
+            PCH.FDI.Off (PCH.FDI_A, PCH.FDI.Clock_Off);
+         end if;
       end if;
    end Off;
 
diff --git a/common/haswell_shared/hw-gfx-gma-connectors.adb b/common/haswell_shared/hw-gfx-gma-connectors.adb
index eb080e8..0d0ed71 100644
--- a/common/haswell_shared/hw-gfx-gma-connectors.adb
+++ b/common/haswell_shared/hw-gfx-gma-connectors.adb
@@ -98,9 +98,6 @@
       for Port in Digital_Port range DIGI_A .. Config.Last_Digital_Port loop
          DDI.Off (Port);
       end loop;
-      if Config.Is_FDI_Port (Analog) then
-         DDI.Off (DIGI_E);
-      end if;
    end Post_All_Off;
 
 end HW.GFX.GMA.Connectors;
diff --git a/common/haswell_shared/hw-gfx-gma-port_detect.adb b/common/haswell_shared/hw-gfx-gma-port_detect.adb
index 1302cf0..be83bd5 100644
--- a/common/haswell_shared/hw-gfx-gma-port_detect.adb
+++ b/common/haswell_shared/hw-gfx-gma-port_detect.adb
@@ -124,7 +124,9 @@
       Config.Valid_Port (Internal) := Internal_Detected;
 
       -- DDI_[BCD]
-      for Port in Ext_Digital_Port range DIGI_B .. Config.Last_Digital_Port loop
+      for Port in Ext_Digital_Port range
+         DIGI_B .. Ext_Digital_Port'Min (DIGI_D, Config.Last_Digital_Port)
+      loop
          if Config.Has_Presence_Straps then
             Registers.Is_Set_Mask
               (Register => Registers.SFUSE_STRAP,
diff --git a/common/hw-gfx-gma-config.ads.template b/common/hw-gfx-gma-config.ads.template
index 98259ff..5bd8eb0 100644
--- a/common/hw-gfx-gma-config.ads.template
+++ b/common/hw-gfx-gma-config.ads.template
@@ -180,7 +180,7 @@
    Valid_Port : Valid_Per_Port renames Valid_Port_GPU (CPU);
 
    Last_Digital_Port : constant Digital_Port :=
-     (if Has_DDI_D then DIGI_D else DIGI_C);
+     (if Has_DDI_E then DIGI_E else DIGI_C);
 
    ----------------------------------------------------------------------------
 
@@ -190,11 +190,8 @@
          when Ironlake .. Ivybridge => FDI_Per_Port'
            (Internal => Internal_Display = LVDS,
             others   => True),
-         when Haswell => FDI_Per_Port'
-           (Analog   => True,
-            others   => False),
-         when Broadwell => FDI_Per_Port'
-           (Analog   => CPU_Var = Normal,
+         when Haswell .. Broadwell => FDI_Per_Port'
+           (Analog   => Has_PCH_DAC,
             others   => False),
          when others => FDI_Per_Port'
            (others   => False));