summaryrefslogtreecommitdiff
path: root/include/temp_sensor.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/temp_sensor.h')
-rw-r--r--include/temp_sensor.h39
1 files changed, 35 insertions, 4 deletions
diff --git a/include/temp_sensor.h b/include/temp_sensor.h
index 863f9d7d51..df937112e1 100644
--- a/include/temp_sensor.h
+++ b/include/temp_sensor.h
@@ -9,13 +9,30 @@
#define __CROS_EC_TEMP_SENSOR_H
#include "common.h"
+#include "board.h"
-enum temp_sensor_id {
- TEMP_SENSOR_CASE = 0, /* Case temperature */
- TEMP_SENSOR_CASE_DIE, /* Case temperature sensor die */
- TEMP_SENSOR_EC_INTERNAL, /* EC internal temperature sensor */
+/* "enum temp_sensor_id" must be defined for each board in board.h. */
+struct temp_sensor_t {
+ const char* name;
+ enum temp_sensor_id id;
+ /* Sensor address. Used by read and print functions. */
+ int addr;
+ /* Read sensor value and return temperature in K. */
+ int (*read)(const struct temp_sensor_t* self);
+ /* Print debug info on console. */
+ int (*print)(const struct temp_sensor_t* self);
};
+/* Dummy value to put in "addr" field in temp_sensor_t if we don't need to
+ * specify address.
+ */
+#define TEMP_SENSOR_NO_ADDR 0
+
+/* Dummy value to put in "print" field in temp_sensor_t if we don't have debug
+ * function for a sensor.
+ */
+#define TEMP_SENSOR_NO_PRINT 0
+
/* Initializes the module. */
int temp_sensor_init(void);
@@ -23,4 +40,18 @@ int temp_sensor_init(void);
* or -1 if error. */
int temp_sensor_read(enum temp_sensor_id id);
+
+#define TMP006_ADDR(PORT,REG) ((PORT << 16) + REG)
+#define TMP006_PORT(ADDR) (ADDR >> 16)
+#define TMP006_REG(ADDR) (ADDR & 0xffff)
+
+/* Read TI TMP006 temperature sensor. Return temperature in K. */
+int temp_sensor_tmp006_read(const struct temp_sensor_t* sensor);
+
+/* Configure TMP006 DRDY pin. */
+void temp_sensor_tmp006_config(const struct temp_sensor_t* sensor);
+
+/* Print debug messages for TMP006. */
+int temp_sensor_tmp006_print(const struct temp_sensor_t* sensor);
+
#endif /* __CROS_EC_TEMP_SENSOR_H */