summaryrefslogtreecommitdiff
path: root/board/link/board_temp_sensor.c
blob: f8d3f93c2cbfd9715dc33d05e4f57c1be2977c1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* 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"
#include "peci.h"
#include "tmp006.h"
#include "util.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] = {
	{"I2C_CPU-Die", tmp006_get_val, 0},
	{"I2C_CPU-Object", tmp006_get_val, 1},
	{"I2C_PCH-Die", tmp006_get_val, 2},
	{"I2C_PCH-Object", tmp006_get_val, 3},
	{"I2C_DDR-Die", tmp006_get_val, 4},
	{"I2C_DDR-Object", tmp006_get_val, 5},
	{"I2C_Charger-Die", tmp006_get_val, 6},
	{"I2C_Charger-Object", tmp006_get_val, 7},
	{"ECInternal", chip_temp_sensor_get_val, 0},
	{"PECI", peci_temp_sensor_get_val, 0},
};

const struct tmp006_t tmp006_sensors[TMP006_COUNT] = {
	{"CPU", TEMP_CPU_ADDR},
	{"PCH", TEMP_PCH_ADDR},
	{"DDR", TEMP_DDR_ADDR},
	{"Charger", TEMP_CHARGER_ADDR},
};