summaryrefslogtreecommitdiff
path: root/common/temp_sensor.c
diff options
context:
space:
mode:
authorDawid Niedzwiecki <dn@semihalf.com>2021-02-05 13:04:18 +0100
committerCommit Bot <commit-bot@chromium.org>2021-02-17 06:49:23 +0000
commitfe93af445598a7d42615ce8a0e7c9d8d0f862ac1 (patch)
tree1bdc7d740b6afaa190dfc2fe8b58f7e7d04d7cd6 /common/temp_sensor.c
parent2adcac085e240c00d4b32ba11404e98be36f1ee9 (diff)
downloadchrome-ec-fe93af445598a7d42615ce8a0e7c9d8d0f862ac1.tar.gz
zephyr: add shim temperature sensors
Add temperature sensors shim. Use platform/ec the temperature sensors drivers. Generate needed global variables/types: enum temp_sensor_id and temp_sensors from dts. Each temperature sensor type has its own compatible property to assign a correct read function in the temp_sensor_t temp_sensors[] array. Themrmisors has also adc property to point an ADC channel connected to the sensor. Enable "temps" console command and EC_CMD_TEMP_SENSOR_GET_INFO host command. BUG=b:174851465 BRANCH=none TEST=build Zephyr TEST=Run "temps" command, it should return the current temperature measurements Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: Ie680ec0771ea3da598066eb98db80944a93daca5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2687218 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common/temp_sensor.c')
-rw-r--r--common/temp_sensor.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/common/temp_sensor.c b/common/temp_sensor.c
index 5428b84949..8c72f1535c 100644
--- a/common/temp_sensor.c
+++ b/common/temp_sensor.c
@@ -15,6 +15,10 @@
#include "timer.h"
#include "util.h"
+#ifdef CONFIG_ZEPHYR
+#include "temp_sensor/temp_sensor.h"
+#endif
+
int temp_sensor_read(enum temp_sensor_id id, int *temp_ptr)
{
const struct temp_sensor_t *sensor;
@@ -113,6 +117,8 @@ int console_command_temps(int argc, char **argv)
case EC_SUCCESS:
ccprintf("%d K = %d C", t, K_TO_C(t));
#ifdef CONFIG_THROTTLE_AP
+#ifndef CONFIG_ZEPHYR
+/* TODO(b/179886912): Add thermal support */
if (thermal_params[i].temp_fan_off &&
thermal_params[i].temp_fan_max)
ccprintf(" %d%%",
@@ -120,6 +126,7 @@ int console_command_temps(int argc, char **argv)
thermal_params[i].temp_fan_off,
thermal_params[i].temp_fan_max,
t));
+#endif /* CONFIG_ZEPHYR */
#endif
ccprintf("\n");
break;