From 2786ce0b485f39dd5c9fa0fc037fe214adb771e5 Mon Sep 17 00:00:00 2001 From: Vadim Bendebury Date: Mon, 8 Sep 2014 14:04:08 -0700 Subject: 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: I69f6afa3de8a175a1d723e95902efd15607e68b7 Signed-off-by: Patrick Georgi Original-Commit-Id: 080c839c1c0c1b5e389b2382144ef67535bb4ff1 Original-Change-Id: I4e237077d1d9a96daebba462cd00f3f40be14518 Original-Signed-off-by: Vadim Bendebury Original-Reviewed-on: https://chromium-review.googlesource.com/217086 Original-Reviewed-by: Aaron Durbin Original-Reviewed-by: David Hendricks Reviewed-on: http://review.coreboot.org/9119 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer --- src/mainboard/google/storm/boardid.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/mainboard/google') 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; +} -- cgit v1.2.3