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@gmx.de>
Reviewed-on: https://review.coreboot.org/21394
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Tested-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
diff --git a/common/hw-gfx-gma.adb b/common/hw-gfx-gma.adb
index 9f835d2..3d174c7 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,19 @@
             Registers.Set_Register_Base (Config.Default_MMIO_Base);
             Success := Config.Default_MMIO_Base_Set;
          end if;
+
+         if Success then
+            Check_Platform_PCI (Success);
+         end if;
       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