summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSue Chen <sue.chen@quanta.corp-partner.google.com>2021-12-30 14:55:57 +0800
committerCommit Bot <commit-bot@chromium.org>2022-01-06 01:58:39 +0000
commit202711bd07f9a29a909deb840e35c80121cece0c (patch)
tree3bcbcde9fbb309765509b7446085043ad985fc31
parent9620d669a2b18bc54ac412a3d69445e19708cf4e (diff)
downloadchrome-ec-202711bd07f9a29a909deb840e35c80121cece0c.tar.gz
Dewatt: Update thermal table and fan control
Modify thermal_params and fan_rpm. temp_fan_off = 27'C temp_fan_max = 80'C Add fan table: on | off | rpm ----------------------------------- X | 0'C ( 1.0%) | 0 30'C ( 5.7%) | 28'C ( 1.9%) | 3000 42'C (28.3%) | 35'C (15.1%) | 3300 45'C (34.0%) | 41'C (26.4%) | 3700 48'C (39.6%) | 44'C (32.1%) | 4000 51'C (45.3%) | 47'C (37.7%) | 4300 54'C (50.9%) | 50'C (43.4%) | 4700 66'C (73.6%) | 60'C (62.3%) | 5400 BUG=b:212658444 BRANCH=none TEST=make sure fan rpm is set correctly as the temperature of temp sensor SOC change. Signed-off-by: Sue Chen <sue.chen@quanta.corp-partner.google.com> Change-Id: Ie72289d3f7b49023b13afe8db96848ce6dd4bbf5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3361705 Reviewed-by: Rob Barnes <robbarnes@google.com>
-rw-r--r--board/dewatt/board.c57
-rw-r--r--board/dewatt/board.h1
-rw-r--r--board/dewatt/thermal.c117
3 files changed, 115 insertions, 60 deletions
diff --git a/board/dewatt/board.c b/board/dewatt/board.c
index c22a430782..c351619f9c 100644
--- a/board/dewatt/board.c
+++ b/board/dewatt/board.c
@@ -415,63 +415,6 @@ const struct temp_sensor_t temp_sensors[] = {
};
BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
-struct ec_thermal_config thermal_params[TEMP_SENSOR_COUNT] = {
- [TEMP_SENSOR_SOC] = {
- .temp_host = {
- [EC_TEMP_THRESH_HIGH] = C_TO_K(100),
- [EC_TEMP_THRESH_HALT] = C_TO_K(105),
- },
- .temp_host_release = {
- [EC_TEMP_THRESH_HIGH] = C_TO_K(80),
- },
- /* TODO: Setting fan off to 0 so it's allways on */
- .temp_fan_off = C_TO_K(0),
- .temp_fan_max = C_TO_K(70),
- },
- [TEMP_SENSOR_CHARGER] = {
- .temp_host = {
- [EC_TEMP_THRESH_HIGH] = C_TO_K(100),
- [EC_TEMP_THRESH_HALT] = C_TO_K(105),
- },
- .temp_host_release = {
- [EC_TEMP_THRESH_HIGH] = C_TO_K(80),
- },
- .temp_fan_off = 0,
- .temp_fan_max = 0,
- },
- [TEMP_SENSOR_MEMORY] = {
- .temp_host = {
- [EC_TEMP_THRESH_HIGH] = C_TO_K(100),
- [EC_TEMP_THRESH_HALT] = C_TO_K(105),
- },
- .temp_host_release = {
- [EC_TEMP_THRESH_HIGH] = C_TO_K(80),
- },
- .temp_fan_off = 0,
- .temp_fan_max = 0,
- },
- [TEMP_SENSOR_CPU] = {
- .temp_host = {
- [EC_TEMP_THRESH_HIGH] = C_TO_K(100),
- [EC_TEMP_THRESH_HALT] = C_TO_K(105),
- },
- .temp_host_release = {
- [EC_TEMP_THRESH_HIGH] = C_TO_K(80),
- },
- /*
- * CPU temp sensor fan thresholds are high because they are a
- * backup for the SOC temp sensor fan thresholds.
- */
- .temp_fan_off = C_TO_K(60),
- .temp_fan_max = C_TO_K(90),
- },
- /*
- * Note: Leave ambient entries at 0, both as it does not represent a
- * hotspot and as not all boards have this sensor
- */
-};
-BUILD_ASSERT(ARRAY_SIZE(thermal_params) == TEMP_SENSOR_COUNT);
-
static int board_get_memory_temp(int idx, int *temp_k)
{
if (chipset_in_state(CHIPSET_STATE_HARD_OFF))
diff --git a/board/dewatt/board.h b/board/dewatt/board.h
index 5aa4960d3a..c89ce748ee 100644
--- a/board/dewatt/board.h
+++ b/board/dewatt/board.h
@@ -48,6 +48,7 @@
/* Volume Button feature */
/* Fan features */
+#define CONFIG_FAN_RPM_CUSTOM
/* LED features */
#define CONFIG_LED_COMMON
diff --git a/board/dewatt/thermal.c b/board/dewatt/thermal.c
index 606d21cfdf..39be5bfd6b 100644
--- a/board/dewatt/thermal.c
+++ b/board/dewatt/thermal.c
@@ -21,9 +21,9 @@ const struct fan_conf fan_conf_0 = {
.enable_gpio = -1,
};
const struct fan_rpm fan_rpm_0 = {
- .rpm_min = 1000,
- .rpm_start = 1000,
- .rpm_max = 6500,
+ .rpm_min = 3000,
+ .rpm_start = 3000,
+ .rpm_max = 6000,
};
const struct fan_t fans[] = {
[FAN_CH_0] = {
@@ -32,3 +32,114 @@ const struct fan_t fans[] = {
},
};
BUILD_ASSERT(ARRAY_SIZE(fans) == FAN_CH_COUNT);
+
+struct ec_thermal_config thermal_params[TEMP_SENSOR_COUNT] = {
+ [TEMP_SENSOR_SOC] = {
+ .temp_host = {
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(80),
+ [EC_TEMP_THRESH_HALT] = C_TO_K(85),
+ },
+ .temp_host_release = {
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(75),
+ },
+ .temp_fan_off = C_TO_K(27),
+ .temp_fan_max = C_TO_K(80),
+ },
+ [TEMP_SENSOR_CHARGER] = {
+ .temp_host = {
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(80),
+ [EC_TEMP_THRESH_HALT] = C_TO_K(85),
+ },
+ .temp_host_release = {
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(75),
+ },
+ .temp_fan_off = 0,
+ .temp_fan_max = 0,
+ },
+ [TEMP_SENSOR_MEMORY] = {
+ .temp_host = {
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(80),
+ [EC_TEMP_THRESH_HALT] = C_TO_K(85),
+ },
+ .temp_host_release = {
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(75),
+ },
+ .temp_fan_off = 0,
+ .temp_fan_max = 0,
+ },
+ [TEMP_SENSOR_CPU] = {
+ .temp_host = {
+ [EC_TEMP_THRESH_HIGH] = 0,
+ [EC_TEMP_THRESH_HALT] = 0,
+ },
+ .temp_host_release = {
+ [EC_TEMP_THRESH_HIGH] = 0,
+ },
+ .temp_fan_off = 0,
+ .temp_fan_max = 0,
+ },
+ /*
+ * Note: Leave ambient entries at 0, both as it does not represent a
+ * hotspot and as not all boards have this sensor
+ */
+};
+BUILD_ASSERT(ARRAY_SIZE(thermal_params) == TEMP_SENSOR_COUNT);
+
+struct fan_step {
+ int on;
+ int off;
+ int rpm;
+};
+
+static const struct fan_step fan_table[] = {
+ {.on = 0, .off = 1, .rpm = 0},
+ {.on = 6, .off = 2, .rpm = 3000},
+ {.on = 28, .off = 15, .rpm = 3300},
+ {.on = 34, .off = 26, .rpm = 3700},
+ {.on = 39, .off = 32, .rpm = 4000},
+ {.on = 45, .off = 38, .rpm = 4300},
+ {.on = 51, .off = 43, .rpm = 4700},
+ {.on = 74, .off = 62, .rpm = 5400},
+};
+#define NUM_FAN_LEVELS ARRAY_SIZE(fan_table)
+
+int fan_percent_to_rpm(int fan, int pct)
+{
+ static int current_level;
+ static int previous_pct;
+ int i;
+
+ /*
+ * Compare the pct and previous pct, we have the three paths :
+ * 1. decreasing path. (check the off point)
+ * 2. increasing path. (check the on point)
+ * 3. invariant path. (return the current RPM)
+ */
+ if (pct < previous_pct) {
+ for (i = current_level; i >= 0; i--) {
+ if (pct <= fan_table[i].off)
+ current_level = i - 1;
+ else
+ break;
+ }
+ } else if (pct > previous_pct) {
+ for (i = current_level + 1; i < NUM_FAN_LEVELS; i++) {
+ if (pct >= fan_table[i].on)
+ current_level = i;
+ else
+ break;
+ }
+ }
+
+ if (current_level < 0)
+ current_level = 0;
+
+ previous_pct = pct;
+
+ if (fan_table[current_level].rpm !=
+ fan_get_rpm_target(FAN_CH(fan)))
+ CPRINTS("Setting fan RPM to %d",
+ fan_table[current_level].rpm);
+
+ return fan_table[current_level].rpm;
+}