summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2013-12-09 15:04:34 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2013-12-10 02:13:52 +0000
commit9f40f11fe815f2b8034d1863a35c0ba1854bdcba (patch)
tree0a6f83e993a6b3f3952764a83e10c672db93e749
parent78992e730bb663180e947650787b4c4c8253fc53 (diff)
downloadchrome-ec-9f40f11fe815f2b8034d1863a35c0ba1854bdcba.tar.gz
Fix bug in Samus DPTF fan control
It worked on Link because the fan number and the fan channel were both 0. Samus has two fans, connected to different GPIOs. In the EC's ACPI interface block, register 0x04 is used to get and set the fan's target duty cycle, as a percentage value. Writing a 0 to this register will set the target duty cycle to 0, writing a 100 (0x64) will set it to 100%. Writing any other value will return the fan control to the EC, rather than driving it manually from the host. Likewise, reading from this register returns the current fan target duty cycle, as a percentage. If the EC is controlling the fan automatically, the returned value will be 0xFF. BUG=chrome-os-partner:23972 BRANCH=samus TEST=manual You can monitor the fan state from the EC console with the "faninfo" command. From the host side, test this interface from a root shell. Read fan duty: iotools io_write8 0x66 0x80 iotools io_write8 0x62 4 iotools io_read8 0x62 Set fan duty to 100%: iotools io_write8 0x66 0x81 iotools io_write8 0x62 4 iotools io_write8 0x62 100 Set fan duty to 50%: iotools io_write8 0x66 0x81 iotools io_write8 0x62 4 iotools io_write8 0x62 50 Set fan duty to 0%: iotools io_write8 0x66 0x81 iotools io_write8 0x62 4 iotools io_write8 0x62 0 Set fan control back to automatic: iotools io_write8 0x66 0x81 iotools io_write8 0x62 4 iotools io_write8 0x62 -1 Change-Id: I3a133b0b16e2a5e1ce04b16cb2bf035a04a83daf Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/179373 Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--common/fan.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/common/fan.c b/common/fan.c
index 520d6fe03b..d61eba67d9 100644
--- a/common/fan.c
+++ b/common/fan.c
@@ -266,10 +266,10 @@ int dptf_get_fan_duty_target(void)
{
int fan = 0; /* TODO(crosbug.com/p/23803) */
- if (thermal_control_enabled[fan] || fan_get_rpm_mode(fan))
+ if (thermal_control_enabled[fan] || fan_get_rpm_mode(fans[fan].ch))
return -1;
- return fan_get_duty(fan);
+ return fan_get_duty(fans[fan].ch);
}
/* 0-100% sets duty, out of range means let the EC drive */
@@ -367,6 +367,7 @@ BUILD_ASSERT(CONFIG_FANS <= EC_FAN_SPEED_ENTRIES);
#define PWM_HOOK_VERSION 1
/* Saved PWM state across sysjumps */
struct pwm_fan_state {
+ /* TODO(crosbug.com/p/23530): Still treating all fans as one. */
uint16_t fan_rpm;
uint8_t fan_en;
};
@@ -381,21 +382,25 @@ static void pwm_fan_init(void)
gpio_config_module(MODULE_PWM_FAN, 1);
- for (i = 0; i < CONFIG_FANS; i++)
- fan_channel_setup(fans[i].ch, fans[i].flags);
+ for (fan = 0; fan < CONFIG_FANS; fan++)
+ fan_channel_setup(fans[fan].ch, fans[fan].flags);
prev = (const struct pwm_fan_state *)
system_get_jump_tag(PWMFAN_SYSJUMP_TAG, &version, &size);
if (prev && version == PWM_HOOK_VERSION && size == sizeof(*prev)) {
/* Restore previous state. */
- fan_set_enabled(fans[fan].ch, prev->fan_en);
- fan_set_rpm_target(fans[fan].ch, prev->fan_rpm);
+ for (fan = 0; fan < CONFIG_FANS; fan++) {
+ fan_set_enabled(fans[fan].ch, prev->fan_en);
+ fan_set_rpm_target(fans[fan].ch, prev->fan_rpm);
+ }
} else {
/* Set initial fan speed to maximum */
- fan_set_duty(fans[fan].ch, 100);
+ for (fan = 0; fan < CONFIG_FANS; fan++)
+ fan_set_duty(fans[fan].ch, 100);
}
- set_thermal_control_enabled(fan, 1);
+ for (fan = 0; fan < CONFIG_FANS; fan++)
+ set_thermal_control_enabled(fan, 1);
/* Initialize memory-mapped data */
mapped = (uint16_t *)host_get_memmap(EC_MEMMAP_FAN);