summaryrefslogtreecommitdiff
path: root/driver/bc12
diff options
context:
space:
mode:
authorScott Collyer <scollyer@google.com>2019-02-22 06:54:32 -0800
committerchrome-bot <chrome-bot@chromium.org>2019-03-14 20:53:57 -0700
commit36db1e3862efd21889acfd698c61e11d355b5318 (patch)
tree65677ead7779e68cb3d3881d73493d273de6d0e6 /driver/bc12
parent63c9ede6e62aa9f6ebe6a2d7dd1245b70f00c8a1 (diff)
downloadchrome-ec-36db1e3862efd21889acfd698c61e11d355b5318.tar.gz
bc12: pi3usb9201: Add 5V rail control for bc1.2 detection
In cases where the pi3usb9201 is powered by a 5V rail which depends on the AP power state, bc1.2 detection may not function when the AP is in G3. This CL adds code to enable the PP5000 rail prior to setting the pi3usb9201 into either host or client mode. BUG=b:122265772 BRANCH=none TEST=Verfied that when pi3usb9201 is accessed while AP is in G3 that the i2c messages no longer fail. Prior to this change, bc1.2 detection following EC reboot was always failing. Change-Id: Ic7113ac8086237e109b4b08bca985127c3bacdf4 Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/1503955 Commit-Ready: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Diffstat (limited to 'driver/bc12')
-rw-r--r--driver/bc12/pi3usb9201.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/driver/bc12/pi3usb9201.c b/driver/bc12/pi3usb9201.c
index 44bb1ca62e..d6e82c3c57 100644
--- a/driver/bc12/pi3usb9201.c
+++ b/driver/bc12/pi3usb9201.c
@@ -194,6 +194,21 @@ static void bc12_power_down(int port)
pi3usb9201_interrupt_mask(port, 1);
/* Let charge manager know there's no more charge available. */
charge_manager_update_charge(CHARGE_SUPPLIER_NONE, port, NULL);
+#if defined(CONFIG_POWER_PP5000_CONTROL) && defined(HAS_TASK_CHIPSET)
+ /* Indicate PP5000_A rail is not required by USB_CHG task. */
+ power_5v_enable(task_get_current(), 0);
+#endif
+}
+
+static void bc12_power_up(int port)
+{
+#if defined(CONFIG_POWER_PP5000_CONTROL) && defined(HAS_TASK_CHIPSET)
+ /* Turn on the 5V rail to allow the chip to be powered. */
+ power_5v_enable(task_get_current(), 1);
+ /* Give the pi3usb9201 time so it's ready to receive i2c messages */
+ msleep(1);
+#endif
+ pi3usb9201_interrupt_mask(port, 1);
}
void usb_charger_task(void *u)
@@ -233,6 +248,7 @@ void usb_charger_task(void *u)
#endif
if (evt & USB_CHG_EVENT_DR_UFP) {
+ bc12_power_up(port);
if (bc12_detect_start(port)) {
struct charge_port_info new_chg;
@@ -266,6 +282,7 @@ void usb_charger_task(void *u)
* If the port is in DFP mode, then need to set mode to
* CDP_HOST which will auto close D+/D- switches.
*/
+ bc12_power_up(port);
rv = pi3usb9201_get_mode(port, &mode);
if (!rv && (mode != PI3USB9201_CDP_HOST_MODE))
pi3usb9201_set_mode(port,