diff options
author | Rex-BC Chen <rex-bc.chen@mediatek.com> | 2021-05-31 19:48:13 +0800 |
---|---|---|
committer | Hung-Te Lin <hungte@chromium.org> | 2021-06-13 03:51:18 +0000 |
commit | 262bcc04d401d5c43f025deaf78c340a68089c91 (patch) | |
tree | cc9bc9c4c8b124c9f06d05190b075480b2b198b2 /src/mainboard/google | |
parent | d593bf7dfe5badb989ad32d920a556eabffaa2ea (diff) |
mb/google/cherry: get SKU ID from EC (CBI)
The SKU ID for Cherry is retrieved via CBI interface.
Signed-off-by: Rex-BC Chen <rex-bc.chen@mediatek.com>
Change-Id: Icefa016c2e5f68bd194f76d2252856835c65b8e8
Reviewed-on: https://review.coreboot.org/c/coreboot/+/55383
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Diffstat (limited to 'src/mainboard/google')
-rw-r--r-- | src/mainboard/google/cherry/Kconfig | 1 | ||||
-rw-r--r-- | src/mainboard/google/cherry/boardid.c | 30 |
2 files changed, 29 insertions, 2 deletions
diff --git a/src/mainboard/google/cherry/Kconfig b/src/mainboard/google/cherry/Kconfig index 7377c6c94a..04f745bfe7 100644 --- a/src/mainboard/google/cherry/Kconfig +++ b/src/mainboard/google/cherry/Kconfig @@ -21,6 +21,7 @@ config BOARD_SPECIFIC_OPTIONS select SPI_FLASH_INCLUDE_ALL_DRIVERS select EC_GOOGLE_CHROMEEC select EC_GOOGLE_CHROMEEC_BOARDID + select EC_GOOGLE_CHROMEEC_SKUID select EC_GOOGLE_CHROMEEC_SPI select MAINBOARD_HAS_I2C_TPM_CR50 if VBOOT select MAINBOARD_HAS_TPM2 if VBOOT diff --git a/src/mainboard/google/cherry/boardid.c b/src/mainboard/google/cherry/boardid.c index a51eee8f42..96031ef408 100644 --- a/src/mainboard/google/cherry/boardid.c +++ b/src/mainboard/google/cherry/boardid.c @@ -3,14 +3,20 @@ #include <assert.h> #include <boardid.h> #include <console/console.h> +#include <ec/google/chromeec/ec.h> #include <soc/auxadc.h> +/* board_id is provided by ec/google/chromeec/ec_boardid.c */ + #define ADC_LEVELS 12 enum { /* RAM IDs */ - RAM_ID_HIGH_CHANNEL = 3, RAM_ID_LOW_CHANNEL = 2, + RAM_ID_HIGH_CHANNEL = 3, + /* SKU IDs */ + SKU_ID_LOW_CHANNEL = 4, + SKU_ID_HIGH_CHANNEL = 5, }; static const unsigned int ram_voltages[ADC_LEVELS] = { @@ -30,8 +36,10 @@ static const unsigned int ram_voltages[ADC_LEVELS] = { }; static const unsigned int *adc_voltages[] = { - [RAM_ID_HIGH_CHANNEL] = ram_voltages, [RAM_ID_LOW_CHANNEL] = ram_voltages, + [RAM_ID_HIGH_CHANNEL] = ram_voltages, + [SKU_ID_LOW_CHANNEL] = ram_voltages, + [SKU_ID_HIGH_CHANNEL] = ram_voltages, }; static uint32_t get_adc_index(unsigned int channel) @@ -52,6 +60,24 @@ static uint32_t get_adc_index(unsigned int channel) return id; } +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) { + printk(BIOS_WARNING, "Failed to get SKU code from EC\n"); + cached_sku_code = (get_adc_index(SKU_ID_HIGH_CHANNEL) << 4 | + get_adc_index(SKU_ID_LOW_CHANNEL)); + } + printk(BIOS_DEBUG, "SKU Code: %#02x\n", cached_sku_code); + } + + return cached_sku_code; +} + uint32_t ram_code(void) { static uint32_t cached_ram_code = BOARD_ID_INIT; |