Skip to content

ec/system76/ec: Add manual fan control #245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: system76
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ec/system76/ec/acpi/ec_ram.asl
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Field (ERAM, ByteAcc, Lock, Preserve)
DUT2, 8, // Fan 2 duty
RPM1, 16, // Fan 1 RPM
RPM2, 16, // Fan 2 RPM
FCTL, 8, // Fan control mode
Offset (0xD9),
AIRP, 8, // Airplane mode LED
WINF, 8, // Enable ACPI brightness controls
Expand Down
58 changes: 57 additions & 1 deletion src/ec/system76/ec/acpi/s76.asl
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,32 @@ Device (S76D) {
Return ((Local1 << 8) | Local0)
}

// Set fan duty
// - Arg0: Fan select
// - Arg1: PWM duty (0-255)
Method (SFD, 2, Serialized) {
If (^^PCI0.LPCB.EC0.ECOK) {
// Fail here, but EC will also ignore writes if fan is
// set to automatic control.
If (^^PCI0.LPCB.EC0.FCTL == 0) {
Return (0xFF)
}

If (ToInteger (Arg0) == 0) {
^^PCI0.LPCB.EC0.DUT1 = Arg1
Return (0x00)
}
#if CONFIG(EC_SYSTEM76_EC_FAN2)
If (ToInteger (Arg0) == 1) {
^^PCI0.LPCB.EC0.DUT2 = Arg1
Return (0x00)
}
#endif
}

Return (0xFF)
}

// Temperature names
Method (NTMP, 0, Serialized) {
Return (Package() {
Expand All @@ -166,7 +192,7 @@ Device (S76D) {

// Get temperature
Method (GTMP, 1, Serialized) {
Local0 = 0;
Local0 = 0
If (^^PCI0.LPCB.EC0.ECOK) {
If (Arg0 == 0) {
Local0 = ^^PCI0.LPCB.EC0.TMP1
Expand All @@ -176,4 +202,34 @@ Device (S76D) {
}
Return (Local0)
}

// Get fan control mode
// - 0: EC automatic control
// - 1: Host control via target PWM
// - 2: Host control via target RPM
Method (GFCM, 0, Serialized) {
Local0 = 0xFF
If (^^PCI0.LPCB.EC0.ECOK) {
Local0 = ^^PCI0.LPCB.EC0.FCTL
}
Return (Local0)
}

// Set fan control mode
// - 0: EC automatic control
// - 1: Host control via target PWM
// - 2: Host control via target RPM
Method (SFCM, 1, Serialized) {
If (^^PCI0.LPCB.EC0.ECOK) {
Switch (ToInteger (Arg0)) {
Case (0x00) {
^^PCI0.LPCB.EC0.FCTL = Arg0
}

Case (0x01) {
^^PCI0.LPCB.EC0.FCTL = Arg0
}
}
}
}
}