summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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,