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 <jagadish.krishnamoorthy@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/961381
Reviewed-by: Divya S Sasidharan <divya.s.sasidharan@intel.com>
Reviewed-by: Duncan Laurie <dlaurie@google.com>
This commit is contained in:
Jagadish Krishnamoorthy
2018-03-13 12:01:04 -07:00
committed by chrome-bot
parent a615f3c7d3
commit b073dba72a
3 changed files with 5 additions and 3 deletions

View File

@@ -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

View File

@@ -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 */

View File

@@ -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)