diff options
-rw-r--r-- | board/amenia/board.c | 13 | ||||
-rw-r--r-- | driver/charger/bd99955.c | 13 | ||||
-rw-r--r-- | driver/charger/bd99955.h | 7 |
3 files changed, 22 insertions, 11 deletions
diff --git a/board/amenia/board.c b/board/amenia/board.c index f3fc62d63c..63d53fdcc2 100644 --- a/board/amenia/board.c +++ b/board/amenia/board.c @@ -347,12 +347,13 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma) { /* Enable charging trigger by BC1.2 detection */ - if (supplier == CHARGE_SUPPLIER_BC12_CDP || - supplier == CHARGE_SUPPLIER_BC12_DCP || - supplier == CHARGE_SUPPLIER_BC12_SDP) { - if (bd99955_bc12_enable_charging(port, 1)) - return; - } + int bc12_enable = (supplier == CHARGE_SUPPLIER_BC12_CDP || + supplier == CHARGE_SUPPLIER_BC12_DCP || + supplier == CHARGE_SUPPLIER_BC12_SDP || + supplier == CHARGE_SUPPLIER_OTHER); + + if (bd99955_bc12_enable_charging(port, bc12_enable)) + return; charge_set_input_current_limit(MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT)); diff --git a/driver/charger/bd99955.c b/driver/charger/bd99955.c index 77923f5bbb..cd3e446fba 100644 --- a/driver/charger/bd99955.c +++ b/driver/charger/bd99955.c @@ -196,6 +196,8 @@ static int bd99955_get_bc12_device_type(enum bd99955_charge_port port) return CHARGE_SUPPLIER_BC12_DCP; case BD99955_TYPE_SDP: return CHARGE_SUPPLIER_BC12_SDP; + case BD99955_TYPE_OTHER: + return CHARGE_SUPPLIER_OTHER; case BD99955_TYPE_VBUS_OPEN: case BD99955_TYPE_PUP_PORT: case BD99955_TYPE_OPEN_PORT: @@ -213,6 +215,17 @@ static int bd99955_get_bc12_ilim(int charge_supplier) return 2000; case CHARGE_SUPPLIER_BC12_SDP: return 900; + case CHARGE_SUPPLIER_OTHER: + /* + * TODO: Setting the higher limit of current may result in an + * anti-collapse hence limiting the current to 1A. (If the + * charger response is slow or BD99955 cannot detect the type + * of the charger, anti-collapse status is not updated in the + * VBUS/VCC_STATUS register. Hence it is not possible to decide + * whether to overwrite the ILIM values to come out of the + * anti-collapse). + */ + return 1000; default: return 500; } diff --git a/driver/charger/bd99955.h b/driver/charger/bd99955.h index c03c349935..6b508611f5 100644 --- a/driver/charger/bd99955.h +++ b/driver/charger/bd99955.h @@ -141,12 +141,9 @@ enum bd99955_charge_port { #define BD99955_CMD_UCD_STATUS_CHGDET (1 << 6) #define BD99955_TYPE_VBUS_OPEN 0 #define BD99955_TYPE_SDP BD99955_CMD_UCD_STATUS_CHGPORT0 -/* - * TODO: For CDP detection, from the datasheet CHGDET & CHGPORT[1] bits need - * to be high and rest need to be low. However following bits are high CHGDET, - * DCDFAIL, CHGPORT[1], CHGPORT[0] and rest low. - */ #define BD99955_TYPE_CDP (BD99955_CMD_UCD_STATUS_CHGDET | \ + BD99955_CMD_UCD_STATUS_CHGPORT1) +#define BD99955_TYPE_OTHER (BD99955_CMD_UCD_STATUS_CHGDET | \ BD99955_CMD_UCD_STATUS_CHGPORT1 | \ BD99955_CMD_UCD_STATUS_CHGPORT0 | \ BD99955_CMD_UCD_STATUS_DCDFAIL) |