diff options
author | loganliao <Logan_Liao@compal.corp-partner.google.com> | 2020-03-03 15:12:02 +0800 |
---|---|---|
committer | Bob Moragues <moragues@chromium.org> | 2020-03-23 23:41:14 +0000 |
commit | 4fbd42f531c8e73902c0d3e45f9fd9aa0efd374a (patch) | |
tree | 115d4c65aa881951aa2a1880cbf6a8b6882d2801 | |
parent | 07909845a4d6f7a2d91bc3438622d28298702729 (diff) | |
download | chrome-ec-4fbd42f531c8e73902c0d3e45f9fd9aa0efd374a.tar.gz |
Mushu : add dual fan control by EC
Currently cannot monitor more than one fan at the same time. This patch
distinguish between temperature which read from GPU and read from
Charger. Allow EC control two fans individually.
BUG=b:148968367
BRANCH=none
TEST=make BOARD=mushu
Change-Id: I7841fb1cd9f214effa1372e24a9b943b4608a2bb
Signed-off-by: loganliao <Logan_Liao@compal.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2082305
Reviewed-by: Bob Moragues <moragues@chromium.org>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Reviewed-by: Logan Liao <logan_liao@compal.corp-partner.google.com>
Tested-by: Bob Moragues <moragues@chromium.org>
-rw-r--r-- | board/mushu/board.h | 1 | ||||
-rw-r--r-- | board/mushu/build.mk | 2 | ||||
-rw-r--r-- | board/mushu/thermal.c | 63 |
3 files changed, 65 insertions, 1 deletions
diff --git a/board/mushu/board.h b/board/mushu/board.h index 9059acf937..38f9984750 100644 --- a/board/mushu/board.h +++ b/board/mushu/board.h @@ -92,6 +92,7 @@ /* Fan features */ #define CONFIG_FANS 2 +#define CONFIG_CUSTOM_FAN_CONTROL #undef CONFIG_FAN_INIT_SPEED #define CONFIG_FAN_INIT_SPEED 50 #define CONFIG_TEMP_SENSOR_POWER_GPIO GPIO_EN_A_RAILS diff --git a/board/mushu/build.mk b/board/mushu/build.mk index 733912454f..2d6118ea70 100644 --- a/board/mushu/build.mk +++ b/board/mushu/build.mk @@ -11,5 +11,5 @@ CHIP_FAMILY:=npcx7 CHIP_VARIANT:=npcx7m6fc BASEBOARD:=hatch -board-y=board.o led.o +board-y=board.o led.o thermal.o board-$(CONFIG_BATTERY_SMART)+=battery.o diff --git a/board/mushu/thermal.c b/board/mushu/thermal.c new file mode 100644 index 0000000000..92fe68ce7e --- /dev/null +++ b/board/mushu/thermal.c @@ -0,0 +1,63 @@ +/* Copyright 2020 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "chipset.h" +#include "common.h" +#include "console.h" +#include "fan.h" +#include "host_command.h" +#include "temp_sensor.h" +#include "thermal.h" +#include "util.h" + +static int fan_control[FAN_CH_COUNT]; + +void fan_set_percent(int fan, int pct) +{ + int actual_rpm; + int new_rpm; + + new_rpm = fan_percent_to_rpm(fan, pct); + actual_rpm = fan_get_rpm_actual(FAN_CH(fan)); + + if (new_rpm && + actual_rpm < fans[fan].rpm->rpm_min * 9 / 10 && + new_rpm < fans[fan].rpm->rpm_start) + new_rpm = fans[fan].rpm->rpm_start; + + fan_set_rpm_target(FAN_CH(fan), new_rpm); +} + +void board_override_fan_control(int fan, int *tmp) +{ + int i, f; + int fmax = 0; + int temp_fan_configured = 0; + + for (i = 0; i < TEMP_SENSOR_COUNT; ++i) { + tmp[i] = C_TO_K(tmp[i]); + + /* figure out the max fan needed */ + if (thermal_params[i].temp_fan_off && + thermal_params[i].temp_fan_max) { + f = thermal_fan_percent(thermal_params[i].temp_fan_off, + thermal_params[i].temp_fan_max, + tmp[i]); + if (i == TEMP_GPU) + fan_control[FAN_CH_1] = f; + else { + if (f > fmax) { + fan_control[FAN_CH_0] = f; + fmax = f; + } else + fan_control[FAN_CH_0] = fmax; + } + temp_fan_configured = 1; + } + } + /* transfer percent to rpm */ + if (temp_fan_configured) + fan_set_percent(fan, fan_control[fan]); +} |