From 4968635d22dcd4f1eed0083565c423f7a42fc74c Mon Sep 17 00:00:00 2001 From: Nicholas Chin Date: Sun, 11 May 2025 15:41:22 -0600 Subject: [PATCH 42/43] ec/dell/mec5035: Add command to disable EC-initiated thermal shutdown If command 0xBF isn't sent, the EC shuts down the system without warning as soon as the CPU temperature reaches about 87 degrees, without letting the CPU thermal throttle to try and reduce the temperature. With vendor firmware, the CPU is able to reach around 100 degrees before thermal throttling. This command was found by collecting EC commands by logging the LPC bus while running with vendor firmware and then replaying observed commands from coreboot. By systematically replaying subsets of commands in a binary search pattern and then stress testing the system, the command to disable the shutdown was isolated. The exact meaning of the parameters for this command are unknown at this time, but do seem to differ between different generations of these laptops. Due to this, the commmand should be called by mainboard specific code which passes the specific parameter value used. The Google Wilco EC code, which runs on Latitude Chromebooks and shares many commands with the standard Latitude ECs, suggests that command 0xBF tells the EC about the processors CPUID. However, the values observed in LPC bus logs do not seem to correspond with any CPUID values on the non-Chromebook systems I tested. Observed command parameter values (sent on mailbox registers 2-4): - E6430 (Ivy Bridge): 0x07, 0x00, 0x00 - M6800 (Haswell): 0x14, 0x00, 0x00 Change-Id: I42f09a3ef681007f64d9c5b1a29248b594737a86 Signed-off-by: Nicholas Chin --- src/ec/dell/mec5035/mec5035.c | 19 +++++++++++++++++++ src/ec/dell/mec5035/mec5035.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/src/ec/dell/mec5035/mec5035.c b/src/ec/dell/mec5035/mec5035.c index dffbb7960c..6c19d1f509 100644 --- a/src/ec/dell/mec5035/mec5035.c +++ b/src/ec/dell/mec5035/mec5035.c @@ -94,6 +94,25 @@ void mec5035_control_radio(enum ec_radio_dev dev, enum ec_radio_state state) ec_command(CMD_RADIO_CTRL); } +void mec5035_cmd_bf(u8 i) +{ + /* + * If this command isn't sent, the EC shuts down the system as soon as + * the CPU temperature reaches about 87 degrees. It is unknown exactly + * what the parameters represent. The Google Wilco EC code, which runs + * on Latitude Chromebooks and shares some commands with the standard + * Latitude EC code, suggests command 0xBF tells the EC the CPUID, but + * the values observed in LPC bus logs don't seem to match any CPUID + * values of the normal Latitudes this was tested with. + * Observed i values: + * - E6430 (Ivy Bridge): 0x7 + * - M6800 (Haswell): 0x14 + */ + u8 buf[3] = {i, 0, 0}; + write_mailbox_regs(buf, 2, 3); + ec_command(CMD_BF); +} + void mec5035_early_init(void) { /* If this isn't sent the EC shuts down the system after about 15 diff --git a/src/ec/dell/mec5035/mec5035.h b/src/ec/dell/mec5035/mec5035.h index 32f791cb01..e2000c455b 100644 --- a/src/ec/dell/mec5035/mec5035.h +++ b/src/ec/dell/mec5035/mec5035.h @@ -10,6 +10,7 @@ enum mec5035_cmd { CMD_MOUSE_TP = 0x1a, CMD_RADIO_CTRL = 0x2b, + CMD_BF = 0xbf, CMD_CPU_OK = 0xc2, }; @@ -37,5 +38,6 @@ u8 mec5035_mouse_touchpad(enum ec_mouse_setting setting); void mec5035_cpu_ok(void); void mec5035_early_init(void); void mec5035_control_radio(enum ec_radio_dev device, enum ec_radio_state state); +void mec5035_cmd_bf(u8 i); #endif /* _EC_DELL_MEC5035_H_ */ -- 2.51.2