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);