diff options
-rw-r--r-- | zephyr/dts/bindings/temp/cros_ec_temp_sensor_sb_tsi.yaml | 16 | ||||
-rw-r--r-- | zephyr/shim/src/temp_sensors.c | 23 |
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 */ |