summaryrefslogtreecommitdiff
path: root/driver/bc12
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2020-04-29 17:44:33 -0700
committerCommit Bot <commit-bot@chromium.org>2020-04-30 23:11:12 +0000
commit03e331ec95e732eab725073e6af22a09ad9c7616 (patch)
tree2af0f50f4799132540a74e6c0dacb7410f9bf820 /driver/bc12
parentff668f5d261b00690d65494eb7543ef5177f72da (diff)
downloadchrome-ec-03e331ec95e732eab725073e6af22a09ad9c7616.tar.gz
bc12: Limit max current to 1.5A
The Type-C specification now prohibits proprietary methods for BC 1.2 to be used over Type-C. In effect, this limits the maximum current for legacy chargers to be 1.5A. Technically, proprietary methods are not allowed, however we'll continue to allow them but limiting their maximum current to 1.5A. This commit changes the maximum current of our BC 1.2 detectors to be 1.5A for all suppliers that would have reported higher capabilities. For more information, see the USB Type-C Engineering Change Request titled "Removal of Proprietary Charging Methods". BUG=b:155337959 BRANCH=hatch,kukui,kevin TEST=Build and flash waddledee, verify that legacy supplier is limited to 1.5A. TEST=`make -j buildall` Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: Ifb8dbde519cd2efe17a27197460291708bef125c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2172777 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'driver/bc12')
-rw-r--r--driver/bc12/max14637.c6
-rw-r--r--driver/bc12/pi3usb9201.c23
-rw-r--r--driver/bc12/pi3usb9281.c15
3 files changed, 29 insertions, 15 deletions
diff --git a/driver/bc12/max14637.c b/driver/bc12/max14637.c
index 36b80bb624..ea5dfa126f 100644
--- a/driver/bc12/max14637.c
+++ b/driver/bc12/max14637.c
@@ -98,9 +98,11 @@ static void bc12_detect(const int port)
* The driver assumes that CHG_AL_N and SW_OPEN are not connected,
* therefore an activated CHG_DET indicates whether the source is NOT a
* low-power standard downstream port (SDP). The system will have to
- * ramp the current to determine the limit.
+ * ramp the current to determine the limit. The Type-C spec prohibits
+ * proprietary methods now, therefore 1500mA is the max.
*/
- new_chg.current = is_chg_det_activated(cfg) ? 2400 : 500;
+ new_chg.current = is_chg_det_activated(cfg) ? USB_CHARGER_MAX_CURR_MA :
+ 500;
#else
/*
* If the board doesn't support charge ramping, then assume the lowest
diff --git a/driver/bc12/pi3usb9201.c b/driver/bc12/pi3usb9201.c
index 0dee6a01d5..f8dbadd5c7 100644
--- a/driver/bc12/pi3usb9201.c
+++ b/driver/bc12/pi3usb9201.c
@@ -40,21 +40,28 @@ struct bc12_status {
/* Used to store last BC1.2 detection result */
static enum charge_supplier bc12_supplier[CONFIG_USB_PD_PORT_MAX_COUNT];
+/*
+ * The USB Type-C specification limits the maximum amount of current from BC 1.2
+ * suppliers to 1.5A. Technically, proprietary methods are not allowed, but we
+ * will continue to allow those.
+ */
static const struct bc12_status bc12_chg_limits[] = {
[CHG_OTHER] = {CHARGE_SUPPLIER_OTHER, 500},
- [CHG_2_4A] = {CHARGE_SUPPLIER_PROPRIETARY, 2400},
- [CHG_2_0A] = {CHARGE_SUPPLIER_PROPRIETARY, 2000},
+ [CHG_2_4A] = {CHARGE_SUPPLIER_PROPRIETARY, USB_CHARGER_MAX_CURR_MA},
+ [CHG_2_0A] = {CHARGE_SUPPLIER_PROPRIETARY, USB_CHARGER_MAX_CURR_MA},
[CHG_1_0A] = {CHARGE_SUPPLIER_PROPRIETARY, 1000},
[CHG_RESERVED] = {CHARGE_SUPPLIER_NONE, 0},
- [CHG_CDP] = {CHARGE_SUPPLIER_BC12_CDP, 1500},
+ [CHG_CDP] = {CHARGE_SUPPLIER_BC12_CDP, USB_CHARGER_MAX_CURR_MA},
[CHG_SDP] = {CHARGE_SUPPLIER_BC12_SDP, 500},
#if defined(CONFIG_CHARGE_RAMP_SW) || defined(CONFIG_CHARGE_RAMP_HW)
/*
* If ramping is supported, then for DCP set the current limit to be the
- * max supported for the port by the board. This because for DCP the
- * charger is allowed to set its own max up to 5A.
+ * max supported for the port by the board or 1.5A (whichever is lower).
+ * Although, the BC 1.2 specification allows DCP suppliers to ramp to
+ * much higher currents, the USB Type-C specification limits the
+ * maximum current allowed for BC 1.2 suppliers to 1.5A.
*/
- [CHG_DCP] = {CHARGE_SUPPLIER_BC12_DCP, PD_MAX_CURRENT_MA},
+ [CHG_DCP] = {CHARGE_SUPPLIER_BC12_DCP, USB_CHARGER_MAX_CURR_MA},
#else
[CHG_DCP] = {CHARGE_SUPPLIER_BC12_DCP, 500},
#endif
@@ -339,13 +346,13 @@ int usb_charger_ramp_max(int supplier, int sup_curr)
{
/*
* Use the level from the bc12_chg_limits table above except for
- * proprietary of CDP and in those cases the charge current from the
+ * proprietary or CDP and in those cases the charge current from the
* charge manager is already set at the max determined by bc1.2
* detection.
*/
switch (supplier) {
case CHARGE_SUPPLIER_BC12_DCP:
- return PD_MAX_CURRENT_MA;
+ return USB_CHARGER_MAX_CURR_MA;
case CHARGE_SUPPLIER_BC12_CDP:
case CHARGE_SUPPLIER_PROPRIETARY:
return sup_curr;
diff --git a/driver/bc12/pi3usb9281.c b/driver/bc12/pi3usb9281.c
index db5d039fd9..1e1304e4f3 100644
--- a/driver/bc12/pi3usb9281.c
+++ b/driver/bc12/pi3usb9281.c
@@ -201,17 +201,22 @@ static int pi3usb9281_get_ilim(int device_type, int charger_status)
/* Limit USB port current. 500mA for not listed types. */
int current_limit_ma = 500;
+ /*
+ * The USB Type-C specification limits the maximum amount of current
+ * from BC 1.2 suppliers to 1.5A. Technically, proprietary methods are
+ * not allowed, but we will continue to allow those.
+ */
if (charger_status & PI3USB9281_CHG_CAR_TYPE1 ||
charger_status & PI3USB9281_CHG_CAR_TYPE2)
- current_limit_ma = 3000;
+ current_limit_ma = USB_CHARGER_MAX_CURR_MA;
else if (charger_status & PI3USB9281_CHG_APPLE_1A)
current_limit_ma = 1000;
else if (charger_status & PI3USB9281_CHG_APPLE_2A)
- current_limit_ma = 2000;
+ current_limit_ma = USB_CHARGER_MAX_CURR_MA;
else if (charger_status & PI3USB9281_CHG_APPLE_2_4A)
- current_limit_ma = 2400;
+ current_limit_ma = USB_CHARGER_MAX_CURR_MA;
else if (device_type & PI3USB9281_TYPE_CDP)
- current_limit_ma = 1500;
+ current_limit_ma = USB_CHARGER_MAX_CURR_MA;
else if (device_type & PI3USB9281_TYPE_DCP)
current_limit_ma = 500;
@@ -469,7 +474,7 @@ int usb_charger_ramp_max(int supplier, int sup_curr)
{
switch (supplier) {
case CHARGE_SUPPLIER_BC12_DCP:
- return 2000;
+ return USB_CHARGER_MAX_CURR_MA;
case CHARGE_SUPPLIER_BC12_SDP:
return 1000;
case CHARGE_SUPPLIER_BC12_CDP: