summaryrefslogtreecommitdiff
path: root/chip/lm4
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2012-08-14 12:49:30 +0800
committerGerrit <chrome-bot@google.com>2012-08-13 23:33:44 -0700
commitdc4ee57307e5df5400ee5dbea44cbaaf94f3ba57 (patch)
treea609bc4905f016ff92b9614128919da49a9902f4 /chip/lm4
parent847a3feca69932e1ea8168a8fab630ff82f95a15 (diff)
downloadchrome-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 'chip/lm4')
-rw-r--r--chip/lm4/chip_temp_sensor.c9
-rw-r--r--chip/lm4/peci.c5
2 files changed, 14 insertions, 0 deletions
diff --git a/chip/lm4/chip_temp_sensor.c b/chip/lm4/chip_temp_sensor.c
index 657f582275..fb9084e82e 100644
--- a/chip/lm4/chip_temp_sensor.c
+++ b/chip/lm4/chip_temp_sensor.c
@@ -7,6 +7,7 @@
#include "adc.h"
#include "board.h"
+#include "hooks.h"
#include "temp_sensor.h"
static int last_val;
@@ -22,3 +23,11 @@ int chip_temp_sensor_get_val(int idx)
{
return last_val;
}
+
+static int chip_temp_sensor_init(void)
+{
+ /* Initialize temperature reading to a sane value. */
+ last_val = 300; /* 27 C */
+ return EC_SUCCESS;
+}
+DECLARE_HOOK(HOOK_INIT, chip_temp_sensor_init, HOOK_PRIO_DEFAULT);
diff --git a/chip/lm4/peci.c b/chip/lm4/peci.c
index 1ea876fbcd..4091ee8640 100644
--- a/chip/lm4/peci.c
+++ b/chip/lm4/peci.c
@@ -139,6 +139,7 @@ DECLARE_CONSOLE_COMMAND(pecitemp, command_peci_temp,
static int peci_init(void)
{
volatile uint32_t scratch __attribute__((unused));
+ int i;
/* Enable the PECI module and delay a few clocks */
LM4_SYSTEM_RCGCPECI = 1;
@@ -150,6 +151,10 @@ static int peci_init(void)
/* Set initial clock frequency */
peci_freq_changed();
+ /* Initialize temperature reading buffer to a sane value. */
+ for (i = 0; i < TEMP_AVG_LENGTH; ++i)
+ temp_vals[i] = 300; /* 27 C */
+
return EC_SUCCESS;
}
DECLARE_HOOK(HOOK_INIT, peci_init, HOOK_PRIO_DEFAULT);