From e2f17f782f6a9236259f2c25ac30d35dc24d45bb Mon Sep 17 00:00:00 2001 From: Julius Werner Date: Tue, 5 Dec 2017 13:39:10 -0800 Subject: boardid: Minor clean up and standardization Merge the different coreboot table strapping ID structures into one because they're really just all the same, and I want to add more. Make the signature of the board_id() function return a uint32_t because that's also what goes in the coreboot table. Add a printk to the generic code handling strapping IDs in ramstage so that not every individual mainboard implementation needs its own print. (In turn, remove one such print from fsp1_1 code because it's in the way of my next patch.) Change-Id: Ib9563edf07b623a586a4dc168fe357564c5e68b5 Signed-off-by: Julius Werner Reviewed-on: https://review.coreboot.org/22741 Tested-by: build bot (Jenkins) --- src/commonlib/include/commonlib/coreboot_tables.h | 12 +++-------- src/drivers/intel/fsp1_1/romstage.c | 8 ------- src/ec/google/chromeec/ec_boardid.c | 2 +- src/include/boardid.h | 4 +++- src/lib/coreboot_table.c | 26 ++++++++++++++--------- src/mainboard/amd/bettong/boardid.c | 2 +- src/mainboard/google/foster/boardid.c | 2 +- src/mainboard/google/gale/boardid.c | 2 +- src/mainboard/google/gru/boardid.c | 2 +- src/mainboard/google/nyan/boardid.c | 2 +- src/mainboard/google/nyan_big/boardid.c | 2 +- src/mainboard/google/nyan_blaze/boardid.c | 2 +- src/mainboard/google/oak/boardid.c | 2 +- src/mainboard/google/purin/boardid.c | 2 +- src/mainboard/google/smaug/boardid.c | 2 +- src/mainboard/google/storm/boardid.c | 2 +- src/mainboard/google/urara/boardid.c | 2 +- src/mainboard/google/veyron/boardid.c | 2 +- src/mainboard/google/veyron_mickey/boardid.c | 2 +- src/mainboard/google/veyron_rialto/boardid.c | 2 +- src/mainboard/google/zoombini/boardid.c | 2 +- src/mainboard/intel/glkrvp/boardid.c | 2 +- 22 files changed, 40 insertions(+), 46 deletions(-) diff --git a/src/commonlib/include/commonlib/coreboot_tables.h b/src/commonlib/include/commonlib/coreboot_tables.h index 4b3f787885..feee17274a 100644 --- a/src/commonlib/include/commonlib/coreboot_tables.h +++ b/src/commonlib/include/commonlib/coreboot_tables.h @@ -289,18 +289,12 @@ struct lb_x86_rom_mtrr { }; #define LB_TAG_BOARD_ID 0x0025 -struct lb_board_id { - uint32_t tag; - uint32_t size; - /* Board ID as retrieved from the board revision GPIOs. */ - uint32_t board_id; -}; - #define LB_TAG_RAM_CODE 0x0028 -struct lb_ram_code { + +struct lb_strapping_id { uint32_t tag; uint32_t size; - uint32_t ram_code; + uint32_t id_code; }; #define LB_TAG_SPI_FLASH 0x0029 diff --git a/src/drivers/intel/fsp1_1/romstage.c b/src/drivers/intel/fsp1_1/romstage.c index d79bc2f8c0..e6dec251be 100644 --- a/src/drivers/intel/fsp1_1/romstage.c +++ b/src/drivers/intel/fsp1_1/romstage.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -74,13 +73,6 @@ asmlinkage void *romstage_main(FSP_INFO_HEADER *fih) /* Get power state */ params.power_state = fill_power_state(); - /* - * Read and print board version. Done after SOC romstage - * in case PCH needs to be configured to talk to the EC. - */ - if (IS_ENABLED(CONFIG_BOARD_ID_AUTO)) - printk(BIOS_INFO, "MLB: board version %d\n", board_id()); - /* Call into mainboard. */ mainboard_romstage_entry(¶ms); soc_after_ram_init(¶ms); diff --git a/src/ec/google/chromeec/ec_boardid.c b/src/ec/google/chromeec/ec_boardid.c index 440a5a9f07..9ec058d1ae 100644 --- a/src/ec/google/chromeec/ec_boardid.c +++ b/src/ec/google/chromeec/ec_boardid.c @@ -16,7 +16,7 @@ #include #include -uint8_t board_id(void) +uint32_t board_id(void) { MAYBE_STATIC int id = -1; diff --git a/src/include/boardid.h b/src/include/boardid.h index 121d05281a..4324a72e5e 100644 --- a/src/include/boardid.h +++ b/src/include/boardid.h @@ -18,7 +18,9 @@ #include -uint8_t board_id(void); +#define UNDEFINED_STRAPPING_ID (~0) + +uint32_t board_id(void); uint32_t ram_code(void); #endif /* __INCLUDE_BOARDID_H__ */ diff --git a/src/lib/coreboot_table.c b/src/lib/coreboot_table.c index 29dd53afad..571d1ba520 100644 --- a/src/lib/coreboot_table.c +++ b/src/lib/coreboot_table.c @@ -247,13 +247,16 @@ static inline void lb_vboot_handoff(struct lb_header *header) {} static void lb_board_id(struct lb_header *header) { #if IS_ENABLED(CONFIG_BOARD_ID_AUTO) - struct lb_board_id *bid; + struct lb_strapping_id *rec; + uint32_t bid = board_id(); - bid = (struct lb_board_id *)lb_new_record(header); + rec = (struct lb_strapping_id *)lb_new_record(header); - bid->tag = LB_TAG_BOARD_ID; - bid->size = sizeof(*bid); - bid->board_id = board_id(); + rec->tag = LB_TAG_BOARD_ID; + rec->size = sizeof(*rec); + rec->id_code = bid; + + printk(BIOS_INFO, "Board ID: %d\n", bid); #endif } @@ -289,13 +292,16 @@ static void lb_boot_media_params(struct lb_header *header) static void lb_ram_code(struct lb_header *header) { #if IS_ENABLED(CONFIG_RAM_CODE_SUPPORT) - struct lb_ram_code *code; + struct lb_strapping_id *rec; + uint32_t code = ram_code(); - code = (struct lb_ram_code *)lb_new_record(header); + rec = (struct lb_strapping_id *)lb_new_record(header); + + rec->tag = LB_TAG_RAM_CODE; + rec->size = sizeof(*rec); + rec->id_code = code; - code->tag = LB_TAG_RAM_CODE; - code->size = sizeof(*code); - code->ram_code = ram_code(); + printk(BIOS_INFO, "RAM code: %d\n", code); #endif } diff --git a/src/mainboard/amd/bettong/boardid.c b/src/mainboard/amd/bettong/boardid.c index 4b2dceb375..a78f9f68c8 100644 --- a/src/mainboard/amd/bettong/boardid.c +++ b/src/mainboard/amd/bettong/boardid.c @@ -28,7 +28,7 @@ * ...... * 1 1 1 H */ -uint8_t board_id(void) +uint32_t board_id(void) { void *gpiommioaddr; u8 value = 0; diff --git a/src/mainboard/google/foster/boardid.c b/src/mainboard/google/foster/boardid.c index 7e99e2a845..ff586958df 100644 --- a/src/mainboard/google/foster/boardid.c +++ b/src/mainboard/google/foster/boardid.c @@ -18,7 +18,7 @@ #include #include -uint8_t board_id(void) +uint32_t board_id(void) { return 0; } diff --git a/src/mainboard/google/gale/boardid.c b/src/mainboard/google/gale/boardid.c index c8d42a9fda..96fc936bf3 100644 --- a/src/mainboard/google/gale/boardid.c +++ b/src/mainboard/google/gale/boardid.c @@ -37,7 +37,7 @@ static uint8_t get_board_id(void) return bid; } -uint8_t board_id(void) +uint32_t board_id(void) { if (board_id_value < 0) board_id_value = get_board_id(); diff --git a/src/mainboard/google/gru/boardid.c b/src/mainboard/google/gru/boardid.c index 683ac39fd6..8158124c7f 100644 --- a/src/mainboard/google/gru/boardid.c +++ b/src/mainboard/google/gru/boardid.c @@ -66,7 +66,7 @@ static uint32_t get_index(uint32_t channel, int *cached_id) die("Read impossible value ( > 1023) from 10-bit ADC!"); } -uint8_t board_id(void) +uint32_t board_id(void) { return get_index(1, &cached_board_id); } diff --git a/src/mainboard/google/nyan/boardid.c b/src/mainboard/google/nyan/boardid.c index e833d90d2a..57b75da24d 100644 --- a/src/mainboard/google/nyan/boardid.c +++ b/src/mainboard/google/nyan/boardid.c @@ -17,7 +17,7 @@ #include #include -uint8_t board_id(void) +uint32_t board_id(void) { static int id = -1; diff --git a/src/mainboard/google/nyan_big/boardid.c b/src/mainboard/google/nyan_big/boardid.c index ac361e28ec..2a2911c9c5 100644 --- a/src/mainboard/google/nyan_big/boardid.c +++ b/src/mainboard/google/nyan_big/boardid.c @@ -18,7 +18,7 @@ #include #include -uint8_t board_id(void) +uint32_t board_id(void) { static int id = -1; gpio_t gpio[] = {[3] = GPIO(X4), [2] = GPIO(X1), /* X4 is MSB */ diff --git a/src/mainboard/google/nyan_blaze/boardid.c b/src/mainboard/google/nyan_blaze/boardid.c index ac361e28ec..2a2911c9c5 100644 --- a/src/mainboard/google/nyan_blaze/boardid.c +++ b/src/mainboard/google/nyan_blaze/boardid.c @@ -18,7 +18,7 @@ #include #include -uint8_t board_id(void) +uint32_t board_id(void) { static int id = -1; gpio_t gpio[] = {[3] = GPIO(X4), [2] = GPIO(X1), /* X4 is MSB */ diff --git a/src/mainboard/google/oak/boardid.c b/src/mainboard/google/oak/boardid.c index 1136f464f2..91e2df3d88 100644 --- a/src/mainboard/google/oak/boardid.c +++ b/src/mainboard/google/oak/boardid.c @@ -34,7 +34,7 @@ static uint8_t get_board_id(void) return bid; } -uint8_t board_id(void) +uint32_t board_id(void) { if (board_id_value < 0) board_id_value = get_board_id(); diff --git a/src/mainboard/google/purin/boardid.c b/src/mainboard/google/purin/boardid.c index f54d6af9df..901d837e38 100644 --- a/src/mainboard/google/purin/boardid.c +++ b/src/mainboard/google/purin/boardid.c @@ -15,7 +15,7 @@ #include -uint8_t board_id(void) +uint32_t board_id(void) { return -1; } diff --git a/src/mainboard/google/smaug/boardid.c b/src/mainboard/google/smaug/boardid.c index 265e75a4c3..208a045443 100644 --- a/src/mainboard/google/smaug/boardid.c +++ b/src/mainboard/google/smaug/boardid.c @@ -20,7 +20,7 @@ #include "gpio.h" -uint8_t board_id(void) +uint32_t board_id(void) { static int id = -1; diff --git a/src/mainboard/google/storm/boardid.c b/src/mainboard/google/storm/boardid.c index 295550fe2b..87f6d2a796 100644 --- a/src/mainboard/google/storm/boardid.c +++ b/src/mainboard/google/storm/boardid.c @@ -48,7 +48,7 @@ static uint8_t get_board_id(void) return bid; } -uint8_t board_id(void) +uint32_t board_id(void) { if (board_id_value < 0) board_id_value = get_board_id(); diff --git a/src/mainboard/google/urara/boardid.c b/src/mainboard/google/urara/boardid.c index 5923d3437e..9a6b64eb78 100644 --- a/src/mainboard/google/urara/boardid.c +++ b/src/mainboard/google/urara/boardid.c @@ -89,7 +89,7 @@ const struct board_hw *board_get_hw(void) return 0; } -uint8_t board_id(void) +uint32_t board_id(void) { if (cached_board_id == -1) cached_board_id = retrieve_board_id(); diff --git a/src/mainboard/google/veyron/boardid.c b/src/mainboard/google/veyron/boardid.c index 8bd1d7665b..604b399676 100644 --- a/src/mainboard/google/veyron/boardid.c +++ b/src/mainboard/google/veyron/boardid.c @@ -18,7 +18,7 @@ #include #include -uint8_t board_id(void) +uint32_t board_id(void) { static int id = -1; gpio_t pins[] = {[3] = GPIO(2, A, 7), [2] = GPIO(2, A, 2), diff --git a/src/mainboard/google/veyron_mickey/boardid.c b/src/mainboard/google/veyron_mickey/boardid.c index 47e946e635..3833dbedfc 100644 --- a/src/mainboard/google/veyron_mickey/boardid.c +++ b/src/mainboard/google/veyron_mickey/boardid.c @@ -18,7 +18,7 @@ #include #include -uint8_t board_id(void) +uint32_t board_id(void) { static int id = -1; gpio_t pins[] = {[3] = GPIO(2, A, 7), [2] = GPIO(2, A, 2), diff --git a/src/mainboard/google/veyron_rialto/boardid.c b/src/mainboard/google/veyron_rialto/boardid.c index 47e946e635..3833dbedfc 100644 --- a/src/mainboard/google/veyron_rialto/boardid.c +++ b/src/mainboard/google/veyron_rialto/boardid.c @@ -18,7 +18,7 @@ #include #include -uint8_t board_id(void) +uint32_t board_id(void) { static int id = -1; gpio_t pins[] = {[3] = GPIO(2, A, 7), [2] = GPIO(2, A, 2), diff --git a/src/mainboard/google/zoombini/boardid.c b/src/mainboard/google/zoombini/boardid.c index bd9afdee27..4b05c52190 100644 --- a/src/mainboard/google/zoombini/boardid.c +++ b/src/mainboard/google/zoombini/boardid.c @@ -17,7 +17,7 @@ #include #include -uint8_t board_id(void) +uint32_t board_id(void) { MAYBE_STATIC int id = -1; diff --git a/src/mainboard/intel/glkrvp/boardid.c b/src/mainboard/intel/glkrvp/boardid.c index 6e2ef0b6c8..9c5aa6daf7 100644 --- a/src/mainboard/intel/glkrvp/boardid.c +++ b/src/mainboard/intel/glkrvp/boardid.c @@ -23,7 +23,7 @@ #define BOARD_ID_GLK_RVP2_LP4 0x8 /* RVP2 - LP4 Socket */ #define EC_FAB_ID_CMD 0x0D /* Get the board fab ID in the lower 3 bits */ -uint8_t board_id(void) +uint32_t board_id(void) { MAYBE_STATIC int id = -1; if (id < 0) { -- cgit v1.2.3