From b536c348359487f0408a17af8d9d506f5a1d18a6 Mon Sep 17 00:00:00 2001 From: Ko_Ko Date: Wed, 30 Sep 2020 14:48:49 +0800 Subject: Madoo: Add thermistors This change adds the temperature sensors for madoo, which are hooked up to 2 of the ADCs. BUG=b:169729477 BRANCH=None TEST=build and test on madoo board. Can obtain value via ectool cmd. Signed-off-by: Ko_Ko Change-Id: Id57a669006db04f9a83ad3b6ebe65b2df7c80b11 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2437723 Reviewed-by: Aseda Aboagye Commit-Queue: Ko Ko Tested-by: Ko Ko --- board/madoo/board.c | 15 +++++++++++++++ board/madoo/board.h | 12 ++++++++++++ 2 files changed, 27 insertions(+) diff --git a/board/madoo/board.c b/board/madoo/board.c index 75e705cd76..9ced2a0ecb 100644 --- a/board/madoo/board.c +++ b/board/madoo/board.c @@ -22,6 +22,7 @@ #include "driver/retimer/nb7v904m.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" @@ -40,6 +41,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" @@ -392,6 +394,19 @@ struct motion_sensor_t motion_sensors[] = { const 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/madoo/board.h b/board/madoo/board.h index 3685a1017f..100e39e842 100644 --- a/board/madoo/board.h +++ b/board/madoo/board.h @@ -110,6 +110,12 @@ #define CONFIG_USB_MUX_RUNTIME_CONFIG +/* 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" @@ -136,6 +142,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_COUNT, -- cgit v1.2.1