jonzhang(a)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(a)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__ */
--
To view, visit https://review.coreboot.org/c/coreboot/+/34636
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I799d27734fe4b67cd1f40cae710151a01562b1b2
Gerrit-Change-Number: 34636
Gerrit-PatchSet: 1
Gerrit-Owner: jonzhang(a)fb.com
Gerrit-MessageType: newchange
jonzhang(a)fb.com has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/34634 )
Change subject: drivers/vpd: Set bool type variable matching with key/value pair
......................................................................
drivers/vpd: Set bool type variable matching with key/value pair
Summary:
Give a key/value pair in VPD binary blob, and name of a bool
type variable, set the variable value if there is a match.
Several checks are in place:
* The key/value length needs to be correct.
* The key name needs to match.
* THe value is either '1' or '0'.
Test Plan:
* Build an OCP MonoLake coreboot image, flash and run.
Reviewers: dhendrix, hpe, anpetrov
Subscribers:
Tasks:
Tags:
Signed-off-by: Jonathan Zhang <jonzhang(a)fb.com>
Change-Id: Iebdba59419a555147fc40391cf17cc6879d9e1b2
---
M src/drivers/vpd/Makefile.inc
A src/drivers/vpd/vpd_fsp.c
A src/drivers/vpd/vpd_fsp.h
3 files changed, 77 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/34/34634/1
diff --git a/src/drivers/vpd/Makefile.inc b/src/drivers/vpd/Makefile.inc
index 17019b5..368024b 100644
--- a/src/drivers/vpd/Makefile.inc
+++ b/src/drivers/vpd/Makefile.inc
@@ -1,2 +1,2 @@
-romstage-$(CONFIG_VPD) += vpd_decode.c
+romstage-$(CONFIG_VPD) += vpd_decode.c vpd_fsp.c
ramstage-$(CONFIG_VPD) += vpd.c vpd_decode.c
diff --git a/src/drivers/vpd/vpd_fsp.c b/src/drivers/vpd/vpd_fsp.c
new file mode 100644
index 0000000..adff8e9
--- /dev/null
+++ b/src/drivers/vpd/vpd_fsp.c
@@ -0,0 +1,44 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (c) 2019 The coreboot Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ */
+#include <string.h>
+#include "vpd_fsp.h"
+
+/*
+ * Process UPD variable of boolean type.
+ * Match the variable name with key name in the key/value pair,
+ * use the value to set *val.
+ * During the process, necessary checking is done, such as making
+ * sure the value length is 1, and value is either '1' or '0'.
+ */
+bool set_upd_bool(const char *upd_var,
+ const uint8_t *key, const int32_t key_len,
+ const uint8_t *value, const int32_t value_len,
+ uint8_t *val)
+{
+ int i;
+ /* Check key length and value length */
+ if (key_len != strlen(upd_var) || value_len != 1)
+ return false;
+
+ /* Matching key with variable name */
+ for (i = 0; i < key_len; i++) {
+ if (key[i] != upd_var[i])
+ return false;
+ }
+
+ /* Make sure the value is either '1' or '0' */
+ if (*value == '1') {
+ *val = 1;
+ return true;
+ } else if (*value == '0') {
+ *val = 0;
+ return true;
+ } else
+ return false;
+}
diff --git a/src/drivers/vpd/vpd_fsp.h b/src/drivers/vpd/vpd_fsp.h
new file mode 100644
index 0000000..c59f249
--- /dev/null
+++ b/src/drivers/vpd/vpd_fsp.h
@@ -0,0 +1,32 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (c) 2019 The coreboot Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ */
+
+#ifndef __VPD_FSP__
+#define __VPD_FSP__
+
+#include <inttypes.h>
+
+#define GOOGLE_VPD_2_0_OFFSET 0x600
+
+/*
+ * Process UPD variable of boolean type.
+ *
+ * Match the variable name with key name in the key/value pair,
+ * use the value to set *val.
+ * During the process, necessary checking is done, such as making
+ * sure the value length is 1, and value is either '1' or '0'.
+ *
+ * If there is a match and checking is successful, set *val
+ * accordingly, and return true; otherwise return false.
+ */
+bool set_upd_bool(const char *upd_var,
+ const uint8_t *key, const int32_t key_len,
+ const uint8_t *value, const int32_t value_len,
+ uint8_t *val);
+#endif /* __VPD_FSP__ */
--
To view, visit https://review.coreboot.org/c/coreboot/+/34634
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Iebdba59419a555147fc40391cf17cc6879d9e1b2
Gerrit-Change-Number: 34634
Gerrit-PatchSet: 1
Gerrit-Owner: jonzhang(a)fb.com
Gerrit-MessageType: newchange
Yu-Ping Wu has uploaded a new patch set (#6) to the change originally created by huayang duan. ( https://review.coreboot.org/c/coreboot/+/35017 )
Change subject: mediatek/mt8183: Set DRAM voltage for each DRAM frequency
......................................................................
mediatek/mt8183: Set DRAM voltage for each DRAM frequency
Adjust voltage for each DRAM frequency.
BUG=b:80501386
BRANCH=none
TEST=Boots correctly and stress test pass on Kukui.
Change-Id: I9539473ff708f9d0d39eb17bd3fdcb916265d33e
Signed-off-by: Huayang Duan <huayang.duan(a)mediatek.com>
---
M src/soc/mediatek/mt8183/emi.c
M src/soc/mediatek/mt8183/include/soc/dramc_pi_api.h
2 files changed, 54 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/17/35017/6
--
To view, visit https://review.coreboot.org/c/coreboot/+/35017
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I9539473ff708f9d0d39eb17bd3fdcb916265d33e
Gerrit-Change-Number: 35017
Gerrit-PatchSet: 6
Gerrit-Owner: huayang duan <huayangduan(a)gmail.com>
Gerrit-Reviewer: Huayang Duan <huayang.duan(a)mediatek.corp-partner.google.com>
Gerrit-Reviewer: Julius Werner <jwerner(a)chromium.org>
Gerrit-Reviewer: Yu-Ping Wu <yupingso(a)google.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Reviewer: hsin-hsiung wang <hsin-hsiung.wang(a)mediatek.com>
Gerrit-Reviewer: huayang duan <huayangduan(a)gmail.com>
Gerrit-CC: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-MessageType: newpatchset
Yu-Ping Wu has uploaded a new patch set (#14) to the change originally created by huayang duan. ( https://review.coreboot.org/c/coreboot/+/34990 )
Change subject: mediatek/mt8183: Enable DRAM frequency 3600Mbps for EMCP DDR
......................................................................
mediatek/mt8183: Enable DRAM frequency 3600Mbps for EMCP DDR
Devices using EMCP may run in a high DRAM frequency (e.g., 3600Mbps) while
discrete DRAM can only run at 3200Mbps. This patch enables 3600Mbps for
EMCP DDR for better system performance.
BUG=b:80501386
BRANCH=none
TEST=Boots correctly and stress test pass on Kukui.
Change-Id: Iab6a9c2c390feeb9497b051a255b29566909e656
Signed-off-by: Huayang Duan <huayang.duan(a)mediatek.com>
---
M src/soc/mediatek/mt8183/emi.c
1 file changed, 6 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/90/34990/14
--
To view, visit https://review.coreboot.org/c/coreboot/+/34990
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Iab6a9c2c390feeb9497b051a255b29566909e656
Gerrit-Change-Number: 34990
Gerrit-PatchSet: 14
Gerrit-Owner: huayang duan <huayangduan(a)gmail.com>
Gerrit-Reviewer: Hung-Te Lin <hungte(a)chromium.org>
Gerrit-Reviewer: Julius Werner <jwerner(a)chromium.org>
Gerrit-Reviewer: SJ Huang <sj.huang(a)mediatek.corp-partner.google.com>
Gerrit-Reviewer: You-Cheng Syu <youcheng(a)google.com>
Gerrit-Reviewer: Yu-Ping Wu <yupingso(a)google.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Reviewer: huayang duan <huayangduan(a)gmail.com>
Gerrit-CC: Huayang Duan <huayang.duan(a)mediatek.corp-partner.google.com>
Gerrit-CC: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-MessageType: newpatchset