summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
authorVijay Hiremath <vijay.p.hiremath@intel.com>2016-06-30 17:06:07 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-08-22 23:27:16 -0700
commit61c45fb33e9ea1b1db6e195c093b02444d303cce (patch)
tree8992827f71403652997e1261cb9ecfa270262e93 /driver
parent82e4ac67acf3c75084be37a52ae14147135437fa (diff)
downloadchrome-ec-61c45fb33e9ea1b1db6e195c093b02444d303cce.tar.gz
BD99955: Map PD port number to charge port number
Charger port number may differ from PD port number hence added a macro to select appropriate port numbers during compilation. BUG=chrome-os-partner:54970 BRANCH=none TEST=Reef can negotiate on both the ports. Change-Id: Id3b4b639a5f8698c27341be037bb09370910cac5 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/357836 Commit-Ready: Martin Roth <martinroth@chromium.org> Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r--driver/charger/bd99955.c4
-rw-r--r--driver/charger/bd99955.h10
2 files changed, 12 insertions, 2 deletions
diff --git a/driver/charger/bd99955.c b/driver/charger/bd99955.c
index a3b1d6e776..43a6bc4bcb 100644
--- a/driver/charger/bd99955.c
+++ b/driver/charger/bd99955.c
@@ -377,8 +377,8 @@ static void usb_charger_process(enum bd99955_charge_port port)
int vbus_provided = bd99955_is_vbus_provided(port);
/* Inform other modules about VBUS level */
- /* TODO: map charger port num to board port num, they may differ. */
- usb_charger_vbus_change(port, vbus_provided);
+ usb_charger_vbus_change(bd99955_pd_port_to_chg_port(port),
+ vbus_provided);
/* Do BC1.2 detection */
if (vbus_provided) {
diff --git a/driver/charger/bd99955.h b/driver/charger/bd99955.h
index f9c95d7663..e4c557eb1d 100644
--- a/driver/charger/bd99955.h
+++ b/driver/charger/bd99955.h
@@ -282,6 +282,16 @@ enum bd99955_charge_port {
#define BD99955_CMD_SMBREG 0x7C
#define BD99955_CMD_DEBUG_MODE_SET 0x7F
+/* Map PD port number to charge port number */
+static inline enum bd99955_charge_port bd99955_pd_port_to_chg_port(int port)
+{
+#ifdef CONFIG_BD99955_PRIMARY_CHARGE_PORT_VCC
+ return port ? BD99955_CHARGE_PORT_VBUS : BD99955_CHARGE_PORT_VCC;
+#else
+ return port ? BD99955_CHARGE_PORT_VCC : BD99955_CHARGE_PORT_VBUS;
+#endif
+}
+
/*
* Non-standard interface functions - bd99955 integrates additional
* functionality not part of the standard charger interface.