summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2021-02-23 17:14:22 -0700
committerCommit Bot <commit-bot@chromium.org>2021-02-24 23:03:04 +0000
commit16f1b7a2aad444de45162924312d88c827039a3c (patch)
tree5cc676411c607321ca3669f5d559d98a3a4b9e9f
parent6acf29d48a6e651c54da0f8057013dea119eadc2 (diff)
downloadchrome-ec-16f1b7a2aad444de45162924312d88c827039a3c.tar.gz
RAA489000: Rearrange inits to sink Vbus faster
In order to more quickly detect and sink Vbus, move up the priority on enabling the Vbus ADC and checking our Vbus status to enable sinking. Additionally, gate this enablement on the battery not being capable of supporting the board to prevent premature Vbus sinking in normal use-cases. BRANCH=None BUG=b:178981107,b:178728138 TEST=on storo and sasukette, confirm board can boot with no battery and TCPC works as expected On galtic, confirm sinking is enabled on a no-battery boot but not automatically enabled with a charged battery attached Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I26eec09c2fa50d2425c5d6b0ef7b8847bd570da7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2715596 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--driver/tcpm/raa489000.c72
1 files changed, 37 insertions, 35 deletions
diff --git a/driver/tcpm/raa489000.c b/driver/tcpm/raa489000.c
index e3cb861ed1..2ba9f44d10 100644
--- a/driver/tcpm/raa489000.c
+++ b/driver/tcpm/raa489000.c
@@ -79,6 +79,27 @@ int raa489000_init(int port)
CPRINTS("%s(%d): DEVICE_ID=%d", __func__, port, device_id);
dev_id[port] = device_id;
+ /* Enable the ADC */
+ /*
+ * TODO(b:147316511) Since this register can be accessed by multiple
+ * tasks, we should add a mutex when modifying this register.
+ */
+ i2c_port = tcpc_config[port].i2c_info.port;
+ rv = i2c_read16(i2c_port, ISL923X_ADDR_FLAGS, ISL9238_REG_CONTROL3,
+ &regval);
+ regval |= RAA489000_ENABLE_ADC;
+ rv |= i2c_write16(i2c_port, ISL923X_ADDR_FLAGS, ISL9238_REG_CONTROL3,
+ regval);
+ if (rv)
+ CPRINTS("c%d: failed to enable ADCs", port);
+
+ /* Enable Vbus detection */
+ rv = tcpc_write(port, TCPC_REG_COMMAND,
+ TCPC_REG_COMMAND_ENABLE_VBUS_DETECT);
+ if (rv)
+ CPRINTS("c%d: failed to enable vbus detect cmd", port);
+
+
if (device_id > 1) {
/*
* A1 silicon has a DEVICE_ID of 1. For B0 and newer, we need
@@ -94,6 +115,22 @@ int raa489000_init(int port)
CPRINTS("C%d: failed to set TCPC power control", port);
}
+ /*
+ * If VBUS is present, start sinking from it if we haven't already
+ * chosen a charge port and no battery is connected. This is
+ * *kinda hacky* doing it here, but we must start sinking VBUS now,
+ * otherwise the board may die (See b/150702984, b/178728138)
+ */
+ tcpc_read(port, TCPC_REG_POWER_STATUS, &regval);
+ if ((regval & TCPC_REG_POWER_STATUS_VBUS_PRES) &&
+ charge_manager_get_active_charge_port() == CHARGE_PORT_NONE &&
+ !pd_is_battery_capable()) {
+ chg.current = 500;
+ chg.voltage = 5000;
+ charge_manager_update_charge(CHARGE_SUPPLIER_VBUS, port, &chg);
+ board_set_active_charge_port(port);
+ }
+
/* Note: registers may not be ready until TCPCI init succeeds */
rv = tcpci_tcpm_init(port);
if (rv)
@@ -118,27 +155,6 @@ int raa489000_init(int port)
CPRINTS("c%d: failed to enable CC comparators", port);
}
- /* Enable the ADC */
- /*
- * TODO(b:147316511) Since this register can be accessed by multiple
- * tasks, we should add a mutex when modifying this register.
- */
- i2c_port = tcpc_config[port].i2c_info.port;
- rv = i2c_read16(i2c_port, ISL923X_ADDR_FLAGS, ISL9238_REG_CONTROL3,
- &regval);
- regval |= RAA489000_ENABLE_ADC;
- rv |= i2c_write16(i2c_port, ISL923X_ADDR_FLAGS, ISL9238_REG_CONTROL3,
- regval);
- if (rv)
- CPRINTS("c%d: failed to enable ADCs", port);
-
- /* Enable Vbus detection */
- rv = tcpc_write(port, TCPC_REG_COMMAND,
- TCPC_REG_COMMAND_ENABLE_VBUS_DETECT);
- if (rv)
- CPRINTS("c%d: failed to enable vbus detect cmd", port);
-
-
/* Set Rx enable for receiver comparator */
rv = tcpc_read16(port, RAA489000_PD_PHYSICAL_SETTING1, &regval);
regval |= RAA489000_PD_PHY_SETTING1_RECEIVER_EN |
@@ -183,20 +199,6 @@ int raa489000_init(int port)
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);
- }
-
- /*
* Set Vbus OCP UV here, PD tasks will set target current
*/
rv = tcpc_write16(port, RAA489000_VBUS_OCP_UV_THRESHOLD,