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>
This commit is contained in:
Julius Werner 2017-12-05 13:39:10 -08:00
parent ec477346bf
commit e2f17f782f
22 changed files with 40 additions and 46 deletions

View File

@ -289,18 +289,12 @@ struct lb_x86_rom_mtrr {
}; };
#define LB_TAG_BOARD_ID 0x0025 #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 #define LB_TAG_RAM_CODE 0x0028
struct lb_ram_code {
struct lb_strapping_id {
uint32_t tag; uint32_t tag;
uint32_t size; uint32_t size;
uint32_t ram_code; uint32_t id_code;
}; };
#define LB_TAG_SPI_FLASH 0x0029 #define LB_TAG_SPI_FLASH 0x0029

View File

@ -20,7 +20,6 @@
#include <arch/cbfs.h> #include <arch/cbfs.h>
#include <arch/early_variables.h> #include <arch/early_variables.h>
#include <assert.h> #include <assert.h>
#include <boardid.h>
#include <console/console.h> #include <console/console.h>
#include <cbmem.h> #include <cbmem.h>
#include <cpu/intel/microcode.h> #include <cpu/intel/microcode.h>
@ -74,13 +73,6 @@ asmlinkage void *romstage_main(FSP_INFO_HEADER *fih)
/* Get power state */ /* Get power state */
params.power_state = fill_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. */ /* Call into mainboard. */
mainboard_romstage_entry(&params); mainboard_romstage_entry(&params);
soc_after_ram_init(&params); soc_after_ram_init(&params);

View File

