diff options
-rw-r--r-- | baseboard/kalista/baseboard.c | 92 |
1 files changed, 33 insertions, 59 deletions
diff --git a/baseboard/kalista/baseboard.c b/baseboard/kalista/baseboard.c index c0c9b4ad77..ba1791d47d 100644 --- a/baseboard/kalista/baseboard.c +++ b/baseboard/kalista/baseboard.c @@ -240,14 +240,18 @@ BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT); * Thermal limits for each temp sensor. All temps are in degrees K. Must be in * same order as enum temp_sensor_id. To always ignore any temp, use 0. */ +static const int temp_fan_off = C_TO_K(30); +static const int temp_fan_max = C_TO_K(55); struct ec_thermal_config thermal_params[] = { /* {Twarn, Thigh, Thalt}, <on> * {Twarn, Thigh, X }, <off> * fan_off, fan_max */ - {{0, C_TO_K(80), C_TO_K(81)}, {0, C_TO_K(78), 0}, - C_TO_K(4), C_TO_K(76)}, /* TMP431_Internal */ - {{0, 0, 0}, {0, 0, 0}, 0, 0}, /* TMP431_Sensor_1 */ + { { 0, C_TO_K(80), C_TO_K(81) }, + { 0, C_TO_K(78), 0 }, + temp_fan_off, + temp_fan_max }, /* TMP431_Internal */ + { { 0, 0, 0 }, { 0, 0, 0 }, 0, 0 }, /* TMP431_Sensor_1 */ }; BUILD_ASSERT(ARRAY_SIZE(thermal_params) == TEMP_SENSOR_COUNT); @@ -436,27 +440,32 @@ const struct pwm_t pwm_channels[] = { }; BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT); -struct fan_step { - int on; - int off; - int rpm; +static const struct fan_step_1_1 fan_table0[] = { + { .decreasing_temp_ratio_threshold = TEMP_TO_RATIO(30), + .increasing_temp_ratio_threshold = TEMP_TO_RATIO(37), + .rpm = 2180 }, + { .decreasing_temp_ratio_threshold = TEMP_TO_RATIO(36), + .increasing_temp_ratio_threshold = TEMP_TO_RATIO(41), + .rpm = 2680 }, + { .decreasing_temp_ratio_threshold = TEMP_TO_RATIO(40), + .increasing_temp_ratio_threshold = TEMP_TO_RATIO(43), + .rpm = 3300 }, + { .decreasing_temp_ratio_threshold = TEMP_TO_RATIO(42), + .increasing_temp_ratio_threshold = TEMP_TO_RATIO(45), + .rpm = 3760 }, + { .decreasing_temp_ratio_threshold = TEMP_TO_RATIO(44), + .increasing_temp_ratio_threshold = TEMP_TO_RATIO(47), + .rpm = 4220 }, + { .decreasing_temp_ratio_threshold = TEMP_TO_RATIO(46), + .increasing_temp_ratio_threshold = TEMP_TO_RATIO(49), + .rpm = 4660 }, + { .decreasing_temp_ratio_threshold = TEMP_TO_RATIO(48), + .increasing_temp_ratio_threshold = TEMP_TO_RATIO(55), + .rpm = 4900 }, }; - -/* Note: Do not make the fan on/off point equal to 0 or 100 */ -static const struct fan_step fan_table0[] = { - {.on = 0, .off = 1, .rpm = 0}, - {.on = 36, .off = 1, .rpm = 2180}, - {.on = 62, .off = 58, .rpm = 2680}, - {.on = 68, .off = 63, .rpm = 3300}, - {.on = 75, .off = 69, .rpm = 3760}, - {.on = 81, .off = 76, .rpm = 4220}, - {.on = 88, .off = 83, .rpm = 4660}, - {.on = 98, .off = 91, .rpm = 4900}, -}; -/* 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; +static const struct fan_step_1_1 *fan_table = fan_table0; static void cbi_init(void) @@ -493,45 +502,10 @@ static void board_init(void) } DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); -int fan_percent_to_rpm(int fan, int pct) +int fan_percent_to_rpm(int fan, int temp_ratio) { - 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))) - cprintf(CC_THERMAL, "[%T Setting fan RPM to %d]\n", - fan_table[current_level].rpm); - - return fan_table[current_level].rpm; + return temp_ratio_to_rpm_hysteresis(fan_table, NUM_FAN_LEVELS, fan, + temp_ratio, NULL); } void board_rtc_reset(void) |