diff options
author | Ryan Zhang <Ryan.Zhang@quanta.corp-partner.google.com> | 2017-10-20 10:08:12 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-11-06 13:48:38 -0800 |
commit | f48cf0e8b27fb484271540e4cc272aea581a3b48 (patch) | |
tree | 08484f3eb500b2f50b0e394101fbb4e5e20225a5 /driver/temp_sensor | |
parent | 1f9b681ac16fd60c245ecd86391f883035cb1037 (diff) | |
download | chrome-ec-f48cf0e8b27fb484271540e4cc272aea581a3b48.tar.gz |
Fizz: Modify thermal table
Modify thermal table for Fizz
reference patches: 627542, 288256, 329359
on off RPM
step0 0
step1 16 2 2800
step2 27 18 3200
step3 35 29 3400
step4 43 37 4200
step5 54 45 4800
step6 64 56 5200
step7 97 83 5600
Prochot degree:
active when t >= 88C
release when t <= 85C
Shutdown degree: when t >= 90C
BUG=b:67487721, b:64439568
BRANCH=master
TEST=fan target speed follows table, make -j buildall pass
Change-Id: I3378668a560b8ddc568fe9cbf2703613fad8e4b6
Signed-off-by: Ryan Zhang <ryan.zhang@quanta.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/729606
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'driver/temp_sensor')
-rw-r--r-- | driver/temp_sensor/tmp432.c | 62 | ||||
-rw-r--r-- | driver/temp_sensor/tmp432.h | 1 |
2 files changed, 55 insertions, 8 deletions
diff --git a/driver/temp_sensor/tmp432.c b/driver/temp_sensor/tmp432.c index f288f40ed5..0874da74b6 100644 --- a/driver/temp_sensor/tmp432.c +++ b/driver/temp_sensor/tmp432.c @@ -17,6 +17,7 @@ static int temp_val_local; static int temp_val_remote1; static int temp_val_remote2; static uint8_t is_sensor_shutdown; +static int fake_temp[TMP432_IDX_COUNT] = {-1, -1, -1}; /** * Determine whether the sensor is powered. @@ -183,18 +184,44 @@ static void temp_sensor_poll(void) if (!has_power()) return; - if (get_temp(TMP432_LOCAL, &temp_c) == EC_SUCCESS) - temp_val_local = C_TO_K(temp_c); + if (fake_temp[TMP432_IDX_LOCAL] != -1) { + temp_val_local = C_TO_K(fake_temp[TMP432_IDX_LOCAL]); + } else { + if (get_temp(TMP432_LOCAL, &temp_c) == EC_SUCCESS) + temp_val_local = C_TO_K(temp_c); + /* else: Keep previous value when it fails */ + } - if (get_temp(TMP432_REMOTE1, &temp_c) == EC_SUCCESS) - temp_val_remote1 = C_TO_K(temp_c); + if (fake_temp[TMP432_IDX_REMOTE1] != -1) { + temp_val_remote1 = C_TO_K(fake_temp[TMP432_IDX_REMOTE1]); + } else { + if (get_temp(TMP432_REMOTE1, &temp_c) == EC_SUCCESS) + temp_val_remote1 = C_TO_K(temp_c); + /* else: Keep previous value when it fails */ + } - if (get_temp(TMP432_REMOTE2, &temp_c) == EC_SUCCESS) - temp_val_remote2 = C_TO_K(temp_c); + if (fake_temp[TMP432_IDX_REMOTE2] != -1) { + temp_val_remote2 = C_TO_K(fake_temp[TMP432_IDX_REMOTE2]); + } else { + if (get_temp(TMP432_REMOTE2, &temp_c) == EC_SUCCESS) + temp_val_remote2 = C_TO_K(temp_c); + /* else: Keep previous value when it fails */ + } } DECLARE_HOOK(HOOK_SECOND, temp_sensor_poll, HOOK_PRIO_TEMP_SENSOR); #ifdef CONFIG_CMD_TEMP_SENSOR +static int tmp432_set_fake_temp(int index, int degree_c) +{ + if ((index < 0) || (index >= TMP432_IDX_COUNT)) + return EC_ERROR_INVAL; + + fake_temp[index] = degree_c; + ccprintf("New degree will be updated 1 sec later\n\n"); + + return EC_SUCCESS; +} + static void print_temps( const char *name, const int tmp432_temp_reg, @@ -226,7 +253,7 @@ static void print_temps( static int print_status(void) { - int value; + int value, i; print_temps("Local", TMP432_LOCAL, TMP432_LOCAL_THERM_LIMIT, @@ -245,6 +272,21 @@ static int print_status(void) ccprintf("\n"); + for (i = 0; i < TMP432_IDX_COUNT; ++i) { + ccprintf("fake temperature[%d]= ", i); + if (fake_temp[i] == -1) { + ccprintf("Not overridden\n"); + continue; + } + + if (tmp432_get_val(i, &value) == EC_SUCCESS) + ccprintf("%d C or %d K\n", (value - 273), value); + else + ccprintf("Access error\n"); + } + + ccprintf("\n"); + if (raw_read8(TMP432_STATUS, &value) == EC_SUCCESS) ccprintf("STATUS: %08b\n", value); @@ -321,6 +363,10 @@ static int command_tmp432(int argc, char **argv) } else if (!strcasecmp(command, "setbyte")) { ccprintf("Setting 0x%02x to 0x%02x\n", offset, data); rv = raw_write8(offset, data); + } else if (!strcasecmp(command, "fake")) { + ccprintf("Hook temperature\n"); + rv = tmp432_set_fake_temp(offset, data); + print_status(); } else return EC_ERROR_PARAM1; @@ -328,7 +374,7 @@ static int command_tmp432(int argc, char **argv) } DECLARE_CONSOLE_COMMAND(tmp432, command_tmp432, "[settemp|setbyte <offset> <value>] or [getbyte <offset>] or" - "[power <on|off>]. " + "[fake <index> <value>] or [power <on|off>]. " "Temps in Celsius.", "Print tmp432 temp sensor status or set parameters."); #endif diff --git a/driver/temp_sensor/tmp432.h b/driver/temp_sensor/tmp432.h index ea6f3286c6..2d8d2515dc 100644 --- a/driver/temp_sensor/tmp432.h +++ b/driver/temp_sensor/tmp432.h @@ -13,6 +13,7 @@ #define TMP432_IDX_LOCAL 0 #define TMP432_IDX_REMOTE1 1 #define TMP432_IDX_REMOTE2 2 +#define TMP432_IDX_COUNT 3 /* Chip-specific registers */ #define TMP432_LOCAL 0x00 |