From ce93a01527aa9214b6b023f4543209dd7612b80a Mon Sep 17 00:00:00 2001 From: Zick Wei Date: Wed, 29 Jul 2020 15:31:11 +0800 Subject: 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 Change-Id: I46dfe5c8ebef29ed6ee7fdf342cfad9d39fe6ca3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2325496 Reviewed-by: Edward Hill Commit-Queue: Edward Hill --- board/ezkinil/board.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'board/ezkinil/board.c') diff --git a/board/ezkinil/board.c b/board/ezkinil/board.c index df593667bb..35194d42fb 100644 --- a/board/ezkinil/board.c +++ b/board/ezkinil/board.c @@ -28,6 +28,7 @@ #include "switch.h" #include "system.h" #include "task.h" +#include "thermistor.h" #include "temp_sensor.h" #include "usb_charge.h" #include "usb_mux.h" @@ -424,6 +425,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", -- cgit v1.2.1