From 367956d58e1446ec63169d9bc08426d519da754e Mon Sep 17 00:00:00 2001 From: Furquan Shaikh Date: Fri, 20 Jul 2018 13:50:16 -0700 Subject: mb/google/octopus: Add support for smbios_mainboard_sku This change provides implementation of smbios_mainboard_sku that queries the EC for SKU ID using CBI. Currently, get_board_sku() is implemented as a common function for all variants since this is the only way used by all the octopus variants to query SKU ID. If this changes in the future, this function can be changed to a variant_* callback. BUG=b:111671163 TEST=Verified following on phaser: 1. "mosys platform sku" returns the SKU ID programmed in CBI 2. "dmidecode -t 1" shows SKU information as "skuXYZ" where XYZ is the SKU ID programmed in CBI. Change-Id: Ic0d344b3c13632f2ca582adc36aa337b99959712 Signed-off-by: Furquan Shaikh Reviewed-on: https://review.coreboot.org/27560 Tested-by: build bot (Jenkins) Reviewed-by: Jett Rink Reviewed-by: Justin TerAvest --- src/mainboard/google/octopus/mainboard.c | 35 ++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/mainboard/google/octopus') diff --git a/src/mainboard/google/octopus/mainboard.c b/src/mainboard/google/octopus/mainboard.c index fc533af8a9..eda44bad11 100644 --- a/src/mainboard/google/octopus/mainboard.c +++ b/src/mainboard/google/octopus/mainboard.c @@ -18,10 +18,13 @@ #include #include #include +#include #include #include +#include #include #include +#include #include #include #include @@ -75,3 +78,35 @@ struct chip_operations mainboard_ops = { .init = mainboard_init, .enable_dev = mainboard_enable, }; + +#define SKU_UNKNOWN 0xFFFFFFFF +#define SKU_MAX 255 + +static uint32_t get_board_sku(void) +{ + static uint32_t sku_id = SKU_UNKNOWN; + + if (sku_id != SKU_UNKNOWN) + return sku_id; + + if (google_chromeec_cbi_get_sku_id(&sku_id)) + sku_id = SKU_UNKNOWN; + + return sku_id; +} + +const char *smbios_mainboard_sku(void) +{ + static char sku_str[7]; /* sku{0..255} */ + uint32_t sku_id = get_board_sku(); + + if ((sku_id == SKU_UNKNOWN) || (sku_id > SKU_MAX)) { + printk(BIOS_ERR, "%s: Unexpected SKU ID %u\n", + __func__, sku_id); + return ""; + } + + snprintf(sku_str, sizeof(sku_str), "sku%u", sku_id); + + return sku_str; +} -- cgit v1.2.3