mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-30 10:31:02 +00:00
Disable fan PWM when +5VS is disabled
Signed-off-by: Randall Spangler <rspangler@chromium.org> BUG=chrome-os-partner:8097 TEST=manual faninfo should report fan is disabled powerbtn system turns on, fan turns on faninfo should report fan is enabled powerbtn system turns off, fan turns off faninfo should report fan is disabled again Change-Id: I8e94c142bf18d07f83bac05287bcd503a098cee7
This commit is contained in:
@@ -43,6 +43,17 @@ static void configure_gpios(void)
|
||||
}
|
||||
|
||||
|
||||
int pwm_enable_fan(int enable)
|
||||
{
|
||||
if (enable)
|
||||
LM4_FAN_FANCTL |= (1 << FAN_CH_CPU);
|
||||
else
|
||||
LM4_FAN_FANCTL &= ~(1 << FAN_CH_CPU);
|
||||
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int pwm_get_fan_rpm(void)
|
||||
{
|
||||
return (LM4_FAN_FANCST(FAN_CH_CPU) & MAX_RPM) * CPU_FAN_SCALE;
|
||||
@@ -90,6 +101,9 @@ static int command_fan_info(int argc, char **argv)
|
||||
((LM4_FAN_FANCMD(FAN_CH_CPU) >> 16)) * 100 / MAX_PWM);
|
||||
uart_printf(" status: %d\n",
|
||||
(LM4_FAN_FANSTS >> (2 * FAN_CH_CPU)) & 0x03);
|
||||
uart_printf(" enabled: %s\n",
|
||||
LM4_FAN_FANCTL & (1 << FAN_CH_CPU) ? "yes" : "no");
|
||||
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
DECLARE_CONSOLE_COMMAND(faninfo, command_fan_info);
|
||||
@@ -116,9 +130,9 @@ static int command_fan_set(int argc, char **argv)
|
||||
|
||||
/* Move the fan to automatic control */
|
||||
if (LM4_FAN_FANCH(FAN_CH_CPU) & 0x0001) {
|
||||
LM4_FAN_FANCTL &= ~(1 << FAN_CH_CPU);
|
||||
LM4_FAN_FANCH(FAN_CH_CPU) &= ~0x0001;
|
||||
LM4_FAN_FANCTL |= (1 << FAN_CH_CPU);
|
||||
pwm_enable_fan(0);
|
||||
LM4_FAN_FANCH(FAN_CH_CPU) &= ~0x0001;
|
||||
pwm_enable_fan(1);
|
||||
}
|
||||
|
||||
rv = pwm_set_fan_target_rpm(rpm);
|
||||
@@ -151,9 +165,9 @@ static int command_fan_duty(int argc, char **argv)
|
||||
|
||||
/* Move the fan to manual control */
|
||||
if (!(LM4_FAN_FANCH(FAN_CH_CPU) & 0x0001)) {
|
||||
LM4_FAN_FANCTL &= ~(1 << FAN_CH_CPU);
|
||||
pwm_enable_fan(0);
|
||||
LM4_FAN_FANCH(FAN_CH_CPU) |= 0x0001;
|
||||
LM4_FAN_FANCTL |= (1 << FAN_CH_CPU);
|
||||
pwm_enable_fan(1);
|
||||
}
|
||||
|
||||
/* Set the duty cycle */
|
||||
@@ -234,8 +248,9 @@ int pwm_init(void)
|
||||
pwm_set_fan_target_rpm(-1);
|
||||
pwm_set_keyboard_backlight(0);
|
||||
|
||||
/* Enable CPU fan and keyboard backlight */
|
||||
LM4_FAN_FANCTL |= (1 << FAN_CH_CPU) | (1 << FAN_CH_KBLIGHT);
|
||||
/* Enable keyboard backlight. Fan will be enabled later by whatever
|
||||
* controls the fan power supply. */
|
||||
LM4_FAN_FANCTL |= (1 << FAN_CH_KBLIGHT);
|
||||
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "clock.h"
|
||||
#include "console.h"
|
||||
#include "gpio.h"
|
||||
#include "pwm.h"
|
||||
#include "task.h"
|
||||
#include "timer.h"
|
||||
#include "uart.h"
|
||||
@@ -261,6 +262,9 @@ void x86_power_task(void)
|
||||
/* Turn on power rails */
|
||||
gpio_set_level(GPIO_ENABLE_VS, 1);
|
||||
|
||||
/* Enable fan, now that +5VS is turned on */
|
||||
pwm_enable_fan(1);
|
||||
|
||||
/* Wait for non-core power rails good */
|
||||
wait_in_signals(IN_PGOOD_ALL_NONCORE);
|
||||
|
||||
@@ -293,6 +297,9 @@ void x86_power_task(void)
|
||||
/* Assert RCINn */
|
||||
gpio_set_level(GPIO_PCH_RCINn, 0);
|
||||
|
||||
/* Disable fan, since it's powered by +5VS */
|
||||
pwm_enable_fan(0);
|
||||
|
||||
/* Turn off power rails */
|
||||
gpio_set_level(GPIO_ENABLE_VS, 0);
|
||||
|
||||
|
||||
@@ -13,6 +13,10 @@
|
||||
/* Initializes the module. */
|
||||
int pwm_init(void);
|
||||
|
||||
/* Enables/disables the fan. This should be called by whatever function
|
||||
* enables the power supply to the fan. */
|
||||
int pwm_enable_fan(int enable);
|
||||
|
||||
/* Gets the current fan RPM. */
|
||||
int pwm_get_fan_rpm(void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user