summaryrefslogtreecommitdiff
path: root/board/berknip
diff options
context:
space:
mode:
authorZick Wei <zick.wei@quanta.corp-partner.google.com>2020-07-03 16:31:10 +0800
committerCommit Bot <commit-bot@chromium.org>2020-07-23 14:58:22 +0000
commitd530b344276f27d0df73b21c54e08ed8ad686664 (patch)
tree07dcc67ce62dd350f4d582d3118f1c32c6300f5e /board/berknip
parentf8229b2b9c2a49d9b69765e946e00c0ce90048a4 (diff)
downloadchrome-ec-d530b344276f27d0df73b21c54e08ed8ad686664.tar.gz
berknip: add thermal table support
This patch add thermal control support for berknip. BUG=b:161470415 BRANCH=none TEST=verify fan rpm follow fan curve setting. Signed-off-by: Zick Wei <zick.wei@quanta.corp-partner.google.com> Change-Id: I5e67a43def0df046af860298a788aa0b3de2d1b8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2306892 Reviewed-by: Edward Hill <ecgh@chromium.org>
Diffstat (limited to 'board/berknip')
-rw-r--r--board/berknip/board.c105
-rw-r--r--board/berknip/board.h3
2 files changed, 92 insertions, 16 deletions
diff --git a/board/berknip/board.c b/board/berknip/board.c
index 27cadd5dd8..c616ba404f 100644
--- a/board/berknip/board.c
+++ b/board/berknip/board.c
@@ -324,9 +324,9 @@ const struct fan_conf fan_conf_0 = {
.enable_gpio = -1,
};
const struct fan_rpm fan_rpm_0 = {
- .rpm_min = 3100,
- .rpm_start = 3100,
- .rpm_max = 6900,
+ .rpm_min = 3000,
+ .rpm_start = 3500,
+ .rpm_max = 6200,
};
const struct fan_t fans[] = {
[FAN_CH_0] = {
@@ -423,36 +423,109 @@ const struct temp_sensor_t temp_sensors[] = {
};
BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
-const static struct ec_thermal_config thermal_thermistor = {
+const static struct ec_thermal_config thermal_thermistor_0 = {
.temp_host = {
- [EC_TEMP_THRESH_HIGH] = C_TO_K(75),
- [EC_TEMP_THRESH_HALT] = C_TO_K(80),
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(99),
+ [EC_TEMP_THRESH_HALT] = C_TO_K(99),
},
.temp_host_release = {
- [EC_TEMP_THRESH_HIGH] = C_TO_K(65),
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(98),
},
- .temp_fan_off = C_TO_K(25),
- .temp_fan_max = C_TO_K(50),
+ .temp_fan_off = C_TO_K(37),
+ .temp_fan_max = C_TO_K(70),
+};
+
+const static struct ec_thermal_config thermal_thermistor_1 = {
+ .temp_host = {
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(99),
+ [EC_TEMP_THRESH_HALT] = C_TO_K(99),
+ },
+ .temp_host_release = {
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(98),
+ },
+ .temp_fan_off = C_TO_K(98),
+ .temp_fan_max = C_TO_K(99),
};
const static struct ec_thermal_config thermal_cpu = {
.temp_host = {
- [EC_TEMP_THRESH_HIGH] = C_TO_K(85),
- [EC_TEMP_THRESH_HALT] = C_TO_K(95),
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(90),
+ [EC_TEMP_THRESH_HALT] = C_TO_K(105),
},
.temp_host_release = {
- [EC_TEMP_THRESH_HIGH] = C_TO_K(65),
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(80),
},
- .temp_fan_off = C_TO_K(25),
- .temp_fan_max = C_TO_K(50),
+ .temp_fan_off = C_TO_K(105),
+ .temp_fan_max = C_TO_K(105),
};
struct ec_thermal_config thermal_params[TEMP_SENSOR_COUNT];
+struct fan_step {
+ int on;
+ int off;
+ int rpm;
+};
+
+static const struct fan_step fan_table0[] = {
+ {.on = 0, .off = 3, .rpm = 0},
+ {.on = 18, .off = 3, .rpm = 3700},
+ {.on = 33, .off = 12, .rpm = 4000},
+ {.on = 48, .off = 24, .rpm = 4500},
+ {.on = 64, .off = 36, .rpm = 4800},
+ {.on = 85, .off = 48, .rpm = 5200},
+ {.on = 100, .off = 70, .rpm = 6200},
+};
+/* All fan tables must have the same number of levels */
+#define NUM_FAN_LEVELS ARRAY_SIZE(fan_table0)
+
+static const struct fan_step *fan_table = fan_table0;
+
+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(CC_THERMAL, "Setting fan RPM to %d",
+ fan_table[current_level].rpm);
+
+ return fan_table[current_level].rpm;
+}
+
static void setup_fans(void)
{
- thermal_params[TEMP_SENSOR_CHARGER] = thermal_thermistor;
- thermal_params[TEMP_SENSOR_SOC] = thermal_thermistor;
+ thermal_params[TEMP_SENSOR_CHARGER] = thermal_thermistor_1;
+ thermal_params[TEMP_SENSOR_SOC] = thermal_thermistor_0;
thermal_params[TEMP_SENSOR_CPU] = thermal_cpu;
}
DECLARE_HOOK(HOOK_INIT, setup_fans, HOOK_PRIO_DEFAULT);
diff --git a/board/berknip/board.h b/board/berknip/board.h
index 26d402dbae..569c9bd49c 100644
--- a/board/berknip/board.h
+++ b/board/berknip/board.h
@@ -15,6 +15,8 @@
#define CONFIG_MKBP_USE_GPIO
+#define RPM_DEVIATION 1
+
/* Motion sensing drivers */
#define CONFIG_ACCELGYRO_BMI160
#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
@@ -23,6 +25,7 @@
#define CONFIG_ACCEL_KX022
#define CONFIG_CMD_ACCELS
#define CONFIG_CMD_ACCEL_INFO
+#define CONFIG_FAN_RPM_CUSTOM
#define CONFIG_TABLET_MODE
#undef CONFIG_LED_ONOFF_STATES
#define CONFIG_LED_COMMON