summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2020-03-10 11:09:26 -0700
committerCommit Bot <commit-bot@chromium.org>2020-03-12 02:32:39 +0000
commit6f186aaa6960f1902ae5b6964ab3dd4e1df26dce (patch)
treef1fc12ba784ec0297fb61c6e4d78cf854e0b4e83
parent326d9a6fa33942aff01b602e96bad6fedd7f48a9 (diff)
downloadchrome-ec-6f186aaa6960f1902ae5b6964ab3dd4e1df26dce.tar.gz
raa489000: Choose charge port if VBUS present @ init
Per the vendor, we need to starting sinking VBUS before writing to the Role control register, otherwise the ASGATE turns off. This commit checks to see if VBUS is present on a port at init time and no other charge port has been selected in order to keep the ASGATE turned on. BUG=b:150702984 BRANCH=None TEST=build and flash waddledoo, verify that VSYS remains up. Change-Id: I00957f7588f503551223d16969785198e1a9fd48 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2097136 Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--driver/tcpm/raa489000.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/driver/tcpm/raa489000.c b/driver/tcpm/raa489000.c
index dec9313fba..f311252843 100644
--- a/driver/tcpm/raa489000.c
+++ b/driver/tcpm/raa489000.c
@@ -5,6 +5,7 @@
* Renesas RAA489000 TCPC driver
*/
+#include "charge_manager.h"
#include "common.h"
#include "console.h"
#include "driver/charger/isl923x.h"
@@ -21,6 +22,7 @@ int raa489000_init(int port)
int rv;
int regval;
int i2c_port;
+ struct charge_port_info chg = { 0 };
/* Perform unlock sequence */
rv = tcpc_write16(port, 0xAA, 0xDAA0);
@@ -111,6 +113,20 @@ int raa489000_init(int port)
if (rv)
CPRINTS("c%d: failed to set TCPCIv1.0 mode", port);
+ /*
+ * If VBUS is present, start sinking from it if we haven't already
+ * chosen a charge port. This is *kinda hacky* doing it here, but we
+ * must start sinking VBUS now, otherwise the board may die if there is
+ * no battery connected. (See b/150702984)
+ */
+ if (pd_snk_is_vbus_provided(port) &&
+ charge_manager_get_active_charge_port() == CHARGE_PORT_NONE) {
+ chg.current = 500;
+ chg.voltage = 5000;
+ charge_manager_update_charge(CHARGE_SUPPLIER_VBUS, port, &chg);
+ board_set_active_charge_port(port);
+ }
+
return rv;
}