diff options
-rw-r--r-- | board/elm/board.c | 73 | ||||
-rw-r--r-- | board/elm/gpio.inc | 2 | ||||
-rw-r--r-- | board/elm/usb_pd_policy.c | 8 |
3 files changed, 2 insertions, 81 deletions
diff --git a/board/elm/board.c b/board/elm/board.c index a1bf08f3e9..9394acea09 100644 --- a/board/elm/board.c +++ b/board/elm/board.c @@ -167,12 +167,6 @@ struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { }; /** - * Store the current DP hardware route. - */ -static int dp_hw_port = PD_PORT_NONE; -static struct mutex dp_hw_lock; - -/** * Reset PD MCU * ANX7688 needs a reset pulse of 50ms after power enable. */ @@ -338,73 +332,6 @@ int board_get_ramp_current_limit(int supplier, int sup_curr) } } -static void board_typec_set_dp_hpd(int port, int level) -{ - gpio_set_level(GPIO_USB_DP_HPD, level); -} - -static void hpd_irq_deferred(void) -{ - board_typec_set_dp_hpd(dp_hw_port, 1); -} -DECLARE_DEFERRED(hpd_irq_deferred); - -/** - * Turn on DP hardware on type-C port. - */ -void board_typec_dp_on(int port) -{ - mutex_lock(&dp_hw_lock); - - if (dp_hw_port != !port) { - /* Get control of DP hardware */ - dp_hw_port = port; - if (!gpio_get_level(GPIO_USB_DP_HPD)) { - board_typec_set_dp_hpd(port, 1); - } else { - board_typec_set_dp_hpd(port, 0); - hook_call_deferred(&hpd_irq_deferred_data, - HPD_DSTREAM_DEBOUNCE_IRQ); - } - } - - mutex_unlock(&dp_hw_lock); -} - -/** - * Turn off a PD port's DP output. - */ -void board_typec_dp_off(int port, int *dp_flags) -{ - mutex_lock(&dp_hw_lock); - - if (dp_hw_port == !port) { - mutex_unlock(&dp_hw_lock); - return; - } - - dp_hw_port = PD_PORT_NONE; - board_typec_set_dp_hpd(port, 0); - - mutex_unlock(&dp_hw_lock); -} - -/** - * Set DP hotplug detect level. - */ -void board_typec_dp_set(int port, int level) -{ - mutex_lock(&dp_hw_lock); - - if (dp_hw_port == PD_PORT_NONE) - dp_hw_port = port; - - if (dp_hw_port == port) - board_typec_set_dp_hpd(port, level); - - mutex_unlock(&dp_hw_lock); -} - /** * Set AP reset. * AP_RESET_L (PC3, CPU_WARM_RESET_L) is connected to PMIC SYSRSTB diff --git a/board/elm/gpio.inc b/board/elm/gpio.inc index dda09cc6e1..00e406dd09 100644 --- a/board/elm/gpio.inc +++ b/board/elm/gpio.inc @@ -82,7 +82,7 @@ GPIO(USB_C0_CHARGE_L, PIN(D, 9), GPIO_OUT_LOW) /* USBC port 0 charge */ GPIO(USB_C0_RST, PIN(D, 10), GPIO_OUT_LOW) /* ANX7688 reset */ GPIO(USB_C0_PWR_EN_L, PIN(B, 15), GPIO_OUT_LOW) /* ANX7688 power enable */ GPIO(USB_C0_EXTPWR_EN, PIN(F, 2), GPIO_OUT_HIGH) /* ANX7688 3.3V ext power enable */ -GPIO(USB_DP_HPD, PIN(F, 3), GPIO_OUT_LOW) +GPIO(USB_DP_HPD, PIN(F, 3), GPIO_INPUT) GPIO(EN_TP_INT_L, PIN(E, 14), GPIO_OUT_LOW) /* touchpad interrupt enable */ /* Analog pins */ diff --git a/board/elm/usb_pd_policy.c b/board/elm/usb_pd_policy.c index b68c532496..adfd814a6f 100644 --- a/board/elm/usb_pd_policy.c +++ b/board/elm/usb_pd_policy.c @@ -292,7 +292,6 @@ static void svdm_dp_post_config(int port) dp_flags[port] |= DP_FLAGS_DP_ON; if (!(dp_flags[port] & DP_FLAGS_HPD_HI_PENDING)) return; - board_typec_dp_set(port, 1); } static int svdm_dp_attention(int port, uint32_t *payload) @@ -312,13 +311,9 @@ static int svdm_dp_attention(int port, uint32_t *payload) return ack; } - if (irq & cur_lvl) { - board_typec_dp_on(port); - } else if (irq & !cur_lvl) { + if (!(irq & cur_lvl) && irq & !cur_lvl) { CPRINTF("ERR:HPD:IRQ&LOW\n"); ack = 0; /* nak */ - } else { - board_typec_dp_set(port, lvl); } /* ack */ return ack; @@ -327,7 +322,6 @@ static int svdm_dp_attention(int port, uint32_t *payload) static void svdm_exit_dp_mode(int port) { svdm_safe_dp_mode(port); - board_typec_dp_off(port, dp_flags); } static int svdm_enter_gfu_mode(int port, uint32_t mode_caps) |