summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaveh Jalali <caveh@chromium.org>2021-02-18 19:40:05 -0800
committerCommit Bot <commit-bot@chromium.org>2021-02-24 23:52:37 +0000
commitae11458164b09e74ba2bc085785d49a6ecb90f69 (patch)
tree298045d54846fba969e643fe1a3efde6afe5b089
parent16f1b7a2aad444de45162924312d88c827039a3c (diff)
downloadchrome-ec-ae11458164b09e74ba2bc085785d49a6ecb90f69.tar.gz
brya: Add thermistor support
This adds support for the two thermistors on brya. BRANCH=none BUG=b:173575131 TEST=buildall passes Change-Id: I198e1ce72910d1798c51cf5c99c9f1f0601f3c31 Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2706263 Commit-Queue: Keith Short <keithshort@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r--board/brya/board.h19
-rw-r--r--board/brya/build.mk1
-rw-r--r--board/brya/sensors.c46
3 files changed, 65 insertions, 1 deletions
diff --git a/board/brya/board.h b/board/brya/board.h
index 4a603df8ee..d5e1b23d70 100644
--- a/board/brya/board.h
+++ b/board/brya/board.h
@@ -14,7 +14,6 @@
/*
* Disable features enabled by default.
*/
-#undef CONFIG_ADC
#undef CONFIG_HIBERNATE
#undef CONFIG_SPI_FLASH
#undef CONFIG_SWITCH
@@ -71,11 +70,29 @@
#define I2C_PORT_CHARGER NPCX_I2C_PORT7_0
#define I2C_PORT_EEPROM NPCX_I2C_PORT7_0
+/* Thermal features */
+#define CONFIG_THERMISTOR
+#define CONFIG_TEMP_SENSOR
+#define CONFIG_TEMP_SENSOR_POWER_GPIO GPIO_SEQ_EC_DSW_PWROK
+#define CONFIG_STEINHART_HART_3V3_30K9_47K_4050B
+
#ifndef __ASSEMBLER__
#include "gpio_signal.h" /* needed by registers.h */
#include "registers.h"
+enum adc_channel {
+ ADC_TEMP_SENSOR_1_DDR_SOC,
+ ADC_TEMP_SENSOR_2_CHARGER,
+ ADC_CH_COUNT
+};
+
+enum temp_sensor_id {
+ TEMP_SENSOR_1_DDR_SOC,
+ TEMP_SENSOR_2_CHARGER,
+ TEMP_SENSOR_COUNT
+};
+
enum ioex_port {
IOEX_C0_NCT38XX = 0,
IOEX_C2_NCT38XX,
diff --git a/board/brya/build.mk b/board/brya/build.mk
index ce658b6e2f..bfe748269e 100644
--- a/board/brya/build.mk
+++ b/board/brya/build.mk
@@ -17,4 +17,5 @@ board-y+=board.o
board-y+=fans.o
board-y+=i2c.o
board-y+=pwm.o
+board-y+=sensors.o
board-y+=usbc_config.o
diff --git a/board/brya/sensors.c b/board/brya/sensors.c
new file mode 100644
index 0000000000..bb51eb245b
--- /dev/null
+++ b/board/brya/sensors.c
@@ -0,0 +1,46 @@
+/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "common.h"
+
+#include "adc_chip.h"
+#include "temp_sensor.h"
+#include "thermistor.h"
+
+/* ADC configuration */
+const struct adc_t adc_channels[] = {
+ [ADC_TEMP_SENSOR_1_DDR_SOC] = {
+ .name = "TEMP_DDR_SOC",
+ .input_ch = NPCX_ADC_CH0,
+ .factor_mul = ADC_MAX_VOLT,
+ .factor_div = ADC_READ_MAX + 1,
+ .shift = 0,
+ },
+ [ADC_TEMP_SENSOR_2_CHARGER] = {
+ .name = "TEMP_CHARGER",
+ .input_ch = NPCX_ADC_CH1,
+ .factor_mul = ADC_MAX_VOLT,
+ .factor_div = ADC_READ_MAX + 1,
+ .shift = 0,
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
+
+/* Temperature sensor configuration */
+const struct temp_sensor_t temp_sensors[] = {
+ [TEMP_SENSOR_1_DDR_SOC] = {
+ .name = "DDR and SOC",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = get_temp_3v3_30k9_47k_4050b,
+ .idx = ADC_TEMP_SENSOR_1_DDR_SOC
+ },
+ [TEMP_SENSOR_2_CHARGER] = {
+ .name = "Charger",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = get_temp_3v3_30k9_47k_4050b,
+ .idx = ADC_TEMP_SENSOR_2_CHARGER
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);