gma: Move Legacy_VGA_Off() into Pipe_Setup

It's about the VGA plane and thus belongs into Pipe_Setup.

Change-Id: I2f59b027c47c06b01f36695c517ed0847617a472
Signed-off-by: Nico Huber <nico.huber@secunet.com>
Reviewed-on: https://review.coreboot.org/17762
Tested-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
diff --git a/common/hw-gfx-gma-pipe_setup.adb b/common/hw-gfx-gma-pipe_setup.adb
index ca57855..6293f20 100644
--- a/common/hw-gfx-gma-pipe_setup.adb
+++ b/common/hw-gfx-gma-pipe_setup.adb
@@ -70,7 +70,10 @@
 
    SPCNTR_ENABLE : constant :=  1 * 2 ** 31;
 
-   VGA_SR01_SCREEN_OFF                 : constant :=        1 * 2 **  5;
+   VGA_SR_INDEX                        : constant :=   16#03c4#;
+   VGA_SR_DATA                         : constant :=   16#03c5#;
+   VGA_SR01                            : constant :=     16#01#;
+   VGA_SR01_SCREEN_OFF                 : constant := 1 * 2 ** 5;
 
    VGA_CONTROL_VGA_DISPLAY_DISABLE     : constant :=        1 * 2 ** 31;
    VGA_CONTROL_BLINK_DUTY_CYCLE_MASK   : constant := 16#0003# * 2 **  6;
@@ -773,6 +776,18 @@
       Trans_Clk_Off (Controllers (Pipe));
    end Off;
 
+   procedure Legacy_VGA_Off
+   is
+      use type HW.Word8;
+      Reg8 : Word8;
+   begin
+      Port_IO.OutB (VGA_SR_INDEX, VGA_SR01);
+      Port_IO.InB  (Reg8, VGA_SR_DATA);
+      Port_IO.OutB (VGA_SR_DATA, Reg8 or VGA_SR01_SCREEN_OFF);
+      Time.U_Delay (100); -- PRM says 100us, Linux does 300
+      Registers.Set_Mask (Registers.VGACNTRL, VGA_CONTROL_VGA_DISPLAY_DISABLE);
+   end Legacy_VGA_Off;
+
    procedure All_Off
    is
       EDP_Enabled, EDP_Piped : Boolean;
@@ -793,6 +808,8 @@
    begin
       pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
 
+      Legacy_VGA_Off;
+
       if Config.Has_EDP_Pipe then
          Registers.Is_Set_Mask
            (Registers.PIPE_EDP_CONF, PIPECONF_ENABLE, EDP_Enabled);
diff --git a/common/hw-gfx-gma-pipe_setup.ads b/common/hw-gfx-gma-pipe_setup.ads
index 01560ab..a57ca18 100644
--- a/common/hw-gfx-gma-pipe_setup.ads
+++ b/common/hw-gfx-gma-pipe_setup.ads
@@ -30,6 +30,8 @@
 
    procedure Off (Pipe : Pipe_Index; Port_Cfg : Port_Config);
 
+   procedure Legacy_VGA_Off;
+
    procedure All_Off;
 
    function Get_Pipe_Hint (Pipe : Pipe_Index) return Word32;
diff --git a/common/hw-gfx-gma.adb b/common/hw-gfx-gma.adb
index 379421c..0fb4e5d 100644
--- a/common/hw-gfx-gma.adb
+++ b/common/hw-gfx-gma.adb
@@ -28,7 +28,6 @@
 with HW.Debug;
 with GNAT.Source_Info;
 
-use type HW.Word8;
 use type HW.Int32;
 
 package body HW.GFX.GMA
@@ -84,20 +83,6 @@
 
    ----------------------------------------------------------------------------
 
-   procedure Legacy_VGA_Off
-   is
-      Reg8 : Word8;
-   begin
-      -- disable legacy VGA plane, taking over control now
-      Port_IO.OutB (VGA_SR_INDEX, VGA_SR01);
-      Port_IO.InB  (Reg8, VGA_SR_DATA);
-      Port_IO.OutB (VGA_SR_DATA, Reg8 or 1 * 2 ** 5);
-      Time.U_Delay (100); -- PRM says 100us, Linux does 300
-      Registers.Set_Mask (Registers.VGACNTRL, 1 * 2 ** 31);
-   end Legacy_VGA_Off;
-
-   ----------------------------------------------------------------------------
-
    procedure Update_Outputs (Configs : Pipe_Configs)
    is
       Did_Power_Up : Boolean := False;
@@ -354,9 +339,6 @@
       Panel.Setup_PP_Sequencer;
       Port_Detect.Initialize;
 
-      Legacy_VGA_Off;   -- According to PRMs, VGA plane is the only
-                        -- thing that's enabled by default after reset.
-
       if Clean_State then
          Power_And_Clocks.Pre_All_Off;
          Connectors.Pre_All_Off;
@@ -364,6 +346,10 @@
          Connectors.Post_All_Off;
          PLLs.All_Off;
          Power_And_Clocks.Post_All_Off;
+      else
+         -- According to PRMs, VGA plane is the only thing
+         -- that's enabled by default after reset.
+         Display_Controller.Legacy_VGA_Off;
       end if;
 
       -------------------- Now restart from a clean state ---------------------
diff --git a/common/hw-gfx-gma.ads b/common/hw-gfx-gma.ads
index 87b464a..45f57f4 100644
--- a/common/hw-gfx-gma.ads
+++ b/common/hw-gfx-gma.ads
@@ -75,8 +75,6 @@
    with
       Global => (Input => Init_State);
 
-   procedure Legacy_VGA_Off;
-
    procedure Update_Outputs (Configs : Pipe_Configs);
 
    pragma Warnings (GNATprove, Off, "subprogram ""Dump_Configs"" has no effect",
@@ -134,10 +132,4 @@
 
    type DP_Port is (DP_A, DP_B, DP_C, DP_D);
 
-   ----------------------------------------------------------------------------
-
-   VGA_SR_INDEX   : constant Port_IO.Port_Type  := 16#03c4#;
-   VGA_SR_DATA    : constant Port_IO.Port_Type  := 16#03c5#;
-   VGA_SR01       : constant Word8 := 16#01#;
-
 end HW.GFX.GMA;