jonzhang@fb.com has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/34636 )
Change subject: mb/ocp/monolake: use RW_VPD to configure FSP UPD ......................................................................
mb/ocp/monolake: use RW_VPD to configure FSP UPD
Summary: This patch adds: * A framework to use VPD binary blob 2.0 data to configure FSP UPD. * A library to configure HyperThreading FSP UPD variable.
The framework is added in romstage to customize FSP UPD settings.
If RW_VPD and binary blob are not found, or if there is no "HyperThreading" setting in the binary blob, original configuration is used.
Test Plan: * Build an OCP MonoLake coreboot image, run following command to initialize RW_VPD and insert HyperThreading key: vpd -f build/coreboot.rom -O -i RW_VPD -s 'HyperThreading=0' * Flash the image to MonoLake, boot and observe following message in boot log: Detected 16 CPU threads
If RW_VPD partition does not exist, or if HyperThreading key/value pair does not exist, the boot log has: Detected 32 CPU threads
Signed-off-by: Jonathan Zhang jonzhang@fb.com Change-Id: Id66c3a7a0992037f59685c0c9250f90aefc3f105
Change-Id: I799d27734fe4b67cd1f40cae710151a01562b1b2 --- M src/mainboard/ocp/monolake/Makefile.inc M src/mainboard/ocp/monolake/romstage.c A src/mainboard/ocp/monolake/vpd_fsp.c A src/mainboard/ocp/monolake/vpd_fsp.h 4 files changed, 125 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/36/34636/1
diff --git a/src/mainboard/ocp/monolake/Makefile.inc b/src/mainboard/ocp/monolake/Makefile.inc index 1606476..ce674e4 100644 --- a/src/mainboard/ocp/monolake/Makefile.inc +++ b/src/mainboard/ocp/monolake/Makefile.inc @@ -13,4 +13,5 @@ ## GNU General Public License for more details. ##
+romstage-y += vpd_fsp.c ramstage-y += irqroute.c diff --git a/src/mainboard/ocp/monolake/romstage.c b/src/mainboard/ocp/monolake/romstage.c index f3ec7e3..4add5f1 100644 --- a/src/mainboard/ocp/monolake/romstage.c +++ b/src/mainboard/ocp/monolake/romstage.c @@ -23,6 +23,9 @@ #include <device/pci_ops.h> #include <soc/pci_devs.h> #include <soc/lpc.h> +#include <fmap.h> + +#include "vpd_fsp.h"
/** * /brief mainboard call for setup that needs to be done before fsp init @@ -57,9 +60,61 @@ 0x0c0ca1); }
+/* + * This function uses a key/value pair to configure UPD. + */ +static int board_configure_upd( + const uint8_t *key, int32_t key_len, + const uint8_t *value, int32_t value_len, + void *UpdData) +{ + set_upd_hyper_threading(key, key_len, value, value_len, UpdData); + + return VPD_OK; +} + /** - * /brief customize fsp parameters here if needed + * /brief customize fsp parameters, use data stored in VPD binary blob + * to configure FSP UPD variables. */ void romstage_fsp_rt_buffer_callback(FSP_INIT_RT_BUFFER *FspRtBuffer) { + struct region_device rdev; + void *rw_vpd_addr = NULL; + size_t rw_vpd_size = -1; + int32_t consumed; + UPD_DATA_REGION *UpdData = FspRtBuffer->Common.UpdDataRgnPtr; + + /* + * If RW_VPD VPD partition exists, search key/value pairs + * to see if there are relevant FSP UPD variable setting(s). + * If so, use such setting(s) to customize FSP behavior. + */ + if (CONFIG(VPD)) { + if (!fmap_locate_area_as_rdev("RW_VPD", &rdev)) { + rdev_chain(&rdev, &rdev, GOOGLE_VPD_2_0_OFFSET, + region_device_sz(&rdev) - GOOGLE_VPD_2_0_OFFSET); + rw_vpd_addr = rdev_mmap_full(&rdev); + if (rw_vpd_addr != NULL) { + rw_vpd_size = region_device_sz(&rdev); + /* Skip the VPD info header */ + rw_vpd_addr += sizeof(struct google_vpd_info); + rw_vpd_size -= sizeof(struct google_vpd_info); + /* + * decodeVpdString() is called iteratively to process + * key/value pairs in RW_VPD iteratively. In such + * processing, callback function board_configure_upd() + * is called to process a pair and update FSP UPD + * variable. + */ + for (consumed = 0; consumed < rw_vpd_size; ) { + if (decodeVpdString(rw_vpd_size, rw_vpd_addr, &consumed, + board_configure_upd, (void *)UpdData) == VPD_FAIL) + break; + } + printk(FSP_INFO_LEVEL, + "Found and Processed VPD binary blob in RW_VPD.\n"); + } + } + }; } diff --git a/src/mainboard/ocp/monolake/vpd_fsp.c b/src/mainboard/ocp/monolake/vpd_fsp.c new file mode 100644 index 0000000..ee5c9ca --- /dev/null +++ b/src/mainboard/ocp/monolake/vpd_fsp.c @@ -0,0 +1,33 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2019 The coreboot Authors. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * This file is part of the coreboot project. + */ +#include <string.h> +#include <drivers/vpd/vpd_fsp.h> +#include "vpd_fsp.h" + +/* + * For "HyperThreading" UPD variable, given a key/value + * pair, use the value to set the variable if there is match. + */ +void set_upd_hyper_threading(const uint8_t *key, + const int32_t key_len, const uint8_t *value, const int32_t value_len, + UPD_DATA_REGION *UpdData) +{ + uint8_t val; + if (set_upd_bool(FSP_VAR_HYPERTHREADING, key, key_len, value, + value_len, &val) == true) { + UpdData->HyperThreading = val; + } +} diff --git a/src/mainboard/ocp/monolake/vpd_fsp.h b/src/mainboard/ocp/monolake/vpd_fsp.h new file mode 100644 index 0000000..1e0965a --- /dev/null +++ b/src/mainboard/ocp/monolake/vpd_fsp.h @@ -0,0 +1,35 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2019 The coreboot Authors. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef __MB_OCP_MONOLAKE_VPD_FSP__ +#define __MB_OCP_MONOLAKE_VPD_FSP__ + +#include <drivers/vpd/lib_vpd.h> +#include <drivers/vpd/vpd_fsp.h> +#include <drivers/vpd/vpd_tables.h> +#include <inttypes.h> +#include <fsp.h> + +/* Define the strings for UPD variables that could be customized */ +#define FSP_VAR_HYPERTHREADING "HyperThreading" + +/* + * For "HyperThreading" UPD variable, given a key/value + * pair, use the value to set the variable if there is match. + */ +void set_upd_hyper_threading(const uint8_t *key, + const int32_t key_len, const uint8_t *value, const int32_t value_len, + UPD_DATA_REGION *UpdData); +#endif /* __MB_OCP_MONOLAKE_VPD_FSP__ */