[coreboot-gerrit] Change in libgfxinit[master]: gma config: Introduce per generation/CPU booleans

Nico Huber (Code Review) gerrit at coreboot.org
Wed Jun 13 01:27:39 CEST 2018


Nico Huber has uploaded this change for review. ( https://review.coreboot.org/27060


Change subject: gma config: Introduce per generation/CPU booleans
......................................................................

gma config: Introduce per generation/CPU booleans

The per CPU booleans are additionally guarded by the respective
generation so that the compiler may decide purely on the generation.
Also use the new booleans to get rid of all direct references to
`Config.CPU` and `Config.CPU_Var`.

Change-Id: I307d1dd56f480fdb4fbc6e2e25fc5f413c4158f8
Signed-off-by: Nico Huber <nico.h at gmx.de>
---
M common/hw-gfx-gma-config.ads.template
M common/hw-gfx-gma.adb
2 files changed, 119 insertions(+), 112 deletions(-)



  git pull ssh://review.coreboot.org:29418/libgfxinit refs/changes/60/27060/1

diff --git a/common/hw-gfx-gma-config.ads.template b/common/hw-gfx-gma-config.ads.template
index 1a0beac..659832f 100644
--- a/common/hw-gfx-gma-config.ads.template
+++ b/common/hw-gfx-gma-config.ads.template
@@ -37,6 +37,30 @@
 
    ----------------------------------------------------------------------------
 
+   Gen_G45           : constant Boolean := Gen = G45;
+   Gen_Ironlake      : constant Boolean := Gen = Ironlake;
+   Gen_Haswell       : constant Boolean := Gen = Haswell;
+   Gen_Broxton       : constant Boolean := Gen = Broxton;
+   Gen_Skylake       : constant Boolean := Gen = Skylake;
+
+   Haswell_Plus      : constant Boolean := Gen >= Haswell;
+   Broxton_Plus      : constant Boolean := Gen >= Broxton;
+
+   CPU_Ironlake      : constant Boolean := Gen_Ironlake and then CPU = Ironlake;
+   CPU_Sandybridge   : constant Boolean := Gen_Ironlake and then CPU = Sandybridge;
+   CPU_Ivybridge     : constant Boolean := Gen_Ironlake and then CPU = Ivybridge;
+   CPU_Haswell       : constant Boolean := Gen_Haswell and then CPU = Haswell;
+   CPU_Broadwell     : constant Boolean := Gen_Haswell and then CPU = Broadwell;
+
+   Sandybridge_Plus  : constant Boolean :=
+     ((Gen_Ironlake and then CPU >= Sandybridge) or Haswell_Plus);
+   Ivybridge_Plus    : constant Boolean :=
+     ((Gen_Ironlake and then CPU >= Ivybridge) or Haswell_Plus);
+   Broadwell_Plus    : constant Boolean :=
+     ((Gen_Haswell and then CPU >= Broadwell) or Broxton_Plus);
+
+   ----------------------------------------------------------------------------
+
    Have_HDMI_Buf_Override  : constant Boolean :=
                                              DDI_HDMI_Buffer_Translation /= -1;
    Default_MMIO_Base_Set   : constant Boolean := Default_MMIO_Base /= 0;
@@ -45,25 +69,26 @@
    Internal_Is_LVDS        : constant Boolean := Internal_Display = LVDS;
    Internal_Is_EDP         : constant Boolean := Internal_Display = DP;
    Have_DVI_I              : constant Boolean := Analog_I2C_Port /= PCH_DAC;
-   Has_Presence_Straps     : constant Boolean := Gen /= Broxton;
-   Is_ULT                  : constant Boolean := CPU_Var = ULT;
+   Has_Presence_Straps     : constant Boolean := not Gen_Broxton;
+   Is_ULT                  : constant Boolean :=
+     ((Gen_Haswell or Gen_Skylake) and then CPU_Var = ULT);
 
    ----- CPU pipe: --------
-   Has_Tertiary_Pipe       : constant Boolean := CPU >= Ivybridge;
+   Has_Tertiary_Pipe       : constant Boolean := Ivybridge_Plus;
    Disable_Trickle_Feed    : constant Boolean := Gen /= Haswell;
-   Pipe_Enabled_Workaround : constant Boolean := CPU = Broadwell;
+   Pipe_Enabled_Workaround : constant Boolean := CPU_Broadwell;
    Has_EDP_Transcoder      : constant Boolean := Gen >= Haswell;
-   Use_PDW_For_EDP_Scaling : constant Boolean := CPU = Haswell;
+   Use_PDW_For_EDP_Scaling : constant Boolean := CPU_Haswell;
    Has_Pipe_DDI_Func       : constant Boolean := Gen >= Haswell;
    Has_Trans_Clk_Sel       : constant Boolean := Gen >= Haswell;
    Has_Pipe_MSA_Misc       : constant Boolean := Gen >= Haswell;
-   Has_Pipeconf_Misc       : constant Boolean := CPU >= Broadwell;
-   Has_Pipeconf_BPC        : constant Boolean := CPU /= Haswell;
+   Has_Pipeconf_Misc       : constant Boolean := Broadwell_Plus;
+   Has_Pipeconf_BPC        : constant Boolean := not CPU_Haswell;
    Has_Plane_Control       : constant Boolean := Gen >= Broxton;
    Has_DSP_Linoff          : constant Boolean := Gen <= Ironlake;
-   Has_PF_Pipe_Select      : constant Boolean := CPU in Ivybridge .. Haswell;
-   Has_Cursor_FBC_Control  : constant Boolean := CPU >= Ivybridge;
-   VGA_Plane_Workaround    : constant Boolean := CPU = Ivybridge;
+   Has_PF_Pipe_Select      : constant Boolean := CPU_Ivybridge or CPU_Haswell;
+   Has_Cursor_FBC_Control  : constant Boolean := Ivybridge_Plus;
+   VGA_Plane_Workaround    : constant Boolean := CPU_Ivybridge;
    Has_GMCH_DP_Transcoder  : constant Boolean := Gen = G45;
    Has_GMCH_VGACNTRL       : constant Boolean := Gen = G45;
    Has_GMCH_PFIT_CONTROL   : constant Boolean := Gen = G45;
@@ -76,24 +101,22 @@
 
    ----- PCH/FDI: ---------
    Has_PCH                 : constant Boolean := Gen /= Broxton and Gen /= G45;
-   Has_PCH_DAC             : constant Boolean := CPU in Ironlake .. Ivybridge or
-                                                 (CPU in Haswell .. Broadwell
-                                                  and not Is_ULT);
+   Has_PCH_DAC             : constant Boolean :=
+     (Gen_Ironlake or (Gen_Haswell and then not Is_ULT));
 
    Has_PCH_Aux_Channels    : constant Boolean := Gen in Ironlake .. Haswell;
 
    VGA_Has_Sync_Disable    : constant Boolean := Gen <= Ironlake;
 
-   Has_Trans_Timing_Ovrrde : constant Boolean := CPU >= Sandybridge;
+   Has_Trans_Timing_Ovrrde : constant Boolean := Sandybridge_Plus;
 
    Has_DPLL_SEL            : constant Boolean := Gen = Ironlake;
    Has_FDI_BPC             : constant Boolean := Gen = Ironlake;
-   Has_FDI_Composite_Sel   : constant Boolean := CPU = Ivybridge;
-   Has_Original_ILK_Trans  : constant Boolean := CPU = Ironlake;
-   Has_Trans_DP_Ctl        : constant Boolean := CPU in
-                                                 Sandybridge .. Ivybridge;
-   Has_Ivy_Bridge_FDI      : constant Boolean := CPU = Ivybridge;
-   Has_FDI_C               : constant Boolean := CPU = Ivybridge;
+   Has_FDI_Composite_Sel   : constant Boolean := CPU_Ivybridge;
+   Has_Original_ILK_Trans  : constant Boolean := CPU_Ironlake;
+   Has_Trans_DP_Ctl        : constant Boolean := CPU_Sandybridge or CPU_Ivybridge;
+   Has_Ivy_Bridge_FDI      : constant Boolean := CPU_Ivybridge;
+   Has_FDI_C               : constant Boolean := CPU_Ivybridge;
 
    Has_FDI_RX_Power_Down   : constant Boolean := Gen = Haswell;
 
@@ -103,21 +126,19 @@
    End_EDP_Training_Late   : constant Boolean := Gen = Haswell;
    Has_Per_DDI_Clock_Sel   : constant Boolean := Gen = Haswell;
    Has_HOTPLUG_CTL         : constant Boolean := Gen = Haswell;
-   Has_SHOTPLUG_CTL_A      : constant Boolean := (CPU in Haswell .. Broadwell
-                                                  and Is_ULT) or
-                                                 CPU >= Skylake;
+   Has_SHOTPLUG_CTL_A      : constant Boolean :=
+     ((Gen_Haswell and then Is_ULT) or Gen_Skylake);
 
    Has_DDI_PHYs            : constant Boolean := Gen = Broxton;
 
-   Has_DDI_D               : constant Boolean := CPU >= Haswell and
-                                                 not Is_ULT and
-                                                 not Has_DDI_PHYs;
+   Has_DDI_D               : constant Boolean :=
+     ((Gen_Haswell or Gen_Skylake) and then not Is_ULT);
    Has_DDI_E               : constant Boolean := -- might be disabled by x4 eDP
                                                  Has_DDI_D;
 
    Has_DDI_Buffer_Trans    : constant Boolean := Gen >= Haswell and
                                                  Gen /= Broxton;
-   Has_Broadwell_DDI_Bufs  : constant Boolean := CPU = Broadwell;
+   Has_Broadwell_DDI_Bufs  : constant Boolean := CPU_Broadwell;
    Has_Low_Voltage_Swing   : constant Boolean := Gen >= Broxton;
    Has_Iboost_Config       : constant Boolean := Gen >= Skylake;
 
@@ -129,14 +150,15 @@
    Has_PCH_GMBUS           : constant Boolean := Gen >= Ironlake;
 
    ----- Power: -----------
-   Has_IPS                 : constant Boolean := (CPU = Haswell and Is_ULT) or
-                                                 CPU = Broadwell;
-   Has_IPS_CTL_Mailbox     : constant Boolean := CPU = Broadwell;
+   Has_IPS                 : constant Boolean :=
+     (Gen_Haswell and then
+      ((CPU_Haswell and Is_ULT) or CPU_Broadwell));
+   Has_IPS_CTL_Mailbox     : constant Boolean := CPU_Broadwell;
 
-   Has_Per_Pipe_SRD        : constant Boolean := CPU >= Broadwell;
+   Has_Per_Pipe_SRD        : constant Boolean := Broadwell_Plus;
 
    ----- GTT: -------------
-   Has_64bit_GTT           : constant Boolean := CPU >= Broadwell;
+   Has_64bit_GTT           : constant Boolean := Broadwell_Plus;
 
    ----------------------------------------------------------------------------
 
@@ -155,54 +177,45 @@
    type FDI_Per_Port is array (Port_Type) of Boolean;
    Is_FDI_Port : constant FDI_Per_Port :=
      (Disabled       => False,
-      Internal       => Gen = Ironlake and Internal_Is_LVDS,
-      DP1 .. HDMI3   => Gen = Ironlake,
+      Internal       => Gen_Ironlake and Internal_Is_LVDS,
+      DP1 .. HDMI3   => Gen_Ironlake,
       Analog         => Has_PCH_DAC);
 
    type FDI_Lanes_Per_Port is array (GPU_Port) of DP_Lane_Count;
    FDI_Lane_Count : constant FDI_Lanes_Per_Port :=
      (DIGI_D => DP_Lane_Count_2,
-      others => (if Gen = Ironlake then DP_Lane_Count_4 else DP_Lane_Count_2));
+      others => (if Gen_Ironlake then DP_Lane_Count_4 else DP_Lane_Count_2));
 
    FDI_Training : constant FDI_Training_Type :=
