From 165f7d6f3bad4d49f977e1c5efad326f11007bf0 Mon Sep 17 00:00:00 2001 From: Shawn Nematbakhsh Date: Fri, 6 Oct 2017 15:46:02 -0700 Subject: charge_ramp: Ramp USB-C DTS sources suzy-qable advertises 1.5A, but its actual capability depends on the host USB port it is attached to. Since suzy-qable is ubiquitous and other DTS sources may behave in the same way, ramp the input current limit in order to find a reasonable maximum. BUG=chromium:770296 BRANCH=None TEST=Attach suzy-qable to kevin and reef, verify that neither OCs and EC console via cr50 is available on reef. Also verify donette chargers kevin at 3A and does not ramp. Change-Id: Idd0683ede3a44111a01da6b4faab52f388ee82fd Signed-off-by: Shawn Nematbakhsh Reviewed-on: https://chromium-review.googlesource.com/693295 Commit-Ready: Shawn N Tested-by: Shawn N Reviewed-by: Vincent Palatin --- common/usb_pd_protocol.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'common/usb_pd_protocol.c') diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 40264b3342..ff8225cf5f 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -1533,9 +1533,9 @@ static inline int get_snk_polarity(int cc1, int cc2) /** * Returns type C current limit (mA) based upon cc_voltage (mV). */ -static inline int get_typec_current_limit(int polarity, int cc1, int cc2) +static typec_current_t get_typec_current_limit(int polarity, int cc1, int cc2) { - int charge; + typec_current_t charge; int cc = polarity ? cc2 : cc1; int cc_alt = polarity ? cc1 : cc2; @@ -1546,6 +1546,9 @@ static inline int get_typec_current_limit(int polarity, int cc1, int cc2) else charge = 0; + if (cc_alt != TYPEC_CC_OPEN) + charge |= TYPEC_CURRENT_DTS_MASK; + return charge; } @@ -1635,7 +1638,7 @@ void pd_task(void *u) const int auto_toggle_supported = tcpm_auto_toggle_supported(port); #endif #if defined(CONFIG_CHARGE_MANAGER) - int typec_curr = 0, typec_curr_change = 0; + typec_current_t typec_curr = 0, typec_curr_change = 0; #endif /* CONFIG_CHARGE_MANAGER */ #endif /* CONFIG_USB_PD_DUAL_ROLE */ enum pd_states this_state; -- cgit v1.2.1