summaryrefslogtreecommitdiff
path: root/zephyr/shim/src/temp_sensors.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-04-02 11:48:41 +1300
committerCommit Bot <commit-bot@chromium.org>2021-04-02 23:12:52 +0000
commit227d8ca20a7ac1cd6dd580b426998a36bdd22994 (patch)
tree95096a8f9b0ec5c1395d67dd36245424e653413e /zephyr/shim/src/temp_sensors.c
parent5e52d647e27bc0f50e3387cdc13bc28e37a6d8f3 (diff)
downloadchrome-ec-227d8ca20a7ac1cd6dd580b426998a36bdd22994.tar.gz
zephyr: Update the temperature-sensor shim
At present this shim relies partially on a hard-coded mapping, in the temp_sensors.c file. Also it uses the node IDs as enum values, which makes it difficult to actually use the enums in the code. With the ADC shim we need to be able to support using ADC enums in the code, such as ADC_PSYS. This will force a change of naming in enum adc_channel, which temperature sensors refer to. Update the shim to use an enum for the temp-sensor ID and another for the function to call to read the temperature. BUG=b:175881324 BRANCH=none TEST=build Zephyr for lazor and volteer Change-Id: I08bd45568be525650b8527830053ee541d6240cf Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2801172 Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'zephyr/shim/src/temp_sensors.c')
-rw-r--r--zephyr/shim/src/temp_sensors.c37
1 files changed, 7 insertions, 30 deletions
diff --git a/zephyr/shim/src/temp_sensors.c b/zephyr/shim/src/temp_sensors.c
index c43dfd8082..dfe259f126 100644
--- a/zephyr/shim/src/temp_sensors.c
+++ b/zephyr/shim/src/temp_sensors.c
@@ -8,39 +8,16 @@
#include "adc.h"
#include "../driver/temp_sensor/thermistor.h"
-#define TEMP_THERMISTOR(node_id, fn) \
- [node_id] = { \
- .name = DT_LABEL(node_id), \
- .read = fn, \
- .idx = DT_PHANDLE(node_id, adc), \
- .type = TEMP_SENSOR_TYPE_BOARD, \
+#define TEMP_THERMISTOR(node_id) \
+ [ZSHIM_TEMP_SENSOR_ID(node_id)] = { \
+ .name = DT_LABEL(node_id), \
+ .read = DT_ENUM_TOKEN(node_id, get_temp_func), \
+ .idx = DT_PHANDLE(node_id, adc), \
+ .type = TEMP_SENSOR_TYPE_BOARD, \
},
-#define TEMP_3V3_30K9_47K_4050B(node_id) \
- TEMP_THERMISTOR(node_id, get_temp_3v3_30k9_47k_4050b)
-
-#define TEMP_3V0_22K6_47K_4050B(node_id) \
- TEMP_THERMISTOR(node_id, get_temp_3v0_22k6_47k_4050b)
-
-#define TEMP_3V3_51K1_47K_4050B(node_id) \
- TEMP_THERMISTOR(node_id, get_temp_3v3_51k1_47k_4050b)
-
-#define TEMP_3V3_13K7_47K_4050B(node_id) \
- TEMP_THERMISTOR(node_id, get_temp_3v3_13k7_47k_4050b)
-
-#define TEMP_DEVICE_INST(inst, compat, expr) expr(DT_INST(inst, compat))
-
-#define TEMP_DEVICE(compat, expr) \
- UTIL_LISTIFY(DT_NUM_INST_STATUS_OKAY(compat), TEMP_DEVICE_INST, \
- compat, expr)
-
#if DT_NODE_EXISTS(DT_PATH(named_temp_sensors))
-
const struct temp_sensor_t temp_sensors[] = {
- TEMP_DEVICE(temp_3v3_13k7_47k_4050b, TEMP_3V3_13K7_47K_4050B)
- TEMP_DEVICE(temp_3v3_51k1_47k_4050b, TEMP_3V3_51K1_47K_4050B)
- TEMP_DEVICE(temp_3v0_22k6_47k_4050b, TEMP_3V0_22K6_47K_4050B)
- TEMP_DEVICE(temp_3v3_30k9_47k_4050b, TEMP_3V3_30K9_47K_4050B)
+ DT_FOREACH_CHILD(DT_PATH(named_temp_sensors), TEMP_THERMISTOR)
};
-
#endif /* named_temp_sensors */