summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWai-Hong Tam <waihong@google.com>2018-11-28 11:06:53 -0800
committerchrome-bot <chrome-bot@chromium.org>2018-12-06 22:06:29 -0800
commitde2442d5ea70c5fd70a1ebec86d6d23146fb92a6 (patch)
treeab052daf8e14cdfd8fe86b4adb6c79376bba86e7
parent5838aa7bb6edfb7cc02d08f35f22dd3783d4013e (diff)
downloadchrome-ec-de2442d5ea70c5fd70a1ebec86d6d23146fb92a6.tar.gz
cheza: Only one port can mux its DisplayPort lines
This is the limitation of the SoC, only one port can be its DisplayPort line at a time. When a HPD happens, it checks if other port is already muxed the DisplayPort lines. It also configures the GPIO for enabling the port 1 redriver. BRANCH=none BUG=b:120142369 TEST=Plugged HDMI cable to a dongle to port 0, checked muxed to DP and correct GPIO setting; then plugged HDMI cable to a dongle to port 1, checked the port 1 not muxed to DP. Swapped the ports and did the same check. Change-Id: I06271b293f83250fb36b6958e09c8fb81e7122bc Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/1354301 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--board/cheza/usb_pd_policy.c34
1 files changed, 32 insertions, 2 deletions
diff --git a/board/cheza/usb_pd_policy.c b/board/cheza/usb_pd_policy.c
index 1344bc9b1b..5f5e707819 100644
--- a/board/cheza/usb_pd_policy.c
+++ b/board/cheza/usb_pd_policy.c
@@ -329,6 +329,29 @@ static void svdm_dp_post_config(int port)
dp_flags[port] |= DP_FLAGS_DP_ON;
}
+/**
+ * Is the port fine to be muxed its DisplayPort lines?
+ *
+ * Only one port can be muxed to DisplayPort at a time.
+ *
+ * @param port Port number of TCPC.
+ * @return 1 is fine; 0 is bad as other port is already muxed;
+ */
+static int is_dp_muxable(int port)
+{
+ int i;
+ const char *dp_str, *usb_str;
+
+ for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++)
+ if (i != port) {
+ usb_mux_get(i, &dp_str, &usb_str);
+ if (dp_str)
+ return 0;
+ }
+
+ return 1;
+}
+
static int svdm_dp_attention(int port, uint32_t *payload)
{
int lvl = PD_VDO_DPSTS_HPD_LVL(payload[1]);
@@ -340,12 +363,19 @@ static int svdm_dp_attention(int port, uint32_t *payload)
mux->hpd_update(port, lvl, irq);
- if (lvl)
+ if (lvl && is_dp_muxable(port)) {
+ /*
+ * The GPIO USBC_MUX_CONF1 enables the mux of the DP redriver
+ * for the port 1.
+ */
+ gpio_set_level(GPIO_USBC_MUX_CONF1, port == 1);
+
usb_mux_set(port, mf_pref ? TYPEC_MUX_DOCK : TYPEC_MUX_DP,
USB_SWITCH_CONNECT, pd_get_polarity(port));
- else
+ } else {
usb_mux_set(port, mf_pref ? TYPEC_MUX_USB : TYPEC_MUX_NONE,
USB_SWITCH_CONNECT, pd_get_polarity(port));
+ }
/* ack */
return 1;