summaryrefslogtreecommitdiff
path: root/common/thermal.c
diff options
context:
space:
mode:
authorDevin Lu <devin.lu@quantatw.com>2019-11-26 16:19:26 +0800
committerCommit Bot <commit-bot@chromium.org>2020-01-31 03:05:02 +0000
commit876de6a603072fe121afe99fbda5d4f0e9efd266 (patch)
treed7a515b7e3c05ebe5a15ba9d9427169a9fb2c994 /common/thermal.c
parentd1af13802e268f629e0f591b8f4f16543ebc6322 (diff)
downloadchrome-ec-876de6a603072fe121afe99fbda5d4f0e9efd266.tar.gz
jinlon: add dual fan control by ec
This patch allows the ec to manage two fans. Currently common/thermal.c cannot monitor more than 1 fan at the same time. This CL implements a board-specific thermal policy with multiple fans. BUG=b:141259174 BRANCH=hatch TEST=thermal team verified thermal policy is expected. Change-Id: I6ababcb0795408e8062b7605bc749e23b8bde45a Signed-off-by: Devin Lu <Devin.Lu@quantatw.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1936077 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Diffstat (limited to 'common/thermal.c')
-rw-r--r--common/thermal.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/common/thermal.c b/common/thermal.c
index f5988f7046..b39dab04cd 100644
--- a/common/thermal.c
+++ b/common/thermal.c
@@ -59,6 +59,10 @@ static void thermal_control(void)
int fmax;
int temp_fan_configured;
+#ifdef CONFIG_CUSTOM_FAN_CONTROL
+ int temp[TEMP_SENSOR_COUNT];
+#endif
+
/* Get ready to count things */
memset(count_over, 0, sizeof(count_over));
memset(count_under, 0, sizeof(count_under));
@@ -72,6 +76,12 @@ static void thermal_control(void)
/* read one */
rv = temp_sensor_read(i, &t);
+
+#ifdef CONFIG_CUSTOM_FAN_CONTROL
+ /* Store all sensors value */
+ temp[i] = K_TO_C(t);
+#endif
+
if (rv != EC_SUCCESS)
continue;
else
@@ -174,14 +184,24 @@ static void thermal_control(void)
if (temp_fan_configured) {
#ifdef CONFIG_FANS
- /* TODO(crosbug.com/p/23797): For now, we just treat all fans the
- * same. It would be better if we could assign different thermal
- * profiles to each fan - in case one fan cools the CPU while another
- * cools the radios or battery.
- */
+#ifdef CONFIG_CUSTOM_FAN_CONTROL
+ for (i = 0; i < fan_get_count(); i++) {
+ if (!is_thermal_control_enabled(i))
+ continue;
+
+ board_override_fan_control(i, temp);
+ }
+#else
+ /* TODO(crosbug.com/p/23797): For now, we just treat all
+ * fans the same. It would be better if we could assign
+ * different thermal profiles to each fan - in case one
+ * fan cools the CPU while another cools the radios or
+ * battery.
+ */
for (i = 0; i < fan_get_count(); i++)
fan_set_percent_needed(i, fmax);
#endif
+#endif
}
}