Add fan module and implement fan_max switch
This commit is contained in:
parent
e01e712745
commit
a8f5fc5ec0
@ -4,8 +4,7 @@
|
||||
|
||||
#if HAVE_DGPU
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <board/fan.h>
|
||||
#include <board/gpio.h>
|
||||
#include <board/power.h>
|
||||
#include <common/debug.h>
|
||||
@ -34,12 +33,6 @@ int16_t dgpu_temp = 0;
|
||||
uint8_t dgpu_duty = 0;
|
||||
|
||||
#define DGPU_TEMP(X) ((int16_t)(X))
|
||||
#define PWM_DUTY(X) ((uint8_t)(((((uint16_t)(X)) * 255) + 99) / 100))
|
||||
|
||||
struct FanPoint {
|
||||
int16_t temp;
|
||||
uint8_t duty;
|
||||
};
|
||||
|
||||
#define FAN_POINT(T, D) { .temp = DGPU_TEMP(T), .duty = PWM_DUTY(D) }
|
||||
|
||||
@ -154,6 +147,10 @@ void dgpu_event(void) {
|
||||
|
||||
uint8_t heatup_duty = fan_heatup(dgpu_duty);
|
||||
uint8_t cooldown_duty = fan_cooldown(heatup_duty);
|
||||
if (fan_max) {
|
||||
// Override duty if fans are manually set to maximum
|
||||
cooldown_duty = 0xFF;
|
||||
}
|
||||
if (cooldown_duty != DCR4) {
|
||||
DCR4 = cooldown_duty;
|
||||
DEBUG("DGPU temp=%d = %d\n", dgpu_temp, cooldown_duty);
|
||||
|
8
src/board/system76/common/fan.c
Normal file
8
src/board/system76/common/fan.c
Normal file
@ -0,0 +1,8 @@
|
||||
#include <board/fan.h>
|
||||
|
||||
bool fan_max = false;
|
||||
|
||||
void fan_reset(void) {
|
||||
// Do not manually set fans to maximum speed
|
||||
fan_max = false;
|
||||
}
|
20
src/board/system76/common/include/board/fan.h
Normal file
20
src/board/system76/common/include/board/fan.h
Normal file
@ -0,0 +1,20 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
#ifndef _BOARD_FAN_H
|
||||
#define _BOARD_FAN_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
struct FanPoint {
|
||||
int16_t temp;
|
||||
uint8_t duty;
|
||||
};
|
||||
|
||||
#define PWM_DUTY(X) ((uint8_t)(((((uint16_t)(X)) * 255) + 99) / 100))
|
||||
|
||||
extern bool fan_max;
|
||||
|
||||
void fan_reset(void);
|
||||
|
||||
#endif // _BOARD_FAN_H
|
@ -1,7 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <board/fan.h>
|
||||
#include <board/peci.h>
|
||||
#include <board/power.h>
|
||||
#include <common/debug.h>
|
||||
@ -34,12 +33,6 @@ int16_t peci_temp = 0;
|
||||
uint8_t peci_duty = 0;
|
||||
|
||||
#define PECI_TEMP(X) (((int16_t)(X)) << 6)
|
||||
#define PWM_DUTY(X) ((uint8_t)(((((uint16_t)(X)) * 255) + 99) / 100))
|
||||
|
||||
struct FanPoint {
|
||||
int16_t temp;
|
||||
uint8_t duty;
|
||||
};
|
||||
|
||||
#define FAN_POINT(T, D) { .temp = PECI_TEMP(T), .duty = PWM_DUTY(D) }
|
||||
|
||||
@ -237,6 +230,10 @@ void peci_event(void) {
|
||||
|
||||
uint8_t heatup_duty = fan_heatup(peci_duty);
|
||||
uint8_t cooldown_duty = fan_cooldown(heatup_duty);
|
||||
if (fan_max) {
|
||||
// Override duty if fans are manually set to maximum
|
||||
cooldown_duty = 0xFF;
|
||||
}
|
||||
if (cooldown_duty != DCR2) {
|
||||
DCR2 = cooldown_duty;
|
||||
DEBUG("PECI offset=%d, temp=%d = %d\n", peci_offset, peci_temp, cooldown_duty);
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <board/battery.h>
|
||||
#include <board/board.h>
|
||||
#include <board/config.h>
|
||||
#include <board/fan.h>
|
||||
#include <board/gpio.h>
|
||||
#include <board/kbled.h>
|
||||
#include <board/lid.h>
|
||||
@ -337,6 +338,8 @@ static void power_cpu_reset(void) {
|
||||
pnp_enable();
|
||||
// Reset ACPI registers
|
||||
acpi_reset();
|
||||
// Reset fans
|
||||
fan_reset();
|
||||
//TODO: reset KBC and touchpad states
|
||||
kbled_reset();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user