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:
Randall Spangler
2012-02-27 10:43:14 -08:00
parent 4f3f3fdf3d
commit 3a460ea765
3 changed files with 33 additions and 7 deletions

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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);