diff options
author | Vic Yang <victoryang@google.com> | 2012-01-12 17:02:10 +0800 |
---|---|---|
committer | Vic Yang <victoryang@google.com> | 2012-02-04 14:37:04 +0800 |
commit | 000a6d57423e96ffaa2061bd764b8141ea46bb8e (patch) | |
tree | 528dd0d5f798101470a1d45f9480bc7b2ecebcb0 /board | |
parent | 249467b9f291e2b10a7aafdbb584c68c8b0a4e88 (diff) | |
download | chrome-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 'board')
-rw-r--r-- | board/bds/board.h | 7 | ||||
-rw-r--r-- | board/bds/board_temp_sensor.c | 22 | ||||
-rw-r--r-- | board/bds/build.mk | 1 | ||||
-rw-r--r-- | board/link/board.h | 17 | ||||
-rw-r--r-- | board/link/board_temp_sensor.c | 37 | ||||
-rw-r--r-- | board/link/build.mk | 1 |
6 files changed, 85 insertions, 0 deletions
diff --git a/board/bds/board.h b/board/bds/board.h index fbd4f153ca..e5cab1f212 100644 --- a/board/bds/board.h +++ b/board/bds/board.h @@ -117,6 +117,13 @@ enum gpio_signal { GPIO_COUNT }; +enum temp_sensor_id { + TEMP_SENSOR_EC_INTERNAL = 0, /* EC internal temperature sensor */ + TEMP_SENSOR_CASE_DIE, + + TEMP_SENSOR_COUNT +}; + void configure_board(void); #endif /* __BOARD_H */ diff --git a/board/bds/board_temp_sensor.c b/board/bds/board_temp_sensor.c new file mode 100644 index 0000000000..709ca8226a --- /dev/null +++ b/board/bds/board_temp_sensor.c @@ -0,0 +1,22 @@ +/* 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. + */ + +/* BDS-specific temp sensor module for Chrome EC */ + +#include "temp_sensor.h" +#include "chip_temp_sensor.h" +#include "board.h" +#include "i2c.h" + +#define TEMP_CASE_DIE_REG_ADDR ((0x40 << 1) | I2C_FLAG_BIG_ENDIAN) +#define TEMP_CASE_DIE_ADDR \ + TMP006_ADDR(I2C_PORT_THERMAL, TEMP_CASE_DIE_REG_ADDR) + +const struct temp_sensor_t temp_sensors[TEMP_SENSOR_COUNT] = { + {"ECInternal", TEMP_SENSOR_EC_INTERNAL, TEMP_SENSOR_NO_ADDR, + chip_temp_sensor_read, TEMP_SENSOR_NO_PRINT}, + {"CaseDie", TEMP_SENSOR_CASE_DIE, TEMP_CASE_DIE_ADDR, + temp_sensor_tmp006_read, temp_sensor_tmp006_print} +}; diff --git a/board/bds/build.mk b/board/bds/build.mk index d026221342..c3fae48c4b 100644 --- a/board/bds/build.mk +++ b/board/bds/build.mk @@ -5,3 +5,4 @@ CHIP:=lm4 board-y=board.o +board-$(CONFIG_TEMP_SENSOR)+=board_temp_sensor.o diff --git a/board/link/board.h b/board/link/board.h index 0387bc45fc..e9917a0932 100644 --- a/board/link/board.h +++ b/board/link/board.h @@ -138,6 +138,23 @@ enum gpio_signal { GPIO_COUNT }; +enum temp_sensor_id { + /* I2C die temperature sensor near CPU */ + TEMP_SENSOR_I2C_DIE_NEAR_CPU = 0, + /* PCH temperature sensor */ + TEMP_SENSOR_I2C_DIE_NEAR_PCH, + /* DDR memory temperature sensor */ + TEMP_SENSOR_I2C_DIE_NEAR_DDR, + /* Battery charger temperature sensor */ + TEMP_SENSOR_I2C_DIE_NEAR_CHARGER, + /* EC internal temperature sensor */ + TEMP_SENSOR_EC_INTERNAL, + + /* TODO: I2C temperature sensors. */ + + TEMP_SENSOR_COUNT +}; + void configure_board(void); #endif /* __BOARD_H */ diff --git a/board/link/board_temp_sensor.c b/board/link/board_temp_sensor.c new file mode 100644 index 0000000000..f04754f2bd --- /dev/null +++ b/board/link/board_temp_sensor.c @@ -0,0 +1,37 @@ +/* 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. + */ + +/* Link-specific temp sensor module for Chrome EC */ + +#include "temp_sensor.h" +#include "chip_temp_sensor.h" +#include "board.h" +#include "i2c.h" + +#define TEMP_CPU_REG_ADDR ((0x40 << 1) | I2C_FLAG_BIG_ENDIAN) +#define TEMP_PCH_REG_ADDR ((0x41 << 1) | I2C_FLAG_BIG_ENDIAN) +#define TEMP_DDR_REG_ADDR ((0x43 << 1) | I2C_FLAG_BIG_ENDIAN) +#define TEMP_CHARGER_REG_ADDR ((0x45 << 1) | I2C_FLAG_BIG_ENDIAN) + +#define TEMP_CPU_ADDR TMP006_ADDR(I2C_PORT_THERMAL, TEMP_CPU_REG_ADDR) +#define TEMP_PCH_ADDR TMP006_ADDR(I2C_PORT_THERMAL, TEMP_PCH_REG_ADDR) +#define TEMP_DDR_ADDR TMP006_ADDR(I2C_PORT_THERMAL, TEMP_DDR_REG_ADDR) +#define TEMP_CHARGER_ADDR TMP006_ADDR(I2C_PORT_THERMAL, TEMP_CHARGER_REG_ADDR) + +/* Temperature sensors data. Must be in the same order as enum + * temp_sensor_id. + */ +const struct temp_sensor_t temp_sensors[TEMP_SENSOR_COUNT] = { + {"CPU", TEMP_SENSOR_I2C_DIE_NEAR_CPU, TEMP_CPU_ADDR, + temp_sensor_tmp006_read, temp_sensor_tmp006_print}, + {"PCH", TEMP_SENSOR_I2C_DIE_NEAR_PCH, TEMP_PCH_ADDR, + temp_sensor_tmp006_read, temp_sensor_tmp006_print}, + {"DDR", TEMP_SENSOR_I2C_DIE_NEAR_DDR, TEMP_DDR_ADDR, + temp_sensor_tmp006_read, temp_sensor_tmp006_print}, + {"Charger", TEMP_SENSOR_I2C_DIE_NEAR_CHARGER, TEMP_CHARGER_ADDR, + temp_sensor_tmp006_read, temp_sensor_tmp006_print}, + {"ECInternal", TEMP_SENSOR_EC_INTERNAL, TEMP_SENSOR_NO_ADDR, + chip_temp_sensor_read, TEMP_SENSOR_NO_PRINT}, +}; diff --git a/board/link/build.mk b/board/link/build.mk index faf9968a45..b600d69d13 100644 --- a/board/link/build.mk +++ b/board/link/build.mk @@ -9,3 +9,4 @@ CHIP:=lm4 board-y=board.o +board-$(CONFIG_TEMP_SENSOR)+=board_temp_sensor.o |