summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Fagerburg <pfagerburg@chromium.org>2019-08-06 14:43:55 -0600
committerCommit Bot <commit-bot@chromium.org>2019-08-12 19:13:53 +0000
commitc5943df788164d0d2c8e984f72af594542244403 (patch)
treef02f4e07ae078e9f3b5f253299852804bcf1be9a
parent99591a03f7e9b3680d80e7cd040d7f437da1dfb1 (diff)
downloadchrome-ec-c5943df788164d0d2c8e984f72af594542244403.tar.gz
thermistor: update Steinhart-Hart equations
Add support for 30.9K pull-up on resistor divider with the 47K thermistor. BRANCH=none BUG=b:124316213 TEST=Rebuild EC and flash Change-Id: I5bc72fa67549ab15c0e4e1b0291eb934990ee61b Signed-off-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1742914 Reviewed-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
-rw-r--r--driver/temp_sensor/thermistor.c36
-rw-r--r--driver/temp_sensor/thermistor.h18
-rw-r--r--include/config.h1
3 files changed, 54 insertions, 1 deletions
diff --git a/driver/temp_sensor/thermistor.c b/driver/temp_sensor/thermistor.c
index 25ff819321..dab0e985ce 100644
--- a/driver/temp_sensor/thermistor.c
+++ b/driver/temp_sensor/thermistor.c
@@ -66,7 +66,8 @@ int thermistor_linear_interpolate(uint16_t mv,
#if defined(CONFIG_STEINHART_HART_3V3_51K1_47K_4050B) || \
defined(CONFIG_STEINHART_HART_3V3_13K7_47K_4050B) || \
defined(CONFIG_STEINHART_HART_6V0_51K1_47K_4050B) || \
- defined(CONFIG_STEINHART_HART_3V0_22K6_47K_4050B)
+ defined(CONFIG_STEINHART_HART_3V0_22K6_47K_4050B) || \
+ defined(CONFIG_STEINHART_HART_3V3_30K9_47K_4050B)
static int thermistor_get_temperature(int idx_adc, int *temp_ptr,
const struct thermistor_info *info)
{
@@ -233,3 +234,36 @@ int get_temp_3v0_22k6_47k_4050b(int idx_adc, int *temp_ptr)
&thermistor_info_22_47);
}
#endif /* CONFIG_STEINHART_HART_3V0_22K6_47K_4050B */
+
+#ifdef CONFIG_STEINHART_HART_3V3_30K9_47K_4050B
+/*
+ * Data derived from Steinhart-Hart equation in a resistor divider circuit with
+ * Vdd=3000mV, R = 30.9Kohm, and thermistor (B = 4050, T0 = 298.15 K, nominal
+ * resistance (R0) = 47Kohm).
+ */
+#define THERMISTOR_SCALING_FACTOR_31_47 11
+static const struct thermistor_data_pair thermistor_data_31_47[] = {
+ { 2753 / THERMISTOR_SCALING_FACTOR_31_47, 0 },
+ { 2487 / THERMISTOR_SCALING_FACTOR_31_47, 10 },
+ { 2165 / THERMISTOR_SCALING_FACTOR_31_47, 20 },
+ { 1813 / THERMISTOR_SCALING_FACTOR_31_47, 30 },
+ { 1145 / THERMISTOR_SCALING_FACTOR_31_47, 50 },
+ { 878 / THERMISTOR_SCALING_FACTOR_31_47, 60 },
+ { 665 / THERMISTOR_SCALING_FACTOR_31_47, 70 },
+ { 500 / THERMISTOR_SCALING_FACTOR_31_47, 80 },
+ { 375 / THERMISTOR_SCALING_FACTOR_31_47, 90 },
+ { 282 / THERMISTOR_SCALING_FACTOR_31_47, 100 },
+};
+
+static const struct thermistor_info thermistor_info_31_47 = {
+ .scaling_factor = THERMISTOR_SCALING_FACTOR_31_47,
+ .num_pairs = ARRAY_SIZE(thermistor_data_31_47),
+ .data = thermistor_data_31_47,
+};
+
+int get_temp_3v3_30k9_47k_4050b(int idx_adc, int *temp_ptr)
+{
+ return thermistor_get_temperature(idx_adc, temp_ptr,
+ &thermistor_info_31_47);
+}
+#endif /* CONFIG_STEINHART_HART_3V3_30K9_47K_4050B */
diff --git a/driver/temp_sensor/thermistor.h b/driver/temp_sensor/thermistor.h
index 5ba338f40f..7ebe2b42ac 100644
--- a/driver/temp_sensor/thermistor.h
+++ b/driver/temp_sensor/thermistor.h
@@ -129,4 +129,22 @@ int get_temp_6v0_51k1_47k_4050b(int idx_adc, int *temp_ptr);
int get_temp_3v0_22k6_47k_4050b(int idx_adc, int *temp_ptr);
#endif
+#ifdef CONFIG_STEINHART_HART_3V3_30K9_47K_4050B
+/**
+ * Reads the specified ADC channel and uses a lookup table and interpolation to
+ * return a temperature in degrees K.
+ *
+ * The lookup table is based off of a resistor divider circuit on 3.3V with a
+ * 30.9K resistor in series with a thermistor with nominal value of 47K (at 25C)
+ * and a B (25/100) value of 4050.
+ *
+ * @param idx_adc The idx value from the temp_sensor_t struct, which is
+ * the ADC channel to read and convert to degrees K
+ * @param temp_ptr Destination for temperature (in degrees K)
+ *
+ * @return EC_SUCCESS, or non-zero if error.
+ */
+int get_temp_3v3_30k9_47k_4050b(int idx_adc, int *temp_ptr);
+#endif
+
#endif /* __CROS_EC_TEMP_SENSOR_THERMISTOR_NCP15WB_H */
diff --git a/include/config.h b/include/config.h
index f81cffcaa9..0748c26206 100644
--- a/include/config.h
+++ b/include/config.h
@@ -3381,6 +3381,7 @@
#undef CONFIG_STEINHART_HART_3V3_13K7_47K_4050B
#undef CONFIG_STEINHART_HART_3V3_51K1_47K_4050B
#undef CONFIG_STEINHART_HART_6V0_51K1_47K_4050B
+#undef CONFIG_STEINHART_HART_3V3_30K9_47K_4050B
/*
* If defined, active-high GPIO which indicates temperature sensor chips are