[coreboot-gerrit] Change in libgfxinit[master]: [WIP] gma: Implement PCI Id based generation check

Nico Huber (Code Review) gerrit at coreboot.org
Tue Sep 5 00:01:51 CEST 2017


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


Change subject: [WIP] gma: Implement PCI Id based generation check
......................................................................

[WIP] gma: Implement PCI Id based generation check

We were used to sanity check the GPU generation by the audio id because
that was easily accessible in MMIO space and only one number per gene-
ration. It doesn't work on Skylake, though, so we read PCI ids instead.

Change-Id: Id6c9cfdb00664dc2c36b2cbd13136568829297d5
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, 57 insertions(+), 3 deletions(-)



  git pull ssh://review.coreboot.org:29418/libgfxinit refs/changes/94/21394/1

diff --git a/common/hw-gfx-gma-config.ads.template b/common/hw-gfx-gma-config.ads.template
index e82b133..ba08664 100644
--- a/common/hw-gfx-gma-config.ads.template
+++ b/common/hw-gfx-gma-config.ads.template
@@ -287,4 +287,46 @@
                                     when Ironlake .. Haswell   => 4,
                                     when Broadwell .. Skylake  => 8);
 
+   ----------------------------------------------------------------------------
+
+   use type HW.Word16;
+
+   function Is_Broadwell_H (Device_Id : Word16) return Boolean is
+     (Device_Id = 16#1612# or Device_Id = 16#1622# or Device_Id = 16#162a#);
+
+   function Is_Skylake_U (Device_Id : Word16) return Boolean is
+     (Device_Id = 16#1906# or Device_Id = 16#1916# or Device_Id = 16#1923# or
+      Device_Id = 16#1926# or Device_Id = 16#1927#);
+
+   -- Rather catch too much here than too little,
+   -- it's only used to distinguish generations.
+   function Is_GPU (Device_Id : Word16; CPU : CPU_Type; CPU_Var : CPU_Variant)
+      return Boolean is
+     (case CPU is
+         when Ironlake     => (Device_Id and 16#fff3#) = 16#0042#,
+         when Sandybridge  => (Device_Id and 16#ffc2#) = 16#0102#,
+         when Ivybridge    => (Device_Id and 16#ffc3#) = 16#0142#,
+         when Haswell =>
+           (case CPU_Var is
+               when Normal => (Device_Id and 16#ffc3#) = 16#0402# or
+                              (Device_Id and 16#ffc3#) = 16#0d02#,
+               when ULT    => (Device_Id and 16#ffc3#) = 16#0a02#),
+         when Broadwell    => ((Device_Id and 16#ffc3#) = 16#1602# or
+                               (Device_Id and 16#ffcf#) = 16#160b# or
+                               (Device_Id and 16#ffcf#) = 16#160d#) and
+                             (case CPU_Var is
+                                 when Normal =>     Is_Broadwell_H (Device_Id),
+                                 when ULT    => not Is_Broadwell_H (Device_Id)),
+         when Broxton      => (Device_Id and 16#fffe#) = 16#5a84#,
+         when Skylake      => ((Device_Id and 16#ffc3#) = 16#1902# or
+                               (Device_Id and 16#ffcf#) = 16#190b# or
+                               (Device_Id and 16#ffcf#) = 16#190d# or
+                               (Device_Id and 16#fff9#) = 16#1921#) and
+                             (case CPU_Var is
+                                 when Normal => not Is_Skylake_U (Device_Id),
+                                 when ULT    =>     Is_Skylake_U (Device_Id)));
+
+   function Compatible_GPU (Device_Id : Word16) return Boolean is
+     (Is_GPU (Device_Id, CPU, CPU_Var));
+
 end HW.GFX.GMA.Config;
diff --git a/common/hw-gfx-gma.adb b/common/hw-gfx-gma.adb
index 6bc6fea..5198272 100644
--- a/common/hw-gfx-gma.adb
+++ b/common/hw-gfx-gma.adb
@@ -345,6 +345,17 @@
                                     Audio_VID_DID = 16#8086_2805#,
                when Ironlake     => Audio_VID_DID = 16#0000_0000#);
       end Check_Platform;
+
+      procedure Check_Platform_PCI (Success : out Boolean)
+      is
+         use type HW.Word16;
+         Vendor, Device : Word16;
+      begin
+         Dev.Read16 (Vendor, PCI.Vendor_Id);
+         Dev.Read16 (Device, PCI.Device_Id);
+
+         Success := Vendor = 16#8086# and Config.Compatible_GPU (Device);
+      end Check_Platform_PCI;
    begin
       pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
 
@@ -374,15 +385,16 @@
             Registers.Set_Register_Base (Config.Default_MMIO_Base);
             Success := Config.Default_MMIO_Base_Set;
          end if;
+         Check_Platform_PCI (Success);
       else
          pragma Debug (Debug.Put_Line
            ("WARNING: Couldn't initialize PCI dev."));
          Registers.Set_Register_Base (Config.Default_MMIO_Base);
          Success := Config.Default_MMIO_Base_Set;
-      end if;
 
-      if Success then
-         Check_Platform (Success);
+         if Success then
+            Check_Platform (Success);
+         end if;
       end if;
 
       if not Success then

-- 
To view, visit https://review.coreboot.org/21394
To unsubscribe, visit https://review.coreboot.org/settings

Gerrit-Project: libgfxinit
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id6c9cfdb00664dc2c36b2cbd13136568829297d5
Gerrit-Change-Number: 21394
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/20170904/d7e553ce/attachment.html>


More information about the coreboot-gerrit mailing list