@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Fan driver for Nintendo Switch
|
||||
*
|
||||
* Copyright (c) 2018-2023 CTCaer
|
||||
* Copyright (c) 2018-2024 CTCaer
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
@@ -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;
|
||||
@@ -49,16 +49,8 @@ void set_fan_duty(u32 duty)
|
||||
|
||||
// Enable PWM if disabled.
|
||||
if (fuse_read_hw_type() == FUSE_NX_HW_TYPE_AULA)
|
||||
{
|
||||
// Ease the stress to APB.
|
||||
bpmp_freq_t prev_fid = bpmp_clk_rate_set(BPMP_CLK_NORMAL);
|
||||
|
||||
clock_enable_pwm();
|
||||
|
||||
// Restore OC.
|
||||
bpmp_clk_rate_set(prev_fid);
|
||||
}
|
||||
|
||||
PWM(PWM_CONTROLLER_PWM_CSR_1) = PWM_CSR_EN | (0x100 << 16); // Max PWM to disable fan.
|
||||
|
||||
PINMUX_AUX(PINMUX_AUX_LCD_GPIO2) = 1; // Set source to PWM1.
|
||||
@@ -91,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)
|
||||
{
|
||||
@@ -122,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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user