mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-09 17:11:42 +00:00
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
This commit is contained in:
13
include/charger.h
Normal file
13
include/charger.h
Normal file
@@ -0,0 +1,13 @@
|
||||
/* Copyright (c) 2012 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.
|
||||
*/
|
||||
|
||||
/* Charger/battery debug command module for Chrome EC */
|
||||
|
||||
#ifndef __CROS_EC_CHARGER_H
|
||||
#define __CROS_EC_CHARGER_H
|
||||
|
||||
int charger_init(void);
|
||||
|
||||
#endif /* __CROS_EC_CHARGER_H */
|
||||
20
include/chip_temp_sensor.h
Normal file
20
include/chip_temp_sensor.h
Normal file
@@ -0,0 +1,20 @@
|
||||
/* Copyright (c) 2012 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 LM4 chip */
|
||||
|
||||
#ifndef __CHIP_TEMP_SENSOR_H
|
||||
#define __CHIP_TEMP_SENSOR_H
|
||||
|
||||
struct temp_sensor_t;
|
||||
|
||||
/* Temperature reading function. Input pointer to a sensor in temp_sensors.
|
||||
* Return temperature in K.
|
||||
*/
|
||||
int chip_temp_sensor_read(const struct temp_sensor_t* sensor);
|
||||
|
||||
int chip_temp_sensor_init(void);
|
||||
|
||||
#endif /* __CHIP_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 */
|
||||
|
||||
Reference in New Issue
Block a user