aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@google.com>2018-05-07 14:42:27 -0700
committerFurquan Shaikh <furquan@google.com>2018-05-09 00:48:05 +0000
commitf5b7e80c22322578f09431b98dfaf9033eb5480e (patch)
tree74e6a146cb5ce2578a00a74bd2f4a450aa76b45e /src
parent492e4db993d8963a3d4c14da38c0c7339764c29c (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/mainboard/google/poppy/Kconfig4
-rw-r--r--src/mainboard/google/poppy/variants/nami/Makefile.inc5
-rw-r--r--src/mainboard/google/poppy/variants/nami/mainboard.c77
3 files changed, 86 insertions, 0 deletions
diff --git a/src/mainboard/google/poppy/Kconfig b/src/mainboard/google/poppy/Kconfig
index 37751f484b..aa61e1c15b 100644
--- a/src/mainboard/google/poppy/Kconfig
+++ b/src/mainboard/google/poppy/Kconfig
@@ -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)
diff --git a/src/mainboard/google/poppy/variants/nami/Makefile.inc b/src/mainboard/google/poppy/variants/nami/Makefile.inc
index fcb22af376..dc436194dc 100644
--- a/src/mainboard/google/poppy/variants/nami/Makefile.inc
+++ b/src/mainboard/google/poppy/variants/nami/Makefile.inc
@@ -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
diff --git a/src/mainboard/google/poppy/variants/nami/mainboard.c b/src/mainboard/google/poppy/variants/nami/mainboard.c
index 544cdd5b24..bb77b6e9d2 100644
--- a/src/mainboard/google/poppy/variants/nami/mainboard.c
+++ b/src/mainboard/google/poppy/variants/nami/mainboard.c
@@ -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;
+}