summaryrefslogtreecommitdiff
path: root/chip
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2018-06-11 18:46:22 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-07-10 09:45:54 -0700
commitba4c0cf0558bc6966c4c7f358fbeb5b87c2e8745 (patch)
treedfcaef74480fb61e9f55e8fe2d4c1ce480e45351 /chip
parent9ed36f03825946dbe4edbf40851d64f5da10f1fe (diff)
downloadchrome-ec-ba4c0cf0558bc6966c4c7f358fbeb5b87c2e8745.tar.gz
npcx: Enable PWM when starting to spin fans
Currently, the EC disables PWM for the fan with PWM=0 but it doesn't enable PWM when PWM goes up. This patch ensures the corresponding PWM channel is enabled when the EC starts spinnning a fan. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:109951096 BRANCH=none TEST=Verify the followings on Teemo: 1. Fan stops when RPM=0 2. Fan starts spinning when RPM goes up from 0 3. Fan stops when entering S3/S5 4. Fan starts spinning when leaving S3. Change-Id: I49654df81953dc22eb1e6f34cb6534886fee6343 Reviewed-on: https://chromium-review.googlesource.com/1096547 Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1128051 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'chip')
-rw-r--r--chip/npcx/fan.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/chip/npcx/fan.c b/chip/npcx/fan.c
index c1a8b671b2..c14d4e20ed 100644
--- a/chip/npcx/fan.c
+++ b/chip/npcx/fan.c
@@ -482,13 +482,18 @@ int fan_get_rpm_target(int ch)
*/
void fan_set_rpm_target(int ch, int rpm)
{
- /* If rpm = 0, disable PWM */
- if (rpm == 0)
+ if (rpm == 0) {
+ /* If rpm = 0, disable PWM immediately. Why?*/
fan_set_duty(ch, 0);
- else if (rpm > fans[ch].rpm->rpm_max)
- rpm = fans[ch].rpm->rpm_max;
- else if (rpm < fans[ch].rpm->rpm_min)
- rpm = fans[ch].rpm->rpm_min;
+ } else {
+ /* This is the counterpart of disabling PWM above. */
+ if (!fan_get_enabled(ch))
+ fan_set_enabled(ch, 1);
+ if (rpm > fans[ch].rpm->rpm_max)
+ rpm = fans[ch].rpm->rpm_max;
+ else if (rpm < fans[ch].rpm->rpm_min)
+ rpm = fans[ch].rpm->rpm_min;
+ }
/* Set target rpm */
fan_status[ch].rpm_target = rpm;