1
0
Fork 0
mirror of https://github.com/CTCaer/hekate.git synced 2024-11-22 09:56:40 +00:00

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

@ -459,7 +459,7 @@ void hw_deinit(bool coreboot, u32 bl_magic)
// Disable temperature sensor, touchscreen, 5V regulators, Joy-Con and VIC. // Disable temperature sensor, touchscreen, 5V regulators, Joy-Con and VIC.
vic_end(); vic_end();
tmp451_end(); tmp451_end();
set_fan_duty(0); fan_set_duty(0);
touch_power_off(); touch_power_off();
jc_deinit(); jc_deinit();
regulator_5v_disable(REGULATOR_5V_ALL); regulator_5v_disable(REGULATOR_5V_ALL);

View file

@ -27,7 +27,7 @@
#include <soc/timer.h> #include <soc/timer.h>
#include <soc/t210.h> #include <soc/t210.h>
void set_fan_duty(u32 duty) void fan_set_duty(u32 duty)
{ {
static bool fan_init = false; static bool fan_init = false;
static u16 curr_duty = -1; 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) if (rpm)
{ {
@ -114,3 +114,15 @@ void get_fan_speed(u32 *duty, u32 *rpm)
if (duty) if (duty)
*duty = 236 - ((PWM(PWM_CONTROLLER_PWM_CSR_1) >> 16) & 0xFF); *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);
}

View file

@ -1,7 +1,7 @@
/* /*
* Fan driver for Nintendo Switch * Fan driver for Nintendo Switch
* *
* Copyright (c) 2018 CTCaer * Copyright (c) 2018-2024 CTCaer
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@ -22,8 +22,10 @@
#include <utils/types.h> #include <utils/types.h>
// Disable: 0 (0 RPM), min duty: 1 (960 RPM), max duty 235 (11000 RPM). // Disable: 0 (0 RPM), min duty: 1 (960 RPM), max duty 235 (11000 RPM).
void set_fan_duty(u32 duty); void fan_set_duty(u32 duty);
// Passing NULL ptr on either of the two, disables parsing of it. // Passing NULL ptr on either of the two, disables results.
void get_fan_speed(u32 *duty, u32 *rpm); void fan_get_speed(u32 *duty, u32 *rpm);
void fan_set_from_temp(u32 temp);
#endif /* __FAN_H_ */ #endif /* __FAN_H_ */