mb/google/poppy/variant/nami: Overwrite AC/DC loadlines
This patch adds a function to overwrite AC/DC loadlines for differnt
projects.
BUG=b:111761175
BRANCH=None
TEST=emerge-nami coreboot chromeos-bootimage and use DCI to dump
AC/DC loadline settings. Tested on Vayne and Akali.
Change-Id: Id0068c5334c257b9f4c32b6088becbfe8391a864
Signed-off-by: Gaggery Tsai <gaggery.tsai@intel.com>
Reviewed-on: https://review.coreboot.org/27644
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
diff --git a/src/mainboard/google/poppy/variants/nami/mainboard.c b/src/mainboard/google/poppy/variants/nami/mainboard.c
index 0db485d..2052ae0 100644
--- a/src/mainboard/google/poppy/variants/nami/mainboard.c
+++ b/src/mainboard/google/poppy/variants/nami/mainboard.c
@@ -33,6 +33,41 @@
#define PL2_DEFAULT 29
#define PL2_KBL_R 25
+/* Variant for AKALI */
+#define AKALI_SA_AC_LOADLINE 1100
+#define AKALI_SA_DC_LOADLINE 1028
+#define AKALI_IA_AC_LOADLINE 272
+#define AKALI_IA_DC_LOADLINE 247
+#define AKALI_GT_AC_LOADLINE 314
+#define AKALI_GT_DC_LOADLINE 321
+
+/* We only have Akali and Nami default settings so far */
+enum project_sku {
+ PRJ_AKALI = 1,
+};
+
+static const struct {
+ enum project_sku sku;
+ int ac_loadline[NUM_VR_DOMAINS];
+ int dc_loadline[NUM_VR_DOMAINS];
+} sku_overwrite_mapping[] = {
+ {
+ .sku = PRJ_AKALI,
+ .ac_loadline = {
+ AKALI_SA_AC_LOADLINE,
+ AKALI_IA_AC_LOADLINE,
+ AKALI_GT_AC_LOADLINE,
+ AKALI_GT_AC_LOADLINE
+ },
+ .dc_loadline = {
+ AKALI_SA_DC_LOADLINE,
+ AKALI_IA_DC_LOADLINE,
+ AKALI_GT_DC_LOADLINE,
+ AKALI_GT_DC_LOADLINE
+ }
+ },
+};
+
static uint32_t get_pl2(uint32_t sku_id)
{
if ((sku_id == SKU_0_SONA) || (sku_id == SKU_1_SONA)) {
@@ -61,33 +96,6 @@
return sku_id;
}
-/* Override dev tree settings per board */
-void variant_devtree_update(void)
-{
- uint32_t sku_id = variant_board_sku();
- struct device *root = SA_DEV_ROOT;
- config_t *cfg = root->chip_info;
-
- /* Update PL2 based on SKU. */
- cfg->tdp_pl2_override = get_pl2(sku_id);
-
- switch (sku_id) {
- case SKU_0_VAYNE:
- case SKU_1_VAYNE:
- case SKU_2_VAYNE:
- case SKU_0_PANTHEON:
- case SKU_1_PANTHEON:
- case SKU_2_PANTHEON:
- case SKU_0_SONA:
- case SKU_1_SONA:
- /* Disable unused port USB port */
- cfg->usb2_ports[5].enable = 0;
- break;
- default:
- break;
- }
-}
-
const char *smbios_mainboard_sku(void)
{
static char sku_str[14]; /* sku{0..4294967295} */
@@ -194,3 +202,57 @@
break;
}
}
+
+static int find_sku_mapping(const uint8_t oem_id)
+{
+ /* Check if this OEM ID has a mapping table entry. */
+ for (int i = 0; i < ARRAY_SIZE(sku_overwrite_mapping); i++)
+ if (oem_id == sku_overwrite_mapping[i].sku)
+ return i;
+
+ return -1;
+}
+
+/* Override dev tree settings per board */
+void variant_devtree_update(void)
+{
+ uint32_t sku_id = variant_board_sku();
+ uint32_t i;
+ int oem_index;
+ struct device *root = SA_DEV_ROOT;
+ config_t *cfg = root->chip_info;
+
+ /* Update PL2 based on SKU. */
+
+ cfg->tdp_pl2_override = get_pl2(sku_id);
+
+ switch (sku_id) {
+ case SKU_0_VAYNE:
+ case SKU_1_VAYNE:
+ case SKU_2_VAYNE:
+ case SKU_0_PANTHEON:
+ case SKU_1_PANTHEON:
+ case SKU_2_PANTHEON:
+ case SKU_0_SONA:
+ case SKU_1_SONA:
+ /* Disable unused port USB port */
+ cfg->usb2_ports[5].enable = 0;
+ break;
+ default:
+ break;
+ }
+
+ /* Overwrite settings for different projects based on OEM ID*/
+ oem_index = find_sku_mapping(read_oem_id());
+
+ /* Return if the OEM ID is not supported or no changes are required */
+ if (oem_index < 0)
+ return;
+
+ for (i = 0; i < ARRAY_SIZE(cfg->domain_vr_config); i++) {
+ cfg->domain_vr_config[i].ac_loadline =
+ sku_overwrite_mapping[oem_index].ac_loadline[i];
+ cfg->domain_vr_config[i].dc_loadline =
+ sku_overwrite_mapping[oem_index].dc_loadline[i];
+ }
+}