fan: Better thermal logic based on HOS patterns

This commit is contained in:
CTCaer 2020-03-03 04:37:59 +02:00
parent ab8801d0de
commit ac92ca220f
2 changed files with 16 additions and 10 deletions

View file

@ -782,13 +782,13 @@ static void _update_status_bar(void *params)
max17050_get_property(MAX17050_VCELL, &batt_volt); max17050_get_property(MAX17050_VCELL, &batt_volt);
max17050_get_property(MAX17050_Current, &batt_curr); max17050_get_property(MAX17050_Current, &batt_curr);
// Enable fan if more than 46 oC.
u32 soc_temp_dec = (soc_temp >> 8); u32 soc_temp_dec = (soc_temp >> 8);
// Enable fan if more than 44 oC. if (soc_temp_dec > 51)
if (soc_temp_dec > 50) set_fan_duty(102);
set_fan_duty(100); else if (soc_temp_dec > 46)
else if (soc_temp_dec > 44) set_fan_duty(51);
set_fan_duty(53); else if (soc_temp_dec < 40)
else
set_fan_duty(0); set_fan_duty(0);
//! TODO: Parse time and use offset. //! TODO: Parse time and use offset.

View file

@ -23,14 +23,18 @@
#include "../soc/t210.h" #include "../soc/t210.h"
#include "../utils/util.h" #include "../utils/util.h"
bool fan_init = false;
void set_fan_duty(u32 duty) void set_fan_duty(u32 duty)
{ {
static bool fan_init = false;
static u16 curr_duty = -1;
if (curr_duty == duty)
return;
if (!fan_init) if (!fan_init)
{ {
// Fan tachometer. // Fan tachometer.
PINMUX_AUX(PINMUX_AUX_CAM1_PWDN) = PINMUX_PULL_UP | PINMUX_TRISTATE | PINMUX_INPUT_ENABLE | 1; PINMUX_AUX(PINMUX_AUX_CAM1_PWDN) = PINMUX_TRISTATE | PINMUX_INPUT_ENABLE | PINMUX_PULL_UP | 1;
gpio_config(GPIO_PORT_S, GPIO_PIN_7, GPIO_MODE_GPIO); gpio_config(GPIO_PORT_S, GPIO_PIN_7, GPIO_MODE_GPIO);
gpio_output_enable(GPIO_PORT_S, GPIO_PIN_7, GPIO_OUTPUT_DISABLE); gpio_output_enable(GPIO_PORT_S, GPIO_PIN_7, GPIO_OUTPUT_DISABLE);
gpio_write(GPIO_PORT_S, GPIO_PIN_7, GPIO_LOW); gpio_write(GPIO_PORT_S, GPIO_PIN_7, GPIO_LOW);
@ -52,7 +56,7 @@ void set_fan_duty(u32 duty)
// If disabled send a 0 duty. // If disabled send a 0 duty.
if (inv_duty == 236) if (inv_duty == 236)
{ {
PWM(PWM_CONTROLLER_PWM_CSR_1) = PWM_CSR_EN | (1 << 24); PWM(PWM_CONTROLLER_PWM_CSR_1) = PWM_CSR_EN | (1 << 24); // Bit 24 is absolute 0%.
regulator_disable_5v(REGULATOR_5V_FAN); regulator_disable_5v(REGULATOR_5V_FAN);
} }
else // Set PWM duty. else // Set PWM duty.
@ -61,6 +65,8 @@ void set_fan_duty(u32 duty)
regulator_enable_5v(REGULATOR_5V_FAN); regulator_enable_5v(REGULATOR_5V_FAN);
PWM(PWM_CONTROLLER_PWM_CSR_1) = PWM_CSR_EN | (inv_duty << 16); PWM(PWM_CONTROLLER_PWM_CSR_1) = PWM_CSR_EN | (inv_duty << 16);
} }
curr_duty = duty;
} }
void get_fan_speed(u32 *duty, u32 *rpm) void get_fan_speed(u32 *duty, u32 *rpm)