summaryrefslogtreecommitdiff
path: root/board/pyro/board.c
diff options
context:
space:
mode:
authorBruce <Bruce.Wan@quantatw.com>2016-11-17 14:11:51 +0800
committerchrome-bot <chrome-bot@chromium.org>2016-11-17 16:09:30 -0800
commit342bf53465ae106febceab563d8159ff7ed17fd5 (patch)
treee9b2a8b68c85103c77d558463fc4abeff7b2e9a2 /board/pyro/board.c
parentff9c5dd0d281d9a4c86449f1a8c2f3db6a0a7217 (diff)
downloadchrome-ec-342bf53465ae106febceab563d8159ff7ed17fd5.tar.gz
pyro/snappy: enable tcpc low power mode
BUG=none BRANCH=none TEST=make buildall Change-Id: I28210f753cb596762facc3f2f3a2bde49d0e40df Signed-off-by: Bruce.Wan <Bruce.Wan@quantatw.com> Reviewed-on: https://chromium-review.googlesource.com/411604 Commit-Ready: Keith Tzeng <keith.tzeng@quantatw.com> Tested-by: Keith Tzeng <keith.tzeng@quantatw.com> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'board/pyro/board.c')
-rw-r--r--board/pyro/board.c43
1 files changed, 31 insertions, 12 deletions
diff --git a/board/pyro/board.c b/board/pyro/board.c
index 7af0038af4..38f4fa83fe 100644
--- a/board/pyro/board.c
+++ b/board/pyro/board.c
@@ -76,6 +76,26 @@ static void tcpc_alert_event(enum gpio_signal signal)
#endif
}
+#ifdef CONFIG_USB_PD_TCPC_LOW_POWER
+static void anx74xx_cable_det_handler(void)
+{
+ /* confirm if cable_det is asserted */
+ if (!gpio_get_level(GPIO_USB_C0_CABLE_DET) ||
+ gpio_get_level(GPIO_USB_C0_PD_RST_L))
+ return;
+
+ task_set_event(TASK_ID_PD_C0, PD_EVENT_TCPC_RESET, 0);
+}
+DECLARE_DEFERRED(anx74xx_cable_det_handler);
+DECLARE_HOOK(HOOK_CHIPSET_RESUME, anx74xx_cable_det_handler, HOOK_PRIO_LAST);
+
+void anx74xx_cable_det_interrupt(enum gpio_signal signal)
+{
+ /* debounce for 2ms */
+ hook_call_deferred(&anx74xx_cable_det_handler_data, (2 * MSEC));
+}
+#endif
+
/*
* enable_input_devices() is called by the tablet_mode ISR, but changes the
* state of GPIOs, so its definition must reside after including gpio_list.
@@ -249,12 +269,11 @@ struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
/* called from anx74xx_set_power_mode() */
void board_set_tcpc_power_mode(int port, int mode)
{
- /*
- * This is called during init by the ANX driver to take the TCPC out
- * of reset and enable power. Since we have two TCPC chips and one
- * power enable on Pyro, we take both chips out of reset in a
- * separate function.
- */
+ if (port == 0) {
+ gpio_set_level(GPIO_USB_C0_PD_RST_L, mode);
+ msleep(mode ? 10 : 1);
+ gpio_set_level(GPIO_EN_USB_TCPC_PWR, mode);
+ }
}
/**
@@ -268,9 +287,7 @@ void board_reset_pd_mcu(void)
gpio_set_level(GPIO_USB_C1_PD_RST_ODL, 0);
/* Assert reset to TCPC0 */
- gpio_set_level(GPIO_USB_C0_PD_RST_L, 0);
- msleep(1);
- gpio_set_level(GPIO_EN_USB_TCPC_PWR, 0);
+ board_set_tcpc_power_mode(0, 0);
/* Deassert reset to TCPC1 */
gpio_set_level(GPIO_USB_C1_PD_RST_ODL, 1);
@@ -279,9 +296,7 @@ void board_reset_pd_mcu(void)
msleep(10);
/* Deassert reset to TCPC0 */
- gpio_set_level(GPIO_EN_USB_TCPC_PWR, 1);
- msleep(10);
- gpio_set_level(GPIO_USB_C0_PD_RST_L, 1);
+ board_set_tcpc_power_mode(0, 1);
}
#ifdef CONFIG_USB_PD_TCPC_FW_VERSION
@@ -314,6 +329,10 @@ void board_tcpc_init(void)
/* Enable TCPC1 interrupt */
gpio_enable_interrupt(GPIO_USB_C1_PD_INT_ODL);
+#ifdef CONFIG_USB_PD_TCPC_LOW_POWER
+ /* Enable CABLE_DET interrupt for ANX3429 wake from standby */
+ gpio_enable_interrupt(GPIO_USB_C0_CABLE_DET);
+#endif
/*
* Initialize HPD to low; after sysjump SOC needs to see
* HPD pulse to enable video path