diff options
author | Vic Yang <victoryang@chromium.org> | 2012-08-14 12:49:30 +0800 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-08-13 23:33:44 -0700 |
commit | dc4ee57307e5df5400ee5dbea44cbaaf94f3ba57 (patch) | |
tree | a609bc4905f016ff92b9614128919da49a9902f4 /common/temp_sensor.c | |
parent | 847a3feca69932e1ea8168a8fab630ff82f95a15 (diff) | |
download | chrome-ec-dc4ee57307e5df5400ee5dbea44cbaaf94f3ba57.tar.gz |
Initialize temperature reading buffer to sane values
This is to prevent temperature value being read before the first time we
poll sensors causes unexpected error.
BUG=chrome-os-partner:12614
TEST="sysjump RW" and then "temps" immediately. Check all temperature
readings are near 300 K.
Change-Id: I5c84d9696b4876fdfcf14c3a416cbc09c040d4ee
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/30138
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'common/temp_sensor.c')
-rw-r--r-- | common/temp_sensor.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/common/temp_sensor.c b/common/temp_sensor.c index 9f653612f0..cdad3ebd1f 100644 --- a/common/temp_sensor.c +++ b/common/temp_sensor.c @@ -106,12 +106,30 @@ static void update_mapped_memory(void) void temp_sensor_task(void) { int i; + uint8_t *base, *base_b; + + /* + * Initialize memory-mapped data. We initialize valid sensors to 23 C + * so that if a temperature value is read before we actually poll the + * sensors, we don't end up with an insane value. + */ + base = host_get_memmap(EC_MEMMAP_TEMP_SENSOR); + base_b = host_get_memmap(EC_MEMMAP_TEMP_SENSOR_B); + for (i = 0; i < TEMP_SENSOR_COUNT; ++i) { + if (i < EC_TEMP_SENSOR_ENTRIES) + base[i] = 0x60; /* 23 C */ + else + base_b[i - EC_TEMP_SENSOR_ENTRIES] = 0x60; /* 23 C */ + } - /* 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); + /* Set the rest of memory region to SENSOR_NOT_PRESENT */ + for (; i < EC_TEMP_SENSOR_ENTRIES + EC_TEMP_SENSOR_B_ENTRIES; ++i) { + if (i < EC_TEMP_SENSOR_ENTRIES) + base[i] = EC_TEMP_SENSOR_NOT_PRESENT; + else + base_b[i - EC_TEMP_SENSOR_ENTRIES] = + EC_TEMP_SENSOR_NOT_PRESENT; + } /* Temp sensor data is present, with B range supported. */ *host_get_memmap(EC_MEMMAP_THERMAL_VERSION) = 2; |