summaryrefslogtreecommitdiff
path: root/test/dm/cros_ec.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-01-16 14:52:26 -0700
committerSimon Glass <sjg@chromium.org>2021-01-30 14:25:41 -0700
commit8aec32f6abd722b141d96bc095999efa76bd0327 (patch)
tree127ce4a016602e527aded6c3ceb97c8121c34c78 /test/dm/cros_ec.c
parent7791df576c4e0bcb0529850e14173d028ec37275 (diff)
downloadu-boot-8aec32f6abd722b141d96bc095999efa76bd0327.tar.gz
u-boot-8aec32f6abd722b141d96bc095999efa76bd0327.tar.bz2
u-boot-8aec32f6abd722b141d96bc095999efa76bd0327.zip
cros_ec: Support reading EC features
The EC can support a variety of features and provides a way to find out what is available. Add support for this. Also update the feature list to the lastest available while we are here. This is at: https://chromium.googlesource.com/chromiumos/platform/ec/+/refs/heads/master/include/ec_commands.h Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test/dm/cros_ec.c')
-rw-r--r--test/dm/cros_ec.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/dm/cros_ec.c b/test/dm/cros_ec.c
index 3d0e5dc08d..a1ec9fccf3 100644
--- a/test/dm/cros_ec.c
+++ b/test/dm/cros_ec.c
@@ -47,3 +47,31 @@ static int dm_test_cros_ec_sku_id(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_cros_ec_sku_id, UT_TESTF_SCAN_FDT);
+
+static int dm_test_cros_ec_features(struct unit_test_state *uts)
+{
+ struct udevice *dev;
+ u64 feat;
+
+ ut_assertok(uclass_first_device_err(UCLASS_CROS_EC, &dev));
+ ut_assertok(cros_ec_get_features(dev, &feat));
+ ut_asserteq_64(1U << EC_FEATURE_FLASH | 1U << EC_FEATURE_I2C |
+ 1ULL << EC_FEATURE_UNIFIED_WAKE_MASKS | 1ULL << EC_FEATURE_ISH,
+ feat);
+
+ ut_asserteq(true, cros_ec_check_feature(dev, EC_FEATURE_I2C));
+ ut_asserteq(false, cros_ec_check_feature(dev, EC_FEATURE_MOTION_SENSE));
+ ut_asserteq(true, cros_ec_check_feature(dev, EC_FEATURE_ISH));
+
+ /* try the command */
+ console_record_reset();
+ ut_assertok(run_command("crosec features", 0));
+ ut_assert_nextline("flash");
+ ut_assert_nextline("i2c");
+ ut_assert_nextline("unified_wake_masks");
+ ut_assert_nextline("ish");
+ ut_assert_console_end();
+
+ return 0;
+}
+DM_TEST(dm_test_cros_ec_features, UT_TESTF_SCAN_FDT);