summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-01-16 14:52:31 -0700
committerSimon Glass <sjg@chromium.org>2021-01-30 14:25:41 -0700
commit10f746591fba16a48f0e3d14641be09f01982807 (patch)
treec311e9e3063e1ca319a9952524ccbc3043c72ac3 /test
parentd9ffaef6fe25e7a29e63911fe1af5d18c9d77a45 (diff)
downloadu-boot-10f746591fba16a48f0e3d14641be09f01982807.tar.gz
u-boot-10f746591fba16a48f0e3d14641be09f01982807.tar.xz
u-boot-10f746591fba16a48f0e3d14641be09f01982807.zip
cros_ec: Add vstore support
The EC can store small amounts of data for the benefit of the verified boot process. Since the EC is seldom reset, this can allow the AP to store data that survives a reboot or a suspend/resume cycle. Add support for this. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/dm/cros_ec.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/dm/cros_ec.c b/test/dm/cros_ec.c
index 0da7548fd2..30cb70e088 100644
--- a/test/dm/cros_ec.c
+++ b/test/dm/cros_ec.c
@@ -56,6 +56,7 @@ static int dm_test_cros_ec_features(struct unit_test_state *uts)
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 |
+ 1u << EC_FEATURE_VSTORE |
1ULL << EC_FEATURE_UNIFIED_WAKE_MASKS | 1ULL << EC_FEATURE_ISH,
feat);
@@ -68,6 +69,7 @@ static int dm_test_cros_ec_features(struct unit_test_state *uts)
ut_assertok(run_command("crosec features", 0));
ut_assert_nextline("flash");
ut_assert_nextline("i2c");
+ ut_assert_nextline("vstore");
ut_assert_nextline("unified_wake_masks");
ut_assert_nextline("ish");
ut_assert_console_end();
@@ -138,3 +140,39 @@ static int dm_test_cros_ec_events(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_cros_ec_events, UT_TESTF_SCAN_FDT);
+
+static int dm_test_cros_ec_vstore(struct unit_test_state *uts)
+{
+ const int size = EC_VSTORE_SLOT_SIZE;
+ u8 test_data[size], data[size];
+ struct udevice *dev;
+ u32 locked;
+ int i;
+
+ ut_assertok(uclass_first_device_err(UCLASS_CROS_EC, &dev));
+ ut_asserteq(true, cros_ec_vstore_supported(dev));
+
+ ut_asserteq(4, cros_ec_vstore_info(dev, &locked));
+ ut_asserteq(0, locked);
+
+ /* Write some data */
+ for (i = 0; i < size; i++)
+ test_data[i] = ' ' + i;
+ ut_assertok(cros_ec_vstore_write(dev, 2, test_data, size));
+
+ /* Check it is locked */
+ ut_asserteq(4, cros_ec_vstore_info(dev, &locked));
+ ut_asserteq(1 << 2, locked);
+
+ /* Read it back and compare */
+ ut_assertok(cros_ec_vstore_read(dev, 2, data));
+ ut_asserteq_mem(test_data, data, size);
+
+ /* Try another slot to make sure it is empty */
+ ut_assertok(cros_ec_vstore_read(dev, 0, data));
+ for (i = 0; i < size; i++)
+ ut_asserteq(0, data[i]);
+
+ return 0;
+}
+DM_TEST(dm_test_cros_ec_vstore, UT_TESTF_SCAN_FDT);