summaryrefslogtreecommitdiff
path: root/board/dewatt
diff options
context:
space:
mode:
authorZick Wei <zick.wei@quanta.corp-partner.google.com>2021-08-31 16:37:33 +0800
committerCommit Bot <commit-bot@chromium.org>2021-09-07 14:29:50 +0000
commitb90e9587c85ee8f7c504e3e23cd8f2273059b2a5 (patch)
tree34180d838e6a4b5e4fa6e594ad7245caf39e9207 /board/dewatt
parent6116078ffe9ab22b61d5a7888aaf772a90f89dcc (diff)
downloadchrome-ec-b90e9587c85ee8f7c504e3e23cd8f2273059b2a5.tar.gz
guybrush: move thermal sensor/setting to variant
This patch move thermal sensor and setting to variant, let variant have their own setting. BUG=none BRANCH=none TEST=make BOARD=dewatt, make BOARD=guybrush, make BOARD=nipperkin Signed-off-by: Zick Wei <zick.wei@quanta.corp-partner.google.com> Change-Id: Ibf37a0a45d1a728abc5ed88dde230f0561698bbc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3132547 Reviewed-by: Devin Lu <Devin.Lu@quantatw.com> Reviewed-by: Rob Barnes <robbarnes@google.com> Commit-Queue: Rob Barnes <robbarnes@google.com>
Diffstat (limited to 'board/dewatt')
-rw-r--r--board/dewatt/board.c152
-rw-r--r--board/dewatt/board.h20
2 files changed, 172 insertions, 0 deletions
diff --git a/board/dewatt/board.c b/board/dewatt/board.c
index d0762fa595..72e803d100 100644
--- a/board/dewatt/board.c
+++ b/board/dewatt/board.c
@@ -5,6 +5,7 @@
/* Guybrush board-specific configuration */
+#include "adc.h"
#include "base_fw_config.h"
#include "board_fw_config.h"
#include "button.h"
@@ -16,6 +17,8 @@
#include "driver/accel_bma422.h"
#include "driver/retimer/ps8811.h"
#include "driver/retimer/ps8818.h"
+#include "driver/temp_sensor/sb_tsi.h"
+#include "driver/temp_sensor/tmp112.h"
#include "extpower.h"
#include "gpio.h"
#include "hooks.h"
@@ -25,8 +28,10 @@
#include "power_button.h"
#include "switch.h"
#include "tablet_mode.h"
+#include "temp_sensor.h"
#include "temp_sensor/thermistor.h"
#include "temp_sensor/tmp112.h"
+#include "thermal.h"
#include "usb_mux.h"
#include "gpio_list.h" /* Must come after other header files. */
@@ -383,3 +388,150 @@ int board_get_ambient_temp_mk(int *temp_mk)
return tmp112_get_val_mk(TMP112_AMB, temp_mk);
}
+
+/* ADC Channels */
+const struct adc_t adc_channels[] = {
+ [ADC_TEMP_SENSOR_SOC] = {
+ .name = "SOC",
+ .input_ch = NPCX_ADC_CH0,
+ .factor_mul = ADC_MAX_VOLT,
+ .factor_div = ADC_READ_MAX + 1,
+ .shift = 0,
+ },
+ [ADC_TEMP_SENSOR_CHARGER] = {
+ .name = "CHARGER",
+ .input_ch = NPCX_ADC_CH1,
+ .factor_mul = ADC_MAX_VOLT,
+ .factor_div = ADC_READ_MAX + 1,
+ .shift = 0,
+ },
+ [ADC_TEMP_SENSOR_MEMORY] = {
+ .name = "MEMORY",
+ .input_ch = NPCX_ADC_CH2,
+ .factor_mul = ADC_MAX_VOLT,
+ .factor_div = ADC_READ_MAX + 1,
+ .shift = 0,
+ },
+ [ADC_CORE_IMON1] = {
+ .name = "CORE_I",
+ .input_ch = NPCX_ADC_CH3,
+ .factor_mul = ADC_MAX_VOLT,
+ .factor_div = ADC_READ_MAX + 1,
+ .shift = 0,
+ },
+ [ADC_SOC_IMON2] = {
+ .name = "SOC_I",
+ .input_ch = NPCX_ADC_CH4,
+ .factor_mul = ADC_MAX_VOLT,
+ .factor_div = ADC_READ_MAX + 1,
+ .shift = 0,
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
+
+/* Temp Sensors */
+static int board_get_memory_temp(int, int *);
+
+const struct tmp112_sensor_t tmp112_sensors[] = {
+ { I2C_PORT_SENSOR, TMP112_I2C_ADDR_FLAGS0 },
+ { I2C_PORT_SENSOR, TMP112_I2C_ADDR_FLAGS1 },
+};
+BUILD_ASSERT(ARRAY_SIZE(tmp112_sensors) == TMP112_COUNT);
+
+const struct temp_sensor_t temp_sensors[] = {
+ [TEMP_SENSOR_SOC] = {
+ .name = "SOC",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = board_get_soc_temp_k,
+ .idx = TMP112_SOC,
+ },
+ [TEMP_SENSOR_CHARGER] = {
+ .name = "Charger",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = get_temp_3v3_30k9_47k_4050b,
+ .idx = ADC_TEMP_SENSOR_CHARGER,
+ },
+ [TEMP_SENSOR_MEMORY] = {
+ .name = "Memory",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = board_get_memory_temp,
+ .idx = ADC_TEMP_SENSOR_MEMORY,
+ },
+ [TEMP_SENSOR_CPU] = {
+ .name = "CPU",
+ .type = TEMP_SENSOR_TYPE_CPU,
+ .read = sb_tsi_get_val,
+ .idx = 0,
+ },
+ [TEMP_SENSOR_AMBIENT] = {
+ .name = "Ambient",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = tmp112_get_val_k,
+ .idx = TMP112_AMB,
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
+
+struct ec_thermal_config thermal_params[TEMP_SENSOR_COUNT] = {
+ [TEMP_SENSOR_SOC] = {
+ .temp_host = {
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(100),
+ [EC_TEMP_THRESH_HALT] = C_TO_K(105),
+ },
+ .temp_host_release = {
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(80),
+ },
+ /* TODO: Setting fan off to 0 so it's allways on */
+ .temp_fan_off = C_TO_K(0),
+ .temp_fan_max = C_TO_K(70),
+ },
+ [TEMP_SENSOR_CHARGER] = {
+ .temp_host = {
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(100),
+ [EC_TEMP_THRESH_HALT] = C_TO_K(105),
+ },
+ .temp_host_release = {
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(80),
+ },
+ .temp_fan_off = 0,
+ .temp_fan_max = 0,
+ },
+ [TEMP_SENSOR_MEMORY] = {
+ .temp_host = {
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(100),
+ [EC_TEMP_THRESH_HALT] = C_TO_K(105),
+ },
+ .temp_host_release = {
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(80),
+ },
+ .temp_fan_off = 0,
+ .temp_fan_max = 0,
+ },
+ [TEMP_SENSOR_CPU] = {
+ .temp_host = {
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(100),
+ [EC_TEMP_THRESH_HALT] = C_TO_K(105),
+ },
+ .temp_host_release = {
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(80),
+ },
+ /*
+ * CPU temp sensor fan thresholds are high because they are a
+ * backup for the SOC temp sensor fan thresholds.
+ */
+ .temp_fan_off = C_TO_K(60),
+ .temp_fan_max = C_TO_K(90),
+ },
+ /*
+ * Note: Leave ambient entries at 0, both as it does not represent a
+ * hotspot and as not all boards have this sensor
+ */
+};
+BUILD_ASSERT(ARRAY_SIZE(thermal_params) == TEMP_SENSOR_COUNT);
+
+static int board_get_memory_temp(int idx, int *temp_k)
+{
+ if (chipset_in_state(CHIPSET_STATE_HARD_OFF))
+ return EC_ERROR_NOT_POWERED;
+ return get_temp_3v3_30k9_47k_4050b(idx, temp_k);
+}
diff --git a/board/dewatt/board.h b/board/dewatt/board.h
index dc09530e8e..f5c47718d5 100644
--- a/board/dewatt/board.h
+++ b/board/dewatt/board.h
@@ -71,6 +71,26 @@ enum base_accelgyro_type {
BASE_GYRO_BMI323 = 2,
};
+/* ADC Channels */
+enum adc_channel {
+ ADC_TEMP_SENSOR_SOC = 0,
+ ADC_TEMP_SENSOR_CHARGER,
+ ADC_TEMP_SENSOR_MEMORY,
+ ADC_CORE_IMON1,
+ ADC_SOC_IMON2,
+ ADC_CH_COUNT
+};
+
+/* Temp Sensors */
+enum temp_sensor_id {
+ TEMP_SENSOR_SOC = 0,
+ TEMP_SENSOR_CHARGER,
+ TEMP_SENSOR_MEMORY,
+ TEMP_SENSOR_CPU,
+ TEMP_SENSOR_AMBIENT,
+ TEMP_SENSOR_COUNT
+};
+
#endif /* !__ASSEMBLER__ */
#endif /* __CROS_EC_BOARD_H */