diff options
-rw-r--r-- | board/paine/board.c | 72 | ||||
-rw-r--r-- | board/paine/board.h | 1 | ||||
-rw-r--r-- | board/yuna/board.c | 72 | ||||
-rw-r--r-- | board/yuna/board.h | 1 |
4 files changed, 140 insertions, 6 deletions
diff --git a/board/paine/board.c b/board/paine/board.c index c513913a3f..fac0e186fe 100644 --- a/board/paine/board.c +++ b/board/paine/board.c @@ -9,6 +9,7 @@ #include "backlight.h" #include "chipset.h" #include "common.h" +#include "console.h" #include "driver/temp_sensor/g781.h" #include "extpower.h" #include "fan.h" @@ -32,6 +33,71 @@ #include "gpio_list.h" +#ifdef CONFIG_FAN_RPM_CUSTOM +#define NUM_FAN_LEVELS 8 + +struct fan_step { + int on; + int off; + int rpm; +}; + +/* Do not make the fan on/off point equal to 0 or 100 */ +const struct fan_step fan_table[NUM_FAN_LEVELS] = { + {.rpm = 0}, + {.on = 11, .off = 1, .rpm = 3200}, + {.on = 20, .off = 11, .rpm = 3700}, + {.on = 26, .off = 18, .rpm = 4000}, + {.on = 33, .off = 25, .rpm = 4400}, + {.on = 40, .off = 31, .rpm = 4900}, + {.on = 56, .off = 48, .rpm = 5500}, + {.on = 98, .off = 90, .rpm = 6500}, +}; + +int fan_percent_to_rpm(int fan, int pct) +{ + static int index; + static int previous_pct; + int i; + int temp_index; + + /* + * 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) { + temp_index = index; + } else if (pct < previous_pct) { + temp_index = 0; + for (i = 1; i <= index; i++) { + if (pct > fan_table[i].off) + temp_index = i; + else + break; + } + } else { + temp_index = NUM_FAN_LEVELS - 1; + for (i = NUM_FAN_LEVELS - 1; i > index; i--) { + if (pct < fan_table[i].on) + temp_index = i - 1; + else + break; + } + } + index = temp_index; + + previous_pct = pct; + + if (fan_table[index].rpm != fan_get_rpm_target(fans[fan].ch)) + cprintf(CC_THERMAL, "[%T Setting fan RPM to %d]\n", + fan_table[index].rpm); + + return fan_table[index].rpm; +} +#endif /* CONFIG_FAN_RPM_CUSTOM */ + /* power signal list. Must match order of enum power_signal. */ const struct power_signal_info power_signal_list[] = { {GPIO_PP5000_PGOOD, 1, "PGOOD_PP5000"}, @@ -68,8 +134,8 @@ BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT); /* Physical fans. These are logically separate from pwm_channels. */ const struct fan_t fans[] = { {.flags = FAN_USE_RPM_MODE, - .rpm_min = 1000, - .rpm_max = 5050, + .rpm_min = 3200, + .rpm_max = 6500, .ch = 2, .pgood_gpio = GPIO_PP5000_PGOOD, .enable_gpio = GPIO_PP5000_FAN_EN, @@ -100,7 +166,7 @@ BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT); */ struct ec_thermal_config thermal_params[] = { /* Only the AP affects the thermal limits and fan speed. */ - {{C_TO_K(95), C_TO_K(97), C_TO_K(99)}, C_TO_K(55), C_TO_K(85)}, + {{C_TO_K(95), C_TO_K(97), C_TO_K(99)}, C_TO_K(36), C_TO_K(96)}, {{0, 0, 0}, 0, 0}, {{0, 0, 0}, 0, 0}, {{0, 0, 0}, 0, 0}, diff --git a/board/paine/board.h b/board/paine/board.h index 91dec41e4a..a153c97e51 100644 --- a/board/paine/board.h +++ b/board/paine/board.h @@ -25,6 +25,7 @@ #define CONFIG_CMD_GSV #define CONFIG_EXTPOWER_GPIO #define CONFIG_FANS 1 +#define CONFIG_FAN_RPM_CUSTOM #define CONFIG_KEYBOARD_BOARD_CONFIG #define CONFIG_KEYBOARD_COL2_INVERTED #define CONFIG_KEYBOARD_PROTOCOL_8042 diff --git a/board/yuna/board.c b/board/yuna/board.c index 078e674162..ff12e9b664 100644 --- a/board/yuna/board.c +++ b/board/yuna/board.c @@ -9,6 +9,7 @@ #include "backlight.h" #include "chipset.h" #include "common.h" +#include "console.h" #include "driver/temp_sensor/g781.h" #include "extpower.h" #include "fan.h" @@ -32,6 +33,71 @@ #include "gpio_list.h" +#ifdef CONFIG_FAN_RPM_CUSTOM +#define NUM_FAN_LEVELS 8 + +struct fan_step { + int on; + int off; + int rpm; +}; + +/* Do not make the fan on/off point equal to 0 or 100 */ +const struct fan_step fan_table[NUM_FAN_LEVELS] = { + {.rpm = 0}, + {.on = 11, .off = 1, .rpm = 3200}, + {.on = 20, .off = 11, .rpm = 3700}, + {.on = 26, .off = 18, .rpm = 4000}, + {.on = 33, .off = 25, .rpm = 4400}, + {.on = 40, .off = 31, .rpm = 4900}, + {.on = 56, .off = 48, .rpm = 5500}, + {.on = 98, .off = 90, .rpm = 6500}, +}; + +int fan_percent_to_rpm(int fan, int pct) +{ + static int index; + static int previous_pct; + int i; + int temp_index; + + /* + * 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) { + temp_index = index; + } else if (pct < previous_pct) { + temp_index = 0; + for (i = 1; i <= index; i++) { + if (pct > fan_table[i].off) + temp_index = i; + else + break; + } + } else { + temp_index = NUM_FAN_LEVELS - 1; + for (i = NUM_FAN_LEVELS - 1; i > index; i--) { + if (pct < fan_table[i].on) + temp_index = i - 1; + else + break; + } + } + index = temp_index; + + previous_pct = pct; + + if (fan_table[index].rpm != fan_get_rpm_target(fans[fan].ch)) + cprintf(CC_THERMAL, "[%T Setting fan RPM to %d]\n", + fan_table[index].rpm); + + return fan_table[index].rpm; +} +#endif /* CONFIG_FAN_RPM_CUSTOM */ + /* power signal list. Must match order of enum power_signal. */ const struct power_signal_info power_signal_list[] = { {GPIO_PP5000_PGOOD, 1, "PGOOD_PP5000"}, @@ -68,8 +134,8 @@ BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT); /* Physical fans. These are logically separate from pwm_channels. */ const struct fan_t fans[] = { {.flags = FAN_USE_RPM_MODE, - .rpm_min = 1000, - .rpm_max = 5050, + .rpm_min = 3200, + .rpm_max = 6500, .ch = 2, .pgood_gpio = GPIO_PP5000_PGOOD, .enable_gpio = GPIO_PP5000_FAN_EN, @@ -100,7 +166,7 @@ BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT); */ struct ec_thermal_config thermal_params[] = { /* Only the AP affects the thermal limits and fan speed. */ - {{C_TO_K(95), C_TO_K(97), C_TO_K(99)}, C_TO_K(55), C_TO_K(85)}, + {{C_TO_K(95), C_TO_K(97), C_TO_K(99)}, C_TO_K(36), C_TO_K(96)}, {{0, 0, 0}, 0, 0}, {{0, 0, 0}, 0, 0}, {{0, 0, 0}, 0, 0}, diff --git a/board/yuna/board.h b/board/yuna/board.h index 4849771581..c6ad6a544c 100644 --- a/board/yuna/board.h +++ b/board/yuna/board.h @@ -25,6 +25,7 @@ #define CONFIG_CMD_GSV #define CONFIG_EXTPOWER_GPIO #define CONFIG_FANS 1 +#define CONFIG_FAN_RPM_CUSTOM #define CONFIG_KEYBOARD_BOARD_CONFIG #define CONFIG_KEYBOARD_COL2_INVERTED #define CONFIG_KEYBOARD_PROTOCOL_8042 |