Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 23f57a6

Browse files
committedJan 2, 2025
ec/system76/ec: Add manual fan control
system76/ec#512 added a manual fan control option. In manual control mode, the system firmware or OS is responsible for setting the fan target duty to manage thermals. CTR0 in the EC code determines the maximum valid PWM duty, which is hard-coded to 255. RPM target is not supported. Change-Id: Iba8cd5ac540f9fdc20473831787cafb6c1fd8129 Signed-off-by: Tim Crawford <[email protected]>
1 parent db5909d commit 23f57a6

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed
 

‎src/ec/system76/ec/acpi/ec_ram.asl

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Field (ERAM, ByteAcc, Lock, Preserve)
4242
DUT2, 8, // Fan 2 duty
4343
RPM1, 16, // Fan 1 RPM
4444
RPM2, 16, // Fan 2 RPM
45+
FCTL, 8, // Fan control mode
4546
Offset (0xD9),
4647
AIRP, 8, // Airplane mode LED
4748
WINF, 8, // Enable ACPI brightness controls

‎src/ec/system76/ec/acpi/s76.asl

+55-1
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,32 @@ Device (S76D) {
154154
Return ((Local1 << 8) | Local0)
155155
}
156156

157+
// Set fan duty
158+
// - Arg0: Fan select
159+
// - Arg1: PWM duty (0-255)
160+
Method (_SFD, 2, Serialized) {
161+
If (^^PCI0.LPCB.EC0.ECOK) {
162+
// Fail here, but EC will also ignore writes if fan is
163+
// set to automatic control.
164+
If (^^PCI0.LPCB.EC0.FCTL == 0) {
165+
Return (0xFF)
166+
}
167+
168+
If (ToInteger (Arg0) == 0) {
169+
^^PCI0.LPCB.EC0.DUT1 = Arg1
170+
Return (0x00)
171+
}
172+
#if CONFIG(EC_SYSTEM76_EC_FAN2)
173+
If (ToInteger (Arg0) == 1) {
174+
^^PCI0.LPCB.EC0.DUT2 = Arg1
175+
Return (0x00)
176+
}
177+
#endif
178+
}
179+
180+
Return (0xFF)
181+
}
182+
157183
// Temperature names
158184
Method (NTMP, 0, Serialized) {
159185
Return (Package() {
@@ -166,7 +192,7 @@ Device (S76D) {
166192

167193
// Get temperature
168194
Method (GTMP, 1, Serialized) {
169-
Local0 = 0;
195+
Local0 = 0
170196
If (^^PCI0.LPCB.EC0.ECOK) {
171197
If (Arg0 == 0) {
172198
Local0 = ^^PCI0.LPCB.EC0.TMP1
@@ -176,4 +202,32 @@ Device (S76D) {
176202
}
177203
Return (Local0)
178204
}
205+
206+
// Get fan control mode
207+
// - 0: EC automatic control
208+
// - 1: EC manual control
209+
Method (GFCM, 0, Serialized) {
210+
Local0 = 0xFF
211+
If (^^PCI0.LPCB.EC0.ECOK) {
212+
Local0 = ^^PCI0.LPCB.EC0.FCTL
213+
}
214+
Return (Local0)
215+
}
216+
217+
// Set fan control mode
218+
// - 0: EC automatic control
219+
// - 1: EC manual control
220+
Method (SFCM, 1, Serialized) {
221+
If (^^PCI0.LPCB.EC0.ECOK) {
222+
Switch (ToInteger (Arg0)) {
223+
Case (0x00) {
224+
^^PCI0.LPCB.EC0.FCTL = Arg0
225+
}
226+
227+
Case (0x01) {
228+
^^PCI0.LPCB.EC0.FCTL = Arg0
229+
}
230+
}
231+
}
232+
}
179233
}

0 commit comments

Comments
 (0)
Please sign in to comment.