summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorGerrit <chrome-bot@google.com>2012-03-01 16:18:35 -0800
committerGerrit Code Review <gerrit@gerrit.golo.chromium.org>2012-03-01 16:18:35 -0800
commit72d8d99c95fadb6b792a8bd21011132face51d2b (patch)
tree1586efff9a7277833c32c5815a353bbd18dd35e4 /common
parent5cd0f292e9c769264c5fa1f0fe262c910a9194ec (diff)
parentfeb5a62d7996a1ea86d79a7bfaa44ecd10c0e18e (diff)
downloadchrome-ec-72d8d99c95fadb6b792a8bd21011132face51d2b.tar.gz
Merge "Make TMP006 polling check for power first."
Diffstat (limited to 'common')
-rw-r--r--common/tmp006.c32
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;