summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--driver/bc12/max14637.c6
-rw-r--r--driver/bc12/pi3usb9201.c23
-rw-r--r--driver/bc12/pi3usb9281.c15
-rw-r--r--driver/charger/bd9995x.c11
-rw-r--r--driver/charger/rt946x.c21
-rw-r--r--include/usb_charge.h8
6 files changed, 53 insertions, 31 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:
diff --git a/driver/charger/bd9995x.c b/driver/charger/bd9995x.c
index d2d3c96751..58f13af6f6 100644
--- a/driver/charger/bd9995x.c
+++ b/driver/charger/bd9995x.c
@@ -101,18 +101,23 @@ static enum usb_switch usb_switch_state[BD9995X_CHARGE_PORT_COUNT] = {
static enum ec_error_list bd9995x_set_current(int chgnum, int current);
static enum ec_error_list bd9995x_set_voltage(int chgnum, int voltage);
+/*
+ * 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 int bd9995x_get_bc12_ilim(int charge_supplier)
{
switch (charge_supplier) {
case CHARGE_SUPPLIER_BC12_CDP:
- return 1500;
+ return USB_CHARGER_MAX_CURR_MA;
case CHARGE_SUPPLIER_BC12_DCP:
- return 2000;
+ return USB_CHARGER_MAX_CURR_MA;
case CHARGE_SUPPLIER_BC12_SDP:
return 900;
case CHARGE_SUPPLIER_OTHER:
#ifdef CONFIG_CHARGE_RAMP_SW
- return 2400;
+ return USB_CHARGER_MAX_CURR_MA;
#else
/*
* Setting the higher limit of current may result in an
diff --git a/driver/charger/rt946x.c b/driver/charger/rt946x.c
index ddc3045e0b..0cf03196a0 100644
--- a/driver/charger/rt946x.c
+++ b/driver/charger/rt946x.c
@@ -1167,6 +1167,11 @@ static int mt6370_get_charger_type(int chgnum)
#endif
}
+/*
+ * 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 int mt6370_get_bc12_ilim(int charge_supplier)
{
switch (charge_supplier) {
@@ -1175,21 +1180,11 @@ static int mt6370_get_bc12_ilim(int charge_supplier)
case MT6370_CHG_TYPE_APPLE_1_0A_CHARGER:
return 1000;
case MT6370_CHG_TYPE_APPLE_2_1A_CHARGER:
- if (IS_ENABLED(CONFIG_CHARGE_RAMP_SW) ||
- IS_ENABLED(CONFIG_CHARGE_RAMP_HW))
- return 2100;
case MT6370_CHG_TYPE_APPLE_2_4A_CHARGER:
- if (IS_ENABLED(CONFIG_CHARGE_RAMP_SW) ||
- IS_ENABLED(CONFIG_CHARGE_RAMP_HW))
- return 2400;
case MT6370_CHG_TYPE_DCP:
- if (IS_ENABLED(CONFIG_CHARGE_RAMP_SW) ||
- IS_ENABLED(CONFIG_CHARGE_RAMP_HW))
- /* A conservative value to prevent a bad charger. */
- return RT946X_AICR_TYP2MAX(2000);
case MT6370_CHG_TYPE_CDP:
case MT6370_CHG_TYPE_SAMSUNG_CHARGER:
- return 1500;
+ return USB_CHARGER_MAX_CURR_MA;
case MT6370_CHG_TYPE_SDP:
default:
return USB_CHARGER_MIN_CURR_MA;
@@ -1222,10 +1217,10 @@ static int rt946x_get_bc12_ilim(int charge_supplier)
if (IS_ENABLED(CONFIG_CHARGE_RAMP_SW) ||
IS_ENABLED(CONFIG_CHARGE_RAMP_HW))
/* A conservative value to prevent a bad charger. */
- return RT946X_AICR_TYP2MAX(2000);
+ return RT946X_AICR_TYP2MAX(USB_CHARGER_MAX_CURR_MA);
/* fallback */
case CHARGE_SUPPLIER_BC12_CDP:
- return 1500;
+ return USB_CHARGER_MAX_CURR_MA;
case CHARGE_SUPPLIER_BC12_SDP:
default:
return USB_CHARGER_MIN_CURR_MA;
diff --git a/include/usb_charge.h b/include/usb_charge.h
index 35aecb5f4a..28d1fd8c84 100644
--- a/include/usb_charge.h
+++ b/include/usb_charge.h
@@ -15,6 +15,14 @@
#define USB_CHARGER_VOLTAGE_MV 5000
/* USB charger minimum current */
#define USB_CHARGER_MIN_CURR_MA 500
+/*
+ * USB charger maximum current
+ *
+ * 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.
+ */
+#define USB_CHARGER_MAX_CURR_MA 1500
#define USB_SYSJUMP_TAG 0x5550 /* "UP" - Usb Port */
#define USB_HOOK_VERSION 1