summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVijay Hiremath <vijay.p.hiremath@intel.com>2016-05-27 16:10:23 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-06-08 17:14:52 -0700
commit6e874dc7e7535189d4bd0e62ae1f98ba8d2c1650 (patch)
tree56f4df5e898a8d924e119ad5769d093e3c2d4775
parentbb6918cbdfd521dc30316deaa03788db569fadc5 (diff)
downloadchrome-ec-6e874dc7e7535189d4bd0e62ae1f98ba8d2c1650.tar.gz
BD99955: Add support to detect non-BC1.2 compliant chargers
If a non-BC1.2 compliant charger is attached and if the USB charge port detection is success then setting the charger supplier type as CHARGE_SUPPLIER_OTHER. BUG=none BRANCH=none TEST=Manually tested on Amenia. Used Apple USB charger (5.1V & 2.1A) and few non-BC1.2 chargers (5V & 1A, 5V & 2.1A). Charger is detected as CHARGE_SUPPLIER_OTHER and the battery can charge. Change-Id: I35458dc173505cea970afc37d8f9ffb3c4376fe2 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/348060 Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com> Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Shawn N <shawnn@chromium.org>
-rw-r--r--board/amenia/board.c13
-rw-r--r--driver/charger/bd99955.c13
-rw-r--r--driver/charger/bd99955.h7
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)