summaryrefslogtreecommitdiff
path: root/driver/temp_sensor
diff options
context:
space:
mode:
authorJustin TerAvest <teravest@chromium.org>2018-07-25 11:19:21 -0600
committerchrome-bot <chrome-bot@chromium.org>2018-07-30 12:25:33 -0700
commit03c74449cd44b4bf4134547a4aded327d0e03d71 (patch)
tree1e8b1857a7354f0e0a52ae783838c2a2469bc61a /driver/temp_sensor
parentd290053f9544a1938b1a0a578fa551855d4738d2 (diff)
downloadchrome-ec-03c74449cd44b4bf4134547a4aded327d0e03d71.tar.gz
bip: Add charger temp sensor
The voltage used for the charger thermistor is 6.0V, which requires new tables to be created for that configuration. Additionally, the voltage rail used for measuring temperature comes from the charger LDO, which is only powered when AC is present. This was tested as below: > temps Battery : 299 K = 26 C Ambient : 300 K = 27 C Charger : 302 K = 29 C [Removed AC power] > temps Battery : 299 K = 26 C Ambient : 300 K = 27 C Charger : Not powered Not Powered BRANCH=None TEST=built, ran "temps" BUG=b:80145756,b:79932676 Change-Id: I391d2b6eaddc0f6a99f7b7ce565c245838f608f9 Signed-off-by: Justin TerAvest <teravest@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1150416 Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'driver/temp_sensor')
-rw-r--r--driver/temp_sensor/thermistor.c44
-rw-r--r--driver/temp_sensor/thermistor.h18
2 files changed, 62 insertions, 0 deletions
diff --git a/driver/temp_sensor/thermistor.c b/driver/temp_sensor/thermistor.c
index d9c70f7386..82a18ff500 100644
--- a/driver/temp_sensor/thermistor.c
+++ b/driver/temp_sensor/thermistor.c
@@ -145,3 +145,47 @@ int get_temp_3v3_13k7_47k_4050b(int idx_adc, int *temp_ptr)
return EC_SUCCESS;
}
#endif /* CONFIG_STEINHART_HART_3V3_13K7_47K_4050B */
+
+#ifdef CONFIG_STEINHART_HART_6V0_51K1_47K_4050B
+/*
+ * Data derived from Steinhart-Hart equation in a resistor divider circuit with
+ * Vdd=6000mV, R = 51.1Kohm, and thermistor (B = 4050, T0 = 298.15 K, nominal
+ * resistance (R0) = 47Kohm).
+ */
+#define THERMISTOR_SCALING_FACTOR_6V0_51_47 18
+static const struct thermistor_data_pair thermistor_data_6v0_51_47[] = {
+ { 4517 / THERMISTOR_SCALING_FACTOR_6V0_51_47, 0 },
+ { 3895 / THERMISTOR_SCALING_FACTOR_6V0_51_47, 10 },
+ { 3214 / THERMISTOR_SCALING_FACTOR_6V0_51_47, 20 },
+ { 2546 / THERMISTOR_SCALING_FACTOR_6V0_51_47, 30 },
+ { 1950 / THERMISTOR_SCALING_FACTOR_6V0_51_47, 40 },
+ { 1459 / THERMISTOR_SCALING_FACTOR_6V0_51_47, 50 },
+ { 1079 / THERMISTOR_SCALING_FACTOR_6V0_51_47, 60 },
+ { 794 / THERMISTOR_SCALING_FACTOR_6V0_51_47, 70 },
+ { 584 / THERMISTOR_SCALING_FACTOR_6V0_51_47, 80 },
+ { 502 / THERMISTOR_SCALING_FACTOR_6V0_51_47, 85 },
+ { 432 / THERMISTOR_SCALING_FACTOR_6V0_51_47, 90 },
+ { 372 / THERMISTOR_SCALING_FACTOR_6V0_51_47, 95 },
+ { 322 / THERMISTOR_SCALING_FACTOR_6V0_51_47, 100 },
+};
+
+static const struct thermistor_info thermistor_info_6v0_51_47 = {
+ .scaling_factor = THERMISTOR_SCALING_FACTOR_6V0_51_47,
+ .num_pairs = ARRAY_SIZE(thermistor_data_6v0_51_47),
+ .data = thermistor_data_6v0_51_47,
+};
+
+int get_temp_6v0_51k1_47k_4050b(int idx_adc, int *temp_ptr)
+{
+ int mv = adc_read_channel(idx_adc);
+
+ if (mv < 0)
+ return EC_ERROR_UNKNOWN;
+
+ *temp_ptr = thermistor_linear_interpolate(mv, &thermistor_info_6v0_51_47);
+ *temp_ptr = C_TO_K(*temp_ptr);
+ return EC_SUCCESS;
+}
+#endif /* CONFIG_STEINHART_HART_6V0_51K1_47K_4050B */
+
+
diff --git a/driver/temp_sensor/thermistor.h b/driver/temp_sensor/thermistor.h
index 49edee5451..1874188b60 100644
--- a/driver/temp_sensor/thermistor.h
+++ b/driver/temp_sensor/thermistor.h
@@ -93,4 +93,22 @@ int get_temp_3v3_13k7_47k_4050b(int idx_adc, int *temp_ptr);
int get_temp_3v3_51k1_47k_4050b(int idx_adc, int *temp_ptr);
#endif
+#ifdef CONFIG_STEINHART_HART_6V0_51K1_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 6.0V with a
+ * 51.1K 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_6v0_51k1_47k_4050b(int idx_adc, int *temp_ptr);
+#endif
+
#endif /* __CROS_EC_TEMP_SENSOR_THERMISTOR_NCP15WB_H */