Skip to content

Commit f31b270

Browse files
p9nCommit Bot
authored andcommitted
corsola: delay the timing to enter DP mode
Corsola uses USB_PD_MUX_DP_ENABLED flag to select DP path, so we have to delay the USB_PD_MUX_DP_ENABLED flag toggle until attention is received. BUG=b:223087778 TEST=See DP=1 only when connected to display. No "The other port is already muxed" error BRANCH=none Signed-off-by: Ting Shen <[email protected]> Change-Id: I3563c818829407c1387016f7a7517f877b648283 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3534748 Reviewed-by: Eric Yilun Lin <[email protected]> Commit-Queue: Ting Shen <[email protected]> Tested-by: Ting Shen <[email protected]>
1 parent 6fab774 commit f31b270

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

zephyr/projects/corsola/src/usb_pd_policy.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,40 @@ void svdm_set_hpd_gpio(int port, int en)
4242
gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ec_ap_dp_hpd_odl), !en);
4343
}
4444

45+
__override int svdm_dp_config(int port, uint32_t *payload)
46+
{
47+
int opos = pd_alt_mode(port, TCPCI_MSG_SOP, USB_SID_DISPLAYPORT);
48+
uint8_t pin_mode = get_dp_pin_mode(port);
49+
mux_state_t mux_mode = svdm_dp_get_mux_mode(port);
50+
int mf_pref = PD_VDO_DPSTS_MF_PREF(dp_status[port]);
51+
52+
if (!pin_mode)
53+
return 0;
54+
55+
CPRINTS("pin_mode: %x, mf: %d, mux: %d", pin_mode, mf_pref, mux_mode);
56+
/*
57+
* Defer setting the usb_mux until HPD goes high, svdm_dp_attention().
58+
* The AP only supports one DP phy. An external DP mux switches between
59+
* the two ports. Should switch those muxes when it is really used,
60+
* i.e. HPD high; otherwise, the real use case is preempted, like:
61+
* (1) plug a dongle without monitor connected to port-0,
62+
* (2) plug a dongle without monitor connected to port-1,
63+
* (3) plug a monitor to the port-1 dongle.
64+
*/
65+
66+
payload[0] = VDO(USB_SID_DISPLAYPORT, 1,
67+
CMD_DP_CONFIG | VDO_OPOS(opos));
68+
payload[1] = VDO_DP_CFG(pin_mode, /* pin mode */
69+
1, /* DPv1.3 signaling */
70+
2); /* UFP connected */
71+
return 2;
72+
};
73+
74+
__override void svdm_dp_post_config(int port)
75+
{
76+
dp_flags[port] |= DP_FLAGS_DP_ON;
77+
}
78+
4579
int corsola_is_dp_muxable(int port)
4680
{
4781
int i;
@@ -76,6 +110,14 @@ __override int svdm_dp_attention(int port, uint32_t *payload)
76110
if (lvl) {
77111
gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(dp_aux_path_sel), port);
78112
CPRINTS("Set DP_AUX_PATH_SEL: %d", port);
113+
114+
usb_mux_set(port, USB_PD_MUX_DOCK,
115+
USB_SWITCH_CONNECT,
116+
polarity_rm_dts(pd_get_polarity(port)));
117+
} else {
118+
usb_mux_set(port, USB_PD_MUX_USB_ENABLED,
119+
USB_SWITCH_CONNECT,
120+
polarity_rm_dts(pd_get_polarity(port)));
79121
}
80122

81123
if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND) &&

0 commit comments

Comments
 (0)