summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2021-12-15 15:49:26 -0700
committerCommit Bot <commit-bot@chromium.org>2022-01-18 17:12:09 +0000
commitbf6bf06464b48394a3620fff1a80acf85f2fa060 (patch)
tree8a2e99cb09f19b0264439fb60e7c986f0f5aa990
parentea90295b26c12bc74b75e649caf05f9db988610c (diff)
downloadchrome-ec-bf6bf06464b48394a3620fff1a80acf85f2fa060.tar.gz
Zephyr: Add SB TSI devicetree support
Add support for the SB TSI temperature sensor in devicetree. Note that only one SB TSI sensor can exist on a board, and the driver is written to have one and only one sensor. BRANCH=None BUG=b:195137794 TEST=zmake testall, add second SB-TSI to guybrush and ensure an error is thrown Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I6c09e08a12eabd0910c3f5270393a0d8d4a4b219 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3384486 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
-rw-r--r--zephyr/dts/bindings/temp/cros_ec_temp_sensor_sb_tsi.yaml16
-rw-r--r--zephyr/shim/src/temp_sensors.c23
2 files changed, 39 insertions, 0 deletions
diff --git a/zephyr/dts/bindings/temp/cros_ec_temp_sensor_sb_tsi.yaml b/zephyr/dts/bindings/temp/cros_ec_temp_sensor_sb_tsi.yaml
new file mode 100644
index 0000000000..a0772281cb
--- /dev/null
+++ b/zephyr/dts/bindings/temp/cros_ec_temp_sensor_sb_tsi.yaml
@@ -0,0 +1,16 @@
+# 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.
+
+description: >
+ Properties for an Side Band Temperature Sensor Interface sensor
+
+include: cros_ec_temp_sensor.yaml
+
+compatible: cros-ec,temp-sensor-sb-tsi
+
+properties:
+ port:
+ required: true
+ type: phandle
+ description: phandle to the sensor's i2c port
diff --git a/zephyr/shim/src/temp_sensors.c b/zephyr/shim/src/temp_sensors.c
index a8533202fa..0249988bd3 100644
--- a/zephyr/shim/src/temp_sensors.c
+++ b/zephyr/shim/src/temp_sensors.c
@@ -5,6 +5,7 @@
#include "adc.h"
#include "temp_sensor.h"
+#include "temp_sensor/sb_tsi.h"
#include "temp_sensor/temp_sensor.h"
#include "temp_sensor/thermistor.h"
#include "temp_sensor/tmp112.h"
@@ -47,6 +48,27 @@ static int thermistor_get_temp(const struct temp_sensor_t *sensor,
DT_FOREACH_STATUS_OKAY(cros_ec_thermistor, DEFINE_THERMISTOR_DATA)
+#if DT_HAS_COMPAT_STATUS_OKAY(cros_ec_temp_sensor_sb_tsi)
+static int sb_tsi_get_temp(const struct temp_sensor_t *sensor, int *temp_ptr)
+{
+ return sb_tsi_get_val(sensor->idx, temp_ptr);
+}
+
+/* There can be only one SB TSI sensor with current driver */
+#if DT_NUM_INST_STATUS_OKAY(cros_ec_temp_sensor_sb_tsi) > 1
+#error "Unsupported number of SB TSI sensors"
+#endif
+
+#endif /* cros_ec_temp_sensor_sb_tsi */
+
+#define TEMP_SB_TSI(node_id) \
+ [ZSHIM_TEMP_SENSOR_ID(node_id)] = { \
+ .name = DT_LABEL(node_id), \
+ .read = sb_tsi_get_temp, \
+ .idx = 0, \
+ .type = TEMP_SENSOR_TYPE_CPU, \
+ },
+
#if DT_HAS_COMPAT_STATUS_OKAY(cros_ec_temp_sensor_tmp112)
static int tmp112_get_temp(const struct temp_sensor_t *sensor, int *temp_ptr)
{
@@ -74,6 +96,7 @@ const struct tmp112_sensor_t tmp112_sensors[TMP112_COUNT] = {
const struct temp_sensor_t temp_sensors[] = {
DT_FOREACH_STATUS_OKAY(cros_ec_temp_sensor_thermistor, TEMP_THERMISTOR)
+ DT_FOREACH_STATUS_OKAY(cros_ec_temp_sensor_sb_tsi, TEMP_SB_TSI)
DT_FOREACH_STATUS_OKAY(cros_ec_temp_sensor_tmp112, TEMP_TMP112)
};
#endif /* named_temp_sensors */