summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTino Liu <tino.liu@quanta.corp-partner.google.com>2018-06-21 19:16:08 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-07-04 02:01:53 -0700
commita84165968ca78fe7d783e522f79dd01abc6303fd (patch)
tree3a81a56a7c69e92fac4fb61e2dfc6e1452ea0c7e
parentfec3c3c7ec17aaa92332b3128ce3afd352585bed (diff)
downloadchrome-ec-a84165968ca78fe7d783e522f79dd01abc6303fd.tar.gz
NPCX/fan: Update rpm_actual in duty mode
For npcx, this patch makes rpm_actual updated at every hook_tick when fan is in duty mode (in addition to rpm mode). It also sets fan_status to LOCKED if rpm_actual > 0. BUG=b:110451144 BRANCH=master TEST=After `fanduty <percent>`, `faninfo` can see actual rpm being updated. Verify that `fanduty` doesn't impact `fanset`. Change-Id: I3685ca2b8e51d5dd12974c83656c88fecae1932c Signed-off-by: Tino Liu <tino.liu@quanta.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/1111477 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Vincent Wang <vwang@chromium.org>
-rw-r--r--chip/npcx/fan.c7
-rw-r--r--include/fan.h18
2 files changed, 23 insertions, 2 deletions
diff --git a/chip/npcx/fan.c b/chip/npcx/fan.c
index c8d6a6949d..c1a8b671b2 100644
--- a/chip/npcx/fan.c
+++ b/chip/npcx/fan.c
@@ -334,7 +334,12 @@ void fan_tick_func(void)
volatile struct fan_status_t *p_status = fan_status + ch;
/* Make sure rpm mode is enabled */
if (p_status->fan_mode != TACHO_FAN_RPM) {
- p_status->auto_status = FAN_STATUS_STOPPED;
+ /* Fan in duty mode still want rpm_actual being updated. */
+ p_status->rpm_actual = mft_fan_rpm(ch);
+ if (p_status->rpm_actual > 0)
+ p_status->auto_status = FAN_STATUS_LOCKED;
+ else
+ p_status->auto_status = FAN_STATUS_STOPPED;
continue;
}
if (!fan_get_enabled(ch))
diff --git a/include/fan.h b/include/fan.h
index 86c2822f80..5a2e010e18 100644
--- a/include/fan.h
+++ b/include/fan.h
@@ -88,7 +88,23 @@ int fan_get_rpm_target(int ch);
/* Is the fan stalled when it shouldn't be? */
int fan_is_stalled(int ch);
-/* How is the automatic RPM control doing? */
+/**
+ * STOPPED means not spinning.
+ *
+ * When setting fan rpm, some implementations in chip layer (npcx and it83xx)
+ * is to adjust fan pwm duty steps by steps. In this period, fan_status will
+ * be marked as CHANGING. After change is done, fan_status will become LOCKED.
+ *
+ * In the period of changing pwm duty, if it's trying to increase/decrease duty
+ * even when duty is already in upper/lower bound. Then this action won't work,
+ * and fan_status will be marked as FRUSTRATED.
+ *
+ * For other implementations in chip layer (mchp and mec1322), there is no
+ * changing period. So they don't have CHANGING status.
+ * Just return status as LOCKED in normal spinning case, return STOPPED when
+ * not spinning, return FRUSTRATED when the related flags (which is read from
+ * chip's register) is set.
+ */
enum fan_status {
FAN_STATUS_STOPPED = 0,
FAN_STATUS_CHANGING = 1,