From b073dba72adb9642fd3ec874ddb49fcb071afbfa Mon Sep 17 00:00:00 2001 From: Jagadish Krishnamoorthy Date: Tue, 13 Mar 2018 12:01:04 -0700 Subject: [PATCH] Eve: Enable usb device mode For the dual data role, when the state is UFP assert the otg pins to activate the usb device controller. This will enable usb gadget mode and the board will act as usb device instead of host. For DFP state, de-assert the otg pins to activate the host mode. BUG=b:74339386 BRANCH=NONE TEST=Connect two Eve boards with the usb type c cable. On ec console, type the command usb pd 0 swap data. pd 0 state should return UFP mode. Verify that the otg pins are high (USB2_OTG_ID and USB2_OTG_VBUSSENSE). Change-Id: I0efb08ae3946ff09ce9dfeb89cff049e551fe000 Signed-off-by: Jagadish Krishnamoorthy Reviewed-on: https://chromium-review.googlesource.com/961381 Reviewed-by: Divya S Sasidharan Reviewed-by: Duncan Laurie --- board/eve/board.h | 1 - board/eve/gpio.inc | 2 +- board/eve/usb_pd_policy.c | 5 ++++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/board/eve/board.h b/board/eve/board.h index e277aa92a2..faa3ee3c1b 100644 --- a/board/eve/board.h +++ b/board/eve/board.h @@ -171,7 +171,6 @@ #define CONFIG_USB_PD_TRY_SRC_MIN_BATT_SOC 2 #define CONFIG_USB_POWER_DELIVERY #define CONFIG_USBC_SS_MUX -#define CONFIG_USBC_SS_MUX_DFP_ONLY #define CONFIG_USBC_VCONN #define CONFIG_USBC_VCONN_SWAP diff --git a/board/eve/gpio.inc b/board/eve/gpio.inc index fe10d3cdee..f9b0c3cfc4 100644 --- a/board/eve/gpio.inc +++ b/board/eve/gpio.inc @@ -84,7 +84,7 @@ GPIO(USB_C0_DP_HPD, PIN(9, 4), GPIO_INPUT) /* C0 DP Hotplug Detect */ GPIO(USB_C1_DP_HPD, PIN(A, 5), GPIO_INPUT) /* C1 DP Hotplug Detect */ GPIO(USB_C0_TCPC_PWR, PIN(8, 4), GPIO_OUT_LOW) /* Enable C0 TCPC Power */ GPIO(USB_C1_TCPC_PWR, PIN(0, 0), GPIO_OUT_LOW) /* Enable C1 TCPC Power */ -GPIO(USB2_OTG_ID, PIN(A, 1), GPIO_ODR_LOW) /* OTG ID */ +GPIO(USB2_OTG_ID, PIN(A, 1), GPIO_OUT_LOW) /* OTG ID */ GPIO(USB2_OTG_VBUSSENSE, PIN(9, 5), GPIO_OUT_LOW) /* OTG VBUS Sense */ /* Board ID */ diff --git a/board/eve/usb_pd_policy.c b/board/eve/usb_pd_policy.c index 1d5540aac1..8dc3de611d 100644 --- a/board/eve/usb_pd_policy.c +++ b/board/eve/usb_pd_policy.c @@ -191,7 +191,10 @@ int pd_check_vconn_swap(int port) void pd_execute_data_swap(int port, int data_role) { - /* Do nothing */ + gpio_set_level(GPIO_USB2_OTG_ID, + (data_role == PD_ROLE_UFP) ? 1 : 0); + gpio_set_level(GPIO_USB2_OTG_VBUSSENSE, + (data_role == PD_ROLE_UFP) ? 1 : 0); } void pd_check_pr_role(int port, int pr_role, int flags)