summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWai-Hong Tam <waihong@google.com>2020-11-13 11:02:05 -0800
committerCommit Bot <commit-bot@chromium.org>2020-11-18 23:40:37 +0000
commit0e4740eaaac3e434120447e1913badfeca6cfa1a (patch)
tree4a0bc048e61e392c503415b34c3186fca22bfce4
parentfac6e6f768d6525bf048d32d8e7a8a6c0c29c289 (diff)
downloadchrome-ec-0e4740eaaac3e434120447e1913badfeca6cfa1a.tar.gz
Trogdor: Ignore HPD Low if the DP path can't be muxed
Only one DP path is allowed in the Trogdor design. If the DP path is occupied by another port, we ignored the HPD High but we forgot to ignore the HPD Low. We should ignore both HPD High and Low. When exit the DP alt-mode, also check if it is the correct path before clean up. BRANCH=None BUG=b:173213397 TEST=Plugged the 1st monitor to a port. Plugging the 2nd monitor to another port didn't affect the 1st monitor. Unplugging the 2nd monitor didn't affect the 1st monitor. Change-Id: Ice2ebc512239f062d22fa69befcaa39b9090c7db Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2537157 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--baseboard/trogdor/usb_pd_policy.c76
1 files changed, 39 insertions, 37 deletions
diff --git a/baseboard/trogdor/usb_pd_policy.c b/baseboard/trogdor/usb_pd_policy.c
index ba88236290..023922038a 100644
--- a/baseboard/trogdor/usb_pd_policy.c
+++ b/baseboard/trogdor/usb_pd_policy.c
@@ -158,6 +158,12 @@ __override int svdm_dp_attention(int port, uint32_t *payload)
dp_status[port] = payload[1];
+ if (!is_dp_muxable(port)) {
+ /* TODO(waihong): Info user? */
+ CPRINTS("p%d: The other port is already muxed.", port);
+ return 0;
+ }
+
/*
* Initial implementation to handle HPD. Only the first-plugged port
* works, i.e. sending HPD signal to AP. The second-plugged port
@@ -167,35 +173,29 @@ __override int svdm_dp_attention(int port, uint32_t *payload)
* is then unplugged, switch to the second-plugged port and signal AP?
*/
if (lvl) {
- if (is_dp_muxable(port)) {
- /*
- * Enable and switch the DP port selection mux to the
- * correct port.
- *
- * TODO(waihong): Better to move switching DP mux to
- * the usb_mux abstraction.
- */
- gpio_set_level(GPIO_DP_MUX_SEL, port == 1);
- gpio_set_level(GPIO_DP_MUX_OE_L, 0);
-
- /* Connect the SBU lines in PPC chip. */
- if (IS_ENABLED(CONFIG_USBC_PPC_SBU))
- ppc_set_sbu(port, 1);
-
- /*
- * Connect the USB SS/DP lines in TCPC chip.
- *
- * When mf_pref not true, still use the dock muxing
- * because of the board USB-C topology (limited to 2
- * lanes DP).
- */
- usb_mux_set(port, USB_PD_MUX_DOCK,
- USB_SWITCH_CONNECT, pd_get_polarity(port));
- } else {
- /* TODO(waihong): Info user? */
- CPRINTS("p%d: The other port is already muxed.", port);
- return 0; /* Nack */
- }
+ /*
+ * Enable and switch the DP port selection mux to the
+ * correct port.
+ *
+ * TODO(waihong): Better to move switching DP mux to
+ * the usb_mux abstraction.
+ */
+ gpio_set_level(GPIO_DP_MUX_SEL, port == 1);
+ gpio_set_level(GPIO_DP_MUX_OE_L, 0);
+
+ /* Connect the SBU lines in PPC chip. */
+ if (IS_ENABLED(CONFIG_USBC_PPC_SBU))
+ ppc_set_sbu(port, 1);
+
+ /*
+ * Connect the USB SS/DP lines in TCPC chip.
+ *
+ * When mf_pref not true, still use the dock muxing
+ * because of the board USB-C topology (limited to 2
+ * lanes DP).
+ */
+ usb_mux_set(port, USB_PD_MUX_DOCK,
+ USB_SWITCH_CONNECT, pd_get_polarity(port));
} else {
/* Disconnect the DP port selection mux. */
gpio_set_level(GPIO_DP_MUX_OE_L, 1);
@@ -238,7 +238,7 @@ __override int svdm_dp_attention(int port, uint32_t *payload)
HPD_USTREAM_DEBOUNCE_LVL;
} else if (irq & !lvl) {
CPRINTF("ERR:HPD:IRQ&LOW\n");
- return 0; /* Nak */
+ return 0;
} else {
gpio_set_level(hpd, lvl);
/* Set the minimum time delay (2ms) for the next HPD IRQ */
@@ -246,17 +246,19 @@ __override int svdm_dp_attention(int port, uint32_t *payload)
HPD_USTREAM_DEBOUNCE_LVL;
}
- return 1; /* Ack */
+ return 1;
}
__override void svdm_exit_dp_mode(int port)
{
- /* Disconnect the DP port selection mux. */
- gpio_set_level(GPIO_DP_MUX_OE_L, 1);
- gpio_set_level(GPIO_DP_MUX_SEL, 0);
+ if (is_dp_muxable(port)) {
+ /* Disconnect the DP port selection mux. */
+ gpio_set_level(GPIO_DP_MUX_OE_L, 1);
+ gpio_set_level(GPIO_DP_MUX_SEL, 0);
- /* Signal AP for the HPD low event */
- usb_mux_hpd_update(port, 0, 0);
- gpio_set_level(GPIO_DP_HOT_PLUG_DET, 0);
+ /* Signal AP for the HPD low event */
+ usb_mux_hpd_update(port, 0, 0);
+ gpio_set_level(GPIO_DP_HOT_PLUG_DET, 0);
+ }
}
#endif /* CONFIG_USB_PD_ALT_MODE_DFP */