diff options
author | Kevin Chiu <Kevin.Chiu@quantatw.com> | 2017-09-14 11:05:57 +0800 |
---|---|---|
committer | Aaron Durbin <adurbin@chromium.org> | 2017-09-26 03:35:29 +0000 |
commit | b6850ddbffa216ae7306d612fafb460ef1608d6f (patch) | |
tree | 4c202c9bd6241e7aaaebbbe0a7154a2896a5406c /src | |
parent | a871059ef2f4a4ddbd539f0af8c89bef8e257ffe (diff) | |
download | coreboot-b6850ddbffa216ae7306d612fafb460ef1608d6f.tar.xz |
google/snappy: Override SKU ID by VPD
Since snappy PCB may have over 9 SKU and current GPIO board ID GP16/GP17
is insufficient to use.
Using VPD to control could prevent H/W change.
BUG=b:65339688
BRANCH=reef
TEST=emerge-snappy coreboot
Change-Id: I55ab741354797e022dd945da9c8499ee5e041316
Signed-off-by: Kevin Chiu <Kevin.Chiu@quantatw.com>
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://review.coreboot.org/21533
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/mainboard/google/reef/variants/snappy/mainboard.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/mainboard/google/reef/variants/snappy/mainboard.c b/src/mainboard/google/reef/variants/snappy/mainboard.c index a04f61a72f..2767df245e 100644 --- a/src/mainboard/google/reef/variants/snappy/mainboard.c +++ b/src/mainboard/google/reef/variants/snappy/mainboard.c @@ -13,10 +13,53 @@ * GNU General Public License for more details. */ +#include <string.h> #include <baseboard/variants.h> #include <ec/google/chromeec/ec.h> +#include <vendorcode/google/chromeos/cros_vpd.h> void variant_board_ec_set_skuid(void) { google_chromeec_set_sku_id(variant_board_sku()); } + +/* + * override SKU ID by VPD definition + */ +uint8_t variant_board_sku(void) +{ + static int board_sku_num = -1; + int vpd_sku_num; + char vpd_skuid[] = "skuid"; + char vpd_buffer[4]; + int vpd_len; + int i; + + if (board_sku_num != -1) + return board_sku_num; + + board_sku_num = sku_strapping_value(); + + if (!IS_ENABLED(CONFIG_CHROMEOS)) + return board_sku_num; + + if (!cros_vpd_gets(vpd_skuid, vpd_buffer, ARRAY_SIZE(vpd_buffer))) + return board_sku_num; + + vpd_len = strlen(vpd_buffer); + + vpd_sku_num = 0; + for (i = 0; i < vpd_len; i++) { + char ch = vpd_buffer[i]; + if ((ch < '0') || (ch > '9')) { + vpd_sku_num = -1; + break; + } else + vpd_sku_num = vpd_sku_num * 10 + (ch - '0'); + } + + if (vpd_sku_num != -1) + board_sku_num = vpd_sku_num; + + return board_sku_num; +} |