diff options
author | Shawn Nematbakhsh <shawnn@chromium.org> | 2016-07-22 18:27:35 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-08-19 14:21:06 -0700 |
commit | 62751ab886de427bb8061ec4534facff993aa47d (patch) | |
tree | dd1ac991ee8b3007f10cbc143c5af2719fdadc19 | |
parent | f895e32b0f28be9a987980204f0b33c1683f0f9d (diff) | |
download | chrome-ec-62751ab886de427bb8061ec4534facff993aa47d.tar.gz |
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>
-rw-r--r-- | common/usb_pd_protocol.c | 17 | ||||
-rw-r--r-- | include/config.h | 6 |
2 files changed, 23 insertions, 0 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index ff88980f5f..7682030291 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -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, diff --git a/include/config.h b/include/config.h index 5f5f90adea..66bbf22e94 100644 --- a/include/config.h +++ b/include/config.h @@ -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 |