From b3dbf4f3bd30cc057801cad4d93ebca4d00331e7 Mon Sep 17 00:00:00 2001 From: johnwc_yeh Date: Thu, 13 May 2021 13:24:19 +0800 Subject: cret: Add thermistors This change adds the temperature sensors for cret, which are hooked up to 2 of the ADCs. BUG=b:187894632 BRANCH=dedede TEST=build and test on cret board. Can obtain value via ectool cmd. Signed-off-by: johnwc_yeh Change-Id: I7d07c36e80b95b149d503fd9e37999291c21d5f4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2891675 Reviewed-by: Elthan Huang Reviewed-by: Aseda Aboagye Commit-Queue: Aseda Aboagye --- board/cret/board.c | 15 +++++++++++++++ board/cret/board.h | 12 ++++++++++++ 2 files changed, 27 insertions(+) diff --git a/board/cret/board.c b/board/cret/board.c index 9c156d03b5..bcba5138a9 100644 --- a/board/cret/board.c +++ b/board/cret/board.c @@ -20,6 +20,7 @@ #include "driver/charger/isl923x.h" #include "driver/tcpm/raa489000.h" #include "driver/tcpm/tcpci.h" +#include "driver/temp_sensor/thermistor.h" #include "driver/usb_mux/pi3usb3x532.h" #include "extpower.h" #include "gpio.h" @@ -38,6 +39,7 @@ #include "system.h" #include "tablet_mode.h" #include "task.h" +#include "temp_sensor.h" #include "usb_mux.h" #include "usb_pd.h" #include "usb_pd_tcpm.h" @@ -415,6 +417,19 @@ struct motion_sensor_t motion_sensors[] = { unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); +/* Thermistors */ +const struct temp_sensor_t temp_sensors[] = { + [TEMP_SENSOR_1] = {.name = "Memory", + .type = TEMP_SENSOR_TYPE_BOARD, + .read = get_temp_3v3_51k1_47k_4050b, + .idx = ADC_TEMP_SENSOR_1}, + [TEMP_SENSOR_2] = {.name = "Charger", + .type = TEMP_SENSOR_TYPE_BOARD, + .read = get_temp_3v3_51k1_47k_4050b, + .idx = ADC_TEMP_SENSOR_2}, +}; +BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT); + __override void ocpc_get_pid_constants(int *kp, int *kp_div, int *ki, int *ki_div, int *kd, int *kd_div) diff --git a/board/cret/board.h b/board/cret/board.h index eb7cd3faf1..e59292bd86 100644 --- a/board/cret/board.h +++ b/board/cret/board.h @@ -130,6 +130,12 @@ #define CONFIG_TABLET_MODE_SWITCH #define CONFIG_GMR_TABLET_MODE +/* Thermistors */ +#define CONFIG_TEMP_SENSOR +#define CONFIG_THERMISTOR +#define CONFIG_STEINHART_HART_3V3_51K1_47K_4050B +#define CONFIG_TEMP_SENSOR_POWER_GPIO GPIO_EN_PP3300_A + #ifndef __ASSEMBLER__ #include "gpio_signal.h" @@ -149,6 +155,12 @@ enum sensor_id { SENSOR_COUNT }; +enum temp_sensor_id { + TEMP_SENSOR_1, + TEMP_SENSOR_2, + TEMP_SENSOR_COUNT +}; + enum pwm_channel { PWM_CH_KBLIGHT, PWM_CH_LED1_AMBER, -- cgit v1.2.1