summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYilun Lin <yllin@google.com>2019-05-27 17:46:50 +0800
committerCommit Bot <commit-bot@chromium.org>2019-06-17 04:57:56 +0000
commit205c777b9f74667a6580d4c4d232417b92637eca (patch)
treedb8502fc4dba9a7a4eea85c0df167ec652e3adad
parent35afaa622676de0b72b727e9ed602bf0820934e7 (diff)
downloadchrome-ec-205c777b9f74667a6580d4c4d232417b92637eca.tar.gz
krane: Enable BC12 detection with gpio controlled.
Support CONFIG_BC12_DETECT_POWER_ROLE_TRIGGER. Krane's BC12 detection is controlled by GPIO_BC12_DET_EN by disconnecting USB-PHY, that is: - Assert GPIO_BC12_DET_EN, then USB-PHY is disconnected - Deassert GPIO_BC12_DET_EN, then USB-PHY is connected. The current usb_chg_task will make USB devices not be enumerated, since GPIO_BC12_DET_EN is deasserted only when VBUS attached and BC12 device identified. However, peripherals won't trigger BC12 detection so GPIO_BC12_DET_EN always asserted. To fix this problem, we trigger BC12 detection only when a port is attached and hook USB_PD_CONNECTED to toggle BC12 detection. We have to - Assert GPIO_BC12_DET_EN on SRC device plugged to recognize BC12 charger. - After BC12 device detected, we have to disable BC12 to connect USB-PHY back for enumerating USB devices. - Deassert GPIO_BC12_DET_EN on SNK device plugged to enumerate USB devices. TEST=Test with https://crrev.com/c/1408751/1, and see it is able to recognize Apple 2.4A charger and 5V2A DCP charger. TEST=Boot w/ USB hub plugged (w/ and w/o external BC1.2 charger on the hub) and see USB devices are enumerated. BUG=b:122866184 BRANCH=None Change-Id: I5b3362305361c0c950288fc83072e9bc79082c08 Signed-off-by: Yilun Lin <yllin@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1575050 Tested-by: Yilun Lin <yllin@chromium.org> Auto-Submit: Yilun Lin <yllin@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Yilun Lin <yllin@chromium.org>
-rw-r--r--driver/charger/rt946x.c18
-rw-r--r--include/config.h8
2 files changed, 24 insertions, 2 deletions
diff --git a/driver/charger/rt946x.c b/driver/charger/rt946x.c
index d38690892a..2915ba5155 100644
--- a/driver/charger/rt946x.c
+++ b/driver/charger/rt946x.c
@@ -257,6 +257,9 @@ static int rt946x_reset_to_zero(void)
static int rt946x_enable_bc12_detection(int en)
{
#if defined(CONFIG_CHARGER_RT9467) || defined(CONFIG_CHARGER_MT6370)
+#ifdef CONFIG_CHARGER_MT6370_BC12_GPIO
+ gpio_set_level(GPIO_BC12_DET_EN, en);
+#endif /* CONFIG_CHARGER_MT6370_BC12_GPIO */
return (en ? rt946x_set_bit : rt946x_clr_bit)
(RT946X_REG_DPDM1, RT946X_MASK_USBCHGEN);
#endif
@@ -941,6 +944,14 @@ int rt946x_toggle_bc12_detection(void)
return rt946x_enable_bc12_detection(1);
}
+#ifdef CONFIG_CHARGER_MT6370_BC12_GPIO
+static void usb_pd_connect(void)
+{
+ rt946x_toggle_bc12_detection();
+}
+DECLARE_HOOK(HOOK_USB_PD_CONNECT, usb_pd_connect, HOOK_PRIO_DEFAULT);
+#endif
+
void usb_charger_task(void *u)
{
struct charge_port_info chg;
@@ -974,8 +985,9 @@ void usb_charger_task(void *u)
#ifdef CONFIG_WIRELESS_CHARGER_P9221_R7
}
#endif
- rt946x_enable_bc12_detection(0);
}
+
+ rt946x_enable_bc12_detection(0);
}
/* VBUS detach event */
@@ -985,7 +997,9 @@ void usb_charger_task(void *u)
p9221_notify_vbus_change(0);
#endif
charge_manager_update_charge(bc12_type, 0, NULL);
- rt946x_enable_bc12_detection(1);
+
+ if (!IS_ENABLED(CONFIG_CHARGER_MT6370_BC12_GPIO))
+ rt946x_enable_bc12_detection(1);
}
task_wait_event(-1);
diff --git a/include/config.h b/include/config.h
index 15482a9687..08b9977dbf 100644
--- a/include/config.h
+++ b/include/config.h
@@ -776,6 +776,14 @@
#undef CONFIG_CHARGER_MT6370_BACKLIGHT
/*
+ * MT6370 BC1.2 USB-PHY control.
+ * If defined, USB-PHY connection is controlled by GPIO_BC12_DET_EN.
+ * Assert GPIO_BC12_DET_EN to detect BC1.2 device, and deassert
+ * GPIO_BC12_DET_EN to mux USB-PHY back.
+ */
+#undef CONFIG_CHARGER_MT6370_BC12_GPIO
+
+/*
* Enable/disable system power monitor PSYS function: this enables output
* from charger chip to SoC.
*/