From 080c839c1c0c1b5e389b2382144ef67535bb4ff1 Mon Sep 17 00:00:00 2001 From: Vadim Bendebury Date: Mon, 8 Sep 2014 14:04:08 -0700 Subject: [PATCH] storm: make sure board ID is calculated only once Figuring out board_id on storm requires reading tertiary gpios, which takes time. Let's calculate it once and reuse it when necessary. BUG=none TEST=verified board ID reported as 0 and 1 on proto0 and proto0.2 respectively. Change-Id: I4e237077d1d9a96daebba462cd00f3f40be14518 Signed-off-by: Vadim Bendebury Reviewed-on: https://chromium-review.googlesource.com/217086 Reviewed-by: Aaron Durbin Reviewed-by: David Hendricks --- src/mainboard/google/storm/boardid.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/mainboard/google/storm/boardid.c b/src/mainboard/google/storm/boardid.c index 6d7a918088..683b5f4812 100644 --- a/src/mainboard/google/storm/boardid.c +++ b/src/mainboard/google/storm/boardid.c @@ -37,7 +37,9 @@ * revision. */ -uint8_t board_id(void) +static int board_id_value = -1; + +static uint8_t get_board_id(void) { uint8_t bid; gpio_t hw_rev_gpios[] = {29, 30, 68}; @@ -50,3 +52,11 @@ uint8_t board_id(void) return bid; } + +uint8_t board_id(void) +{ + if (board_id_value < 0) + board_id_value = get_board_id(); + + return board_id_value; +}