diff options
Diffstat (limited to 'common/charge_ramp.c')
-rw-r--r-- | common/charge_ramp.c | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/common/charge_ramp.c b/common/charge_ramp.c index 86a0b454cc..3ca5bd89bb 100644 --- a/common/charge_ramp.c +++ b/common/charge_ramp.c @@ -11,17 +11,22 @@ #include "usb_charge.h" #include "util.h" -#define TYPEC_DTS_RAMP_MAX 2400 - test_mockable int chg_ramp_allowed(int supplier) { /* Don't allow ramping in RO when write protected. */ if (!system_is_in_rw() && system_is_locked()) return 0; - /* Ramp DTS suppliers. */ - if (supplier == CHARGE_SUPPLIER_TYPEC_DTS) + switch (supplier) { + case CHARGE_SUPPLIER_TYPEC_DTS: +#ifdef CONFIG_CHARGE_RAMP_HW + /* Need ramping for USB-C chargers as well to avoid voltage droops. */ + case CHARGE_SUPPLIER_PD: + case CHARGE_SUPPLIER_TYPEC: +#endif return 1; + /* default: fall through */ + } /* Othewise ask the BC1.2 detect module */ return usb_charger_ramp_allowed(supplier); @@ -29,12 +34,19 @@ test_mockable int chg_ramp_allowed(int supplier) test_mockable int chg_ramp_max(int supplier, int sup_curr) { - /* - * Ramp DTS suppliers to advertised current or predetermined - * limit, whichever is greater. - */ - if (supplier == CHARGE_SUPPLIER_TYPEC_DTS) - return MAX(TYPEC_DTS_RAMP_MAX, sup_curr); + switch (supplier) { +#ifdef CONFIG_CHARGE_RAMP_HW + case CHARGE_SUPPLIER_PD: + case CHARGE_SUPPLIER_TYPEC: +#endif + case CHARGE_SUPPLIER_TYPEC_DTS: + /* + * We should not ramp DTS beyond what they advertise, otherwise + * we may brownout the systems they are connected to. + */ + return sup_curr; + /* default: fall through */ + } /* Otherwise ask the BC1.2 detect module */ return usb_charger_ramp_max(supplier, sup_curr); |