diff options
author | Shawn Nematbakhsh <shawnn@chromium.org> | 2017-10-06 15:46:02 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-10-19 12:56:42 -0700 |
commit | 165f7d6f3bad4d49f977e1c5efad326f11007bf0 (patch) | |
tree | 0d7d8aaf3d2ccbd5df041d7f55a2573355a31d62 /common/charge_manager.c | |
parent | 251212fb9dea6d95a8caa43ec9eeb210abfa2df8 (diff) | |
download | chrome-ec-165f7d6f3bad4d49f977e1c5efad326f11007bf0.tar.gz |
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 <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/693295
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'common/charge_manager.c')
-rw-r--r-- | common/charge_manager.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/common/charge_manager.c b/common/charge_manager.c index 9f4c776159..9a753aa011 100644 --- a/common/charge_manager.c +++ b/common/charge_manager.c @@ -35,6 +35,7 @@ test_mockable const int supplier_priority[] = { [CHARGE_SUPPLIER_DEDICATED] = 0, #endif [CHARGE_SUPPLIER_TYPEC] = 1, + [CHARGE_SUPPLIER_TYPEC_DTS] = 1, #ifdef CHARGE_MANAGER_BC12 [CHARGE_SUPPLIER_PROPRIETARY] = 1, [CHARGE_SUPPLIER_BC12_DCP] = 2, @@ -282,6 +283,7 @@ static void charge_manager_fill_power_info(int port, r->type = USB_CHG_TYPE_PD; break; case CHARGE_SUPPLIER_TYPEC: + case CHARGE_SUPPLIER_TYPEC_DTS: r->type = USB_CHG_TYPE_C; break; #ifdef CHARGE_MANAGER_BC12 @@ -841,14 +843,36 @@ void pd_set_input_current_limit(int port, uint32_t max_ma, charge_manager_update_charge(CHARGE_SUPPLIER_PD, port, &charge); } -void typec_set_input_current_limit(int port, uint32_t max_ma, +void typec_set_input_current_limit(int port, typec_current_t max_ma, uint32_t supply_voltage) { struct charge_port_info charge; + int dts = !!(max_ma & TYPEC_CURRENT_DTS_MASK); - charge.current = max_ma; + charge.current = max_ma & TYPEC_CURRENT_ILIM_MASK; charge.voltage = supply_voltage; - charge_manager_update_charge(CHARGE_SUPPLIER_TYPEC, port, &charge); +#if !defined(HAS_TASK_CHG_RAMP) && !defined(CONFIG_CHARGE_RAMP_HW) + /* + * DTS sources such as suzy-q may not be able to actually deliver + * their advertised current, so limit it to reduce chance of OC, + * if we can't ramp. + */ + if (dts) + charge.current = MIN(charge.current, 500); +#endif + charge_manager_update_charge(dts ? CHARGE_SUPPLIER_TYPEC_DTS : + CHARGE_SUPPLIER_TYPEC, + port, &charge); + + /* + * Zero TYPEC / TYPEC-DTS when zero'ing the other, since they are + * mutually exclusive and DTS status of port partner will no longer + * be reflected on disconnect. + */ + if (max_ma == 0 || supply_voltage == 0) + charge_manager_update_charge(dts ? CHARGE_SUPPLIER_TYPEC : + CHARGE_SUPPLIER_TYPEC_DTS, + port, &charge); } void charge_manager_update_charge(int supplier, |