nb/intel/sandybridge: Use SA devid to identify PC type

Instead of using MSR IA32_PLATFORM_ID read the SystemAgent device id
to figure out the PC type. This follows the BWG which suggest to not
use MSR IA32_PLATFORM_ID for system identification.

Tested: Lenovo X220 still boots.

Change-Id: Ibddf6c75d15ca7a99758c377ed956d483abe7ec1
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/78826
Reviewed-by: Lean Sheng Tan <sheng.tan@9elements.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
diff --git a/src/cpu/intel/model_206ax/Makefile.inc b/src/cpu/intel/model_206ax/Makefile.inc
index cd947df..e6e6e37 100644
--- a/src/cpu/intel/model_206ax/Makefile.inc
+++ b/src/cpu/intel/model_206ax/Makefile.inc
@@ -9,10 +9,6 @@
 
 ramstage-y += acpi.c
 
-ramstage-y += common.c
-romstage-y += common.c
-smm-y += common.c
-
 smm-y += finalize.c
 
 cpu_microcode_bins += $(wildcard 3rdparty/intel-microcode/intel-ucode/06-2a-*)
diff --git a/src/cpu/intel/model_206ax/common.c b/src/cpu/intel/model_206ax/common.c
deleted file mode 100644
index a881314..0000000
--- a/src/cpu/intel/model_206ax/common.c
+++ /dev/null
@@ -1,13 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-
-#include <cpu/x86/msr.h>
-#include "model_206ax.h"
-
-int get_platform_id(void)
-{
-	msr_t msr;
-
-	msr = rdmsr(IA32_PLATFORM_ID);
-	/* Read Platform Id Bits 52:50 */
-	return (msr.hi >> 18) & 0x7;
-}
diff --git a/src/cpu/intel/model_206ax/model_206ax.h b/src/cpu/intel/model_206ax/model_206ax.h
index 9379c29..9a2fefb 100644
--- a/src/cpu/intel/model_206ax/model_206ax.h
+++ b/src/cpu/intel/model_206ax/model_206ax.h
@@ -131,7 +131,6 @@
 /* Configure power limits for turbo mode */
 void set_power_limits(u8 power_limit_1_time);
 int cpu_config_tdp_levels(void);
-int get_platform_id(void);
 
 static inline u8 cpu_stepping(void)
 {
diff --git a/src/cpu/intel/model_206ax/model_206ax_init.c b/src/cpu/intel/model_206ax/model_206ax_init.c
index dfe7ae5..1568372 100644
--- a/src/cpu/intel/model_206ax/model_206ax_init.c
+++ b/src/cpu/intel/model_206ax/model_206ax_init.c
@@ -323,9 +323,6 @@
 	fill_processor_name(processor_name);
 	printk(BIOS_INFO, "CPU: %s.\n", processor_name);
 
-	/* Print platform ID */
-	printk(BIOS_INFO, "CPU: platform id %x\n", get_platform_id());
-
 	/* CPUID and features */
 	cpu_id = cpu_get_cpuid();
 	printk(BIOS_INFO, "CPU: cpuid(1) 0x%x\n", cpu_id);
diff --git a/src/northbridge/intel/sandybridge/common.c b/src/northbridge/intel/sandybridge/common.c
index a8f718c..a670491 100644
--- a/src/northbridge/intel/sandybridge/common.c
+++ b/src/northbridge/intel/sandybridge/common.c
@@ -2,14 +2,19 @@
 
 #include <console/console.h>
 #include <device/device.h>
-#include <cpu/intel/model_206ax/model_206ax.h>
+#include <device/pci_def.h>
+#include <device/pci_ops.h>
 #include "sandybridge.h"
 
 enum platform_type get_platform_type(void)
 {
-	const int id = get_platform_id();
-	if (id != 1 && id != 4)
-		printk(BIOS_WARNING, "Unknown platform id 0x%x\n", id);
-
-	return (id == 4) ? PLATFORM_MOBILE : PLATFORM_DESKTOP_SERVER;
+	switch (pci_s_read_config16(HOST_BRIDGE, PCI_DEVICE_ID) & 0xc) {
+	case 0x0: /* Desktop */
+		return PLATFORM_DESKTOP_SERVER;
+	case 0x4: /* Mobile */
+		return PLATFORM_MOBILE;
+	case 0x8: /* Server */
+	default:
+		return PLATFORM_DESKTOP_SERVER;
+	}
 }
diff --git a/src/northbridge/intel/sandybridge/early_init.c b/src/northbridge/intel/sandybridge/early_init.c
index e3525135..a5ebf9d 100644
--- a/src/northbridge/intel/sandybridge/early_init.c
+++ b/src/northbridge/intel/sandybridge/early_init.c
@@ -150,14 +150,13 @@
 
 void systemagent_early_init(void)
 {
+	const size_t is_mobile = get_platform_type() == PLATFORM_MOBILE;
 	u32 capid0_a;
 	u8 reg8;
 
 	/* Device ID Override Enable should be done very early */
 	capid0_a = pci_read_config32(HOST_BRIDGE, CAPID0_A);
 	if (capid0_a & (1 << 10)) {
-		const size_t is_mobile = get_platform_type() == PLATFORM_MOBILE;
-
 		reg8 = pci_read_config8(HOST_BRIDGE, DIDOR);
 		reg8 &= ~7; /* Clear 2:0 */
 
@@ -167,6 +166,9 @@
 		pci_write_config8(HOST_BRIDGE, DIDOR, reg8);
 	}
 
+	/* Print platform type */
+	printk(BIOS_INFO, "Detected system type: %s\n", is_mobile ? "mobile" : "desktop");
+
 	/* Setup all BARs required for early PCIe and raminit */
 	sandybridge_setup_bars();