From 6c5a4424d7dc0f636aef2f6e8b28511433d28939 Mon Sep 17 00:00:00 2001 From: Ryan Zhang Date: Thu, 25 Jan 2018 14:35:37 +0800 Subject: Fizz: Update thermal table by project 1. Prochot/Shutdown Point a. Prochot on: >=81C, off: <=77C b. Shutodwn: >=82C 2. custom fan table There are three projects sharing two tables, and use Kench & Teemo's table before getting correct OEM ID because it raises fan speed quicker than the other one. a. Kench & Teemo & default b. Sion BUG=b:70294260 BRANCH=master TEST=EC can get two fan tables with different cbi value. Change-Id: Ie1bffbcf5c353a9aae5806f6c2b41554eed22b7d Signed-off-by: Ryan Zhang Reviewed-on: https://chromium-review.googlesource.com/886121 Commit-Ready: Daisuke Nojiri Tested-by: Daisuke Nojiri Reviewed-by: Daisuke Nojiri --- board/fizz/board.c | 58 +++++++++++++++++++++++++++++++++++++++++------------- common/cbi.c | 9 +++++++++ 2 files changed, 53 insertions(+), 14 deletions(-) diff --git a/board/fizz/board.c b/board/fizz/board.c index 6bbaf25e70..d3de09dc05 100644 --- a/board/fizz/board.c +++ b/board/fizz/board.c @@ -291,8 +291,8 @@ struct ec_thermal_config thermal_params[] = { * {Twarn, Thigh, X }, * fan_off, fan_max */ - {{0, C_TO_K(87), C_TO_K(89)}, {0, C_TO_K(86), 0}, - C_TO_K(44), C_TO_K(81)},/* TMP432_Internal */ + {{0, C_TO_K(80), C_TO_K(81)}, {0, C_TO_K(78), 0}, + C_TO_K(4), C_TO_K(76)}, /* TMP432_Internal */ {{0, 0, 0}, {0, 0, 0}, 0, 0}, /* TMP432_Sensor_1 */ {{0, 0, 0}, {0, 0, 0}, 0, 0}, /* TMP432_Sensor_2 */ }; @@ -600,23 +600,43 @@ struct fan_step { int rpm; }; -/* Do not make the fan on/off point equal to 0 or 100 */ -const struct fan_step fan_table[] = { - {.off = 2, .rpm = 0}, - {.on = 16, .off = 2, .rpm = 2800}, - {.on = 27, .off = 18, .rpm = 3200}, - {.on = 35, .off = 29, .rpm = 3400}, - {.on = 43, .off = 37, .rpm = 4200}, - {.on = 54, .off = 45, .rpm = 4800}, - {.on = 64, .off = 56, .rpm = 5200}, - {.on = 97, .off = 83, .rpm = 5600}, +/* 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 = 2800}, + {.on = 58, .off = 58, .rpm = 3200}, + {.on = 66, .off = 61, .rpm = 3400}, + {.on = 75, .off = 69, .rpm = 4200}, + {.on = 81, .off = 76, .rpm = 4800}, + {.on = 88, .off = 83, .rpm = 5200}, + {.on = 98, .off = 91, .rpm = 5600}, +}; +static const struct fan_step fan_table1[] = { + {.on = 0, .off = 1, .rpm = 0}, + {.on = 36, .off = 1, .rpm = 2800}, + {.on = 62, .off = 58, .rpm = 3200}, + {.on = 68, .off = 63, .rpm = 3400}, + {.on = 75, .off = 69, .rpm = 4200}, + {.on = 81, .off = 76, .rpm = 4800}, + {.on = 88, .off = 83, .rpm = 5200}, + {.on = 98, .off = 91, .rpm = 5600}, +}; +/* All fan tables must have the same number of levels */ +#define NUM_FAN_LEVELS ARRAY_SIZE(fan_table0) +BUILD_ASSERT(ARRAY_SIZE(fan_table1) == NUM_FAN_LEVELS); + +/* Default uses table0 due to its smaller active point */ +static const struct fan_step *fan_tables[] = { + fan_table0, /* Kench & Default */ + fan_table0, /* Teemo */ + fan_table1, /* Sion */ }; -#define NUM_FAN_LEVELS ARRAY_SIZE(fan_table) -int fan_percent_to_rpm(int fan, int pct) +static int get_custom_rpm(int fan, int pct, int oem_id) { static int current_level; static int previous_pct; + const struct fan_step *fan_table = fan_tables[oem_id]; int i; /* @@ -653,3 +673,13 @@ int fan_percent_to_rpm(int fan, int pct) return fan_table[current_level].rpm; } + +int fan_percent_to_rpm(int fan, int pct) +{ + uint32_t oem_id; + if (cbi_get_oem_id(&oem_id) || oem_id >= ARRAY_SIZE(fan_tables)) { + CPRINTF("Fan OEM%d not supported or failed to get OEM", oem_id); + oem_id = 0; + } + return get_custom_rpm(fan, pct, oem_id); +} diff --git a/common/cbi.c b/common/cbi.c index 7d7594df98..ac7708c12c 100644 --- a/common/cbi.c +++ b/common/cbi.c @@ -254,3 +254,12 @@ static int hc_cbi_set(struct host_cmd_handler_args *args) DECLARE_HOST_COMMAND(EC_CMD_SET_CROS_BOARD_INFO, hc_cbi_set, EC_VER_MASK(0)); + +static int command_dump_cbi(int argc, char **argv) +{ + ccprintf("BOARD_VERSION: %u (0x%x)\n", bi.version, bi.version); + ccprintf("OEM_ID: %u (0x%x)\n", bi.oem_id, bi.oem_id); + ccprintf("SKU_ID: %u (0x%x)\n", bi.sku_id, bi.sku_id); + return EC_SUCCESS; +} +DECLARE_CONSOLE_COMMAND(cbi, command_dump_cbi, NULL, NULL); -- cgit v1.2.1