summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAaron Massey <aaronmassey@google.com>2021-09-24 11:22:12 -0600
committerCommit Bot <commit-bot@chromium.org>2021-09-24 19:47:45 +0000
commit465c9dc87a353f48b969da0631c4fd2b6df32a4f (patch)
treeeae7fa5a0f92cb81af315eb7912267167ed078e1 /include
parentfc2b67a878f6c57c02569253032fc5d09f6c581e (diff)
downloadchrome-ec-465c9dc87a353f48b969da0631c4fd2b6df32a4f.tar.gz
zephyr: drivers: thermistors are device tree nodes
Thermistor drivers now query the device tree for configuration. Thermistor tests have been updated to be parameterized on all thermistors enabled in the device tree. BRANCH=none BUG=b:184374937 TEST= 1) zmake testall 2) make runhosttests Cq-Depend: chromium:3161332 Signed-off-by: Aaron Massey <aaronmassey@chromium.org> Change-Id: Ic5330cd5c33e79e192428ca857651de9a225856e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3133812 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Tested-by: Aaron Massey <aaronmassey@google.com> Commit-Queue: Aaron Massey <aaronmassey@google.com>
Diffstat (limited to 'include')
-rw-r--r--include/driver/temp_sensor/thermistor.h18
-rw-r--r--include/temp_sensor.h10
2 files changed, 27 insertions, 1 deletions
diff --git a/include/driver/temp_sensor/thermistor.h b/include/driver/temp_sensor/thermistor.h
index 7ebe2b42ac..adcd5c5be4 100644
--- a/include/driver/temp_sensor/thermistor.h
+++ b/include/driver/temp_sensor/thermistor.h
@@ -147,4 +147,20 @@ int get_temp_3v0_22k6_47k_4050b(int idx_adc, int *temp_ptr);
int get_temp_3v3_30k9_47k_4050b(int idx_adc, int *temp_ptr);
#endif
-#endif /* __CROS_EC_TEMP_SENSOR_THERMISTOR_NCP15WB_H */
+/**
+ * Reads the sensor's ADC channel and uses a lookup table and interpolation to
+ * argument thermistor_info for interpolation to return a temperature in degrees
+ * K.
+ *
+ * @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)
+ * @param info Structure containing information about the underlying thermistor
+ * that is necessary to interpolate temperature
+ *
+ * @return EC_SUCCESS, or non-zero if error.
+ */
+int thermistor_get_temperature(int idx_adc, int *temp_ptr,
+ const struct thermistor_info *info);
+
+#endif /* __CROS_EC_TEMP_SENSOR_THERMISTOR_NCP15WB_H */
diff --git a/include/temp_sensor.h b/include/temp_sensor.h
index e5eff92cf1..50a174193f 100644
--- a/include/temp_sensor.h
+++ b/include/temp_sensor.h
@@ -33,8 +33,18 @@ struct temp_sensor_t {
const char *name;
/* Temperature sensor type. */
enum temp_sensor_type type;
+ /*
+ * TODO(b:201081891) Refactor temp_sensor_t references
+ * to all use OO style sensor argument to get adc idx.
+ */
+#ifdef CONFIG_ZEPHYR
+ /* Read sensor value in K into temp_ptr; return non-zero if error. */
+ int (*read)(const struct temp_sensor_t *sensor, int *temp_ptr);
+ struct thermistor_info *thermistor;
+#else
/* Read sensor value in K into temp_ptr; return non-zero if error. */
int (*read)(int idx, int *temp_ptr);
+#endif
/* Index among the same kind of sensors. */
int idx;
};