summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Chao <scott_chao@wistron.corp-partner.google.com>2022-09-28 09:52:57 +0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-10-07 03:38:21 +0000
commit6d8bb5bebea72249b1744d12104277a71b6882dd (patch)
tree045b1c923b4ecca7c8274f5b437cb4249738ba16
parent88dd1318c379cd76e7e703541d969abeabdf9f9d (diff)
downloadchrome-ec-6d8bb5bebea72249b1744d12104277a71b6882dd.tar.gz
TCPMv2: Add bist share mode console command
This CL enable bist share mode control by ec console. BUG=b:242957100 BRANCH=none TEST=pd bistsharemode [disable|enable] TEST=./twister -v -T zephyr/test TEST=make run-usb_pd_console TEST=make buildall TEST=make test-coverage Change-Id: I3aaaf91eaa1321d57fd773bba18d126ead29f944 Signed-off-by: Scott Chao <scott_chao@wistron.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3924556 Reviewed-by: Diana Z <dzigterman@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
-rw-r--r--common/usbc/usb_pd_console.c11
-rw-r--r--test/usb_pd_console.c33
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c16
3 files changed, 60 insertions, 0 deletions
diff --git a/common/usbc/usb_pd_console.c b/common/usbc/usb_pd_console.c
index 027a0d66c5..89a5492ad5 100644
--- a/common/usbc/usb_pd_console.c
+++ b/common/usbc/usb_pd_console.c
@@ -6,6 +6,7 @@
#include "common.h"
#include "console.h"
#include "usb_common.h"
+#include "usb_pd_dpm.h"
#include "usb_pd_timer.h"
#include "usb_pe_sm.h"
#include "usb_prl_sm.h"
@@ -21,6 +22,7 @@ static
{
int port;
char *e;
+ int rv = EC_SUCCESS;
if (argc < 2)
return EC_ERROR_PARAM_COUNT;
@@ -63,6 +65,14 @@ static
} else if (!strcasecmp(argv[1], "version")) {
ccprintf("%d\n", PD_STACK_VERSION);
return EC_SUCCESS;
+ } else if (!strcasecmp(argv[1], "bistsharemode")) {
+ if (!strcasecmp(argv[2], "disable"))
+ rv = pd_set_bist_share_mode(0);
+ else if (!strcasecmp(argv[2], "enable"))
+ rv = pd_set_bist_share_mode(1);
+ else
+ rv = EC_ERROR_PARAM2;
+ return rv;
}
/* command: pd <port> <subcmd> [args] */
@@ -208,6 +218,7 @@ DECLARE_CONSOLE_COMMAND(pd, command_pd,
#ifdef CONFIG_USB_PD_TRY_SRC
"\ntrysrc [0|1|2]"
#endif
+ "\nbistsharemode [disable|enable]"
"\n\t<port> state"
"\n\t<port> srccaps"
"\n\t<port> cc"
diff --git a/test/usb_pd_console.c b/test/usb_pd_console.c
index 711664aeb0..cb2539fea4 100644
--- a/test/usb_pd_console.c
+++ b/test/usb_pd_console.c
@@ -43,6 +43,7 @@ static enum pd_dpm_request request;
static int max_volt;
static int comm_enable;
static int pd_suspended;
+static int pd_bistsharemode;
static int dev_info;
static int vdm_cmd;
static int vdm_count;
@@ -186,6 +187,12 @@ void pd_set_suspend(int port, int enable)
pd_suspended = enable;
}
+enum ec_status pd_set_bist_share_mode(uint8_t enable)
+{
+ pd_bistsharemode = enable;
+ return EC_RES_SUCCESS;
+}
+
void tc_print_dev_info(int port)
{
test_port = port;
@@ -310,6 +317,30 @@ static int test_command_pd_version(void)
return EC_SUCCESS;
}
+static int test_command_pd_bistsharemode_enable(void)
+{
+ int argc = 3;
+ static const char *argv[10] = { "pd", "bistsharemode", "enable" };
+
+ pd_bistsharemode = -1;
+ TEST_ASSERT(command_pd(argc, argv) == EC_SUCCESS);
+ TEST_ASSERT(pd_bistsharemode == 1);
+
+ return EC_SUCCESS;
+}
+
+static int test_command_pd_bistsharemode_disable(void)
+{
+ int argc = 3;
+ static const char *argv[10] = { "pd", "bistsharemode", "disable" };
+
+ pd_bistsharemode = -1;
+ TEST_ASSERT(command_pd(argc, argv) == EC_SUCCESS);
+ TEST_ASSERT(pd_bistsharemode == 0);
+
+ return EC_SUCCESS;
+}
+
static int test_command_pd_arg_count(void)
{
int argc;
@@ -679,6 +710,8 @@ void run_test(int argc, const char **argv)
RUN_TEST(test_command_pd_soft);
RUN_TEST(test_command_pd_suspend);
RUN_TEST(test_command_pd_resume);
+ RUN_TEST(test_command_pd_bistsharemode_enable);
+ RUN_TEST(test_command_pd_bistsharemode_disable);
RUN_TEST(test_command_pd_swap1);
RUN_TEST(test_command_pd_swap2);
RUN_TEST(test_command_pd_swap3);
diff --git a/zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c b/zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c
index 21056056d4..d521f7bb06 100644
--- a/zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c
+++ b/zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c
@@ -10,6 +10,8 @@
#include "ec_commands.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include "usb_pd.h"
+#include "usb_pd_dpm.h"
#include "usb_prl_sm.h"
static void console_cmd_usb_pd_after(void *fixture)
@@ -25,6 +27,7 @@ static void console_cmd_usb_pd_after(void *fixture)
/* Keep port used by testsuite enabled (default state) */
pd_comm_enable(0, 1);
pd_set_suspend(0, 0);
+ pd_set_bist_share_mode(0);
}
ZTEST_SUITE(console_cmd_usb_pd, drivers_predicate_post_main, NULL, NULL,
@@ -174,6 +177,19 @@ ZTEST_USER(console_cmd_usb_pd, test_resume)
rv);
}
+ZTEST_USER(console_cmd_usb_pd, test_bistsharemode)
+{
+ int rv;
+
+ rv = shell_execute_cmd(get_ec_shell(), "pd bistsharemode enable");
+ zassert_equal(rv, EC_SUCCESS, "Expected %d, but got %d", EC_SUCCESS,
+ rv);
+
+ rv = shell_execute_cmd(get_ec_shell(), "pd bistsharemode disable");
+ zassert_equal(rv, EC_SUCCESS, "Expected %d, but got %d", EC_SUCCESS,
+ rv);
+}
+
ZTEST_USER(console_cmd_usb_pd, test_hard)
{
int rv;