mb/google/poppy/variants/nami: Add support for getting OEM name from CBFS
This change: 1. Allows mainboard to add OEM table to CBFS 2. Provides mainboard specific smbios_mainboard_manufacturer that reads OEM ID from EC using CBI and compares it against the OEM ID in CBFS table to identify the right OEM string. BUG=b:74617340 Change-Id: Iff54b12745de3efa7be0801c9a3a9f2a57767dde Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://review.coreboot.org/26142 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
parent
492e4db993
commit
f5b7e80c22
|
@ -111,6 +111,10 @@ config MAX_CPUS
|
|||
int
|
||||
default 8
|
||||
|
||||
config OEM_BIN_FILE
|
||||
string "OEM ID table"
|
||||
default ""
|
||||
|
||||
config TPM_TIS_ACPI_INTERRUPT
|
||||
int
|
||||
default 64 # GPE0_DW2_00 (GPP_E0)
|
||||
|
|
|
@ -33,3 +33,8 @@ ramstage-y += gpio.c
|
|||
ramstage-y += nhlt.c
|
||||
ramstage-y += pl2.c
|
||||
ramstage-y += mainboard.c
|
||||
|
||||
# Add OEM ID table
|
||||
cbfs-files-y += oem.bin
|
||||
oem.bin-file := $(call strip_quotes,$(CONFIG_OEM_BIN_FILE))
|
||||
oem.bin-type := raw
|
||||
|
|
|
@ -16,7 +16,10 @@
|
|||
#include <arch/cpu.h>
|
||||
#include <assert.h>
|
||||
#include <baseboard/variants.h>
|
||||
#include <cbfs.h>
|
||||
#include <chip.h>
|
||||
#include <commonlib/cbfs_serialized.h>
|
||||
#include <compiler.h>
|
||||
#include <device/device.h>
|
||||
#include <ec/google/chromeec/ec.h>
|
||||
#include <smbios.h>
|
||||
|
@ -62,3 +65,77 @@ const char *smbios_mainboard_sku(void)
|
|||
|
||||
return sku_str;
|
||||
}
|
||||
|
||||
#define OEM_UNKNOWN 0xff
|
||||
|
||||
/*
|
||||
* Read OEM ID from EC using cbi commands.
|
||||
* Return value:
|
||||
* Success = OEM ID read from EC
|
||||
* Failure = OEM_UNKNOWN (0xff)
|
||||
*/
|
||||
static uint8_t read_oem_id(void)
|
||||
{
|
||||
static uint8_t oem_id = OEM_UNKNOWN;
|
||||
uint32_t id;
|
||||
|
||||
if (oem_id != OEM_UNKNOWN)
|
||||
return oem_id;
|
||||
|
||||
if (google_chromeec_cbi_get_oem_id(&id))
|
||||
return OEM_UNKNOWN;
|
||||
|
||||
if (id > OEM_UNKNOWN) {
|
||||
printk(BIOS_ERR, "%s: OEM ID too big %u!\n", __func__, id);
|
||||
return OEM_UNKNOWN;
|
||||
}
|
||||
|
||||
oem_id = id;
|
||||
printk(BIOS_DEBUG, "%s: OEM ID=%d\n", __func__, oem_id);
|
||||
|
||||
return oem_id;
|
||||
}
|
||||
|
||||
/* "oem.bin" in cbfs contains array of records using the following structure. */
|
||||
struct oem_mapping {
|
||||
uint8_t oem_id;
|
||||
char oem_name[10];
|
||||
} __packed;
|
||||
|
||||
/* Local buffer to read "oem.bin" */
|
||||
static char oem_bin_data[200];
|
||||
|
||||
const char *smbios_mainboard_manufacturer(void)
|
||||
{
|
||||
uint8_t oem_id = read_oem_id();
|
||||
const struct oem_mapping *oem_entry = (void *)&oem_bin_data;
|
||||
size_t oem_data_size;
|
||||
size_t curr = 0;
|
||||
static const char *manuf;
|
||||
|
||||
if (manuf)
|
||||
return manuf;
|
||||
|
||||
/* If OEM ID cannot be determined, return default manuf string. */
|
||||
if (oem_id == OEM_UNKNOWN)
|
||||
return CONFIG_MAINBOARD_SMBIOS_MANUFACTURER;
|
||||
|
||||
oem_data_size = cbfs_boot_load_file("oem.bin", oem_bin_data,
|
||||
sizeof(oem_bin_data),
|
||||
CBFS_TYPE_RAW);
|
||||
|
||||
while ((curr < oem_data_size) &&
|
||||
((oem_data_size - curr) >= sizeof(*oem_entry))) {
|
||||
if (oem_id == oem_entry->oem_id) {
|
||||
manuf = oem_entry->oem_name;
|
||||
break;
|
||||
}
|
||||
curr += sizeof(*oem_entry);
|
||||
oem_entry++;
|
||||
}
|
||||
|
||||
if (manuf == NULL)
|
||||
manuf = CONFIG_MAINBOARD_SMBIOS_MANUFACTURER;
|
||||
|
||||
return manuf;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue