pd: Support GPIO-controlled 5v discharge

Enable 5v discharge when power swapping out of source role.

BUG=chrome-os-partner:54923
BRANCH=None
TEST=Verify power swap succeeds on kevin when connected to Samus.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I2f57c4dd7d0fdbf70a0ffed659489f752811ea1b
Reviewed-on: https://chromium-review.googlesource.com/362760
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: David Schneider <dnschneid@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
Shawn Nematbakhsh
2016-07-22 18:27:35 -07:00
committed by chrome-bot
parent f895e32b0f
commit 62751ab886
2 changed files with 23 additions and 0 deletions

View File

@@ -97,6 +97,15 @@ enum pd_dual_role_states drp_state = PD_DRP_TOGGLE_OFF;
static uint32_t pd_src_caps[CONFIG_USB_PD_PORT_COUNT][PDO_MAX_OBJECTS];
static int pd_src_cap_cnt[CONFIG_USB_PD_PORT_COUNT];
#ifdef CONFIG_USB_PD_DISCHARGE_GPIO
static const enum gpio_signal pd_discharge_gpio[CONFIG_USB_PD_PORT_COUNT] = {
[0] = GPIO_USB_C0_DISCHARGE,
#if CONFIG_USB_PD_PORT_COUNT > 0
[1] = GPIO_USB_C1_DISCHARGE,
#endif
};
#endif /* CONFIG_USB_PD_DISCHARGE_GPIO */
/* Enable varible for Try.SRC states */
static uint8_t pd_try_src_enable;
#endif
@@ -282,6 +291,11 @@ static inline void set_state(int port, enum pd_states next_state)
#endif
#ifdef CONFIG_USB_PD_DUAL_ROLE
#ifdef CONFIG_USB_PD_DISCHARGE_GPIO
if (last_state == PD_STATE_SRC_SWAP_SRC_DISABLE)
gpio_set_level(pd_discharge_gpio[port], 0);
#endif
if (next_state == PD_STATE_SRC_DISCONNECTED ||
next_state == PD_STATE_SNK_DISCONNECTED) {
/* Clear the input current limit */
@@ -1941,6 +1955,9 @@ void pd_task(void)
/* Turn power off */
if (pd[port].last_state != pd[port].task_state) {
pd_power_supply_reset(port);
#ifdef CONFIG_USB_PD_DISCHARGE_GPIO
gpio_set_level(pd_discharge_gpio[port], 1);
#endif
set_state_timeout(port,
get_time().val +
PD_POWER_SUPPLY_TURN_OFF_DELAY,

View File

@@ -1910,6 +1910,12 @@
/* Default USB data role when a USB PD debug accessory is seen */
#define CONFIG_USB_PD_DEBUG_DR PD_ROLE_DFP
/*
* Define if this board has a GPIO-controlled 5v discharge circuit that can be
* used to discharge VBUS when power swapping out of source role.
*/
#undef CONFIG_USB_PD_DISCHARGE_GPIO
/* Define if this board can act as a dual-role PD port (source and sink) */
#undef CONFIG_USB_PD_DUAL_ROLE