From b3edaa7b10af69f9e3cbcf7c86b450ba2ed4e698 Mon Sep 17 00:00:00 2001 From: Jarried Lin Date: Mon, 23 Dec 2024 17:17:17 +0800 Subject: [PATCH] mb/google/rauru: Implement SKU ID Retrieve the SKU ID for Rauru via CBI interface. If that failed (or no data found), fall back to ADC channels for SKU ID. TEST=Build pass, boot ok, log show: SKU Code: 0x2 BUG=b:317009620 Change-Id: I49ba6f428f55d3aae1b84a4d5ce06bec765caece Signed-off-by: Jarried Lin Reviewed-on: https://review.coreboot.org/c/coreboot/+/85666 Reviewed-by: Yu-Ping Wu Tested-by: build bot (Jenkins) Reviewed-by: Yidi Lin --- src/mainboard/google/rauru/Kconfig | 1 + src/mainboard/google/rauru/boardid.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/mainboard/google/rauru/Kconfig b/src/mainboard/google/rauru/Kconfig index 18a1699e87..57e8c1b5cf 100644 --- a/src/mainboard/google/rauru/Kconfig +++ b/src/mainboard/google/rauru/Kconfig @@ -26,6 +26,7 @@ config BOARD_SPECIFIC_OPTIONS select CHROMEOS_USE_EC_WATCHDOG_FLAG if CHROMEOS select EC_GOOGLE_CHROMEEC select EC_GOOGLE_CHROMEEC_BOARDID + select EC_GOOGLE_CHROMEEC_SKUID select EC_GOOGLE_CHROMEEC_SPI select I2C_TPM if VBOOT select MAINBOARD_HAS_TPM2 if VBOOT diff --git a/src/mainboard/google/rauru/boardid.c b/src/mainboard/google/rauru/boardid.c index 1d49e03b6a..e3e0979012 100644 --- a/src/mainboard/google/rauru/boardid.c +++ b/src/mainboard/google/rauru/boardid.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -10,6 +11,10 @@ #define ADC_LEVELS 8 +DEFINE_BITFIELD(STORAGE_TYPE, 11, 9); +DEFINE_BITFIELD(CPU_TYPE, 8, 8); +DEFINE_BITFIELD(PANEL_TYPE, 7, 0); + enum { /* Storage IDs */ STORAGE_ID_LOW_CHANNEL = AUXADC_CHAN_VIN1, @@ -75,3 +80,22 @@ enum ufs_type storage_type(uint32_t index) } return UFS_UNKNOWN; } + +uint32_t sku_id(void) +{ + static uint32_t cached_sku_code = BOARD_ID_INIT; + + if (cached_sku_code == BOARD_ID_INIT) { + cached_sku_code = google_chromeec_get_board_sku(); + + if (cached_sku_code == CROS_SKU_UNKNOWN || + cached_sku_code == CROS_SKU_UNPROVISIONED) { + printk(BIOS_WARNING, "Failed to get SKU code from EC\n"); + cached_sku_code = CROS_SKU_UNPROVISIONED; + SET32_BITFIELDS(&cached_sku_code, STORAGE_TYPE, storage_id()); + } + printk(BIOS_DEBUG, "SKU Code: %#02x\n", cached_sku_code); + } + + return cached_sku_code; +}