summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHsu Henry <Henry.Hsu@quantatw.com>2014-12-09 06:33:06 +0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-12-12 20:08:09 +0000
commit3e18ac03f3562fe290046fbb9cdbc0702f96f333 (patch)
tree03479e11f0dcf0f3d99267e4364f4dbada1eeb85
parentcec6f0a6482e71a1a930444df50568862872a6b6 (diff)
downloadchrome-ec-3e18ac03f3562fe290046fbb9cdbc0702f96f333.tar.gz
Paine, Yuna: Fan table implement.
Yuna, Paine define the thermal table for fan. The table is below: on off RPM step0 0 step1 43 37 3200 step2 48 43 3700 step3 52 47 4000 step4 56 51 4400 step5 60 55 4900 step6 70 65 5500 step7 95 90 6500 Where the temperature scale is celsius degree. BUG=chrome-os-partner:34418 BRANCH=paine, yuna TEST=Use the hacked code to return the fake temperature, check all the steps with yuna. The fan behavior works properly. Change-Id: Id4f5957d63a81046539bc96a95e30b6b022803fe Signed-off-by: Henry Hsu <Henry.Hsu@quantatw.com> Reviewed-on: https://chromium-review.googlesource.com/233828 Reviewed-by: Mohammed Habibulla <moch@chromium.org>
-rw-r--r--board/paine/board.c72
-rw-r--r--board/paine/board.h1
-rw-r--r--board/yuna/board.c72
-rw-r--r--board/yuna/board.h1
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