gma: Implement automatic CPU detection
In dynamic CPU configurations, Config.Detect_CPU() sets the CPU
variables according to the given PCI device id. In static confi-
gurations it does nothing.
We update the default configs to make use of this feature where
applicable. This should still give us full build-test coverage
while cutting the amount of tests in half.
Change-Id: I8ce31c867f97c8d6ef99ca096cb45f7719e78a19
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/libgfxinit/+/27138
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
diff --git a/common/dyncpu/hw-gfx-gma-config.adb b/common/dyncpu/hw-gfx-gma-config.adb
new file mode 100644
index 0000000..762ff6f
--- /dev/null
+++ b/common/dyncpu/hw-gfx-gma-config.adb
@@ -0,0 +1,31 @@
+--
+-- Copyright (C) 2018 Nico Huber <nico.h@gmx.de>
+--
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 2 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+
+package body HW.GFX.GMA.Config
+is
+
+ procedure Detect_CPU (Device : Word16) is
+ begin
+ for CPU in Gen_CPU_Type loop
+ for CPU_Var in Gen_CPU_Variant loop
+ if Is_GPU (Device, CPU, CPU_Var) then
+ Config.CPU := CPU;
+ Config.CPU_Var := CPU_Var;
+ exit;
+ end if;
+ end loop;
+ end loop;
+ end Detect_CPU;
+
+end HW.GFX.GMA.Config;