UPSTREAM: 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

(cherry picked from commit 514277f7462e338c41c27e37198725923128d039)

Original-Change-Id: I9b30338645a87f29f96a249808b90f1ec16f82df
Original-Signed-off-by: Yu-Ping Wu <yupingso@chromium.org>
Original-Reviewed-on: https://review.coreboot.org/c/coreboot/+/66580
Original-Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Original-Reviewed-by: Yidi Lin <yidilin@google.com>
Original-Reviewed-by: Hung-Te Lin <hungte@chromium.org>
GitOrigin-RevId: 514277f7462e338c41c27e37198725923128d039
Change-Id: I132bd516a4fc0aafc0ece1eeda4c3b89cdf62629
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/coreboot/+/3913281
Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
Tested-by: CopyBot Service Account <copybot.service@gmail.com>
Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
(cherry picked from commit e8a326e6da1550781e795b99bcadb3e0f8947ca6)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/coreboot/+/3928488
Tested-by: Yu-Ping Wu <yupingso@chromium.org>
Reviewed-by: Yidi Lin <yidilin@chromium.org>
Commit-Queue: Hung-Te Lin <hungte@chromium.org>
Auto-Submit: Yu-Ping Wu <yupingso@chromium.org>
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 b69403e..381c048 100644
--- a/src/mainboard/google/cherry/mainboard.c
+++ b/src/mainboard/google/cherry/mainboard.c
@@ -7,6 +7,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"
 
@@ -33,28 +35,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;
 }
 
 static void register_reset_to_bl31(void)