summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@google.com>2017-02-16 18:05:14 +0800
committerchrome-bot <chrome-bot@chromium.org>2017-02-17 04:09:37 -0800
commitcb6e3ec3a0db005e62c94e3d8b667d4ef4a2d8d9 (patch)
tree4c74a103ebe2e72bc07e8637a04d00b12e7d5e50
parent887298ba503ec80011ec35f761cd752b0e2f0b7a (diff)
downloadchrome-ec-cb6e3ec3a0db005e62c94e3d8b667d4ef4a2d8d9.tar.gz
poppy: Add ANX3429 cable detection handling
Enable CONFIG_USB_PD_TCPC_LOW_POWER, and add cable detection handling. BRANCH=none BUG=chrome-os-partner:62964 TEST=on poppy, connect USB-A keyboard to ANX port via A-C adapter: keyboard works; charging works Change-Id: I0751cc7b5fc8ba71388f08b7001c0daceda37bb6 Reviewed-on: https://chromium-review.googlesource.com/443747 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--board/poppy/board.c29
-rw-r--r--board/poppy/board.h1
-rw-r--r--board/poppy/gpio.inc2
3 files changed, 31 insertions, 1 deletions
diff --git a/board/poppy/board.c b/board/poppy/board.c
index d17566415a..bb29baaea3 100644
--- a/board/poppy/board.c
+++ b/board/poppy/board.c
@@ -93,6 +93,35 @@ void usb1_evt(enum gpio_signal signal)
task_set_event(TASK_ID_USB_CHG_P1, USB_CHG_EVENT_BC12, 0);
}
+#ifdef CONFIG_USB_PD_TCPC_LOW_POWER
+static void anx74xx_cable_det_handler(void)
+{
+ int level = gpio_get_level(GPIO_USB_C0_CABLE_DET);
+
+ /*
+ * Setting the low power is handled by DRP status hence
+ * handle only the attach event.
+ */
+ if (level)
+ anx74xx_handle_power_mode(NPCX_I2C_PORT0_0,
+ ANX74XX_NORMAL_MODE);
+
+ /* confirm if cable_det is asserted */
+ if (!level || 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
+
/*
* Base detection and debouncing
*
diff --git a/board/poppy/board.h b/board/poppy/board.h
index 8a5b82d35e..8151705a65 100644
--- a/board/poppy/board.h
+++ b/board/poppy/board.h
@@ -124,6 +124,7 @@
#define CONFIG_USB_PD_PORT_COUNT 2
#define CONFIG_USB_PD_QUIRK_SLOW_CC_STATUS
#define CONFIG_USB_PD_VBUS_DETECT_GPIO
+#define CONFIG_USB_PD_TCPC_LOW_POWER
#define CONFIG_USB_PD_TCPM_MUX
#define CONFIG_USB_PD_TCPM_ANX74XX
#define CONFIG_USB_PD_TCPM_TCPCI
diff --git a/board/poppy/gpio.inc b/board/poppy/gpio.inc
index c3d6a34e51..01cb09b7cb 100644
--- a/board/poppy/gpio.inc
+++ b/board/poppy/gpio.inc
@@ -31,6 +31,7 @@ GPIO_INT(USB_C0_BC12_INT_L, PIN(D, 3), GPIO_INT_FALLING, usb0_evt)
GPIO_INT(USB_C1_BC12_INT_L, PIN(3, 3), GPIO_INT_FALLING, usb1_evt)
GPIO_INT(ACCELGYRO3_INT_L, PIN(3, 0), GPIO_INT_FALLING, bmi160_interrupt)
GPIO_INT(BASE_DET_A, PIN(4, 5), GPIO_INT_BOTH, base_detect_interrupt)
+GPIO_INT(USB_C0_CABLE_DET, PIN(D, 2), GPIO_INT_RISING, anx74xx_cable_det_interrupt)
GPIO(PCH_RTCRST, PIN(E, 7), GPIO_OUT_LOW) /* RTCRST# to SOC */
GPIO(ENABLE_BACKLIGHT, PIN(2, 6), GPIO_OUT_LOW) /* Enable Backlight */
@@ -89,7 +90,6 @@ GPIO(USB_C0_5V_EN, PIN(4, 2), GPIO_OUT_LOW) /* C0 5V Enable */
GPIO(USB_C0_CHARGE_L, PIN(C, 0), GPIO_OUT_LOW) /* C0 Charge enable */
GPIO(USB_C1_5V_EN, PIN(B, 1), GPIO_OUT_LOW) /* C1 5V Enable */
GPIO(USB_C1_CHARGE_L, PIN(C, 3), GPIO_OUT_LOW) /* C1 Charge enable */
-GPIO(USB_C0_CABLE_DET, PIN(D, 2), GPIO_INPUT) /* C0 Cable Detect */
GPIO(USB_C0_PD_RST_L, PIN(0, 3), GPIO_OUT_LOW) /* C0 PD Reset */
GPIO(USB_C1_PD_RST_L, PIN(7, 4), GPIO_OUT_LOW) /* C1 PD Reset */
GPIO(USB_C0_DP_HPD, PIN(9, 4), GPIO_INPUT) /* C0 DP Hotplug Detect */