From a04d353096c0ece80b68e43aa0c95c20e6db48b1 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Fri, 2 Apr 2021 10:21:39 -0600 Subject: [PATCH] Fix fan_max keeping fan on when in S0iX --- src/board/system76/common/dgpu.c | 3 ++- src/board/system76/common/include/board/peci.h | 1 + src/board/system76/common/peci.c | 10 ++++++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/board/system76/common/dgpu.c b/src/board/system76/common/dgpu.c index 2ae1f55..c921f9a 100644 --- a/src/board/system76/common/dgpu.c +++ b/src/board/system76/common/dgpu.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -81,7 +82,7 @@ void dgpu_event(void) { duty = PWM_DUTY(0); } - if (fan_max) { + if (peci_on && fan_max) { // Override duty if fans are manually set to maximum duty = PWM_DUTY(100); } else { diff --git a/src/board/system76/common/include/board/peci.h b/src/board/system76/common/include/board/peci.h index c968245..dbef89c 100644 --- a/src/board/system76/common/include/board/peci.h +++ b/src/board/system76/common/include/board/peci.h @@ -5,6 +5,7 @@ #include +extern bool peci_on; extern int16_t peci_temp; void peci_init(void); diff --git a/src/board/system76/common/peci.c b/src/board/system76/common/peci.c index 7a35cd4..1a47a62 100644 --- a/src/board/system76/common/peci.c +++ b/src/board/system76/common/peci.c @@ -27,6 +27,7 @@ static uint8_t FAN_COOLDOWN[BOARD_COOLDOWN] = { 0 }; // Tjunction = 100C for i7-8565U (and probably the same for all WHL-U) #define T_JUNCTION 100 +bool peci_on = false; int16_t peci_temp = 0; #define PECI_TEMP(X) (((int16_t)(X)) << 6) @@ -123,12 +124,13 @@ void peci_event(void) { #if EC_ESPI // Use PECI if CPU is not in C10 state - if (gpio_get(&CPU_C10_GATE_N)) + peci_on = gpio_get(&CPU_C10_GATE_N); #else // EC_ESPI // Use PECI if in S0 state - if (power_state == POWER_STATE_S0) + peci_on = power_state == POWER_STATE_S0; #endif // EC_ESPI - { + + if (peci_on) { // Wait for completion while (HOSTAR & 1) {} // Clear status @@ -169,7 +171,7 @@ void peci_event(void) { duty = PWM_DUTY(0); } - if (fan_max) { + if (peci_on && fan_max) { // Override duty if fans are manually set to maximum duty = PWM_DUTY(100); } else {