diff options
author | Scott <scollyer@chromium.org> | 2017-02-17 11:31:01 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-02-20 14:28:02 -0800 |
commit | a3f152f1b2e9fcd00c7871cc44285cba554ae966 (patch) | |
tree | 432035051905e5c5a69c7809977b56f731bb3f28 /board/eve | |
parent | 318a863ad5451d0f223625aa6841a0afb5357219 (diff) | |
download | chrome-ec-a3f152f1b2e9fcd00c7871cc44285cba554ae966.tar.gz |
eve: Add support for anx3429 tcpc low power mode
Added interrupt handler for CABLE_DET signal on both port 0/1. This
allows us to define CONFIG_USB_PD_TCPC_LOW_POWER.
BUG=chrome-os-partner:63067
BRANCH=none
TEST=Connected USB mouse, keyboard and USB stick to both ports and
verified the devices were recognized and attached properly. Verified
that ports 0/1 always worked with blackcat typeC charger.
Change-Id: I4d8a8bdba4f95e73333e2e01f11fe1d48453a2fe
Signed-off-by: Scott <scollyer@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/444315
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Duncan Laurie <dlaurie@google.com>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Diffstat (limited to 'board/eve')
-rw-r--r-- | board/eve/board.c | 61 | ||||
-rw-r--r-- | board/eve/board.h | 1 | ||||
-rw-r--r-- | board/eve/gpio.inc | 4 |
3 files changed, 64 insertions, 2 deletions
diff --git a/board/eve/board.c b/board/eve/board.c index 50190f0fba..5a11f21241 100644 --- a/board/eve/board.c +++ b/board/eve/board.c @@ -85,6 +85,61 @@ void tablet_mode_interrupt(enum gpio_signal signal) hook_call_deferred(&enable_input_devices_data, LID_DEBOUNCE_US); } +#ifdef CONFIG_USB_PD_TCPC_LOW_POWER +static void anx74xx_c0_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(I2C_PORT_TCPC0, + 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_c0_cable_det_handler); +DECLARE_HOOK(HOOK_CHIPSET_RESUME, anx74xx_c0_cable_det_handler, HOOK_PRIO_LAST); + +static void anx74xx_c1_cable_det_handler(void) +{ + int level = gpio_get_level(GPIO_USB_C1_CABLE_DET); + + /* + * Setting the low power is handled by DRP status hence + * handle only the attach event. + */ + if (level) + anx74xx_handle_power_mode(I2C_PORT_TCPC1, + ANX74XX_NORMAL_MODE); + + /* confirm if cable_det is asserted */ + if (!level || gpio_get_level(GPIO_USB_C1_PD_RST_L)) + return; + + task_set_event(TASK_ID_PD_C1, PD_EVENT_TCPC_RESET, 0); +} +DECLARE_DEFERRED(anx74xx_c1_cable_det_handler); +DECLARE_HOOK(HOOK_CHIPSET_RESUME, anx74xx_c1_cable_det_handler, HOOK_PRIO_LAST); + +void anx74xx_cable_det_interrupt(enum gpio_signal signal) +{ + /* Check if it is port 0 or 1, and debounce for 2 msec. */ + if (signal == GPIO_USB_C0_CABLE_DET) + hook_call_deferred(&anx74xx_c0_cable_det_handler_data, + (2 * MSEC)); + else + hook_call_deferred(&anx74xx_c1_cable_det_handler_data, + (2 * MSEC)); +} +#endif + #include "gpio_list.h" /* power signal list. Must match order of enum power_signal. */ @@ -221,6 +276,12 @@ void board_tcpc_init(void) gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL); 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); + gpio_enable_interrupt(GPIO_USB_C1_CABLE_DET); +#endif + /* * Initialize HPD to low; after sysjump SOC needs to see * HPD pulse to enable video path diff --git a/board/eve/board.h b/board/eve/board.h index b69d3c78b9..0e9b325d4a 100644 --- a/board/eve/board.h +++ b/board/eve/board.h @@ -151,6 +151,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_TCPM_MUX #define CONFIG_USB_PD_TCPM_ANX74XX #define CONFIG_USB_PD_TCPM_TCPCI diff --git a/board/eve/gpio.inc b/board/eve/gpio.inc index f53ca43ce6..87fc3b3929 100644 --- a/board/eve/gpio.inc +++ b/board/eve/gpio.inc @@ -23,6 +23,8 @@ GPIO_INT(VOLUME_UP_L, PIN(8, 2), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt GPIO_INT(WP_L, PIN(4, 0), GPIO_INT_BOTH, switch_interrupt) GPIO_INT(AC_PRESENT, PIN(C, 1), GPIO_INT_BOTH, extpower_interrupt) GPIO_INT(ACCELGYRO3_INT_L, PIN(9, 3), GPIO_INT_FALLING, bmi160_interrupt) +GPIO_INT(USB_C0_CABLE_DET, PIN(D, 2), GPIO_INT_RISING, anx74xx_cable_det_interrupt) +GPIO_INT(USB_C1_CABLE_DET, PIN(D, 3), GPIO_INT_RISING, anx74xx_cable_det_interrupt) /* Lid KCJX9 accelerometer sensor interrupt */ GPIO(ACCEL1_INT_L, PIN(C, 7), GPIO_INPUT | GPIO_PULL_UP) @@ -66,8 +68,6 @@ GPIO(DSP_WAKE_L, PIN(C, 6), GPIO_INPUT | GPIO_SEL_1P8V) /* INT# from DSP Mic * /* 5V enables: INPUT=1.5A, OUT_LOW=OFF, OUT_HIGH=3A */ GPIO(USB_C0_5V_EN, PIN(4, 2), GPIO_OUT_LOW | GPIO_PULL_UP) /* C0 5V Enable */ GPIO(USB_C1_5V_EN, PIN(B, 1), GPIO_OUT_LOW | GPIO_PULL_UP) /* C1 5V Enable */ -GPIO(USB_C0_CABLE_DET, PIN(D, 2), GPIO_INPUT) /* C0 Cable Detect */ -GPIO(USB_C1_CABLE_DET, PIN(D, 3), GPIO_INPUT) /* C1 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 */ |