Fix fan turning on when powering on or resuming from suspend

This commit is contained in:
Jeremy Soller
2020-04-01 20:03:09 -06:00
parent d2ae447f4c
commit 4fdb9ecbdc
6 changed files with 114 additions and 84 deletions

View File

@ -1,6 +1,7 @@
#include <stdbool.h>
#include <board/peci.h>
#include <board/power.h>
#include <common/debug.h>
#include <common/macro.h>
#include <ec/gpio.h>
@ -77,6 +78,9 @@ void peci_init(void) {
// PECI information can be found here: https://www.intel.com/content/dam/www/public/us/en/documents/design-guides/core-i7-lga-2011-guide.pdf
void peci_event(void) {
if (power_state == POWER_STATE_S0) {
// Use PECI if in S0 state
// Wait for completion
while (HOSTAR & 1) {}
// Clear status
@ -112,6 +116,12 @@ void peci_event(void) {
peci_temp = 0;
peci_duty = PWM_DUTY(50);
}
} else {
// Turn fan off if not in S0 state
peci_offset = 0;
peci_temp = 0;
peci_duty = PWM_DUTY(0);
}
if (peci_duty != DCR2) {
DCR2 = peci_duty;

View File

@ -372,7 +372,7 @@ void power_event(void) {
rst_last = rst_new;
#if LEVEL >= LEVEL_DEBUG
static bool sus_last = false;
static bool sus_last = true;
bool sus_new = gpio_get(&SLP_SUS_N);
if (!sus_new && sus_last) {
DEBUG("%02X: SLP_SUS# asserted\n", main_cycle);

View File

@ -1,6 +1,7 @@
#include <stdbool.h>
#include <board/peci.h>
#include <board/power.h>
#include <common/debug.h>
#include <common/macro.h>
#include <ec/gpio.h>
@ -77,6 +78,9 @@ void peci_init(void) {
// PECI information can be found here: https://www.intel.com/content/dam/www/public/us/en/documents/design-guides/core-i7-lga-2011-guide.pdf
void peci_event(void) {
if (power_state == POWER_STATE_S0) {
// Use PECI if in S0 state
// Wait for completion
while (HOSTAR & 1) {}
// Clear status
@ -112,6 +116,12 @@ void peci_event(void) {
peci_temp = 0;
peci_duty = PWM_DUTY(50);
}
} else {
// Turn fan off if not in S0 state
peci_offset = 0;
peci_temp = 0;
peci_duty = PWM_DUTY(0);
}
if (peci_duty != DCR2) {
DCR2 = peci_duty;

View File

@ -369,7 +369,7 @@ void power_event(void) {
rst_last = rst_new;
#if LEVEL >= LEVEL_DEBUG
static bool sus_last = false;
static bool sus_last = true;
bool sus_new = gpio_get(&SLP_SUS_N);
if (!sus_new && sus_last) {
DEBUG("%02X: SLP_SUS# asserted\n", main_cycle);

View File

@ -1,6 +1,7 @@
#include <stdbool.h>
#include <board/peci.h>
#include <board/power.h>
#include <common/debug.h>
#include <common/macro.h>
#include <ec/gpio.h>
@ -77,6 +78,9 @@ void peci_init(void) {
// PECI information can be found here: https://www.intel.com/content/dam/www/public/us/en/documents/design-guides/core-i7-lga-2011-guide.pdf
void peci_event(void) {
if (power_state == POWER_STATE_S0) {
// Use PECI if in S0 state
// Wait for completion
while (HOSTAR & 1) {}
// Clear status
@ -112,6 +116,12 @@ void peci_event(void) {
peci_temp = 0;
peci_duty = PWM_DUTY(50);
}
} else {
// Turn fan off if not in S0 state
peci_offset = 0;
peci_temp = 0;
peci_duty = PWM_DUTY(0);
}
if (peci_duty != DCR2) {
DCR2 = peci_duty;

View File

@ -369,7 +369,7 @@ void power_event(void) {
rst_last = rst_new;
#if LEVEL >= LEVEL_DEBUG
static bool sus_last = false;
static bool sus_last = true;
bool sus_new = gpio_get(&SLP_SUS_N);
if (!sus_new && sus_last) {
DEBUG("%02X: SLP_SUS# asserted\n", main_cycle);