-     (case CPU is
-         when Ironlake     => Simple_Training,
-         when Sandybridge  => Full_Training,
-         when others       => Auto_Training);
+     (if    CPU_Ironlake      then Simple_Training
+      elsif CPU_Sandybridge   then Full_Training
+                              else Auto_Training);
 
    ----------------------------------------------------------------------------
 
    Default_DDI_HDMI_Buffer_Translation : constant DDI_HDMI_Buf_Trans_Range :=
-     (case CPU is
-         when Haswell   => 6,
-         when Broadwell => 7,
-         when Broxton   => 8,
-         when Skylake   => 8,
-         when others    => 0);
+     (if    CPU_Haswell       then 6
+      elsif CPU_Broadwell     then 7
+      elsif Broxton_Plus      then 8
+                              else 0);
 
    ----------------------------------------------------------------------------
 
    Default_CDClk_Freq : constant Frequency_Type :=
-     (case CPU is
-         when G45          => 320_000_000, -- unused
-         when Ironlake     |
-              Haswell      |
-              Broadwell    => 450_000_000,
-         when Sandybridge  |
-              Ivybridge    => 400_000_000,
-         when Broxton      => 288_000_000,
-         when Skylake      => 337_500_000);
+     (if    Gen_G45                          then 320_000_000  -- unused
+      elsif CPU_Ironlake or Gen_Haswell      then 450_000_000
+      elsif CPU_Sandybridge or CPU_Ivybridge then 400_000_000
+      elsif Gen_Broxton                      then 288_000_000
+      elsif Gen_Skylake                      then 337_500_000
+                                             else Frequency_Type'First);
 
    Default_RawClk_Freq : constant Frequency_Type :=
-     (case CPU is
-         when G45          => 100_000_000, -- unused, depends on FSB
-         when Ironlake     |
-              Sandybridge  |
-              Ivybridge    => 125_000_000,
-         when Haswell      |
-              Broadwell    => (if Is_ULT then 24_000_000 else 125_000_000),
-         when Broxton      => Frequency_Type'First,   -- none needed
-         when Skylake      => 24_000_000);
+     (if    Gen_G45        then 100_000_000  -- unused, depends on FSB
+      elsif Gen_Ironlake   then 125_000_000
+      elsif Gen_Haswell    then (if Is_ULT then 24_000_000 else 125_000_000)
+      elsif Gen_Broxton    then Frequency_Type'First  -- none needed
+      elsif Gen_Skylake    then 24_000_000
+                           else Frequency_Type'First);
 
     Raw_Clock : Frequency_Type := Default_RawClk_Freq
     with Part_Of => GMA.Config_State;
@@ -215,19 +228,18 @@
    type Width_Per_Pipe is array (Pipe_Index) of Width_Type;
 
    Maximum_Scalable_Width : constant Width_Per_Pipe :=
-     (case CPU is
-         when G45 => -- TODO: Is this true?
-           (Primary     => 4096,
-            Secondary   => 2048,
-            Tertiary    => Pos32'First),
-         when Ironlake..Haswell =>
-           (Primary     => 4096,
-            Secondary   => 2048,
-            Tertiary    => 2048),
-         when Broadwell..Skylake =>
-           (Primary     => 4096,
-            Secondary   => 4096,
-            Tertiary    => 4096));
+     (if Gen_G45 then   -- TODO: Is this true?
+        (Primary     => 4096,
+         Secondary   => 2048,
+         Tertiary    => Pos32'First)
+      elsif Gen_Ironlake or else CPU_Haswell then
+        (Primary     => 4096,
+         Secondary   => 2048,
+         Tertiary    => 2048)
+      else
+        (Primary     => 4096,
+         Secondary   => 4096,
+         Tertiary    => 4096));
 
    -- Maximum X position of hardware cursors
    Maximum_Cursor_X : constant := (case Gen is
@@ -240,19 +252,17 @@
 
    -- FIXME: Unknown for Broxton, Linux' i915 contains a fixme too :-D
    HDMI_Max_Clock_24bpp : constant Frequency_Type :=
-     (if Gen >= Haswell then 300_000_000 else 225_000_000);
+     (if Haswell_Plus then 300_000_000 else 225_000_000);
 
    ----------------------------------------------------------------------------
 
    GTT_PTE_Size : constant := (if Has_64bit_GTT then 8 else 4);
 
-   Fence_Base : constant := (case CPU is
-                              when G45 .. Ironlake          => 16#0000_3000#,
-                              when Sandybridge .. Skylake   => 16#0010_0000#);
+   Fence_Base : constant :=
+     (if not Sandybridge_Plus then 16#0000_3000# else 16#0010_0000#);
 
-   Fence_Count : constant := (case CPU is
-                                 when G45 .. Sandybridge       => 16,
-                                 when Ivybridge .. Skylake     => 32);
+   Fence_Count : constant :=
+     (if not Ivybridge_Plus then 16 else 32);
 
    ----------------------------------------------------------------------------
 
diff --git a/common/hw-gfx-gma.adb b/common/hw-gfx-gma.adb
index 967ca05..17dbeae 100644
--- a/common/hw-gfx-gma.adb
+++ b/common/hw-gfx-gma.adb
@@ -407,18 +407,17 @@
                Registers.Read (Registers.AUD_VID_DID, Audio_VID_DID);
          end case;
          Success :=
-           (case Config.CPU is
-               when Broxton      => Audio_VID_DID = 16#8086_280a#,
-               when Skylake      => Audio_VID_DID = 16#8086_2809#,
-               when Broadwell    => Audio_VID_DID = 16#8086_2808#,
-               when Haswell      => Audio_VID_DID = 16#8086_2807#,
-               when Ivybridge |
-                    Sandybridge  => Audio_VID_DID = 16#8086_2806# or
-                                    Audio_VID_DID = 16#8086_2805#,
-               when Ironlake     => Audio_VID_DID = 16#0000_0000#,
-               when G45          => Audio_VID_DID = 16#8086_2801# or
-                                    Audio_VID_DID = 16#8086_2802# or
-                                    Audio_VID_DID = 16#8086_2803#);
+           ((Config.Gen_Broxton        and Audio_VID_DID = 16#8086_280a#) or
+            (Config.Gen_Skylake        and Audio_VID_DID = 16#8086_2809#) or
+            (Config.CPU_Broadwell      and Audio_VID_DID = 16#8086_2808#) or
+            (Config.CPU_Haswell        and Audio_VID_DID = 16#8086_2807#) or
+            ((Config.CPU_Ivybridge or
+              Config.CPU_Sandybridge)  and (Audio_VID_DID = 16#8086_2806# or
+                                            Audio_VID_DID = 16#8086_2805#)) or
+            (Config.CPU_Ironlake       and Audio_VID_DID = 16#0000_0000#) or
+            (Config.Gen_G45            and (Audio_VID_DID = 16#8086_2801# or
+                                            Audio_VID_DID = 16#8086_2802# or
+                                            Audio_VID_DID = 16#8086_2803#)));
       end Check_Platform;
 
       procedure Check_Platform_PCI (Success : out Boolean)
@@ -681,26 +680,24 @@
       Pre => Is_Initialized
    is
       GGC_Reg : constant :=
-        (case Config.CPU is
-            when G45 | Ironlake           => 16#52#,
-            when Sandybridge .. Skylake   => 16#50#);
+        (if Config.Gen_G45 or Config.CPU_Ironlake then 16#52# else 16#50#);
       GGC : Word16;
    begin
       Dev.Read16 (GGC, GGC_Reg);
-      case Config.CPU is
-         when G45 | Ironlake =>
-            GTT_Size    := GTT_Size_Gen4 (GGC);
-            Stolen_Size := Stolen_Size_Gen4 (GGC);
-         when Sandybridge .. Haswell =>
-            GTT_Size    := GTT_Size_Gen6 (GGC);
-            Stolen_Size := Stolen_Size_Gen6 (GGC);
-         when Broadwell =>
-            GTT_Size    := GTT_Size_Gen8 (GGC);
-            Stolen_Size := Stolen_Size_Gen8 (GGC);
-         when Broxton .. Skylake =>
-            GTT_Size    := GTT_Size_Gen8 (GGC);
-            Stolen_Size := Stolen_Size_Gen9 (GGC);
-      end case;
+      if Config.Gen_G45 or Config.CPU_Ironlake then
+         GTT_Size    := GTT_Size_Gen4 (GGC);
+         Stolen_Size := Stolen_Size_Gen4 (GGC);
+      elsif Config.CPU_Sandybridge or Config.CPU_Ivybridge or Config.CPU_Haswell
+      then
+         GTT_Size    := GTT_Size_Gen6 (GGC);
+         Stolen_Size := Stolen_Size_Gen6 (GGC);
+      elsif Config.CPU_Broadwell then
+         GTT_Size    := GTT_Size_Gen8 (GGC);
+         Stolen_Size := Stolen_Size_Gen8 (GGC);
+      else
+         GTT_Size    := GTT_Size_Gen8 (GGC);
+         Stolen_Size := Stolen_Size_Gen9 (GGC);
+      end if;
    end Decode_Stolen;
 
    -- Additional runtime validation that FB fits stolen memory and aperture.

-- 
To view, visit https://review.coreboot.org/27060
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings

Gerrit-Project: libgfxinit
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I307d1dd56f480fdb4fbc6e2e25fc5f413c4158f8
Gerrit-Change-Number: 27060
Gerrit-PatchSet: 1
Gerrit-Owner: Nico Huber <nico.h at gmx.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20180612/938890d1/attachment-0001.html>


More information about the coreboot-gerrit mailing list