summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Chi <peter_chi@wistron.corp-partner.google.com>2022-07-22 14:41:42 +0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-08-05 00:51:18 +0000
commit18e2818a999503c3f130fc71379488047b4cef89 (patch)
tree6e9188756cd902dadfa7a5ccb582b838a73a42f5
parent36f17e697c83b5df64cb22de9d75d4c31aa3a19a (diff)
downloadchrome-ec-18e2818a999503c3f130fc71379488047b4cef89.tar.gz
crota: modify fan rpm range and rpm deviation
Crota's fan speed is control by four sensors, and sensor SOC has two slopes for fan speed, so we have five tables. Priority is: Charger > SOC > DDR > Ambient, and the sensor table decided on priorty sensor. Currently rpm deviation is 7%, It will cause [ectool pwmsetfanrpm 4000] and [ectool pwmgetfanrpm] not accurate. BUG=b:241191468 BRANCH=none TEST=make -j BOARD=crota Signed-off-by: Peter Chi <peter_chi@wistron.corp-partner.google.com> Change-Id: I7ea9c53f168b2ab3f050b87006adb772c9f08ba4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3782467 Reviewed-by: Boris Mittelberg <bmbm@google.com>
-rw-r--r--board/crota/board.h13
-rw-r--r--board/crota/fans.c185
-rw-r--r--board/crota/sensors.c15
3 files changed, 129 insertions, 84 deletions
diff --git a/board/crota/board.h b/board/crota/board.h
index 5ab17f70b3..bd9d4dc3d4 100644
--- a/board/crota/board.h
+++ b/board/crota/board.h
@@ -178,15 +178,15 @@
#define CONFIG_TEMP_SENSOR_POWER
#define CONFIG_STEINHART_HART_3V3_30K9_47K_4050B
-#define CONFIG_FANS FAN_CH_COUNT
-
/* LED defines */
#define CONFIG_LED_ONOFF_STATES
#define CONFIG_LED_ONOFF_STATES_BAT_LOW 10
/* Fan features */
#define CONFIG_CUSTOM_FAN_CONTROL
+#define CONFIG_FANS FAN_CH_COUNT
#define CONFIG_FAN_DYNAMIC
+#define RPM_DEVIATION 1
/* Charger defines */
#define CONFIG_CHARGER_BQ25720
@@ -250,6 +250,15 @@ enum pwm_channel {
enum fan_channel { FAN_CH_0 = 0, FAN_CH_COUNT };
+enum fan_rpm_table {
+ RPM_TABLE_CPU0,
+ RPM_TABLE_CPU1,
+ RPM_TABLE_DDR,
+ RPM_TABLE_CHARGER,
+ RPM_TABLE_AMBIENT,
+ FAN_RPM_TABLE_COUNT
+};
+
enum mft_channel { MFT_CH_0 = 0, MFT_CH_COUNT };
#endif /* !__ASSEMBLER__ */
diff --git a/board/crota/fans.c b/board/crota/fans.c
index ccd89f16f9..cbae27512f 100644
--- a/board/crota/fans.c
+++ b/board/crota/fans.c
@@ -15,6 +15,10 @@
#include "thermal.h"
#include "util.h"
+#define SENSOR_SOC_FAN_OFF 35
+#define SENSOR_SOC_FAN_MID 45
+#define SENSOR_SOC_FAN_MAX 51
+
/* MFT channels. These are logically separate from pwm_channels. */
const struct mft_t mft_channels[] = {
[MFT_CH_0] = {
@@ -32,118 +36,143 @@ static const struct fan_conf fan_conf_0 = {
.enable_gpio = GPIO_EN_PP5000_FAN,
};
-static const struct fan_rpm fan_rpm_0 = {
- .rpm_min = 3500,
- .rpm_start = 3500,
- .rpm_max = 4300,
-};
+static const struct fan_rpm rpm_table[FAN_RPM_TABLE_COUNT] = {
+ [RPM_TABLE_CPU0] = {
+ .rpm_min = 2200,
+ .rpm_start = 2200,
+ .rpm_max = 3700,
+ },
+
+ [RPM_TABLE_CPU1] = {
+ .rpm_min = 3700,
+ .rpm_start = 3700,
+ .rpm_max = 4000,
+ },
-static const struct fan_rpm fan_rpm_1 = {
- .rpm_min = 4300,
- .rpm_start = 4300,
- .rpm_max = 4700,
+ [RPM_TABLE_DDR] = {
+ .rpm_min = 4000,
+ .rpm_start = 4000,
+ .rpm_max = 4200,
+ },
+
+ [RPM_TABLE_CHARGER] = {
+ .rpm_min = 4000,
+ .rpm_start = 4000,
+ .rpm_max = 4200,
+ },
+
+ [RPM_TABLE_AMBIENT] = {
+ .rpm_min = 4000,
+ .rpm_start = 4000,
+ .rpm_max = 4200,
+ },
};
struct fan_t fans[FAN_CH_COUNT] = {
[FAN_CH_0] = {
.conf = &fan_conf_0,
- .rpm = &fan_rpm_0,
+ .rpm = &rpm_table[RPM_TABLE_CPU0],
},
};
-#ifndef CONFIG_FANS
-
-/*
- * TODO(b/181271666): use static fan speeds until fan and sensors are
- * tuned. for now, use:
- *
- * AP off: 33%
- * AP on: 100%
- */
-
-static void fan_slow(void)
-{
- const int duty_pct = 33;
-
- ccprints("%s: speed %d%%", __func__, duty_pct);
-
- pwm_enable(PWM_CH_FAN, 1);
- pwm_set_duty(PWM_CH_FAN, duty_pct);
-}
-
-static void fan_max(void)
-{
- const int duty_pct = 100;
-
- ccprints("%s: speed %d%%", __func__, duty_pct);
-
- pwm_enable(PWM_CH_FAN, 1);
- pwm_set_duty(PWM_CH_FAN, duty_pct);
-}
-
-DECLARE_HOOK(HOOK_INIT, fan_slow, HOOK_PRIO_DEFAULT);
-DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, fan_slow, HOOK_PRIO_DEFAULT);
-DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, fan_slow, HOOK_PRIO_DEFAULT);
-DECLARE_HOOK(HOOK_CHIPSET_RESET, fan_max, HOOK_PRIO_FIRST);
-DECLARE_HOOK(HOOK_CHIPSET_RESUME, fan_max, HOOK_PRIO_DEFAULT);
-
-#endif /* CONFIG_FANS */
-
-static void fan_set_percent(int fan, int pct, bool fan_triggered)
+static void fan_set_percent(int fan, int pct, int soc_temp, int fan_triggered)
{
int new_rpm;
- if (fan_triggered)
- fans[fan].rpm = &fan_rpm_1;
- else
- fans[fan].rpm = &fan_rpm_0;
+ switch (fan_triggered) {
+ case TEMP_SENSOR_1_SOC:
+ if (soc_temp > SENSOR_SOC_FAN_MID)
+ fans[fan].rpm = &rpm_table[RPM_TABLE_CPU1];
+ else
+ fans[fan].rpm = &rpm_table[RPM_TABLE_CPU0];
+ break;
+ case TEMP_SENSOR_2_DDR:
+ fans[fan].rpm = &rpm_table[RPM_TABLE_DDR];
+ break;
+ case TEMP_SENSOR_3_CHARGER:
+ fans[fan].rpm = &rpm_table[RPM_TABLE_CHARGER];
+ break;
+ case TEMP_SENSOR_4_AMBIENT:
+ fans[fan].rpm = &rpm_table[RPM_TABLE_AMBIENT];
+ break;
+ }
new_rpm = fan_percent_to_rpm(fan, pct);
-
fan_set_rpm_target(FAN_CH(fan), new_rpm);
}
void board_override_fan_control(int fan, int *tmp)
{
/*
- * Crota's fan speed is control by three sensors.
+ * Crota's fan speed is control by four sensors.
*
- * Sensor SOC control high loading's speed.
- * Sensor ambient control low loading's speed.
* Sensor charger control the speed when system's temperature
* is too high.
- *
- * When sensor charger is not triggered, the fan is control
- * and choose the smaller speed between SOC and ambient.
+ * Other sensors control normal loading's speed.
*
* When sensor charger is triggered, the fan speed is only
* control by sensor charger, avoid heat damage to system.
+ * When other sensors is triggered, the fan is control
+ * by other sensors.
+ *
+ * Sensor SOC has two slopes for fan speed.
+ *
*/
-
int pct;
int sensor_soc;
- int sensor_ambient;
+ int sensor_ddr;
int sensor_charger;
- bool fan_triggered;
-
- sensor_soc = thermal_fan_percent(thermal_params[0].temp_fan_off,
- thermal_params[0].temp_fan_max,
- C_TO_K(tmp[0]));
- sensor_ambient = thermal_fan_percent(thermal_params[3].temp_fan_off,
- thermal_params[3].temp_fan_max,
- C_TO_K(tmp[3]));
- sensor_charger = thermal_fan_percent(thermal_params[2].temp_fan_off,
- thermal_params[2].temp_fan_max,
- C_TO_K(tmp[2]));
+ int sensor_ambient;
+ int fan_triggered;
+
+ /* Decide sensor SOC temperature using which slope */
+ if (tmp[TEMP_SENSOR_1_SOC] > SENSOR_SOC_FAN_MID) {
+ thermal_params[TEMP_SENSOR_1_SOC].temp_fan_off =
+ C_TO_K(SENSOR_SOC_FAN_MID);
+ thermal_params[TEMP_SENSOR_1_SOC].temp_fan_max =
+ C_TO_K(SENSOR_SOC_FAN_MAX);
+ } else {
+ thermal_params[TEMP_SENSOR_1_SOC].temp_fan_off =
+ C_TO_K(SENSOR_SOC_FAN_OFF);
+ thermal_params[TEMP_SENSOR_1_SOC].temp_fan_max =
+ C_TO_K(SENSOR_SOC_FAN_MID);
+ }
+
+ sensor_soc = thermal_fan_percent(
+ thermal_params[TEMP_SENSOR_1_SOC].temp_fan_off,
+ thermal_params[TEMP_SENSOR_1_SOC].temp_fan_max,
+ C_TO_K(tmp[TEMP_SENSOR_1_SOC]));
+ sensor_ddr = thermal_fan_percent(
+ thermal_params[TEMP_SENSOR_2_DDR].temp_fan_off,
+ thermal_params[TEMP_SENSOR_2_DDR].temp_fan_max,
+ C_TO_K(tmp[TEMP_SENSOR_2_DDR]));
+ sensor_charger = thermal_fan_percent(
+ thermal_params[TEMP_SENSOR_3_CHARGER].temp_fan_off,
+ thermal_params[TEMP_SENSOR_3_CHARGER].temp_fan_max,
+ C_TO_K(tmp[TEMP_SENSOR_3_CHARGER]));
+ sensor_ambient = thermal_fan_percent(
+ thermal_params[TEMP_SENSOR_4_AMBIENT].temp_fan_off,
+ thermal_params[TEMP_SENSOR_4_AMBIENT].temp_fan_max,
+ C_TO_K(tmp[TEMP_SENSOR_4_AMBIENT]));
+ /*
+ * Decide which sensor was triggered
+ * Priority: charger > soc > ddr > ambient
+ */
if (sensor_charger) {
- fan_triggered = true;
+ fan_triggered = TEMP_SENSOR_3_CHARGER;
pct = sensor_charger;
+ } else if (sensor_soc) {
+ fan_triggered = TEMP_SENSOR_1_SOC;
+ pct = sensor_soc;
+ } else if (sensor_ddr) {
+ fan_triggered = TEMP_SENSOR_2_DDR;
+ pct = sensor_ddr;
} else {
- fan_triggered = false;
- pct = MIN(sensor_soc, sensor_ambient);
+ fan_triggered = TEMP_SENSOR_4_AMBIENT;
+ pct = sensor_ambient;
}
- /* transfer percent to rpm */
- fan_set_percent(fan, pct, fan_triggered);
+ /* Transfer percent to rpm */
+ fan_set_percent(fan, pct, tmp[TEMP_SENSOR_1_SOC], fan_triggered);
}
diff --git a/board/crota/sensors.c b/board/crota/sensors.c
index a50ad4a298..9f80bedc23 100644
--- a/board/crota/sensors.c
+++ b/board/crota/sensors.c
@@ -187,27 +187,34 @@ BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
.temp_host_release = { \
[EC_TEMP_THRESH_HIGH] = C_TO_K(77), \
}, \
- .temp_fan_off = C_TO_K(39), \
- .temp_fan_max = C_TO_K(52), \
+ .temp_fan_off = C_TO_K(35), \
+ .temp_fan_max = C_TO_K(45), \
}
__maybe_unused static const struct ec_thermal_config thermal_cpu = THERMAL_CPU;
+#define THERMAL_DDR \
+ { \
+ .temp_fan_off = C_TO_K(56), .temp_fan_max = C_TO_K(59), \
+ }
+__maybe_unused static const struct ec_thermal_config thermal_ddr = THERMAL_DDR;
+
#define THERMAL_CHARGER \
{ \
- .temp_fan_off = C_TO_K(59), .temp_fan_max = C_TO_K(65), \
+ .temp_fan_off = C_TO_K(67), .temp_fan_max = C_TO_K(70), \
}
__maybe_unused static const struct ec_thermal_config thermal_charger =
THERMAL_CHARGER;
#define THERMAL_AMBIENT \
{ \
- .temp_fan_off = C_TO_K(26), .temp_fan_max = C_TO_K(31), \
+ .temp_fan_off = C_TO_K(38), .temp_fan_max = C_TO_K(45), \
}
__maybe_unused static const struct ec_thermal_config thermal_ambient =
THERMAL_AMBIENT;
struct ec_thermal_config thermal_params[] = {
[TEMP_SENSOR_1_SOC] = THERMAL_CPU,
+ [TEMP_SENSOR_2_DDR] = THERMAL_DDR,
[TEMP_SENSOR_3_CHARGER] = THERMAL_CHARGER,
[TEMP_SENSOR_4_AMBIENT] = THERMAL_AMBIENT,
};