@ -16,7 +16,7 @@
#include <boardid.h> #include <boardid.h>
#include <ec/google/chromeec/ec.h> #include <ec/google/chromeec/ec.h>
uint8_t board_id(void) uint32_t board_id(void)
{ {
MAYBE_STATIC int id = -1; MAYBE_STATIC int id = -1;

View File

@ -18,7 +18,9 @@
#include <stdint.h> #include <stdint.h>
uint8_t board_id(void); #define UNDEFINED_STRAPPING_ID (~0)
uint32_t board_id(void);
uint32_t ram_code(void); uint32_t ram_code(void);
#endif /* __INCLUDE_BOARDID_H__ */ #endif /* __INCLUDE_BOARDID_H__ */

View File

@ -247,13 +247,16 @@ static inline void lb_vboot_handoff(struct lb_header *header) {}
static void lb_board_id(struct lb_header *header) static void lb_board_id(struct lb_header *header)
{ {
#if IS_ENABLED(CONFIG_BOARD_ID_AUTO) #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; rec->tag = LB_TAG_BOARD_ID;
bid->size = sizeof(*bid); rec->size = sizeof(*rec);
bid->board_id = board_id(); rec->id_code = bid;
printk(BIOS_INFO, "Board ID: %d\n", bid);
#endif #endif
} }
@ -289,13 +292,16 @@ static void lb_boot_media_params(struct lb_header *header)
static void lb_ram_code(struct lb_header *header) static void lb_ram_code(struct lb_header *header)
{ {
#if IS_ENABLED(CONFIG_RAM_CODE_SUPPORT) #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; rec->tag = LB_TAG_RAM_CODE;
code->size = sizeof(*code); rec->size = sizeof(*rec);
code->ram_code = ram_code(); rec->id_code = code;
printk(BIOS_INFO, "RAM code: %d\n", code);
#endif #endif
} }

View File

@ -28,7 +28,7 @@
* ...... * ......
* 1 1 1 H * 1 1 1 H
*/ */
uint8_t board_id(void) uint32_t board_id(void)
{ {
void *gpiommioaddr; void *gpiommioaddr;
u8 value = 0; u8 value = 0;

View File

@ -18,7 +18,7 @@
#include <console/console.h> #include <console/console.h>
#include <gpio.h> #include <gpio.h>
uint8_t board_id(void) uint32_t board_id(void)
{ {
return 0; return 0;
} }

View File

@ -37,7 +37,7 @@ static uint8_t get_board_id(void)
return bid; return bid;
} }
uint8_t board_id(void) uint32_t board_id(void)
{ {
if (board_id_value < 0) if (board_id_value < 0)
board_id_value = get_board_id(); board_id_value = get_board_id();

View File

@ -66,7 +66,7 @@ static uint32_t get_index(uint32_t channel, int *cached_id)
die("Read impossible value ( > 1023) from 10-bit ADC!"); 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); return get_index(1, &cached_board_id);
} }

View File

@ -17,7 +17,7 @@
#include <console/console.h> #include <console/console.h>
#include <gpio.h> #include <gpio.h>
uint8_t board_id(void) uint32_t board_id(void)
{ {
static int id = -1; static int id = -1;

View File

@ -18,7 +18,7 @@
#include <gpio.h> #include <gpio.h>
#include <stdlib.h> #include <stdlib.h>
uint8_t board_id(void) uint32_t board_id(void)
{ {
static int id = -1; static int id = -1;
gpio_t gpio[] = {[3] = GPIO(X4), [2] = GPIO(X1), /* X4 is MSB */ gpio_t gpio[] = {[3] = GPIO(X4), [2] = GPIO(X1), /* X4 is MSB */

View File

@ -18,7 +18,7 @@
#include <gpio.h> #include <gpio.h>
#include <stdlib.h> #include <stdlib.h>
uint8_t board_id(void) uint32_t board_id(void)
{ {
static int id = -1; static int id = -1;
gpio_t gpio[] = {[3] = GPIO(X4), [2] = GPIO(X1), /* X4 is MSB */ gpio_t gpio[] = {[3] = GPIO(X4), [2] = GPIO(X1), /* X4 is MSB */

View File

@ -34,7 +34,7 @@ static uint8_t get_board_id(void)
return bid; return bid;
} }
uint8_t board_id(void) uint32_t board_id(void)
{ {
if (board_id_value < 0) if (board_id_value < 0)
board_id_value = get_board_id(); board_id_value = get_board_id();

View File

@ -15,7 +15,7 @@
#include <boardid.h> #include <boardid.h>
uint8_t board_id(void) uint32_t board_id(void)
{ {
return -1; return -1;
} }

View File

@ -20,7 +20,7 @@
#include "gpio.h" #include "gpio.h"
uint8_t board_id(void) uint32_t board_id(void)
{ {
static int id = -1; static int id = -1;

View File

@ -48,7 +48,7 @@ static uint8_t get_board_id(void)
return bid; return bid;
} }
uint8_t board_id(void) uint32_t board_id(void)
{ {
if (board_id_value < 0) if (board_id_value < 0)
board_id_value = get_board_id(); board_id_value = get_board_id();

View File

@ -89,7 +89,7 @@ const struct board_hw *board_get_hw(void)
return 0; return 0;
} }
uint8_t board_id(void) uint32_t board_id(void)
{ {
if (cached_board_id == -1) if (cached_board_id == -1)
cached_board_id = retrieve_board_id(); cached_board_id = retrieve_board_id();

View File

@ -18,7 +18,7 @@
#include <gpio.h> #include <gpio.h>
#include <stdlib.h> #include <stdlib.h>
uint8_t board_id(void) uint32_t board_id(void)
{ {
static int id = -1; static int id = -1;
gpio_t pins[] = {[3] = GPIO(2, A, 7), [2] = GPIO(2, A, 2), gpio_t pins[] = {[3] = GPIO(2, A, 7), [2] = GPIO(2, A, 2),

View File

@ -18,7 +18,7 @@
#include <gpio.h> #include <gpio.h>
#include <stdlib.h> #include <stdlib.h>
uint8_t board_id(void) uint32_t board_id(void)
{ {
static int id = -1; static int id = -1;
gpio_t pins[] = {[3] = GPIO(2, A, 7), [2] = GPIO(2, A, 2), gpio_t pins[] = {[3] = GPIO(2, A, 7), [2] = GPIO(2, A, 2),

View File

@ -18,7 +18,7 @@
#include <gpio.h> #include <gpio.h>
#include <stdlib.h> #include <stdlib.h>
uint8_t board_id(void) uint32_t board_id(void)
{ {
static int id = -1; static int id = -1;
gpio_t pins[] = {[3] = GPIO(2, A, 7), [2] = GPIO(2, A, 2), gpio_t pins[] = {[3] = GPIO(2, A, 7), [2] = GPIO(2, A, 2),

View File

@ -17,7 +17,7 @@
#include <boardid.h> #include <boardid.h>
#include <stddef.h> #include <stddef.h>
uint8_t board_id(void) uint32_t board_id(void)
{ {
MAYBE_STATIC int id = -1; MAYBE_STATIC int id = -1;

View File

@ -23,7 +23,7 @@
#define BOARD_ID_GLK_RVP2_LP4 0x8 /* RVP2 - LP4 Socket */ #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 */ #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; MAYBE_STATIC int id = -1;
if (id < 0) { if (id < 0) {