bdk: fan: rename functions and add set from temp

- Rename functions to proper style (drivername_)
- Add fan_set_from_temp for managing the fan with passed SoC temperature.
This commit is contained in:
CTCaer
2024-06-07 17:14:05 +03:00
parent a34206df5b
commit 8b4f776c9d
3 changed files with 21 additions and 7 deletions

View File

@@ -27,7 +27,7 @@
#include <soc/timer.h>
#include <soc/t210.h>
void set_fan_duty(u32 duty)
void fan_set_duty(u32 duty)
{
static bool fan_init = false;
static u16 curr_duty = -1;
@@ -83,7 +83,7 @@ void set_fan_duty(u32 duty)
}
}
void get_fan_speed(u32 *duty, u32 *rpm)
void fan_get_speed(u32 *duty, u32 *rpm)
{
if (rpm)
{
@@ -114,3 +114,15 @@ void get_fan_speed(u32 *duty, u32 *rpm)
if (duty)
*duty = 236 - ((PWM(PWM_CONTROLLER_PWM_CSR_1) >> 16) & 0xFF);
}
void fan_set_from_temp(u32 temp)
{
if (temp >= 52)
fan_set_duty(102);
else if (temp >= 47)
fan_set_duty(76);
else if (temp >= 42)
fan_set_duty(51);
else if (temp <= 39)
fan_set_duty(0);
}