diff options
author | Vic Yang <victoryang@chromium.org> | 2012-03-01 13:30:08 -0800 |
---|---|---|
committer | Vic Yang <victoryang@chromium.org> | 2012-03-01 13:30:08 -0800 |
commit | feb5a62d7996a1ea86d79a7bfaa44ecd10c0e18e (patch) | |
tree | 424a26acdab7a257028013a52a7dc82b8bf51e49 | |
parent | 42a9405d112864f15ffd6df96bebcb293d656dc6 (diff) | |
download | chrome-ec-feb5a62d7996a1ea86d79a7bfaa44ecd10c0e18e.tar.gz |
Make TMP006 polling check for power first.
Currently if ENABLE_VS is off, each time we poll TMP006 sensors, it
takes 1 second for each sensor to return ERROR. Checking for power
before polling help to reduce the time spent on temperature polling.
Signed-off-by: Vic Yang <victoryang@chromium.org>
BUG=chrome-os-partner:8275
TEST=Manual test
Change-Id: I2da83f09cccc331074f9bb5483b2ba92c0865742
-rw-r--r-- | common/tmp006.c | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/common/tmp006.c b/common/tmp006.c index 54e37f8e2b..46cd8dbe30 100644 --- a/common/tmp006.c +++ b/common/tmp006.c @@ -5,16 +5,18 @@ /* TMP006 temperature sensor module for Chrome EC */ -#include "tmp006.h" -#include "temp_sensor.h" #include "board.h" -#include "uart.h" -#include "util.h" +#include "config.h" #include "console.h" -#include "task.h" #include "fpu.h" -#include "math.h" +#include "gpio.h" #include "i2c.h" +#include "math.h" +#include "task.h" +#include "temp_sensor.h" +#include "tmp006.h" +#include "uart.h" +#include "util.h" /* Defined in board_temp_sensor.c. */ extern const struct tmp006_t tmp006_sensors[TMP006_COUNT]; @@ -170,6 +172,14 @@ static int tmp006_poll_sensor(int sensor_id) int addr = tmp006_sensors[sensor_id].addr; int idx; + /* TODO: For now, all TMP006 sensors are powered by VS. Modify this + * if we have different design. + */ + if (gpio_get_level(GPIO_PGOOD_1_8VS) == 0) { + tmp006_data[sensor_id].fail = 1; + return EC_ERROR_UNKNOWN; + } + rv = i2c_read16(TMP006_PORT(addr), TMP006_REG(addr), 0x01, &traw); if (rv) { tmp006_data[sensor_id].fail = 1; @@ -201,7 +211,17 @@ static int tmp006_print(int idx) int d; int addr = tmp006_sensors[idx].addr; + uart_printf("Debug data from %s:\n", tmp006_sensors[idx].name); + + /* TODO: For now, all TMP006 sensors are powered by VS. Modify this + * if we have different design. + */ + if (gpio_get_level(GPIO_PGOOD_1_8VS) == 0) { + uart_puts("Sensor powered off.\n"); + return EC_ERROR_UNKNOWN; + } + rv = i2c_read16(TMP006_PORT(addr), TMP006_REG(addr), 0xfe, &d); if (rv) return rv; |