summaryrefslogtreecommitdiff
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
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>
-rw-r--r--board/pyro/board.c43
-rw-r--r--board/pyro/board.h1
-rw-r--r--board/pyro/gpio.inc9
-rw-r--r--board/snappy/board.c43
-rw-r--r--board/snappy/board.h1
-rw-r--r--board/snappy/gpio.inc9
6 files changed, 68 insertions, 38 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
diff --git a/board/pyro/board.h b/board/pyro/board.h
index e22ebb95a8..fc357d3872 100644
--- a/board/pyro/board.h
+++ b/board/pyro/board.h
@@ -89,6 +89,7 @@
#define CONFIG_USB_PD_PORT_COUNT 2
#define CONFIG_USB_PD_QUIRK_SLOW_CC_STATUS
#define CONFIG_USB_PD_VBUS_DETECT_CHARGER
+#define CONFIG_USB_PD_TCPC_LOW_POWER
#define CONFIG_USB_PD_TCPC_FW_VERSION
#define CONFIG_USB_PD_TCPM_MUX /* for both PS8751 and ANX3429 */
#define CONFIG_USB_PD_TCPM_ANX74XX
diff --git a/board/pyro/gpio.inc b/board/pyro/gpio.inc
index fca8bd3a0b..87808e1fe0 100644
--- a/board/pyro/gpio.inc
+++ b/board/pyro/gpio.inc
@@ -17,6 +17,8 @@ GPIO_INT(CHARGER_INT_L, PIN(3, 3), GPIO_INT_FALLING, bd9995x_vbus_interrupt) /
GPIO_INT(USB_C0_PD_INT_ODL, PIN(3, 7), GPIO_INT_FALLING, tcpc_alert_event) /* from Analogix TCPC */
GPIO_INT(USB_C1_PD_INT_ODL, PIN(B, 1), GPIO_INT_FALLING | GPIO_PULL_UP, tcpc_alert_event) /* from Parade TCPC */
+GPIO_INT(USB_C0_CABLE_DET, PIN(C, 5), GPIO_INT_RISING, anx74xx_cable_det_interrupt) /* CABLE_DET from ANX3429 */
+
GPIO_INT(PCH_SLP_S4_L, PIN(8, 6), GPIO_INT_BOTH, power_signal_interrupt) /* SLP_S4_L */
GPIO_INT(PCH_SLP_S3_L, PIN(7, 3), GPIO_INT_BOTH, power_signal_interrupt) /* SLP_S3_L */
GPIO_INT(PCH_SLP_S0_L, PIN(7, 5), GPIO_INT_BOTH, power_signal_interrupt) /* SLP_S0_L */
@@ -76,13 +78,6 @@ GPIO(CCD_MODE_ODL, PIN(6, 3), GPIO_INPUT)
GPIO(EC_HAVEN_RESET_ODL, PIN(0, 2), GPIO_ODR_HIGH)
GPIO(ENTERING_RW, PIN(7, 6), GPIO_OUTPUT) /* EC_ENTERING_RW */
-/*
- * FIXME(dhendrix): Should this be an interrupt? It's a normal input on elm.
- * ANX72xx programming guide section 6 suggests it should interrupt on both
- * high and low edges and we should use it to set PWR_EN and RESET_N pins.
- */
-GPIO(USB_C0_CABLE_DET, PIN(C, 5), GPIO_INPUT)
-
GPIO(PCH_RSMRST_L, PIN(7, 0), GPIO_OUT_LOW)
GPIO(EC_BATT_PRES_L, PIN(3, 4), GPIO_INPUT)
GPIO(PMIC_EN, PIN(8, 5), GPIO_OUT_LOW)
diff --git a/board/snappy/board.c b/board/snappy/board.c
index 6510f2bdb4..f9abb27b71 100644
--- a/board/snappy/board.c
+++ b/board/snappy/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.
@@ -248,12 +268,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 Snappy, 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);
+ }
}
/**
@@ -267,9 +286,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);
@@ -278,9 +295,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
@@ -313,6 +328,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
diff --git a/board/snappy/board.h b/board/snappy/board.h
index b6cdfd8a62..b8eba48142 100644
--- a/board/snappy/board.h
+++ b/board/snappy/board.h
@@ -88,6 +88,7 @@
#define CONFIG_USB_PD_PORT_COUNT 2
#define CONFIG_USB_PD_QUIRK_SLOW_CC_STATUS
#define CONFIG_USB_PD_VBUS_DETECT_CHARGER
+#define CONFIG_USB_PD_TCPC_LOW_POWER
#define CONFIG_USB_PD_TCPC_FW_VERSION
#define CONFIG_USB_PD_TCPM_MUX /* for both PS8751 and ANX3429 */
#define CONFIG_USB_PD_TCPM_ANX74XX
diff --git a/board/snappy/gpio.inc b/board/snappy/gpio.inc
index 9cd800c5d0..e2f2c13211 100644
--- a/board/snappy/gpio.inc
+++ b/board/snappy/gpio.inc
@@ -17,6 +17,8 @@ GPIO_INT(CHARGER_INT_L, PIN(3, 3), GPIO_INT_FALLING, bd9995x_vbus_interrupt) /
GPIO_INT(USB_C0_PD_INT_ODL, PIN(3, 7), GPIO_INT_FALLING, tcpc_alert_event) /* from Analogix TCPC */
GPIO_INT(USB_C1_PD_INT_ODL, PIN(B, 1), GPIO_INT_FALLING | GPIO_PULL_UP, tcpc_alert_event) /* from Parade TCPC */
+GPIO_INT(USB_C0_CABLE_DET, PIN(C, 5), GPIO_INT_RISING, anx74xx_cable_det_interrupt) /* CABLE_DET from ANX3429 */
+
GPIO_INT(PCH_SLP_S4_L, PIN(8, 6), GPIO_INT_BOTH, power_signal_interrupt) /* SLP_S4_L */
GPIO_INT(PCH_SLP_S3_L, PIN(7, 3), GPIO_INT_BOTH, power_signal_interrupt) /* SLP_S3_L */
GPIO_INT(PCH_SLP_S0_L, PIN(7, 5), GPIO_INT_BOTH, power_signal_interrupt) /* SLP_S0_L */
@@ -76,13 +78,6 @@ GPIO(CCD_MODE_ODL, PIN(6, 3), GPIO_INPUT)
GPIO(EC_HAVEN_RESET_ODL, PIN(0, 2), GPIO_ODR_HIGH)
GPIO(ENTERING_RW, PIN(7, 6), GPIO_OUTPUT) /* EC_ENTERING_RW */
-/*
- * FIXME(dhendrix): Should this be an interrupt? It's a normal input on elm.
- * ANX72xx programming guide section 6 suggests it should interrupt on both
- * high and low edges and we should use it to set PWR_EN and RESET_N pins.
- */
-GPIO(USB_C0_CABLE_DET, PIN(C, 5), GPIO_INPUT)
-
GPIO(PCH_RSMRST_L, PIN(7, 0), GPIO_OUT_LOW)
GPIO(EC_BATT_PRES_L, PIN(3, 4), GPIO_INPUT)
GPIO(PMIC_EN, PIN(8, 5), GPIO_OUT_LOW)