summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRex-BC Chen <rex-bc.chen@mediatek.corp-partner.google.com>2021-11-18 18:35:55 +0800
committerHung-Te Lin <hungte@chromium.org>2021-12-09 01:51:45 +0000
commit9f6805afe8d014f4a8fe2d3a342221b2c62f15df (patch)
tree69d1cf652e8a2541c70051de4a541bd602cd5873 /src
parent7edea1b79013b66b73f89074f4af8c906fe04670 (diff)
mb/google/corsola: get SKU ID
Retrieve the SKU ID for Corsola via CBI interface. If that failed (or no data found), fallback to ADC channels for SKU ID. TEST=build pass BUG=b:202871018 Signed-off-by: Rex-BC Chen <rex-bc.chen@mediatek.com> Change-Id: I2888190d498df28b5ae13cf92cc41d088e8f8ee7 Reviewed-on: https://review.coreboot.org/c/coreboot/+/59944 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/mainboard/google/corsola/Kconfig1
-rw-r--r--src/mainboard/google/corsola/boardid.c24
2 files changed, 25 insertions, 0 deletions
diff --git a/src/mainboard/google/corsola/Kconfig b/src/mainboard/google/corsola/Kconfig
index 8877f2fc75..193cafd01b 100644
--- a/src/mainboard/google/corsola/Kconfig
+++ b/src/mainboard/google/corsola/Kconfig
@@ -23,6 +23,7 @@ config BOARD_SPECIFIC_OPTIONS
select COMMONLIB_STORAGE_MMC
select EC_GOOGLE_CHROMEEC
select EC_GOOGLE_CHROMEEC_BOARDID
+ select EC_GOOGLE_CHROMEEC_SKUID
select EC_GOOGLE_CHROMEEC_SPI
select MAINBOARD_HAS_SPI_TPM_CR50 if VBOOT
select MAINBOARD_HAS_TPM2 if VBOOT
diff --git a/src/mainboard/google/corsola/boardid.c b/src/mainboard/google/corsola/boardid.c
index 285b065045..96031ef408 100644
--- a/src/mainboard/google/corsola/boardid.c
+++ b/src/mainboard/google/corsola/boardid.c
@@ -3,6 +3,7 @@
#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 */
@@ -13,6 +14,9 @@ enum {
/* RAM IDs */
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] = {
@@ -34,6 +38,8 @@ static const unsigned int ram_voltages[ADC_LEVELS] = {
static const unsigned int *adc_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)
@@ -54,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;