summaryrefslogtreecommitdiff
path: root/src/mainboard/google/kahlee/variants/baseboard/mainboard.c
diff options
context:
space:
mode:
authorMartin Roth <martinroth@chromium.org>2018-09-17 13:30:51 -0600
committerPatrick Georgi <pgeorgi@google.com>2018-09-21 07:07:52 +0000
commit4ae44fce56e7d13ff2a4246b1ab229cf603a1423 (patch)
tree3223f9c3c6baf7b358f471429e47fac17927342c /src/mainboard/google/kahlee/variants/baseboard/mainboard.c
parent06c14d096200fcd2fb595732225a5a8272b09617 (diff)
mainboard/google/kahlee: allow oem.bin file to update smbios
Grunt variants need a way to customize the mainboard vendor based on the platform. For future boards, this can probably be done via CBI, but grunt doesn't support that method. BUG=b:79874904 TEST=Build, boot, see updated mainboard vendor Change-Id: I997dc39c7f36f70cf4320ef335831245889eb475 Signed-off-by: Martin Roth <martinroth@chromium.org> Reviewed-on: https://review.coreboot.org/28651 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Raul Rangel <rrangel@google.com>
Diffstat (limited to 'src/mainboard/google/kahlee/variants/baseboard/mainboard.c')
-rw-r--r--src/mainboard/google/kahlee/variants/baseboard/mainboard.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/mainboard/google/kahlee/variants/baseboard/mainboard.c b/src/mainboard/google/kahlee/variants/baseboard/mainboard.c
index 3edcd65dc1..ad5fb2bc4f 100644
--- a/src/mainboard/google/kahlee/variants/baseboard/mainboard.c
+++ b/src/mainboard/google/kahlee/variants/baseboard/mainboard.c
@@ -15,7 +15,9 @@
#include <ec/google/chromeec/ec.h>
#include <baseboard/variants.h>
+#include <cbfs.h>
#include <gpio.h>
+#include <smbios.h>
#include <variant/gpio.h>
#include <device/pci.h>
#include <drivers/generic/bayhub/bh720.h>
@@ -73,3 +75,50 @@ void board_bh720(struct device *dev)
write32((void *)(sdbar + BH720_MEM_RW_ADR), 0x800000D0);
write32((void *)(sdbar + BH720_MEM_ACCESS_EN), 0x80000000);
}
+
+static uint8_t calc_oem_id(void)
+{
+ return variant_board_sku() / 0x10;
+}
+
+/* "oem.bin" in cbfs contains an 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;
+ const struct oem_mapping *oem_entry = (void *)&oem_bin_data;
+ size_t oem_data_size;
+ unsigned int i, oem_entries_count;
+ static const char *manuf;
+
+ if (!IS_ENABLED(CONFIG_USE_OEM_BIN))
+ return CONFIG_MAINBOARD_SMBIOS_MANUFACTURER;
+
+ if (manuf)
+ return manuf;
+
+ oem_data_size = cbfs_boot_load_file("oem.bin", oem_bin_data,
+ sizeof(oem_bin_data),
+ CBFS_TYPE_RAW);
+ oem_id = calc_oem_id();
+ oem_entries_count = oem_data_size / sizeof(*oem_entry);
+ for (i = 0; i < oem_entries_count; i++) {
+ if (oem_id == oem_entry->oem_id) {
+ manuf = oem_entry->oem_name;
+ break;
+ }
+ oem_entry++;
+ }
+
+ if (manuf == NULL)
+ manuf = CONFIG_MAINBOARD_SMBIOS_MANUFACTURER;
+
+ return manuf;
+}