mb/google/cherry: Initialize PCIe by SKU encoding

All cherry boards (tomato, dojo) share the same SKU ID encoding, in the
sense that a device has NVMe storage if and only if the BIT(1) of SKU ID
is set (otherwise eMMC). Therefore, instead of hard coding the list of
NVMe (PCIe) SKU IDs, we check the BIT(1) to decide whether to initialize
PCIe.

In addition, in preparation for UFS devices coming in the future,
reserve BIT(3) (which is unset for all of current SKUs) for them.

BUG=b:237953117, b:233327674
TEST=emerge-cherry coreboot
BRANCH=cherry

Change-Id: I9b30338645a87f29f96a249808b90f1ec16f82df
Signed-off-by: Yu-Ping Wu <yupingso@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/66580
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yidi Lin <yidilin@google.com>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
diff --git a/src/mainboard/google/cherry/mainboard.c b/src/mainboard/google/cherry/mainboard.c
index c67a581..704a299 100644
--- a/src/mainboard/google/cherry/mainboard.c
+++ b/src/mainboard/google/cherry/mainboard.c
@@ -6,6 +6,7 @@
 #include <delay.h>
 #include <device/device.h>
 #include <device/mmio.h>
+#include <ec/google/chromeec/ec.h>
 #include <edid.h>
 #include <framebuffer_info.h>
 #include <gpio.h>
@@ -20,6 +21,7 @@
 #include <soc/pcie.h>
 #include <soc/spm.h>
 #include <soc/usb.h>
+#include <types.h>
 
 #include "gpio.h"
 
@@ -31,28 +33,29 @@
 
 bool mainboard_needs_pcie_init(void)
 {
-	uint32_t sku;
+	uint32_t sku = sku_id();
 
-	if (!CONFIG(BOARD_GOOGLE_DOJO))
-		return false;
-
-	sku = sku_id();
-	switch (sku) {
-	case 0:
-	case 1:
-	case 4:
-	case 5:
-		return false;
-	case 2:
-	case 3:
-	case 6:
-	case 7:
+	if (sku == CROS_SKU_UNKNOWN) {
+		printk(BIOS_WARNING, "Unknown SKU (%#x); assuming PCIe", sku);
 		return true;
-	default:
-		/* For example CROS_SKU_UNPROVISIONED */
-		printk(BIOS_WARNING, "Unexpected sku %#x; assuming PCIe", sku);
+	} else if (sku == CROS_SKU_UNPROVISIONED) {
+		printk(BIOS_WARNING, "Unprovisioned SKU (%#x); assuming PCIe", sku);
 		return true;
 	}
+
+	/*
+	 * All cherry boards share the same SKU encoding. Therefore there is no need to check
+	 * the board here.
+	 * - BIT(1): NVMe (PCIe)
+	 * - BIT(3): UFS (which takes precedence over BIT(1))
+	 */
+	if (sku & BIT(3))
+		return false;
+	if (sku & BIT(1))
+		return true;
+
+	/* Otherwise, eMMC */
+	return false;
 }
 
 /* Set up backlight control pins as output pin and power-off by default */