diff options
author | Scott <scollyer@chromium.org> | 2017-03-02 20:59:17 -0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2017-05-17 17:20:50 +0000 |
commit | cb2e9d9c0aa281022110ffe05df70c4b9fe3a7a2 (patch) | |
tree | d13e4992691cecaebcd4bc5079812ff9207e881b | |
parent | 135c9cd1bcfc0cf44b9ccf333b3861a193712edb (diff) | |
download | chrome-ec-cb2e9d9c0aa281022110ffe05df70c4b9fe3a7a2.tar.gz |
pd: Changes to USB PD state machine for SRC DTS mode
In order to make pass through charging safe, there must be a mechanism
to signal the CHG port manager that Vbus is available and in a steady
state. When a typec only charger is used for the CHG port, then it's
steady state is SRC_DISCOVERY. Need a way to differentiate the TypeC
only charger from a USB PD charger that's also going through
SNK_DISCOVERY.
In addition, to allow a DTS device to support PD messaging, can't
stay in SRC_ACCESSORY state. This CL makes a modification to the
USB PD state machine so that if a debug accessory is detected and
CONFIG_USB_PD_DTS is defined, then the state machine will advance to
SRC_STARTUP and prepare for messages similar to when a UFP attach
is detected.
BUG=b:35586526
BRANCH=servo
TEST=Manual Built for both Plankton and Reef, verified that Reef
connects as both SNK and SRC.
Signed-off-by: Scott <scollyer@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/448987
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Change-Id: I9aea0341cd9b6e6773023f0923a9a18a86fc4627
Reviewed-on: https://chromium-review.googlesource.com/506955
Reviewed-by: Nick Sanders <nsanders@chromium.org>
-rw-r--r-- | common/usb_pd_protocol.c | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 805189eae4..77e5255726 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -1424,7 +1424,7 @@ static inline int get_snk_polarity(int cc1, int cc2) return (cc2 > cc1); } -#ifdef CONFIG_CHARGE_MANAGER +#if defined(CONFIG_CHARGE_MANAGER) || defined(CONFIG_USB_PD_DTS) /** * Returns type C current limit (mA) based upon cc_voltage (mV). */ @@ -1512,7 +1512,7 @@ void pd_task(void) #ifndef CONFIG_USB_PD_VBUS_DETECT_NONE int snk_hard_reset_vbus_off = 0; #endif -#ifdef CONFIG_CHARGE_MANAGER +#if defined(CONFIG_CHARGE_MANAGER) || defined(CONFIG_USB_PD_DTS) int typec_curr = 0, typec_curr_change = 0; #endif /* CONFIG_CHARGE_MANAGER */ #endif /* CONFIG_USB_PD_DUAL_ROLE */ @@ -1793,10 +1793,6 @@ void pd_task(void) /* Remove VBUS */ pd_power_supply_reset(port); #endif -#ifdef CONFIG_USB_PD_DTS - if (new_cc_state == PD_CC_DEBUG_ACC) - pd_set_power_supply_ready(port); -#endif /* Set the USB muxes and the default USB role */ pd_set_data_role(port, CONFIG_USB_PD_DEBUG_DR); @@ -1807,6 +1803,22 @@ void pd_task(void) CCD_MODE_ENABLED); } #endif +#ifdef CONFIG_USB_PD_DTS + if (new_cc_state == PD_CC_DEBUG_ACC) { + /* Enable Vbus */ + pd_set_power_supply_ready(port); + /* Captive cable, CC1 always */ + pd[port].polarity = 0; + tcpm_set_polarity(port, 0); + /* Enable TCPC RX */ + if (pd_comm_enabled) + tcpm_set_rx_enable(port, 1); + hard_reset_count = 0; + timeout = 10*MSEC; + set_state(port, PD_STATE_SRC_STARTUP); + break; + } +#endif set_state(port, PD_STATE_SRC_ACCESSORY); } break; @@ -2259,7 +2271,7 @@ void pd_task(void) pd[port].msg_id = 0; /* initial data role for sink is UFP */ pd_set_data_role(port, PD_ROLE_UFP); -#ifdef CONFIG_CHARGE_MANAGER +#if defined(CONFIG_CHARGE_MANAGER) || defined(CONFIG_USB_PD_DTS) typec_curr = get_typec_current_limit(pd[port].polarity, cc1, cc2); typec_set_input_current_limit( @@ -2403,7 +2415,7 @@ defined(CONFIG_CASE_CLOSED_DEBUG_EXTERNAL) get_time().val + PD_T_NO_RESPONSE, PD_STATE_SNK_DISCONNECTED); -#ifdef CONFIG_CHARGE_MANAGER +#if defined(CONFIG_CHARGE_MANAGER) || defined(CONFIG_USB_PD_DTS) /* * If we didn't come from disconnected, must * have come from some path that did not set @@ -2416,7 +2428,7 @@ defined(CONFIG_CASE_CLOSED_DEBUG_EXTERNAL) #endif } -#ifdef CONFIG_CHARGE_MANAGER +#if defined(CONFIG_CHARGE_MANAGER) || defined(CONFIG_USB_PD_DTS) timeout = PD_T_SINK_ADJ - PD_T_DEBOUNCE; /* Check if CC pull-up has changed */ @@ -2840,6 +2852,16 @@ defined(CONFIG_CASE_CLOSED_DEBUG_EXTERNAL) if (pd[port].power_role == PD_ROLE_SOURCE) { /* Source: detect disconnect by monitoring CC */ tcpm_get_cc(port, &cc1, &cc2); +#ifdef CONFIG_USB_PD_DTS + /* If accessory becomes detached */ + if (cc1 != TYPEC_CC_VOLT_RD || + cc2 != TYPEC_CC_VOLT_RD) { + set_state(port, PD_STATE_SRC_DISCONNECTED); + /* Debouncing */ + timeout = 10*MSEC; + ccd_set_mode(CCD_MODE_DISABLED); + } +#endif if (pd[port].polarity) cc1 = cc2; if (cc1 == TYPEC_CC_VOLT_OPEN) { |