diff options
author | Aseda Aboagye <aaboagye@google.com> | 2021-07-22 16:41:59 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-07-29 20:36:11 +0000 |
commit | dd9b5de765fd683a2e25cbfe83925d71fe524be2 (patch) | |
tree | a7967998b1d539c49256008a4eafa9f9777740c0 /test | |
parent | 5e07ac82ecf51aff07a8def8a4bae1330c426b22 (diff) | |
download | chrome-ec-dd9b5de765fd683a2e25cbfe83925d71fe524be2.tar.gz |
cbi: Add CONFIG_EEPROM_CBI_WP
This commit adds the config option, CONFIG_EEPROM_CBI_WP. It is to be
defined when the EC directly controls the CBI EEPROM WP signal. The EC
will set the WP according to the result of `system_is_locked()`. Note
that once the WP is set, the EC must be reset via EC_RST_ODL in order
for the WP to become unset. This is enabled by the accompanying
hardware.
BUG=b:181769483
BRANCH=None
TEST=`make -j buildall`
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Change-Id: If490594ab4dd24af98119b01299215b997913b66
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3046412
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Auto-Submit: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/build.mk | 2 | ||||
-rw-r--r-- | test/cbi_wp.c | 56 | ||||
-rw-r--r-- | test/cbi_wp.tasklist | 9 | ||||
-rw-r--r-- | test/test_config.h | 4 |
4 files changed, 71 insertions, 0 deletions
diff --git a/test/build.mk b/test/build.mk index 6b156ccaf0..ec9e66ead3 100644 --- a/test/build.mk +++ b/test/build.mk @@ -20,6 +20,7 @@ test-list-host += bklight_passthru test-list-host += body_detection test-list-host += button test-list-host += cbi +test-list-host += cbi_wp test-list-host += cec test-list-host += charge_manager test-list-host += charge_manager_drp_charging @@ -132,6 +133,7 @@ bklight_passthru-y=bklight_passthru.o body_detection-y=body_detection.o body_detection_data_literals.o motion_common.o button-y=button.o cbi-y=cbi.o +cbi_wp-y=cbi_wp.o cec-y=cec.o charge_manager-y=charge_manager.o charge_manager_drp_charging-y=charge_manager.o diff --git a/test/cbi_wp.c b/test/cbi_wp.c new file mode 100644 index 0000000000..7bdfa4b0c8 --- /dev/null +++ b/test/cbi_wp.c @@ -0,0 +1,56 @@ +/* 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. + * + * Test CBI EEPROM WP + */ + +#include "common.h" +#include "console.h" +#include "cros_board_info.h" +#include "gpio.h" +#include "system.h" +#include "test_util.h" +#include "util.h" + +static int system_locked; + +static void test_setup(void) +{ + /* Make sure that write protect is disabled */ + gpio_set_level(GPIO_WP, 0); + gpio_set_level(GPIO_EC_CBI_WP, 0); + system_locked = 0; +} + +static void test_teardown(void) +{ +} + +int system_is_locked(void) +{ + return system_locked; +} + +DECLARE_EC_TEST(test_wp) +{ + int cbi_wp; + + cbi_wp = gpio_get_level(GPIO_EC_CBI_WP); + zassert_equal(cbi_wp, 0, NULL); + + cbi_latch_eeprom_wp(); + cbi_wp = gpio_get_level(GPIO_EC_CBI_WP); + zassert_equal(cbi_wp, 1, NULL); + + return EC_SUCCESS; +} + +TEST_SUITE(test_suite_cbi_wp) +{ + ztest_test_suite(test_cbi_wp, + ztest_unit_test_setup_teardown(test_wp, + test_setup, + test_teardown)); + ztest_run_test_suite(test_cbi_wp); +} diff --git a/test/cbi_wp.tasklist b/test/cbi_wp.tasklist new file mode 100644 index 0000000000..e54ea001bd --- /dev/null +++ b/test/cbi_wp.tasklist @@ -0,0 +1,9 @@ +/* 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. + */ + +/** + * See CONFIG_TASK_LIST in config.h for details. + */ +#define CONFIG_TEST_TASK_LIST /* No test task */ diff --git a/test/test_config.h b/test/test_config.h index 8b98dc1087..5afc5d1282 100644 --- a/test/test_config.h +++ b/test/test_config.h @@ -40,6 +40,10 @@ #define CONFIG_BACKLIGHT_REQ_GPIO GPIO_PCH_BKLTEN #endif +#ifdef TEST_CBI_WP +#define CONFIG_EEPROM_CBI_WP +#endif + #ifdef TEST_FLASH_LOG #define CONFIG_CRC8 #define CONFIG_FLASH_ERASED_VALUE32 (-1U) |