summaryrefslogtreecommitdiff
path: root/zephyr/shim/src
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2021-09-07 09:30:22 -0600
committerCommit Bot <commit-bot@chromium.org>2021-09-07 17:32:58 +0000
commitf8cbf77dc5dc10b21d3baa50e7bb3ec3c280380f (patch)
tree1c8289d90d2aedcbd620746d44102acd383404f0 /zephyr/shim/src
parentc96175bef0c7985f55e0fc82c89d79d5b1adf2f5 (diff)
downloadchrome-ec-f8cbf77dc5dc10b21d3baa50e7bb3ec3c280380f.tar.gz
zephyr: Replace DT_ENUM_TOKEN with DT_STRING_TOKEN
In Zephyr v2.7, DT_ENUM_TOKEN is deprecated in favor of DT_STRING_TOKEN. Additionally, DT_ENUM_UPPER_TOKEN is deprecated in favor of DT_STRING_UPPER_TOKEN. See the v2.7 release notes for details: https://docs.zephyrproject.org/latest/releases/release-notes-2.7.html Since we backported the DT_STRING_* macros to our v2.6 branch, let's switch to them ahead of time to prepare for the v2.7 uprev. Note: the DT_STRING_* macros are compatible with Zephyr's device tree enums, but also allow non-enum properties to be used in the same fashion. This commit does the bare minimum for compatibility with v2.7, i.e., just swap the macros without dropping enum properties anywhere. We should investigate whether we want to continue using the enum properties or abandon some of them for any string in the future. BUG=b:198824039 BRANCH=none TEST=zmake testall Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I1efd8f99bc7d93504c0ab94510406cd36ad24cd3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3144536 Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'zephyr/shim/src')
-rw-r--r--zephyr/shim/src/adc.c28
-rw-r--r--zephyr/shim/src/battery.c2
-rw-r--r--zephyr/shim/src/gpio_id.c12
-rw-r--r--zephyr/shim/src/i2c.c2
-rw-r--r--zephyr/shim/src/motionsense_sensors.c12
-rw-r--r--zephyr/shim/src/switchcap_ln9310.c6
-rw-r--r--zephyr/shim/src/temp_sensors.c12
7 files changed, 35 insertions, 39 deletions
diff --git a/zephyr/shim/src/adc.c b/zephyr/shim/src/adc.c
index c8b90b0211..4f66774466 100644
--- a/zephyr/shim/src/adc.c
+++ b/zephyr/shim/src/adc.c
@@ -16,20 +16,20 @@ const struct device *adc_dev;
#define HAS_NAMED_ADC_CHANNELS DT_NODE_EXISTS(DT_INST(0, named_adc_channels))
#if HAS_NAMED_ADC_CHANNELS
-#define ADC_CHANNEL_COMMA(node_id) \
- [ZSHIM_ADC_ID(node_id)] = { \
- .name = DT_LABEL(node_id), \
- .input_ch = DT_PROP(node_id, channel), \
- .factor_mul = DT_PROP(node_id, mul), \
- .factor_div = DT_PROP(node_id, div), \
- .channel_cfg = { \
- .channel_id = DT_PROP(node_id, channel), \
- .gain = DT_ENUM_TOKEN(node_id, gain), \
- .reference = DT_ENUM_TOKEN(node_id, reference), \
- .acquisition_time = \
- DT_PROP(node_id, acquisition_time), \
- .differential = DT_PROP(node_id, differential), \
- }, \
+#define ADC_CHANNEL_COMMA(node_id) \
+ [ZSHIM_ADC_ID(node_id)] = { \
+ .name = DT_LABEL(node_id), \
+ .input_ch = DT_PROP(node_id, channel), \
+ .factor_mul = DT_PROP(node_id, mul), \
+ .factor_div = DT_PROP(node_id, div), \
+ .channel_cfg = { \
+ .channel_id = DT_PROP(node_id, channel), \
+ .gain = DT_STRING_TOKEN(node_id, gain), \
+ .reference = DT_STRING_TOKEN(node_id, reference), \
+ .acquisition_time = \
+ DT_PROP(node_id, acquisition_time), \
+ .differential = DT_PROP(node_id, differential), \
+ }, \
},
#ifdef CONFIG_ADC_CHANNELS_RUNTIME_CONFIG
struct adc_t adc_channels[] = { DT_FOREACH_CHILD(
diff --git a/zephyr/shim/src/battery.c b/zephyr/shim/src/battery.c
index bd4af10f03..6c4f211eda 100644
--- a/zephyr/shim/src/battery.c
+++ b/zephyr/shim/src/battery.c
@@ -32,7 +32,7 @@
}, \
COND_CODE_1(UTIL_AND(IS_ENABLED(CONFIG_BATTERY_MEASURE_IMBALANCE), \
DT_NODE_HAS_PROP(node, imbalance_mv)), \
- (.imbalance_mv = DT_ENUM_TOKEN(node, imbalance_mv),), ()) \
+ (.imbalance_mv = DT_STRING_TOKEN(node, imbalance_mv),), ()) \
},
#define NODE_BATT_INFO(node) \
diff --git a/zephyr/shim/src/gpio_id.c b/zephyr/shim/src/gpio_id.c
index f07ea8bd22..1dddac2c88 100644
--- a/zephyr/shim/src/gpio_id.c
+++ b/zephyr/shim/src/gpio_id.c
@@ -36,10 +36,9 @@ __override uint32_t board_get_sku_id(void)
if (sizeof(bits) == 0)
return (uint32_t)-1;
- sku_id = CONVERT_NUMERAL_SYSTEM(
- DT_ENUM_TOKEN(DT_PATH(sku), system),
- bits,
- ARRAY_SIZE(bits));
+ sku_id = CONVERT_NUMERAL_SYSTEM(DT_STRING_TOKEN(DT_PATH(sku),
+ system),
+ bits, ARRAY_SIZE(bits));
}
return sku_id;
@@ -64,9 +63,8 @@ __override int board_get_version(void)
return -1;
board_version = CONVERT_NUMERAL_SYSTEM(
- DT_ENUM_TOKEN(DT_PATH(board), system),
- bits,
- ARRAY_SIZE(bits));
+ DT_STRING_TOKEN(DT_PATH(board), system), bits,
+ ARRAY_SIZE(bits));
}
return board_version;
diff --git a/zephyr/shim/src/i2c.c b/zephyr/shim/src/i2c.c
index ae82db1a0a..afb102be2a 100644
--- a/zephyr/shim/src/i2c.c
+++ b/zephyr/shim/src/i2c.c
@@ -22,7 +22,7 @@
i2c_physical_ports[I2C_PORT(id)] = DT_PROP_OR(id, physical_port, -1);
#define I2C_CONFIG_GPIO(id, type) \
- DT_ENUM_UPPER_TOKEN(DT_CHILD(DT_CHILD(id, config), type), enum_name)
+ DT_STRING_UPPER_TOKEN(DT_CHILD(DT_CHILD(id, config), type), enum_name)
#define I2C_PORT_INIT(id) \
{ \
diff --git a/zephyr/shim/src/motionsense_sensors.c b/zephyr/shim/src/motionsense_sensors.c
index a7df4dbe5c..0c54160e2e 100644
--- a/zephyr/shim/src/motionsense_sensors.c
+++ b/zephyr/shim/src/motionsense_sensors.c
@@ -132,9 +132,10 @@ DT_FOREACH_CHILD(SENSOR_ROT_REF_NODE, DECLARE_SENSOR_ROT_REF)
* Get I2C or SPI address.
* See motionsense-sensor-base.yaml for DT example and details.
*/
-#define SENSOR_I2C_SPI_ADDR_FLAGS(id) \
- IF_ENABLED(DT_NODE_HAS_PROP(id, i2c_spi_addr_flags), \
- (.i2c_spi_addr_flags = DT_ENUM_TOKEN(id, i2c_spi_addr_flags),))
+#define SENSOR_I2C_SPI_ADDR_FLAGS(id) \
+ IF_ENABLED(DT_NODE_HAS_PROP(id, i2c_spi_addr_flags), \
+ (.i2c_spi_addr_flags = \
+ DT_STRING_TOKEN(id, i2c_spi_addr_flags), ))
/*
* Get the address of rotation matrix which is referred by phandle.
@@ -187,8 +188,8 @@ DT_FOREACH_CHILD(SENSOR_ROT_REF_NODE, DECLARE_SENSOR_ROT_REF)
/* Get and assign the basic information for a motion sensor */
#define SENSOR_BASIC_INFO(id) \
.name = DT_LABEL(id), \
- .active_mask = DT_ENUM_TOKEN(id, active_mask), \
- .location = DT_ENUM_TOKEN(id, location), \
+ .active_mask = DT_STRING_TOKEN(id, active_mask), \
+ .location = DT_STRING_TOKEN(id, location), \
.default_range = DT_PROP(id, default_range), \
SENSOR_I2C_SPI_ADDR_FLAGS(id) \
SENSOR_MUTEX(id) \
@@ -197,7 +198,6 @@ DT_FOREACH_CHILD(SENSOR_ROT_REF_NODE, DECLARE_SENSOR_ROT_REF)
SENSOR_DRV_DATA(id) \
SENSOR_CONFIG(id)
-
/* Create motion sensor node with node ID */
#define DO_MK_SENSOR_ENTRY( \
id, s_chip, s_type, s_drv, s_min_freq, s_max_freq) \
diff --git a/zephyr/shim/src/switchcap_ln9310.c b/zephyr/shim/src/switchcap_ln9310.c
index 997ed8d15f..0647c2d9ae 100644
--- a/zephyr/shim/src/switchcap_ln9310.c
+++ b/zephyr/shim/src/switchcap_ln9310.c
@@ -21,11 +21,9 @@
#define SC_PORT_PHANDLE \
DT_PHANDLE(DT_PATH(switchcap), port)
-#define SC_PORT \
- DT_ENUM_UPPER_TOKEN(SC_PORT_PHANDLE, enum_name)
+#define SC_PORT DT_STRING_UPPER_TOKEN(SC_PORT_PHANDLE, enum_name)
-#define SC_ADDR_FLAGS \
- DT_ENUM_UPPER_TOKEN(DT_PATH(switchcap), addr_flags)
+#define SC_ADDR_FLAGS DT_STRING_UPPER_TOKEN(DT_PATH(switchcap), addr_flags)
void board_set_switchcap_power(int enable)
{
diff --git a/zephyr/shim/src/temp_sensors.c b/zephyr/shim/src/temp_sensors.c
index 384a86d706..2544169ba3 100644
--- a/zephyr/shim/src/temp_sensors.c
+++ b/zephyr/shim/src/temp_sensors.c
@@ -8,12 +8,12 @@
#include "adc.h"
#include "temp_sensor/thermistor.h"
-#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 = ZSHIM_ADC_ID(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_STRING_TOKEN(node_id, get_temp_func), \
+ .idx = ZSHIM_ADC_ID(DT_PHANDLE(node_id, adc)), \
+ .type = TEMP_SENSOR_TYPE_BOARD, \
},
#if DT_NODE_EXISTS(DT_PATH(named_temp_sensors))