diff options
author | Alec Thilenius <athilenius@chromium.org> | 2017-12-18 14:36:46 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-01-03 16:54:31 -0800 |
commit | 27f92a378aad37bac9f2de1a311f78012eac574b (patch) | |
tree | 9acf1e0da797136fadb5a8b117fa1c3f29d890fc | |
parent | bb113312271f790639cf6c7fc1da04ecd71f647d (diff) | |
download | chrome-ec-27f92a378aad37bac9f2de1a311f78012eac574b.tar.gz |
Add SB-TSI temp sensor driver
This adds the driver for the SB-TSI temp sensor.
This is a sensor on the AMD AP SOC (Stoney Ridege FT2) that acts like an
8-pin temp sensor with an I2C interface.
BUG=b:69379715
BRANCH=None
TEST=Build
Change-Id: Iaafe6c7beb3e02e4e341617e8f117c03c0a882a2
Signed-off-by: Alec Thilenius <athilenius@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/833346
Commit-Ready: Alec Thilenius <athilenius@google.com>
Tested-by: Alec Thilenius <athilenius@google.com>
Reviewed-by: Edward Hill <ecgh@chromium.org>
-rw-r--r-- | driver/build.mk | 1 | ||||
-rw-r--r-- | driver/temp_sensor/sb_tsi.c | 40 | ||||
-rw-r--r-- | driver/temp_sensor/sb_tsi.h | 46 | ||||
-rw-r--r-- | include/config.h | 1 |
4 files changed, 88 insertions, 0 deletions
diff --git a/driver/build.mk b/driver/build.mk index e7aca3313d..5497a7a049 100644 --- a/driver/build.mk +++ b/driver/build.mk @@ -78,6 +78,7 @@ driver-$(CONFIG_TEMP_SENSOR_BD99992GW)+=temp_sensor/bd99992gw.o driver-$(CONFIG_TEMP_SENSOR_EC_ADC)+=temp_sensor/ec_adc.o driver-$(CONFIG_TEMP_SENSOR_G781)+=temp_sensor/g78x.o driver-$(CONFIG_TEMP_SENSOR_G782)+=temp_sensor/g78x.o +driver-$(CONFIG_TEMP_SENSOR_SB_TSI)+=temp_sensor/sb_tsi.o driver-$(CONFIG_TEMP_SENSOR_TMP006)+=temp_sensor/tmp006.o driver-$(CONFIG_TEMP_SENSOR_TMP112)+=temp_sensor/tmp112.o driver-$(CONFIG_TEMP_SENSOR_TMP411)+=temp_sensor/tmp411.o diff --git a/driver/temp_sensor/sb_tsi.c b/driver/temp_sensor/sb_tsi.c new file mode 100644 index 0000000000..9cf42d983f --- /dev/null +++ b/driver/temp_sensor/sb_tsi.c @@ -0,0 +1,40 @@ +/* Copyright 2016 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. + */ + +/* + * SB-TSI: SB Temperature Sensor Interface. + * This is an I2C slave temp sensor on the AMD Stony Ridge FT4 SOC. + */ + +#include "chipset.h" +#include "common.h" +#include "console.h" +#include "gpio.h" +#include "hooks.h" +#include "i2c.h" +#include "sb_tsi.h" +#include "util.h" + +static int raw_read8(const int offset, int *data_ptr) +{ + return i2c_read8(I2C_PORT_THERMAL, SB_TSI_I2C_ADDR, offset, data_ptr); +} + +int sb_tsi_get_val(int idx, int *temp_ptr) +{ + int ret; + /* There is only one temp sensor on the FT4 */ + if (idx != 0) + return EC_ERROR_PARAM1; + /* FT4 SB-TSI sensor only powered in S0 */ + if (!chipset_in_state(CHIPSET_STATE_ON)) + return EC_ERROR_NOT_POWERED; + /* Read the value over I2C */ + ret = raw_read8(SB_TSI_TEMP_H, temp_ptr); + if (ret) + return ret; + *temp_ptr = C_TO_K(*temp_ptr); + return EC_SUCCESS; +} diff --git a/driver/temp_sensor/sb_tsi.h b/driver/temp_sensor/sb_tsi.h new file mode 100644 index 0000000000..3ae11c5dbd --- /dev/null +++ b/driver/temp_sensor/sb_tsi.h @@ -0,0 +1,46 @@ +/* Copyright 2016 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. + */ + +/* + * SB-TSI: SB Temperature Sensor Interface. + * This is an I2C slave temp sensor on the AMD Stony Ridge FT4 SOC. + */ + +#ifndef __CROS_EC_SB_TSI_H +#define __CROS_EC_SB_TSI_H + +#define SB_TSI_I2C_ADDR 0x98 /* 7-bit address is 0x4C */ + +/* G781 register */ +#define SB_TSI_TEMP_H 0x01 +#define SB_TSI_STATUS 0x02 +#define SB_TSI_CONFIG_1 0x03 +#define SB_TSI_UPDATE_RATE 0x04 +#define SB_TSI_HIGH_TEMP_THRESHOLD_H 0x07 +#define SB_TSI_LOW_TEMP_THRESHOLD_H 0x08 +#define SB_TSI_CONFIG_2 0x09 +#define SB_TSI_TEMP_L 0x10 +#define SB_TSI_TEMP_OFFSET_H 0x11 +#define SB_TSI_TEMP_OFFSET_L 0x12 +#define SB_TSI_HIGH_TEMP_THRESHOLD_L 0x13 +#define SB_TSI_LOW_TEMP_THRESHOLD_L 0x14 +#define SB_TSI_TIMEOUT_CONFIG 0x22 +#define SB_TSI_PSTATE_LIMIT_CONFIG 0x2F +#define SB_TSI_ALERT_THRESHOLD 0x32 +#define SB_TSI_ALERT_CONFIG 0xBF +#define SB_TSI_MANUFACTURE_ID 0xFE +#define SB_TSI_REVISION 0xFF + +/** + * Get the value of a sensor in K. + * + * @param idx Index to read. Only 0 is valid for sb_tsi. + * @param temp_ptr Destination for temperature in K. + * + * @return EC_SUCCESS if successful, non-zero if error. + */ +int sb_tsi_get_val(int idx, int *temp_ptr); + +#endif /* __CROS_EC_SB_TSI_H */ diff --git a/include/config.h b/include/config.h index b242092064..4d047c7186 100644 --- a/include/config.h +++ b/include/config.h @@ -2418,6 +2418,7 @@ #undef CONFIG_TEMP_SENSOR_EC_ADC /* Thermistors on EC's own ADC */ #undef CONFIG_TEMP_SENSOR_G781 /* G781 sensor, on I2C bus */ #undef CONFIG_TEMP_SENSOR_G782 /* G782 sensor, on I2C bus */ +#undef CONFIG_TEMP_SENSOR_SB_TSI /* SB_TSI sensor, on I2C bus */ #undef CONFIG_TEMP_SENSOR_TMP006 /* TI TMP006 sensor, on I2C bus */ #undef CONFIG_TEMP_SENSOR_TMP411 /* TI TMP411 sensor, on I2C bus */ #undef CONFIG_TEMP_SENSOR_TMP432 /* TI TMP432 sensor, on I2C bus */ |