summaryrefslogtreecommitdiff
path: root/config/coreboot/default/patches/0042-ec-dell-mec5035-Add-command-to-disable-EC-initiated-.patch
blob: 1b6ed2d374e1cef56ca9bcab6a458a67b7d4a1e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
From 4968635d22dcd4f1eed0083565c423f7a42fc74c Mon Sep 17 00:00:00 2001
From: Nicholas Chin <nic.c3.14@gmail.com>
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 <nic.c3.14@gmail.com>
---
 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