From 0283c73bc51f0e271b848df9db536492a512d906 Mon Sep 17 00:00:00 2001 From: Owen_Ou Date: Thu, 16 Dec 2021 10:26:26 +0800 Subject: Corori2: Add thermal params and thermistor define Add thermal params and thermal's define for Corori2. BUG=b:202238812 BRANCH=none TEST=make -j BOARD=corori2 Signed-off-by: Owen_Ou Change-Id: Ifc83dbd21ad765dc91ef4b414a310d973aac8b43 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3343575 Reviewed-by: SamSP Liu Reviewed-by: Elmo Lan Reviewed-by: Aseda Aboagye Reviewed-by: Owen Ou Tested-by: Owen Ou Auto-Submit: Owen Ou Commit-Queue: Owen Ou --- board/corori2/board.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++ board/corori2/board.h | 13 +++++++++++ 2 files changed, 77 insertions(+) diff --git a/board/corori2/board.c b/board/corori2/board.c index 4c38716e68..df2fac683f 100644 --- a/board/corori2/board.c +++ b/board/corori2/board.c @@ -14,6 +14,8 @@ #include "chipset.h" #include "common.h" #include "compile_time_macros.h" +#include "driver/temp_sensor/thermistor.h" +#include "temp_sensor.h" #include "driver/accel_bma2x2.h" #include "driver/accelgyro_bmi_common.h" #include "driver/bc12/pi3usb9201.h" @@ -163,6 +165,65 @@ const struct adc_t adc_channels[] = { }; BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT); +/* Thermistors */ +const struct temp_sensor_t temp_sensors[] = { + [ADC_TEMP_SENSOR_1] = {.name = "Memory", + .type = TEMP_SENSOR_TYPE_BOARD, + .read = get_temp_3v3_51k1_47k_4050b, + .idx = ADC_TEMP_SENSOR_1}, + [ADC_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); + +/* + * TODO(b/202062363): Remove when clang is fixed. + */ +#define THERMAL_MEMORY \ + { \ + .temp_host = { \ + [EC_TEMP_THRESH_WARN] = 0, \ + [EC_TEMP_THRESH_HIGH] = C_TO_K(85), \ + [EC_TEMP_THRESH_HALT] = C_TO_K(95), \ + }, \ + .temp_host_release = { \ + [EC_TEMP_THRESH_WARN] = 0, \ + [EC_TEMP_THRESH_HIGH] = C_TO_K(70), \ + [EC_TEMP_THRESH_HALT] = 0, \ + }, \ + } +__maybe_unused static const struct ec_thermal_config thermal_memory = + THERMAL_MEMORY; + +/* + * TODO(b/202062363): Remove when clang is fixed. + */ +#define THERMAL_CHARGER \ + { \ + .temp_host = { \ + [EC_TEMP_THRESH_WARN] = 0, \ + [EC_TEMP_THRESH_HIGH] = C_TO_K(80), \ + [EC_TEMP_THRESH_HALT] = C_TO_K(85), \ + }, \ + .temp_host_release = { \ + [EC_TEMP_THRESH_WARN] = 0, \ + [EC_TEMP_THRESH_HIGH] = C_TO_K(55), \ + [EC_TEMP_THRESH_HALT] = 0, \ + }, \ + } +__maybe_unused static const struct ec_thermal_config thermal_charger = + THERMAL_CHARGER; + +struct ec_thermal_config thermal_params[TEMP_SENSOR_COUNT]; + +static void setup_thermal(void) +{ + thermal_params[ADC_TEMP_SENSOR_1] = thermal_memory; + thermal_params[ADC_TEMP_SENSOR_2] = thermal_charger; +} + void board_init(void) { int on; @@ -205,6 +266,9 @@ void board_init(void) on = chipset_in_state(CHIPSET_STATE_ON | CHIPSET_STATE_ANY_SUSPEND | CHIPSET_STATE_SOFT_OFF); board_power_5v_enable(on); + + /* Initialize THERMAL */ + setup_thermal(); } DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); diff --git a/board/corori2/board.h b/board/corori2/board.h index f32d796eba..b5381bd4ab 100644 --- a/board/corori2/board.h +++ b/board/corori2/board.h @@ -70,6 +70,13 @@ #define CONFIG_PWM #define NPCX7_PWM1_SEL 1 /* GPIO C2 is used as PWM1. */ +/* Temp sensor */ +#define CONFIG_TEMP_SENSOR +#define CONFIG_THERMISTOR +#define CONFIG_STEINHART_HART_3V3_51K1_47K_4050B +#define CONFIG_THROTTLE_AP +#define CONFIG_CHIPSET_CAN_THROTTLE + /* USB */ #define CONFIG_BC12_DETECT_PI3USB9201 #define CONFIG_USBC_RETIMER_NB7V904M @@ -165,6 +172,12 @@ enum adc_channel { ADC_CH_COUNT }; +enum temp_sensor_id { + TEMP_SENSOR_1, + TEMP_SENSOR_2, + TEMP_SENSOR_COUNT +}; + enum sensor_id { LID_ACCEL, BASE_ACCEL, -- cgit v1.2.1