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 <jwerner@chromium.org>
Reviewed-on: https://review.coreboot.org/22741
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/src/commonlib/include/commonlib/coreboot_tables.h b/src/commonlib/include/commonlib/coreboot_tables.h
index 4b3f787..feee172 100644
--- a/src/commonlib/include/commonlib/coreboot_tables.h
+++ b/src/commonlib/include/commonlib/coreboot_tables.h
@@ -289,18 +289,12 @@
};
#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 d79bc2f..e6dec25 100644
--- a/src/drivers/intel/fsp1_1/romstage.c
+++ b/src/drivers/intel/fsp1_1/romstage.c
@@ -20,7 +20,6 @@
#include <arch/cbfs.h>
#include <arch/early_variables.h>
#include <assert.h>
-#include <boardid.h>
#include <console/console.h>
#include <cbmem.h>
#include <cpu/intel/microcode.h>
@@ -74,13 +73,6 @@
/* 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 440a5a9..9ec058d 100644
--- a/src/ec/google/chromeec/ec_boardid.c
+++ b/src/ec/google/chromeec/ec_boardid.c
@@ -16,7 +16,7 @@
#include <boardid.h>
#include <ec/google/chromeec/ec.h>
-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 121d052..4324a72 100644
--- a/src/include/boardid.h
+++ b/src/include/boardid.h
@@ -18,7 +18,9 @@
#include <stdint.h>
-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 29dd53a..571d1ba 100644
--- a/src/lib/coreboot_table.c
+++ b/src/lib/coreboot_table.c
@@ -247,13 +247,16 @@
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_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);
- code->tag = LB_TAG_RAM_CODE;
- code->size = sizeof(*code);
- code->ram_code = ram_code();
+ rec->tag = LB_TAG_RAM_CODE;
+ rec->size = sizeof(*rec);
+ rec->id_code = 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 4b2dceb..a78f9f6 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 7e99e2a..ff58695 100644
--- a/src/mainboard/google/foster/boardid.c
+++ b/src/mainboard/google/foster/boardid.c
@@ -18,7 +18,7 @@
#include <console/console.h>
#include <gpio.h>
-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 c8d42a9..96fc936 100644
--- a/src/mainboard/google/gale/boardid.c
+++ b/src/mainboard/google/gale/boardid.c
@@ -37,7 +37,7 @@
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 683ac39..8158124 100644
--- a/src/mainboard/google/gru/boardid.c
+++ b/src/mainboard/google/gru/boardid.c
@@ -66,7 +66,7 @@
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 e833d90..57b75da 100644
--- a/src/mainboard/google/nyan/boardid.c
+++ b/src/mainboard/google/nyan/boardid.c
@@ -17,7 +17,7 @@
#include <console/console.h>
#include <gpio.h>
-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 ac361e2..2a2911c 100644
--- a/src/mainboard/google/nyan_big/boardid.c
+++ b/src/mainboard/google/nyan_big/boardid.c
@@ -18,7 +18,7 @@
#include <gpio.h>
#include <stdlib.h>
-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 ac361e2..2a2911c 100644
--- a/src/mainboard/google/nyan_blaze/boardid.c
+++ b/src/mainboard/google/nyan_blaze/boardid.c
@@ -18,7 +18,7 @@
#include <gpio.h>
#include <stdlib.h>
-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 1136f46..91e2df3 100644
--- a/src/mainboard/google/oak/boardid.c
+++ b/src/mainboard/google/oak/boardid.c
@@ -34,7 +34,7 @@
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 f54d6af..901d837 100644
--- a/src/mainboard/google/purin/boardid.c
+++ b/src/mainboard/google/purin/boardid.c
@@ -15,7 +15,7 @@
#include <boardid.h>
-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 265e75a..208a045 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 295550f..87f6d2a 100644
--- a/src/mainboard/google/storm/boardid.c
+++ b/src/mainboard/google/storm/boardid.c
@@ -48,7 +48,7 @@
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 5923d34..9a6b64e 100644
--- a/src/mainboard/google/urara/boardid.c
+++ b/src/mainboard/google/urara/boardid.c
@@ -89,7 +89,7 @@
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 8bd1d76..604b399 100644
--- a/src/mainboard/google/veyron/boardid.c
+++ b/src/mainboard/google/veyron/boardid.c
@@ -18,7 +18,7 @@
#include <gpio.h>
#include <stdlib.h>
-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 47e946e..3833dbe 100644
--- a/src/mainboard/google/veyron_mickey/boardid.c
+++ b/src/mainboard/google/veyron_mickey/boardid.c
@@ -18,7 +18,7 @@
#include <gpio.h>
#include <stdlib.h>
-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 47e946e..3833dbe 100644
--- a/src/mainboard/google/veyron_rialto/boardid.c
+++ b/src/mainboard/google/veyron_rialto/boardid.c
@@ -18,7 +18,7 @@
#include <gpio.h>
#include <stdlib.h>
-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 bd9afde..4b05c52 100644
--- a/src/mainboard/google/zoombini/boardid.c
+++ b/src/mainboard/google/zoombini/boardid.c
@@ -17,7 +17,7 @@
#include <boardid.h>
#include <stddef.h>
-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 6e2ef0b..9c5aa6d 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) {