summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen_Ou <Owen_Ou@compal.corp-partner.google.com>2021-12-16 10:26:26 +0800
committerCommit Bot <commit-bot@chromium.org>2021-12-17 02:44:09 +0000
commit0283c73bc51f0e271b848df9db536492a512d906 (patch)
tree6e9d630c2f8ebcdd37e8bfd344c30b1cadcfa61d
parent096ee6ac1d101aa31252a2d02a57086876243f2c (diff)
downloadchrome-ec-0283c73bc51f0e271b848df9db536492a512d906.tar.gz
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 <Owen_Ou@compal.corp-partner.google.com> Change-Id: Ifc83dbd21ad765dc91ef4b414a310d973aac8b43 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3343575 Reviewed-by: SamSP Liu <samsp_liu@compal.corp-partner.google.com> Reviewed-by: Elmo Lan <elmo_lan@compal.corp-partner.google.com> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Owen Ou <owen_ou@compal.corp-partner.google.com> Tested-by: Owen Ou <owen_ou@compal.corp-partner.google.com> Auto-Submit: Owen Ou <owen_ou@compal.corp-partner.google.com> Commit-Queue: Owen Ou <owen_ou@compal.corp-partner.google.com>
-rw-r--r--board/corori2/board.c64
-rw-r--r--board/corori2/board.h13
2 files changed, 77 insertions, 0 deletions
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,