summaryrefslogtreecommitdiff
path: root/common/temp_sensor.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-07-20 11:05:07 -0700
committerGerrit <chrome-bot@google.com>2012-07-22 13:17:02 -0700
commit360d91573a12994ec9fa0e2790ea89a0cd2c5b32 (patch)
tree8f1ed4d143cc68f2c983bcadec6113cd1abbe45b /common/temp_sensor.c
parentbff14cac0b17217a6be02924d109e58b3aaa50b1 (diff)
downloadchrome-ec-360d91573a12994ec9fa0e2790ea89a0cd2c5b32.tar.gz
Support up to 24 thermal sensors
And tidy reporting fan/thermal via memmap. BUG=chrome-os-partner:11628 TEST=manual ectool pwmgetfanrpm -> should report fan speed ectool temps N -> should work for N=0-9 reports error for N=15-23 reports invalid sensor ID for N<0 or N>23 Change-Id: I484f81399f5e9dae9c759401091cc6f5acc733ff Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/28032 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'common/temp_sensor.c')
-rw-r--r--common/temp_sensor.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/common/temp_sensor.c b/common/temp_sensor.c
index 5579683aa8..9f653612f0 100644
--- a/common/temp_sensor.c
+++ b/common/temp_sensor.c
@@ -76,20 +76,29 @@ static void poll_fast_sensors(void)
static void update_mapped_memory(void)
{
int i, t;
- uint8_t *mapped = host_get_memmap(EC_MEMMAP_TEMP_SENSOR);
+ uint8_t *mptr = host_get_memmap(EC_MEMMAP_TEMP_SENSOR);
+
+ for (i = 0; i < TEMP_SENSOR_COUNT; i++, mptr++) {
+ /*
+ * Switch to second range if first one is full, or stop if
+ * second range is also full.
+ */
+ if (i == EC_TEMP_SENSOR_ENTRIES)
+ mptr = host_get_memmap(EC_MEMMAP_TEMP_SENSOR_B);
+ else if (i >= EC_TEMP_SENSOR_ENTRIES +
+ EC_TEMP_SENSOR_B_ENTRIES)
+ break;
- memset(mapped, 0xff, 16);
-
- for (i = 0; i < TEMP_SENSOR_COUNT && i < 16; ++i) {
if (!temp_sensor_powered(i)) {
- mapped[i] = 0xfd;
+ *mptr = EC_TEMP_SENSOR_NOT_POWERED;
continue;
}
+
t = temp_sensor_read(i);
- if (t != -1)
- mapped[i] = t - EC_TEMP_SENSOR_OFFSET;
+ if (t == -1)
+ *mptr = EC_TEMP_SENSOR_ERROR;
else
- mapped[i] = 0xfe;
+ *mptr = t - EC_TEMP_SENSOR_OFFSET;
}
}
@@ -98,8 +107,14 @@ void temp_sensor_task(void)
{
int i;
- /* Switch data is now present */
- *host_get_memmap(EC_MEMMAP_THERMAL_VERSION) = 1;
+ /* Initialize memory-mapped data */
+ memset(host_get_memmap(EC_MEMMAP_TEMP_SENSOR),
+ EC_TEMP_SENSOR_NOT_PRESENT, EC_TEMP_SENSOR_ENTRIES);
+ memset(host_get_memmap(EC_MEMMAP_TEMP_SENSOR_B),
+ EC_TEMP_SENSOR_NOT_PRESENT, EC_TEMP_SENSOR_B_ENTRIES);
+
+ /* Temp sensor data is present, with B range supported. */
+ *host_get_memmap(EC_MEMMAP_THERMAL_VERSION) = 2;
while (1) {
for (i = 0; i < 4; ++i) {