Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1576271pxk; Tue, 1 Sep 2020 02:10:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4dtY6JlNY7F1JYBSsfrX3NaDP3Z6SkrL6Hhhh19Z3BQkt2SldFyEg4HsWt7JQ3grV4ZRu X-Received: by 2002:aa7:d959:: with SMTP id l25mr834133eds.383.1598951403935; Tue, 01 Sep 2020 02:10:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598951403; cv=none; d=google.com; s=arc-20160816; b=GZgRSgfdd5m3TTPpSlH6GTBBomRP9j4S1FiwHJaZCrp5lTckhiHLWp3mXik4VJ2Pms 8rhdldbMrfOfqMR0Bf9OI9rZEa4VNHN9g7Zh936+EgHbLA+SVUIvv0xGoIBaxll11YDf AghObSUP2z9bv3RgeCVF1quOC9eKV1n2cXgp+NQG+IZ/Un90xsY9BKheDVglJRBbV8Od moFDpYYi2ww0HTPucodDcQbNJcRLfZCswRZaprVNR68oCNa4gZbBgAZmGqJ7RiaEbBg8 SO61X//zctuitxdNCuVCMuyjdGwDlJEZFvyRVkCQkLEzZg9WbvjMld3DEWAY/qPQje4X 53wg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=Ho3jgMxuRT8Og78AHL9p4VT+f39KnAZzVyXLRDjhOZE=; b=UiGEeJ/w/ukmAjQSPrXRhaUjws7aQF3u9Rzp1NwBHXOiTF1PGXZAwM8ui6cou0Ezo1 rPOvnKNY3iKvLdDfFEwtAr37DxwVxXjsE8tMczdFFip348X84kNfJt7F8AJCYceFTjIw IokYJlablxcLXkujJvPVLUVQduDpvyeGz1pHL5xLQT/+9RVV7D21hxJKpmUIgzovLbsF GQP7f0XhtRLM9c31MTqLW5gJsCd6KATsz13Jy1CIRzDNR8tzIFdz/ujFCdKSS1wJHPGk Q7pz674h6+NdaJRM/QLAeexwBUZqQ12opYakFlmossxf8tHal3L/t6VTjy5qeQvFkflz uvdw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i2si333220eja.141.2020.09.01.02.09.41; Tue, 01 Sep 2020 02:10: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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726193AbgIAJIl (ORCPT + 99 others); Tue, 1 Sep 2020 05:08:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725848AbgIAJIl (ORCPT ); Tue, 1 Sep 2020 05:08:41 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD349C061244 for ; Tue, 1 Sep 2020 02:08:40 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id 7804A2993BC Subject: Re: [PATCH v2] platform/chrome: cros_ec_typec: USB4 support To: Prashant Malani , linux-kernel@vger.kernel.org Cc: rajmohan.mani@intel.com, Heikki Krogerus , Benson Leung , Guenter Roeck References: <20200710194017.1126000-1-pmalani@chromium.org> From: Enric Balletbo i Serra Message-ID: <7c539d28-d1aa-4f4b-ebc4-f92ef3af93d6@collabora.com> Date: Tue, 1 Sep 2020 11:08:33 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <20200710194017.1126000-1-pmalani@chromium.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Prashant and Heikki, On 10/7/20 21:40, Prashant Malani wrote: > 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 > --- > Applied for 5.10. Thanks, Enric > 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); >