summaryrefslogtreecommitdiff
path: root/common/temp_sensor.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-10-11 11:06:29 -0700
committerGerrit <chrome-bot@google.com>2012-10-11 14:24:36 -0700
commit22e03a1de6d525e84e511f4b25531caf6f1a93fd (patch)
tree4b060ef35e12ea2d551518489244bdf59f9a14b8 /common/temp_sensor.c
parent8f2e99da75152c428c6c92b20a13a62a5fcb40d1 (diff)
downloadchrome-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/temp_sensor.c')
-rw-r--r--common/temp_sensor.c30
1 files changed, 8 insertions, 22 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;
+ }
}
}