summaryrefslogtreecommitdiff
path: root/common/fan.c
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2014-11-05 12:43:57 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-11-06 02:28:22 +0000
commit41cde665166da1aced2ece17f7b503c78cdb5c8f (patch)
tree6e95a130dadbd38846ad8cf32124ccdbb49ff353 /common/fan.c
parentf0809a23997d66265e625d23ebef8dba1465732f (diff)
downloadchrome-ec-41cde665166da1aced2ece17f7b503c78cdb5c8f.tar.gz
Samus: Handle fan startup in the EC, not the fan controller
The fans on samus have a recommended minimum duty cycle of 20% while running, but 30% in order to start. We've been using the EC's built-in fan controller for the start requirement, but it has a minimum fast-start duty cycle of 50%. It turns out that that speed is noticeably noisy. This change handles the startup with logic in the EC instead, so that the fan only tries to spin at 30% initially (or if it drops too much below the minimum turning speed). BUG=chrome-os-partner:33429 BRANCH=ToT,samus TEST=make buildall -j Boot the system, let it idle with the browser windows closed, the browse a bit, then idle. Listen for changes to the fans. Before, I could hear the fans kick in and out as the AP load changed. Now it's much quieter. Change-Id: Id35215520c064eb6843686ec8bb5f3618dac6cf6 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/227658 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'common/fan.c')
-rw-r--r--common/fan.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/common/fan.c b/common/fan.c
index db0b9a0d86..b99b770580 100644
--- a/common/fan.c
+++ b/common/fan.c
@@ -15,6 +15,10 @@
#include "system.h"
#include "util.h"
+/* Console output macros */
+#define CPUTS(outstr) cputs(CC_THERMAL, outstr)
+#define CPRINTS(format, args...) cprints(CC_THERMAL, format, ## args)
+
/* True if we're listening to the thermal control task. False if we're setting
* things manually. */
static int thermal_control_enabled[CONFIG_FANS];
@@ -44,14 +48,29 @@ int fan_percent_to_rpm(int fan, int pct)
/* The thermal task will only call this function with pct in [0,100]. */
test_mockable void fan_set_percent_needed(int fan, int pct)
{
- int rpm;
+ int actual_rpm, new_rpm;
+ static int prev_rpm[CONFIG_FANS];
if (!thermal_control_enabled[fan])
return;
- rpm = fan_percent_to_rpm(fan, pct);
+ new_rpm = fan_percent_to_rpm(fan, pct);
+ actual_rpm = fan_get_rpm_actual(fans[fan].ch);
- fan_set_rpm_target(fans[fan].ch, rpm);
+ /* If we want to turn and the fans are currently significantly below
+ * the minimum turning speed, we should turn at least as fast as the
+ * necessary start speed instead. */
+ if (new_rpm &&
+ actual_rpm < fans[fan].rpm_min * 9 / 10 &&
+ new_rpm < fans[fan].rpm_start)
+ new_rpm = fans[fan].rpm_start;
+
+ if (new_rpm != prev_rpm[fan]) {
+ CPRINTS("Fan %d %d%% => %d rpm", fan, pct, new_rpm);
+ prev_rpm[fan] = new_rpm;
+ }
+
+ fan_set_rpm_target(fans[fan].ch, new_rpm);
}
static void set_enabled(int fan, int enable)