From a871059ef2f4a4ddbd539f0af8c89bef8e257ffe Mon Sep 17 00:00:00 2001 From: Aaron Durbin Date: Fri, 22 Sep 2017 17:05:59 -0600 Subject: [PATCH] mainboard/google/reef: expose sku strapping helper function variant_board_sku() callback exists to allow some of the variants to report the sku id differently based on board implementation. However, there are cases where there are multiple ways to encode the sku id, but the original way should be used as a fallback. As such expose a helper function, sku_strapping_value(), such that there isn't code duplication for the common fallback case. BUG=b:65339688 Change-Id: I1e917733eb89aebc41a483e2001a02acfda31bf4 Signed-off-by: Aaron Durbin Reviewed-on: https://review.coreboot.org/21645 Tested-by: build bot (Jenkins) --- src/mainboard/google/reef/mainboard.c | 12 +++++++++--- .../variants/baseboard/include/baseboard/variants.h | 3 +++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/mainboard/google/reef/mainboard.c b/src/mainboard/google/reef/mainboard.c index 8c7ec3cc05..3de383a689 100644 --- a/src/mainboard/google/reef/mainboard.c +++ b/src/mainboard/google/reef/mainboard.c @@ -52,16 +52,22 @@ static void mainboard_init(void *chip_info) * a pulldown. This way we can generate 9 different values with the * 2 pins. */ -uint8_t __attribute__((weak)) variant_board_sku(void) +uint8_t sku_strapping_value(void) { - static int board_sku_num = -1; gpio_t board_sku_gpios[] = { [1] = GPIO_17, [0] = GPIO_16, }; const size_t num = ARRAY_SIZE(board_sku_gpios); + return gpio_base3_value(board_sku_gpios, num); +} + +uint8_t __attribute__((weak)) variant_board_sku(void) +{ + static int board_sku_num = -1; + if (board_sku_num < 0) - board_sku_num = gpio_base3_value(board_sku_gpios, num); + board_sku_num = sku_strapping_value(); return board_sku_num; } diff --git a/src/mainboard/google/reef/variants/baseboard/include/baseboard/variants.h b/src/mainboard/google/reef/variants/baseboard/include/baseboard/variants.h index 535bf34311..13a52f55d0 100644 --- a/src/mainboard/google/reef/variants/baseboard/include/baseboard/variants.h +++ b/src/mainboard/google/reef/variants/baseboard/include/baseboard/variants.h @@ -21,6 +21,9 @@ #include #include +/* Return the sku id based off the strapping resistors attached to SoC. */ +uint8_t sku_strapping_value(void); + /* Return the board id for the current variant board. */ uint8_t variant_board_id(void);