diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2018-02-01 07:46:02 -0800 |
---|---|---|
committer | Martin Roth <martinroth@google.com> | 2018-02-05 23:37:14 +0000 |
commit | 0592776467012a371655ccfaa0a4e708be904b2c (patch) | |
tree | 6b6ef925c2b7a88d64223d3c3d73fb171107dd4e /src | |
parent | 07f9748f2255f7c157d55feccd12ff713ce255c6 (diff) | |
download | coreboot-0592776467012a371655ccfaa0a4e708be904b2c.tar.xz |
mb/google/fizz: Get OEM ID and SKU ID from EC
This patch makes coreboot fetch OEM ID and SKU ID from EC. If it fails,
it falls back to GPIO pins.
BUG=b:70294260
BRANCH=none
TEST=Verify AP log shows expected OEM ID and SKU ID on Fizz.
Change-Id: I06d3a205275b46660b3974bc3673d4be8e13f6d1
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://review.coreboot.org/23548
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/mainboard/google/fizz/mainboard.c | 60 |
1 files changed, 46 insertions, 14 deletions
diff --git a/src/mainboard/google/fizz/mainboard.c b/src/mainboard/google/fizz/mainboard.c index 3a8aa5420f..1e545c7f97 100644 --- a/src/mainboard/google/fizz/mainboard.c +++ b/src/mainboard/google/fizz/mainboard.c @@ -86,21 +86,34 @@ static const enum bj_adapter bj_adapter_table[OEM_ID_COUNT][SKU_ID_COUNT] = { BJ_90W_19V, BJ_90W_19V, BJ_65W_19V }, }; -static const char *oem_id = "GOOGLE"; -static const char *oem_table_id = "FIZZ"; - -static uint8_t board_sku_id(void) +static uint8_t read_sku_id_from_gpio(void) { - static int id = -1; const gpio_t sku_id_gpios[] = { GPIO_SKU_ID0, GPIO_SKU_ID1, GPIO_SKU_ID2, GPIO_SKU_ID3, }; - if (id < 0) - id = gpio_base2_value(sku_id_gpios, ARRAY_SIZE(sku_id_gpios)); - return id; + return gpio_base2_value(sku_id_gpios, ARRAY_SIZE(sku_id_gpios)); +} + +static uint8_t board_sku_id(void) +{ + static int sku_id = -1; + + if (sku_id < 0) { + uint32_t id; + if (google_chromeec_cbi_get_sku_id(&id)) + /* TODO: Once transition completes, raise error instead + of returning gpio value which could be unintended. */ + /* Reading from EC may succeed next time but we do not + want to return different values. So, we cache the + value read from GPIOs. */ + id = read_sku_id_from_gpio(); + sku_id = id; + } + + return sku_id; } /* @@ -162,17 +175,33 @@ static void mainboard_set_power_limits(u32 *pl2_val, u32 *psyspl2_val) *psyspl2_val = SET_PSYSPL2(psyspl2); } -static uint8_t board_oem_id(void) +static uint8_t read_oem_id_from_gpio(void) { - static int id = -1; const gpio_t oem_id_gpios[] = { GPIO_OEM_ID1, GPIO_OEM_ID2, GPIO_OEM_ID3, }; - if (id < 0) - id = gpio_base2_value(oem_id_gpios, ARRAY_SIZE(oem_id_gpios)); - return id; + return gpio_base2_value(oem_id_gpios, ARRAY_SIZE(oem_id_gpios)); +} + +static uint8_t board_oem_id(void) +{ + static int oem_id = -1; + + if (oem_id < 0) { + uint32_t id; + if (google_chromeec_cbi_get_oem_id(&id)) + /* TODO: Once transition completes, raise error instead + of returning gpio value which could be unintended. */ + /* Reading from EC may succeed next time but we do not + want to return different values. So, we cache the + value read from GPIOs. */ + id = read_oem_id_from_gpio(); + oem_id = id; + } + + return oem_id; } const char *smbios_mainboard_sku(void) @@ -192,6 +221,8 @@ static void mainboard_init(device_t dev) static unsigned long mainboard_write_acpi_tables( device_t device, unsigned long current, acpi_rsdp_t *rsdp) { + const char *oem_id = "GOOGLE"; + const char *oem_table_id = "FIZZ"; uintptr_t start_addr; uintptr_t end_addr; struct nhlt *nhlt; @@ -227,8 +258,9 @@ static void set_bj_adapter_limit(void) uint8_t sku = board_sku_id(); enum bj_adapter bj; + printk(BIOS_INFO, "OEM:%u(0x%x) SKU:%u(0x%x)\n", oem, oem, sku, sku); if (oem >= OEM_ID_COUNT || sku >= SKU_ID_COUNT) { - printk(BIOS_ERR, "Unrecognized OEM or SKU: %d/%d\n", oem, sku); + printk(BIOS_ERR, "Unrecognized OEM or SKU\n"); return; } |