mb/google/nissa/var/joxer: support DPTF oem_variables

1. Joxer uses dptf.dv to distinguish 6W/15W by setting OEM variable.
2. Update passive policy and critical policy.

BUG=b:285477026, b:293540179
TEST=emerge-nissa coreboot and check the OEM variable.

Signed-off-by: Mark Hsieh <mark_hsieh@wistron.corp-partner.google.com>
Change-Id: I4e52ac624f7d7628cce3035a2bac67fc527bc167
Reviewed-on: https://review.coreboot.org/c/coreboot/+/76773
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Eric Lai <eric_lai@quanta.corp-partner.google.com>
Reviewed-by: Sumeet R Pawnikar <sumeet.r.pawnikar@intel.com>
Reviewed-by: Derek Huang <derekhuang@google.com>
Reviewed-by: Ivan Chen <yulunchen@google.com>
diff --git a/src/mainboard/google/brya/variants/joxer/overridetree.cb b/src/mainboard/google/brya/variants/joxer/overridetree.cb
index bab93f6..f5118b7 100644
--- a/src/mainboard/google/brya/variants/joxer/overridetree.cb
+++ b/src/mainboard/google/brya/variants/joxer/overridetree.cb
@@ -1,4 +1,8 @@
 fw_config
+	field THERMAL 2 2
+		option THERMAL_FANLESS		0
+		option THERMAL_FAN		1
+	end
 	field WIFI_SAR_ID 6 6
 		option WIFI_GFP2_SAR_ID_0	0
 		option WIFI_GFP2_SAR_ID_1	1
@@ -88,22 +92,22 @@
 				## Passive Policy
 				register "policies.passive" = "{
 					[0] = DPTF_PASSIVE(CPU,         CPU,           95, 5000),
-					[1] = DPTF_PASSIVE(CPU,         TEMP_SENSOR_0, 75, 5000),
-					[2] = DPTF_PASSIVE(CHARGER,     TEMP_SENSOR_1, 75, 5000),
-					[3] = DPTF_PASSIVE(CPU,         TEMP_SENSOR_2, 75, 5000),
+					[1] = DPTF_PASSIVE(CPU,         TEMP_SENSOR_0, 65, 5000),
+					[2] = DPTF_PASSIVE(CHARGER,     TEMP_SENSOR_1, 65, 5000),
+					[3] = DPTF_PASSIVE(CPU,         TEMP_SENSOR_2, 65, 5000),
 				}"
 
 				## Critical Policy
 				register "policies.critical" = "{
 					[0] = DPTF_CRITICAL(CPU,               105, SHUTDOWN),
-					[1] = DPTF_CRITICAL(TEMP_SENSOR_0,      85, SHUTDOWN),
-					[2] = DPTF_CRITICAL(TEMP_SENSOR_1,      85, SHUTDOWN),
-					[3] = DPTF_CRITICAL(TEMP_SENSOR_2,      85, SHUTDOWN),
+					[1] = DPTF_CRITICAL(TEMP_SENSOR_0,      75, SHUTDOWN),
+					[2] = DPTF_CRITICAL(TEMP_SENSOR_1,      75, SHUTDOWN),
+					[3] = DPTF_CRITICAL(TEMP_SENSOR_2,      75, SHUTDOWN),
 				}"
 
 				register "controls.power_limits" = "{
 					.pl1 = {
-							.min_power = 3000,
+							.min_power = 6000,
 							.max_power = 6000,
 							.time_window_min = 28 * MSECS_PER_SEC,
 							.time_window_max = 32 * MSECS_PER_SEC,
@@ -126,7 +130,11 @@
 					[3] = {   8,  500 }
 				}"
 
-				device generic 0 on end
+				register "oem_data.oem_variables" = "{
+						[1] = 0x1
+				}"
+
+				device generic 0 alias dptf_policy on end
 			end
 		end
 		device ref i2c1 on
diff --git a/src/mainboard/google/brya/variants/joxer/variant.c b/src/mainboard/google/brya/variants/joxer/variant.c
index 3c23dd1..e371ada 100644
--- a/src/mainboard/google/brya/variants/joxer/variant.c
+++ b/src/mainboard/google/brya/variants/joxer/variant.c
@@ -3,10 +3,34 @@
 #include <baseboard/variants.h>
 #include <console/console.h>
 #include <device/device.h>
+#include <device/pci.h>
+#include <drivers/intel/dptf/chip.h>
 #include <fw_config.h>
 #include <soc/bootblock.h>
 #include <sar.h>
 
+WEAK_DEV_PTR(dptf_policy);
+
+static void update_oem_variables(void)
+{
+	const struct device *policy_dev = DEV_PTR(dptf_policy);
+	struct drivers_intel_dptf_config *config = policy_dev->chip_info;
+
+	if (fw_config_probe(FW_CONFIG(THERMAL, THERMAL_FANLESS))) {
+		config->oem_data.oem_variables[0] = 0;
+		config->oem_data.oem_variables[1] = 1;
+		printk(BIOS_INFO, "Set OEM Variable [0] to 0.\n");
+		printk(BIOS_INFO, "Set OEM Variable [1] to 1.\n");
+	}
+
+	if (fw_config_probe(FW_CONFIG(THERMAL, THERMAL_FAN))) {
+		config->oem_data.oem_variables[0] = 1;
+		config->oem_data.oem_variables[1] = 0;
+		printk(BIOS_INFO, "Set OEM Variable [0] to 1.\n");
+		printk(BIOS_INFO, "Set OEM Variable [1] to 0.\n");
+	}
+}
+
 const char *get_wifi_sar_cbfs_filename(void)
 {
 	return get_wifi_sar_fw_config_filename(FW_CONFIG_FIELD(WIFI_SAR_ID));
@@ -18,6 +42,8 @@
 	struct device *ufs = DEV_PTR(ufs);
 	struct device *ish = DEV_PTR(ish);
 
+	update_oem_variables();
+
 	if (!fw_config_is_provisioned()) {
 		printk(BIOS_INFO, "fw_config unprovisioned so enable all storage devices\n");
 		return;