summaryrefslogtreecommitdiff
path: root/board/nami/board.c
diff options
context:
space:
mode:
Diffstat (limited to 'board/nami/board.c')
-rw-r--r--board/nami/board.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/board/nami/board.c b/board/nami/board.c
index 58c9ba2628..9c3a179a08 100644
--- a/board/nami/board.c
+++ b/board/nami/board.c
@@ -997,6 +997,26 @@ void board_bc12_enable(void)
CPRINTS("BC12 enabled");
}
+static void anx7447_set_aux_switch(void)
+{
+ const int port = USB_PD_PORT_ANX7447;
+
+ /* Debounce */
+ if (gpio_get_level(GPIO_CCD_MODE_ODL))
+ return;
+
+ CPRINTS("C%d: AUX_SW_SEL=0x%x", port, 0xc);
+ if (tcpc_write(port, ANX7447_REG_TCPC_AUX_SWITCH, 0xc))
+ CPRINTS("C%d: Setting AUX_SW_SEL failed", port);
+}
+DECLARE_DEFERRED(anx7447_set_aux_switch);
+
+void ccd_mode_isr(enum gpio_signal signal)
+{
+ /* Wait 2 seconds until all mux setting is done by PD task */
+ hook_call_deferred(&anx7447_set_aux_switch_data, 2 * SECOND);
+}
+
static void board_init(void)
{
int reg;
@@ -1029,6 +1049,10 @@ static void board_init(void)
gpio_enable_interrupt(GPIO_USB_C0_BC12_INT_L);
gpio_enable_interrupt(GPIO_USB_C1_BC12_INT_L);
+ /* Trigger once to set mux in case CCD cable is already connected. */
+ ccd_mode_isr(GPIO_CCD_MODE_ODL);
+ gpio_enable_interrupt(GPIO_CCD_MODE_ODL);
+
/* Enable Accel/Gyro interrupt for convertibles. */
if (sku & SKU_ID_MASK_CONVERTIBLE)
gpio_enable_interrupt(GPIO_ACCELGYRO3_INT_L);