gma config: Initialize stateful configs late

Defer initialization of config variables until GMA.Initialize().

Change-Id: I9192c9a7c4d67e4af7f3e26659489f58998ae832
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/libgfxinit/+/27066
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
diff --git a/common/hw-gfx-gma-config.ads.template b/common/hw-gfx-gma-config.ads.template
index ea42443..d12a9f1 100644
--- a/common/hw-gfx-gma-config.ads.template
+++ b/common/hw-gfx-gma-config.ads.template
@@ -12,10 +12,7 @@
 -- GNU General Public License for more details.
 --
 
-private package HW.GFX.GMA.Config
-with
-   Initializes => Variable
-is
+private package HW.GFX.GMA.Config is
 
    Gen : constant Generation := <<GEN>>;
 
@@ -64,11 +61,11 @@
       Raw_Clock      : Frequency_Type;
    end record;
 
-   Variable : Variable_Config :=
+   Initial_Settings : constant Variable_Config :=
      (Valid_Port     => (others => False),
-      Raw_Clock      => Frequency_Type'First)
-   with
-      Part_Of => GMA.Config_State;
+      Raw_Clock      => Frequency_Type'First);
+
+   Variable : Variable_Config with Part_Of => GMA.Config_State;
 
    Valid_Port  : Valid_Port_Array renames Variable.Valid_Port;
    Raw_Clock   : Frequency_Type renames Variable.Raw_Clock;
diff --git a/common/hw-gfx-gma.adb b/common/hw-gfx-gma.adb
index b62ebce..1d97adb 100644
--- a/common/hw-gfx-gma.adb
+++ b/common/hw-gfx-gma.adb
@@ -370,13 +370,11 @@
       Success     :    out Boolean)
    with
       Refined_Global =>
-        (In_Out =>
-           (Config.Variable, Dev.PCI_State,
-            Registers.Register_State, Port_IO.State),
-         Input =>
-           (Time.State),
+        (Input => (Time.State),
+         In_Out => (Dev.PCI_State, Registers.Register_State, Port_IO.State),
          Output =>
-           (Dev.Address_State,
+           (Config.Variable,
+            Dev.Address_State,
             Registers.Address_State,
             PLLs.State, Panel.Panel_State,
             Cur_Configs, Allocated_PLLs,
@@ -444,6 +442,7 @@
             Framebuffer => HW.GFX.Default_FB,
             Cursor      => Default_Cursor,
             Mode        => HW.GFX.Invalid_Mode));
+      Config.Variable := Config.Initial_Settings;
       PLLs.Initialize;
 
       Dev.Initialize (Success);
diff --git a/common/hw-gfx-gma.ads b/common/hw-gfx-gma.ads
index db7f2bf..7c40dd9 100644
--- a/common/hw-gfx-gma.ads
+++ b/common/hw-gfx-gma.ads
@@ -25,9 +25,7 @@
       Init_State,
       Config_State,
       (Device_State with External)),
-   Initializes =>
-     (Init_State,
-      Config_State)
+   Initializes => Init_State
 is
 
    GTT_Page_Size : constant := 4096;
@@ -101,8 +99,8 @@
       Success     :    out Boolean)
    with
       Global =>
-        (In_Out => (Config_State, Device_State, Port_IO.State),
-         Output => (State, Init_State),
+        (In_Out => (Device_State, Port_IO.State),
+         Output => (State, Init_State, Config_State),
          Input  => (Time.State)),
       Post => Success = Is_Initialized;
    function Is_Initialized return Boolean