diff options
author | Zick Wei <zick.wei@quanta.corp-partner.google.com> | 2020-07-29 15:31:11 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-08-03 22:16:15 +0000 |
commit | ce93a01527aa9214b6b023f4543209dd7612b80a (patch) | |
tree | 3d8a45c19b236ca3a25e76b0c919d15ca17c6dda /board/woomax | |
parent | bc064edfa739ab1b56ef0873467329f0d0456a94 (diff) | |
download | chrome-ec-ce93a01527aa9214b6b023f4543209dd7612b80a.tar.gz |
zork: move board_get_temp to variant
This patch rename thermal sensor name by placement for morphius,
and move board_get_temp from baseboard to variant
BUG=b:162325433
BRANCH=none
TEST=verify that thermal sensor name change in EC console
Signed-off-by: Zick Wei <zick.wei@quanta.corp-partner.google.com>
Change-Id: I46dfe5c8ebef29ed6ee7fdf342cfad9d39fe6ca3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2325496
Reviewed-by: Edward Hill <ecgh@chromium.org>
Commit-Queue: Edward Hill <ecgh@chromium.org>
Diffstat (limited to 'board/woomax')
-rw-r--r-- | board/woomax/board.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/board/woomax/board.c b/board/woomax/board.c index 0298eecf37..e7796b87a7 100644 --- a/board/woomax/board.c +++ b/board/woomax/board.c @@ -32,6 +32,7 @@ #include "tablet_mode.h" #include "task.h" #include "temp_sensor.h" +#include "thermistor.h" #include "usb_charge.h" #include "usb_mux.h" @@ -343,6 +344,37 @@ const struct fan_t fans[] = { }; BUILD_ASSERT(ARRAY_SIZE(fans) == FAN_CH_COUNT); +int board_get_temp(int idx, int *temp_k) +{ + int mv; + int temp_c; + enum adc_channel channel; + + /* idx is the sensor index set in board temp_sensors[] */ + switch (idx) { + case TEMP_SENSOR_CHARGER: + channel = ADC_TEMP_SENSOR_CHARGER; + break; + case TEMP_SENSOR_SOC: + /* thermistor is not powered in G3 */ + if (chipset_in_state(CHIPSET_STATE_HARD_OFF)) + return EC_ERROR_NOT_POWERED; + + channel = ADC_TEMP_SENSOR_SOC; + break; + default: + return EC_ERROR_INVAL; + } + + mv = adc_read_channel(channel); + if (mv < 0) + return EC_ERROR_INVAL; + + temp_c = thermistor_linear_interpolate(mv, &thermistor_info); + *temp_k = C_TO_K(temp_c); + return EC_SUCCESS; +} + const struct adc_t adc_channels[] = { [ADC_TEMP_SENSOR_CHARGER] = { .name = "CHARGER", |