summaryrefslogtreecommitdiff
path: root/chip/lm4/chip_temp_sensor.c
diff options
context:
space:
mode:
authorVic Yang <victoryang@google.com>2012-01-12 17:02:10 +0800
committerVic Yang <victoryang@google.com>2012-02-04 14:37:04 +0800
commit000a6d57423e96ffaa2061bd764b8141ea46bb8e (patch)
tree528dd0d5f798101470a1d45f9480bc7b2ecebcb0 /chip/lm4/chip_temp_sensor.c
parent249467b9f291e2b10a7aafdbb584c68c8b0a4e88 (diff)
downloadchrome-ec-000a6d57423e96ffaa2061bd764b8141ea46bb8e.tar.gz
Refactor temperature sensor code and add support of Link I2C temp sensor.
Refactor board/chip-specific code into corresponding directories. Add support of the four I2C temp sensor in Link. Use table lookup to handle different types of temperature sensors. BUG=chrome-os-partner:7527 TEST=Correctly read EC internal temperature on bds. Compile for link succeeded. Change-Id: I694cfa54e1545798d877fafdf18c5585ab5f03e2
Diffstat (limited to 'chip/lm4/chip_temp_sensor.c')
-rw-r--r--chip/lm4/chip_temp_sensor.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/chip/lm4/chip_temp_sensor.c b/chip/lm4/chip_temp_sensor.c
new file mode 100644
index 0000000000..d810216851
--- /dev/null
+++ b/chip/lm4/chip_temp_sensor.c
@@ -0,0 +1,24 @@
+/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Temperature sensor module for Chrome EC */
+
+#include "adc.h"
+#include "board.h"
+#include "temp_sensor.h"
+
+int chip_temp_sensor_read(const struct temp_sensor_t* sensor)
+{
+ /* LM4 only has internal temperature sensor */
+ if (sensor->id != TEMP_SENSOR_EC_INTERNAL)
+ return EC_ERROR_INVAL;
+
+ return adc_read_channel(ADC_CH_EC_TEMP);
+}
+
+int chip_temp_sensor_init(void)
+{
+ return EC_SUCCESS;
+}