Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp798392ybt; Fri, 10 Jul 2020 12:41:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyoFwITBjYVpRMV6usCSqbv9T/CYEWOgR3/XxikF503+1yg4QbvJl94BX28zZLZHRTfG38R X-Received: by 2002:a05:6402:304a:: with SMTP id bu10mr6501385edb.70.1594410063100; Fri, 10 Jul 2020 12:41:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594410063; cv=none; d=google.com; s=arc-20160816; b=SdvfVahzObI9xReN/lZ+ezQyTzC5ZHwwMbLebR0GS21Dcmrry85QtNVPrLH0asGI3I a4+CVMQMKC2joa+TUTw7ub9BXQPS17OFcRXmUO7i4XFlNgKWTt4iLBTlEl1mvGkHbtvk iywILB066vRWj0NBCErKp3iKDOftt35CQMY0tVtqD4i341FbsdpyY6BSS+iLx7plhXtm Y/7dJO1xgkY0gdQJEwKVqln4y+cTRnD5oajUVLIq2tn8L1AAEa3fwC9WJbF0ToYxhYUo GifM2lkVYMguSUIu8xFgOosTzJeKtGn8SdTfMcxadcnBHUhTJe0db0RVQTCOGo/BtvC3 a0GA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=xViBTlv9cSoxxlcOtJ3GbtHVyweRCXfn0dWGulD2yKY=; b=NY4ZKM/m3HJ/94p8bXhysqadSisWCrGwg3MSgWbZApWOceddY91Cu3fBWEcd6tmiEW dINRXTgzOALXw92j0JXihoGlRIVZcUP6tgdUU0Qgu+GB2XB6GSRwzoQXYs/FcQlzAI/t RsFNhgItM3Kngix0yuotfQqYINjhopBpGNGL2pnyq2yBUwqLokFmp9/0csDVvcE7VfGh OedbY7enR0gR75moJ0Vxlkl7XpWckCf1gTryGoh/rZz1sSxlGWIYnAqsKUyDNWhjnuPy 35OWLv1lzlmFPCJqtmsUJ4BOWcnNi2i6MSJXRCzNAzged78s2Tpk0SS/bdJeCjh+86FU 40uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Dc5a20YR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r22si4623249edq.411.2020.07.10.12.40.38; Fri, 10 Jul 2020 12:41:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Dc5a20YR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728154AbgGJTka (ORCPT + 99 others); Fri, 10 Jul 2020 15:40:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726908AbgGJTka (ORCPT ); Fri, 10 Jul 2020 15:40:30 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C8DBC08C5DC for ; Fri, 10 Jul 2020 12:40:30 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id b92so3036178pjc.4 for ; Fri, 10 Jul 2020 12:40:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=xViBTlv9cSoxxlcOtJ3GbtHVyweRCXfn0dWGulD2yKY=; b=Dc5a20YRN25bSCamOxJU2/YZhDhvasjQGjQvtSknIWDQDKYJ2FtYiWNrgDIdpGG/TN /eHR8897jGCDqVU03FQ5/YKPC14TYaupxdXsKb0oQeWwI+9y/tHaddKW6JgWJO1DxYiw FnWkoxj/E7r52WCaRng9QkkE0AUbYNTtaKQLg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=xViBTlv9cSoxxlcOtJ3GbtHVyweRCXfn0dWGulD2yKY=; b=lrKdUihh5XjnGnroS5J++ZMWWda3P4nionrJKbucn+fomrPrhn7qw8fDDzQMojqJjN cCM4U499JOiBQj8fzlMAkIBL4ZmQ0ACBAHfTcrI7B93WyosWGZr/LMO4mw0dRzw4i93M iT0ZTdhMc5LopV+5mNVzUbpryQ/uMe9rVCd+f+HvLosb9SsXCjs6/ayPvqSi8AgXM8d0 +afJWlxytstzLNacWN561wworpu8WedWb6YWT3XQE0UOL9jKdTwgZcArHERxEFuwMYfQ Ppr31HrJU6ccSPGUbdfsPx/SHglM30dW+g+n+FdcLIo9nG/s5FPSGd063kGcgfBZI/R7 Gf9Q== X-Gm-Message-State: AOAM531XQMr1avc0HcJ3CgJljNyLKQF4Sw8hZKFF1zV+fgIHmy2pqG5B Fu2r0rt9B64OxwTwhjq2XJFzDqu0tAo= X-Received: by 2002:a17:902:6b45:: with SMTP id g5mr12137494plt.42.1594410029166; Fri, 10 Jul 2020 12:40:29 -0700 (PDT) Received: from pmalani2.mtv.corp.google.com ([100.99.132.145]) by smtp.gmail.com with ESMTPSA id m68sm6669845pje.24.2020.07.10.12.40.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jul 2020 12:40:28 -0700 (PDT) From: Prashant Malani To: linux-kernel@vger.kernel.org Cc: rajmohan.mani@intel.com, Heikki Krogerus , Prashant Malani , Benson Leung , Enric Balletbo i Serra , Guenter Roeck Subject: [PATCH v2] platform/chrome: cros_ec_typec: USB4 support Date: Fri, 10 Jul 2020 12:40:17 -0700 Message-Id: <20200710194017.1126000-1-pmalani@chromium.org> X-Mailer: git-send-email 2.27.0.383.g050319c2ae-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Heikki Krogerus With USB4 mode the mux driver needs the Enter_USB Data Object (EUDO) that was used when the USB mode was entered. Though the object is not available in the driver, it is possible to construct it from the information we have. Signed-off-by: Heikki Krogerus Signed-off-by: Prashant Malani --- This patch depends on latest usb-next from Greg KH, this commit in particular: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/commit/?h=usb-next&id=ad8db94d6813dc659bd4de0531a8a1150559eafb Changes in v2: - Removed EUDO bits for cable current and tunneling support. drivers/platform/chrome/cros_ec_typec.c | 33 ++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index 0c041b79cbba..a9700275a851 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -494,6 +495,34 @@ static int cros_typec_enable_dp(struct cros_typec_data *typec, return typec_mux_set(port->mux, &port->state); } +static int cros_typec_enable_usb4(struct cros_typec_data *typec, + int port_num, + struct ec_response_usb_pd_control_v2 *pd_ctrl) +{ + struct cros_typec_port *port = typec->ports[port_num]; + struct enter_usb_data data; + + data.eudo = EUDO_USB_MODE_USB4 << EUDO_USB_MODE_SHIFT; + + /* Cable Speed */ + data.eudo |= pd_ctrl->cable_speed << EUDO_CABLE_SPEED_SHIFT; + + /* Cable Type */ + if (pd_ctrl->control_flags & USB_PD_CTRL_OPTICAL_CABLE) + data.eudo |= EUDO_CABLE_TYPE_OPTICAL << EUDO_CABLE_TYPE_SHIFT; + else if (pd_ctrl->control_flags & USB_PD_CTRL_ACTIVE_CABLE) + data.eudo |= EUDO_CABLE_TYPE_RE_TIMER << EUDO_CABLE_TYPE_SHIFT; + + data.active_link_training = !!(pd_ctrl->control_flags & + USB_PD_CTRL_ACTIVE_LINK_UNIDIR); + + port->state.alt = NULL; + port->state.data = &data; + port->state.mode = TYPEC_MODE_USB4; + + return typec_mux_set(port->mux, &port->state); +} + static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num, uint8_t mux_flags, struct ec_response_usb_pd_control_v2 *pd_ctrl) @@ -514,7 +543,9 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num, if (ret) return ret; - if (mux_flags & USB_PD_MUX_TBT_COMPAT_ENABLED) { + if (mux_flags & USB_PD_MUX_USB4_ENABLED) { + ret = cros_typec_enable_usb4(typec, port_num, pd_ctrl); + } else if (mux_flags & USB_PD_MUX_TBT_COMPAT_ENABLED) { ret = cros_typec_enable_tbt(typec, port_num, pd_ctrl); } else if (mux_flags & USB_PD_MUX_DP_ENABLED) { ret = cros_typec_enable_dp(typec, port_num, pd_ctrl); -- 2.27.0.383.g050319c2ae-goog