gma hsw: Enable Power Down Well for scaling on DDI A

The primary pipe can drive DDI A (eDP) without the Power Down
Well (PDW). The scalers are inside the PDW, though. To enable
scaling for DDI A, ensure the PDW is active.

When switching between scaled / unscaled modes, we'll have to
reconfigure the whole pipe.

Change-Id: I46318bb74d00a584d268a9d76787f8b26249264d
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/26663
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
diff --git a/common/haswell_shared/hw-gfx-gma-power_and_clocks_haswell.adb b/common/haswell_shared/hw-gfx-gma-power_and_clocks_haswell.adb
index c0d1e78..1c23254 100644
--- a/common/haswell_shared/hw-gfx-gma-power_and_clocks_haswell.adb
+++ b/common/haswell_shared/hw-gfx-gma-power_and_clocks_haswell.adb
@@ -1,5 +1,5 @@
 --
--- Copyright (C) 2014-2016 secunet Security Networks AG
+-- Copyright (C) 2014-2018 secunet Security Networks AG
 --
 -- This program is free software; you can redistribute it and/or modify
 -- it under the terms of the GNU General Public License as published by
@@ -185,12 +185,19 @@
       end if;
    end PDW_On;
 
-   function Need_PDW (Checked_Configs : Pipe_Configs) return Boolean is
+   function Need_PDW (Checked_Configs : Pipe_Configs) return Boolean
+   is
+      Primary : Pipe_Config renames Checked_Configs (GMA.Primary);
    begin
-      return (Checked_Configs (Primary).Port /= Disabled and
-              Checked_Configs (Primary).Port /= Internal) or
-             Checked_Configs (Secondary).Port /= Disabled or
-             Checked_Configs (Tertiary).Port /= Disabled;
+      return
+         (Config.Use_PDW_For_EDP_Scaling and then
+          (Primary.Port = Internal and Requires_Scaling (Primary)))
+         or
+         (Primary.Port /= Disabled and Primary.Port /= Internal)
+         or
+         Checked_Configs (Secondary).Port /= Disabled
+         or
+         Checked_Configs (Tertiary).Port /= Disabled;
    end Need_PDW;
 
    ----------------------------------------------------------------------------