summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJett Rink <jettrink@chromium.org>2019-11-01 16:14:12 -0600
committerCommit Bot <commit-bot@chromium.org>2019-11-07 23:54:57 +0000
commitcf54e8664faaed51f4d622f84d6475f90f53e06e (patch)
tree3e3479ce204bf2147c78c573c596b47d0437c166 /test
parentb3cb8a6f818f425bfe11b817d7b873dd36d239a8 (diff)
downloadchrome-ec-cf54e8664faaed51f4d622f84d6475f90f53e06e.tar.gz
usbc: fix vbus discharge path for GPIO
Code on Tot assumes that port count was the port to discharge instead of port parameter BRANCH=none BUG=none TEST=verified with unit test (in this CL) Change-Id: I17658a0c555f9cea56fa4ec1652e0faf62e3d6cc Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1896125
Diffstat (limited to 'test')
-rw-r--r--test/test_config.h1
-rw-r--r--test/usb_pe_drp.c17
2 files changed, 18 insertions, 0 deletions
diff --git a/test/test_config.h b/test/test_config.h
index 8a947d1717..045f399803 100644
--- a/test/test_config.h
+++ b/test/test_config.h
@@ -295,6 +295,7 @@ int ncp15wb_calculate_temp(uint16_t adc);
#undef CONFIG_USB_TYPEC_SM
#define CONFIG_USBC_VCONN
#define PD_VCONN_SWAP_DELAY 5000 /* us */
+#define CONFIG_USB_PD_DISCHARGE_GPIO
#endif
/* Common TypeC tests defines */
diff --git a/test/usb_pe_drp.c b/test/usb_pe_drp.c
index b2457a8298..c6a1dc0af7 100644
--- a/test/usb_pe_drp.c
+++ b/test/usb_pe_drp.c
@@ -25,6 +25,11 @@ const struct svdm_response svdm_rsp = {
.modes = NULL,
};
+int board_vbus_source_enabled(int port)
+{
+ return 0;
+}
+
/**
* Test section
*/
@@ -120,11 +125,23 @@ static int test_pe_frs(void)
return EC_SUCCESS;
}
+static int test_vbus_gpio_discharge(void)
+{
+ pd_set_vbus_discharge(PORT0, 1);
+ TEST_EQ(gpio_get_level(GPIO_USB_C0_DISCHARGE), 1, "%d");
+
+ pd_set_vbus_discharge(PORT0, 0);
+ TEST_EQ(gpio_get_level(GPIO_USB_C0_DISCHARGE), 0, "%d");
+
+ return EC_SUCCESS;
+}
+
void run_test(void)
{
test_reset();
RUN_TEST(test_pe_frs);
+ RUN_TEST(test_vbus_gpio_discharge);
/* Do basic state machine sanity checks last. */
RUN_TEST(test_pe_no_parent_cycles);