summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVijay Hiremath <vijay.p.hiremath@intel.com>2016-05-26 18:26:11 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-05-28 00:08:38 -0700
commit52fdd95321cb56094498f358872400969e260f9e (patch)
treef1f716696a316c2ec0620c5ebd3e90a5517c2cdd
parent0c5782495d60c3980b0c6ed91a7d8f000bb8d02a (diff)
downloadchrome-ec-52fdd95321cb56094498f358872400969e260f9e.tar.gz
BD99955: Get the VBUS provided status from individual ports
BUG=chrome-os-partner:53786 BRANCH=none TEST=Manually tested on Amenia. VBUS provide status is updated properly for inividual ports. Change-Id: I59c41988438543033db2322029169f405f347869 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/347895 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/kevin/board.c3
-rw-r--r--board/reef/board.c3
-rw-r--r--board/reef/usb_pd_policy.c20
-rw-r--r--driver/charger/bd99955.c19
-rw-r--r--driver/charger/bd99955.h4
5 files changed, 39 insertions, 10 deletions
diff --git a/board/kevin/board.c b/board/kevin/board.c
index f3f99d38b9..65fa97f125 100644
--- a/board/kevin/board.c
+++ b/board/kevin/board.c
@@ -204,7 +204,8 @@ void board_set_charge_limit(int port, int supplier, int charge_ma)
int extpower_is_present(void)
{
- return bd99955_extpower_is_present();
+ /* Check VBUS on either port */
+ return bd99955_is_vbus_provided(BD99955_CHARGE_PORT_BOTH);
}
static void board_init(void)
diff --git a/board/reef/board.c b/board/reef/board.c
index d61ae11b58..395ef77ef2 100644
--- a/board/reef/board.c
+++ b/board/reef/board.c
@@ -412,7 +412,8 @@ void board_set_charge_limit(int port, int supplier, int charge_ma)
int extpower_is_present(void)
{
- return bd99955_extpower_is_present();
+ /* Check VBUS on either port */
+ return bd99955_is_vbus_provided(BD99955_CHARGE_PORT_BOTH);
}
int usb_charger_port_is_sourcing_vbus(int port)
diff --git a/board/reef/usb_pd_policy.c b/board/reef/usb_pd_policy.c
index 8af728b936..e399e1686c 100644
--- a/board/reef/usb_pd_policy.c
+++ b/board/reef/usb_pd_policy.c
@@ -106,7 +106,25 @@ void typec_set_input_current_limit(int port, uint32_t max_ma,
int pd_snk_is_vbus_provided(int port)
{
- return extpower_is_present();
+ enum bd99955_charge_port bd99955_port;
+
+ /*
+ * TODO: Add a compile-time mapping to prevent
+ * duplication of this code.
+ */
+ switch (port) {
+ case 0:
+ bd99955_port = BD99955_CHARGE_PORT_VBUS;
+ break;
+ case 1:
+ bd99955_port = BD99955_CHARGE_PORT_VCC;
+ break;
+ default:
+ panic("Invalid charge port\n");
+ break;
+ }
+
+ return bd99955_is_vbus_provided(bd99955_port);
}
int pd_board_checks(void)
diff --git a/driver/charger/bd99955.c b/driver/charger/bd99955.c
index c07cf70493..6953592fb1 100644
--- a/driver/charger/bd99955.c
+++ b/driver/charger/bd99955.c
@@ -437,7 +437,7 @@ int charger_get_status(int *status)
}
/* source of power */
- if (bd99955_extpower_is_present())
+ if (bd99955_is_vbus_provided(BD99955_CHARGE_PORT_BOTH))
*status |= CHARGER_AC_PRESENT;
return EC_SUCCESS;
@@ -550,7 +550,7 @@ static void bd99995_init(void)
(bi->voltage_max + 500) & 0x7ff0,
BD99955_EXTENDED_COMMAND);
}
-DECLARE_HOOK(HOOK_INIT, bd99995_init, HOOK_PRIO_DEFAULT);
+DECLARE_HOOK(HOOK_INIT, bd99995_init, HOOK_PRIO_INIT_EXTPOWER);
int charger_post_init(void)
{
@@ -578,7 +578,7 @@ int charger_discharge_on_ac(int enable)
/*** Non-standard interface functions ***/
-int bd99955_extpower_is_present(void)
+int bd99955_is_vbus_provided(int port)
{
int reg;
@@ -586,8 +586,17 @@ int bd99955_extpower_is_present(void)
BD99955_EXTENDED_COMMAND))
return 0;
- reg &= (BD99955_CMD_VBUS_VCC_STATUS_VCC_DETECT |
- BD99955_CMD_VBUS_VCC_STATUS_VBUS_DETECT);
+ if (port == BD99955_CHARGE_PORT_VBUS)
+ reg &= BD99955_CMD_VBUS_VCC_STATUS_VBUS_DETECT;
+ else if (port == BD99955_CHARGE_PORT_VCC)
+ reg &= BD99955_CMD_VBUS_VCC_STATUS_VCC_DETECT;
+ else if (port == BD99955_CHARGE_PORT_BOTH) {
+ /* Check VBUS on either port */
+ reg &= (BD99955_CMD_VBUS_VCC_STATUS_VCC_DETECT |
+ BD99955_CMD_VBUS_VCC_STATUS_VBUS_DETECT);
+ } else
+ reg = 0;
+
return !!reg;
}
diff --git a/driver/charger/bd99955.h b/driver/charger/bd99955.h
index 69884dce13..7deae54b09 100644
--- a/driver/charger/bd99955.h
+++ b/driver/charger/bd99955.h
@@ -247,8 +247,8 @@ enum bd99955_charge_port {
* functionality not part of the standard charger interface.
*/
-/* Return true if extpower is present on their input port. */
-int bd99955_extpower_is_present(void);
+/* Is VBUS provided or external power present */
+int bd99955_is_vbus_provided(int port);
/* Select input port from {VCC, VBUS, VCC&VBUS, NONE}. */
int bd99955_select_input_port(enum bd99955_charge_port port);
/* Enable/Disable charging triggered by BC1.2 */