ec/intel: read board ID one time from EC per stage
Use a static variable to cache the board ID. It optimizes boot time by reading the ID once per stage and retaining it for subsequent use. Rewrite the function to avoid the unnecessary ChromeEC wrapper function. Signed-off-by: Wonkyu Kim <wonkyu.kim@intel.com> Change-Id: I166ca1abdf7838f91319d0bcf11354055ed93eef Reviewed-on: https://review.coreboot.org/c/coreboot/+/87247 Reviewed-by: Maximilian Brune <maximilian.brune@9elements.com> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Bora Guvendik <bora.guvendik@intel.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
08722cd9f9
commit
4b871c6314
1 changed files with 32 additions and 17 deletions
|
|
@ -2,32 +2,47 @@
|
|||
|
||||
#include <boardid.h>
|
||||
#include "board_id.h"
|
||||
#include <console/console.h>
|
||||
#include <ec/acpi/ec.h>
|
||||
#include <ec/google/chromeec/ec.h>
|
||||
#include <types.h>
|
||||
|
||||
static uint32_t get_board_id_via_ext_ec(void)
|
||||
static int intel_ec_get_board_version(uint32_t *id)
|
||||
{
|
||||
uint32_t id = BOARD_ID_INIT;
|
||||
if (send_ec_command(EC_FAB_ID_CMD))
|
||||
return -1;
|
||||
|
||||
if (google_chromeec_get_board_version(&id))
|
||||
*id = recv_ec_data() << 8 | recv_ec_data();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Read Board ID from EC */
|
||||
int get_rvp_board_id(void)
|
||||
{
|
||||
static uint32_t id = BOARD_ID_INIT;
|
||||
const char *ec_type;
|
||||
int ret;
|
||||
|
||||
/* If already initialized, return the cached board ID. */
|
||||
if (id != BOARD_ID_INIT)
|
||||
return id;
|
||||
|
||||
/* Reading board ID. */
|
||||
if (CONFIG(EC_GOOGLE_CHROMEEC)) { /* Chrome EC */
|
||||
ec_type = "ChromeEC";
|
||||
ret = google_chromeec_get_board_version(&id);
|
||||
} else { /* Intel EC */
|
||||
ec_type = "IntelEC";
|
||||
ret = intel_ec_get_board_version(&id);
|
||||
}
|
||||
|
||||
if (ret == -1) {
|
||||
id = BOARD_ID_UNKNOWN;
|
||||
printk(BIOS_INFO, "[%s] board id: unknown\n", ec_type);
|
||||
} else {
|
||||
id &= BOARD_ID_MASK;
|
||||
printk(BIOS_INFO, "[%s] board id: 0x%x\n", ec_type, id);
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
/* Get Board ID via EC I/O port write/read */
|
||||
int get_rvp_board_id(void)
|
||||
{
|
||||
static int id = BOARD_ID_UNKNOWN;
|
||||
|
||||
if (CONFIG(EC_GOOGLE_CHROMEEC)) { /* CHROME_EC */
|
||||
id = get_board_id_via_ext_ec();
|
||||
} else { /* WINDOWS_EC */
|
||||
if (send_ec_command(EC_FAB_ID_CMD) == 0) {
|
||||
id = recv_ec_data() << 8;
|
||||
id |= recv_ec_data();
|
||||
}
|
||||
}
|
||||
return (id & BOARD_ID_MASK);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue