diff options
author | Randall Spangler <rspangler@chromium.org> | 2012-10-11 11:06:29 -0700 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-10-11 14:24:36 -0700 |
commit | 22e03a1de6d525e84e511f4b25531caf6f1a93fd (patch) | |
tree | 4b060ef35e12ea2d551518489244bdf59f9a14b8 /common | |
parent | 8f2e99da75152c428c6c92b20a13a62a5fcb40d1 (diff) | |
download | chrome-ec-22e03a1de6d525e84e511f4b25531caf6f1a93fd.tar.gz |
link: Temp sensors can return not-powered error code
This removes the need for a separate method to check sensor power, and
gets rid of temp_sensor.c knowledge of what powers each sensor.
BUG=chrome-os-partner:15174
BRANCH=link
TEST=manual
- reboot
- within a second, type 'temps'; I2C sensors should return error 1
- type 'temps' again; all sensors should return data
- power off system
- type 'temps' again; I2C sensors and PECI should return error 8
- 'gpioset enable_vs 1'
- type 'temps' again; I2C sensors should return valid data; PECI should still
return error 8.
Change-Id: I17c353b3c483bc320769307c7715008ec729089b
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35287
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/temp_sensor.c | 30 | ||||
-rw-r--r-- | common/thermal.c | 10 | ||||
-rw-r--r-- | common/tmp006.c | 6 |
3 files changed, 19 insertions, 27 deletions
diff --git a/common/temp_sensor.c b/common/temp_sensor.c index 333ed1d266..ee1299f78d 100644 --- a/common/temp_sensor.c +++ b/common/temp_sensor.c @@ -36,21 +36,6 @@ int temp_sensor_read(enum temp_sensor_id id, int *temp_ptr) return sensor->read(sensor->idx, temp_ptr); } -int temp_sensor_powered(enum temp_sensor_id id) -{ - int flag = temp_sensors[id].power_flags; - - if (flag & TEMP_SENSOR_POWER_VS && - gpio_get_level(GPIO_PGOOD_1_8VS) == 0) - return 0; - - if (flag & TEMP_SENSOR_POWER_CPU && - !chipset_in_state(CHIPSET_STATE_ON)) - return 0; - - return 1; -} - void poll_slow_sensors(void) { /* Poll every second */ @@ -86,15 +71,16 @@ static void update_mapped_memory(void) EC_TEMP_SENSOR_B_ENTRIES) break; - if (!temp_sensor_powered(i)) { + switch (temp_sensor_read(i, &t)) { + case EC_ERROR_NOT_POWERED: *mptr = EC_TEMP_SENSOR_NOT_POWERED; - continue; - } - - if (temp_sensor_read(i, &t)) - *mptr = EC_TEMP_SENSOR_ERROR; - else + break; + case EC_SUCCESS: *mptr = t - EC_TEMP_SENSOR_OFFSET; + break; + default: + *mptr = EC_TEMP_SENSOR_ERROR; + } } } diff --git a/common/thermal.c b/common/thermal.c index 6b4f3fa355..a300497bde 100644 --- a/common/thermal.c +++ b/common/thermal.c @@ -173,6 +173,7 @@ static void thermal_process(void) int i, j; int cur_temp; int flag; + int rv; for (i = 0; i < THRESHOLD_COUNT + THERMAL_FAN_STEPS; ++i) overheated[i] = 0; @@ -185,11 +186,12 @@ static void thermal_process(void) flag = thermal_config[type].config_flags; - if (!temp_sensor_powered(i)) + rv = temp_sensor_read(i, &cur_temp); + if (rv == EC_ERROR_NOT_POWERED) { + /* Sensor not powered; ignore it */ continue; - - if (temp_sensor_read(i, &cur_temp)) { - /* Sensor failure. */ + } else if (rv) { + /* Other sensor failure */ if (flag & THERMAL_CONFIG_WARNING_ON_FAIL) smi_sensor_failure_warning(); continue; diff --git a/common/tmp006.c b/common/tmp006.c index edb20af586..d7407397a7 100644 --- a/common/tmp006.c +++ b/common/tmp006.c @@ -217,7 +217,11 @@ int tmp006_get_val(int idx, int *temp_ptr) * Note: idx is a thermal sensor index, where the top N-1 bits are the * TMP006 index and the bottom bit is (0=die, 1=remote). */ - const struct tmp006_data_t *tdata = tmp006_data + (idx >> 1); + int tidx = idx >> 1; + const struct tmp006_data_t *tdata = tmp006_data + tidx; + + if (tdata->fail & FAIL_POWER) + return EC_ERROR_NOT_POWERED; /* Check the low bit to determine which temperature to read. */ if ((idx & 0x1) == 0) |