diff options
author | Michael5 Chen <michael5_chen1@pegatron.corp-partner.google.com> | 2020-10-22 18:11:11 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-10-28 20:38:56 +0000 |
commit | 4a9ba76bf50fe343f0665935489d32c4df3f7e26 (patch) | |
tree | efa76b59e79e845c8077f8398ce337c761af97f2 /board/woomax | |
parent | 53962368a6c70d4e2e885df211c96950c8b26d25 (diff) | |
download | chrome-ec-4a9ba76bf50fe343f0665935489d32c4df3f7e26.tar.gz |
woomax: Implement EC fan control table
Implement EC fan control table by thermal request.
BUG=b:171025573
BRANCH=firmware-zork-13434.B
TEST=make BOARD=woomax
Signed-off-by: Michael5 Chen <michael5_chen1@pegatron.corp-partner.google.com>
Change-Id: Iafdea26ecc9f27092df92634f7d89a9b4ce8d7db
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2491940
Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Commit-Queue: Denis Brockus <dbrockus@chromium.org>
Diffstat (limited to 'board/woomax')
-rw-r--r-- | board/woomax/board.c | 18 | ||||
-rw-r--r-- | board/woomax/board.h | 3 | ||||
-rw-r--r-- | board/woomax/build.mk | 2 | ||||
-rw-r--r-- | board/woomax/thermal.c | 139 |
4 files changed, 152 insertions, 10 deletions
diff --git a/board/woomax/board.c b/board/woomax/board.c index e70d1fcb1d..80d9329a71 100644 --- a/board/woomax/board.c +++ b/board/woomax/board.c @@ -369,9 +369,9 @@ const struct fan_conf fan_conf_0 = { .enable_gpio = -1, }; const struct fan_rpm fan_rpm_0 = { - .rpm_min = 3000, - .rpm_start = 3000, - .rpm_max = 4900, + .rpm_min = 1100, + .rpm_start = 1100, + .rpm_max = 5120, }; const struct fan_t fans[] = { [FAN_CH_0] = { @@ -454,11 +454,11 @@ BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT); const static struct ec_thermal_config thermal_thermistor = { .temp_host = { - [EC_TEMP_THRESH_HIGH] = C_TO_K(90), - [EC_TEMP_THRESH_HALT] = C_TO_K(92), + [EC_TEMP_THRESH_HIGH] = C_TO_K(95), + [EC_TEMP_THRESH_HALT] = C_TO_K(100), }, .temp_host_release = { - [EC_TEMP_THRESH_HIGH] = C_TO_K(80), + [EC_TEMP_THRESH_HIGH] = C_TO_K(90), }, .temp_fan_off = C_TO_K(25), .temp_fan_max = C_TO_K(58), @@ -466,11 +466,11 @@ const static struct ec_thermal_config thermal_thermistor = { const static struct ec_thermal_config thermal_cpu = { .temp_host = { - [EC_TEMP_THRESH_HIGH] = C_TO_K(90), - [EC_TEMP_THRESH_HALT] = C_TO_K(92), + [EC_TEMP_THRESH_HIGH] = C_TO_K(95), + [EC_TEMP_THRESH_HALT] = C_TO_K(100), }, .temp_host_release = { - [EC_TEMP_THRESH_HIGH] = C_TO_K(80), + [EC_TEMP_THRESH_HIGH] = C_TO_K(90), }, .temp_fan_off = C_TO_K(25), .temp_fan_max = C_TO_K(58), diff --git a/board/woomax/board.h b/board/woomax/board.h index 6bc09a7a47..049f327df9 100644 --- a/board/woomax/board.h +++ b/board/woomax/board.h @@ -46,6 +46,9 @@ #undef CONFIG_POWER_BUTTON_INIT_TIMEOUT #define CONFIG_POWER_BUTTON_INIT_TIMEOUT 5 +/* Thermal */ +#define CONFIG_CUSTOM_FAN_CONTROL + /* GPIO mapping from board specific name to EC common name. */ #define CONFIG_BATTERY_PRESENT_GPIO GPIO_EC_BATT_PRES_ODL #define CONFIG_SCI_GPIO GPIO_EC_FCH_SCI_ODL diff --git a/board/woomax/build.mk b/board/woomax/build.mk index 1c0cbc4f63..a674573a4d 100644 --- a/board/woomax/build.mk +++ b/board/woomax/build.mk @@ -11,5 +11,5 @@ CHIP_FAMILY:=npcx7 CHIP_VARIANT:=npcx7m7wc BASEBOARD:=zork -board-y=board.o led.o +board-y=board.o led.o thermal.o board-$(CONFIG_BATTERY_SMART)+=battery.o diff --git a/board/woomax/thermal.c b/board/woomax/thermal.c new file mode 100644 index 0000000000..2e77f78e42 --- /dev/null +++ b/board/woomax/thermal.c @@ -0,0 +1,139 @@ +/* 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 "extpower.h" +#include "fan.h" +#include "hooks.h" +#include "host_command.h" +#include "temp_sensor.h" +#include "thermal.h" +#include "util.h" + +/* Console output macros */ +#define CPUTS(outstr) cputs(CC_THERMAL, outstr) +#define CPRINTS(format, args...) cprints(CC_THERMAL, format, ## args) + +struct fan_step { + /* + * Sensor 1~3 trigger point, set -1 if we're not using this + * sensor to determine fan speed. + */ + int8_t on[TEMP_SENSOR_COUNT]; + + /* + * Sensor 1~3 trigger point, set -1 if we're not using this + * sensor to determine fan speed. + */ + int8_t off[TEMP_SENSOR_COUNT]; + + /* Fan rpm */ + uint16_t rpm; +}; + +static const struct fan_step fan_step_table[] = { + { + /* level 0 */ + .on = {-1, -1, 36}, + .off = {-1, -1, 99}, + .rpm = 0, + }, + { + /* level 1 */ + .on = {-1, -1, 40}, + .off = {-1, -1, 32}, + .rpm = 2244, + }, + { + /* level 2 */ + .on = {-1, -1, 45}, + .off = {-1, -1, 35}, + .rpm = 2580, + }, + { + /* level 3 */ + .on = {-1, -1, 50}, + .off = {-1, -1, 40}, + .rpm = 2824, + }, + { + /* level 4 */ + .on = {-1, -1, 55}, + .off = {-1, -1, 45}, + .rpm = 3120, + }, + { + /* level 5 */ + .on = {-1, -1, 60}, + .off = {-1, -1, 50}, + .rpm = 3321, + }, + { + /* level 6 */ + .on = {-1, -1, 70}, + .off = {-1, -1, 55}, + .rpm = 3780, + }, + { + /* level 7 */ + .on = {-1, -1, 80}, + .off = {-1, -1, 60}, + .rpm = 4339, + }, + { + /* level 8 */ + .on = {-1, -1, 99}, + .off = {-1, -1, 74}, + }, +}; + +#define NUM_FAN_LEVELS ARRAY_SIZE(fan_step_table) + +int fan_table_to_rpm(int fan, int *temp) +{ + static int current_level; + static int prev_tmp[TEMP_SENSOR_COUNT]; + int i; + + /* + * Comopare the current and previous temperature, we have + * the three path: + * 1. decreasing path. (check the release point) + * 2. increasing path. (check the trigger point) + * 3. invariant path. (return the current RPM) + */ + if (temp[TEMP_SENSOR_CPU] < prev_tmp[TEMP_SENSOR_CPU]) { + if (temp[TEMP_SENSOR_CPU] < + fan_step_table[current_level].off[TEMP_SENSOR_CPU]) + current_level = current_level - 1; + } else if (temp[TEMP_SENSOR_CPU] > prev_tmp[TEMP_SENSOR_CPU]) { + if (temp[TEMP_SENSOR_CPU] > + fan_step_table[current_level].on[TEMP_SENSOR_CPU]) + current_level = current_level + 1; + } + + if (current_level < 0) + current_level = 0; + else if (current_level > NUM_FAN_LEVELS) + current_level = NUM_FAN_LEVELS; + + for (i = 0; i < TEMP_SENSOR_COUNT; i++) + prev_tmp[i] = temp[i]; + + return fan_step_table[current_level].rpm; +} + +void board_override_fan_control(int fan, int *tmp) +{ + if (chipset_in_state(CHIPSET_STATE_ON | + CHIPSET_STATE_ANY_SUSPEND)) { + fan_set_rpm_mode(FAN_CH(fan), 1); + fan_set_rpm_target(FAN_CH(fan), + fan_table_to_rpm(fan, tmp)); + } +} + |