From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Prashant Malani <pmalani@chromium.org>
Cc: linux-kernel@vger.kernel.org,
Azhar Shaikh <azhar.shaikh@intel.com>,
Casey Bowman <casey.g.bowman@intel.com>,
Benson Leung <bleung@chromium.org>,
Enric Balletbo i Serra <enric.balletbo@collabora.com>,
Guenter Roeck <groeck@chromium.org>,
Lee Jones <lee.jones@linaro.org>, Mark Brown <broonie@kernel.org>,
Tzung-Bi Shih <tzungbi@google.com>,
Yicheng Li <yichengli@chromium.org>
Subject: Re: [PATCH 2/2] platform/chrome: cros_ec_typec: Add TBT compat support
Date: Wed, 24 Jun 2020 12:15:20 +0300 [thread overview]
Message-ID: <20200624091520.GA1487@kuha.fi.intel.com> (raw)
In-Reply-To: <20200624080926.165107-2-pmalani@chromium.org>
[-- Attachment #1: Type: text/plain, Size: 741 bytes --]
On Wed, Jun 24, 2020 at 01:09:24AM -0700, Prashant Malani wrote:
> Add mux control support for Thunderbolt compatibility mode.
>
> Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Co-developed-by: Azhar Shaikh <azhar.shaikh@intel.com>
> Co-developed-by: Casey Bowman <casey.g.bowman@intel.com>
> Signed-off-by: Prashant Malani <pmalani@chromium.org>
> ---
> drivers/platform/chrome/cros_ec_typec.c | 70 ++++++++++++++++++++++++-
> 1 file changed, 69 insertions(+), 1 deletion(-)
Cool! Can you guys test also USB4 with the attached patch (still work
in progress)? It should apply on top of these.
The mux driver is still missing USB4 support, but I'll send the
patches needed for that right now...
thanks,
--
heikki
[-- Attachment #2: 0001-platform-chrome-typec-USB4-support.patch --]
[-- Type: text/plain, Size: 2873 bytes --]
From cdc5d9528c4f751d856dfc1781f125a767a5de20 Mon Sep 17 00:00:00 2001
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Date: Tue, 23 Jun 2020 15:53:02 +0300
Subject: [PATCH] platform/chrome: typec: USB4 support
With USB4 the mux driver needs the Enter_USB VDO.
Constructing one from the information we have.
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
drivers/platform/chrome/cros_ec_typec.c | 39 ++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index 688d12efe9c42..c6448485ddfa3 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -13,6 +13,7 @@
#include <linux/platform_data/cros_ec_proto.h>
#include <linux/platform_data/cros_usbpd_notify.h>
#include <linux/platform_device.h>
+#include <linux/usb/pd.h>
#include <linux/usb/typec.h>
#include <linux/usb/typec_altmode.h>
#include <linux/usb/typec_dp.h>
@@ -511,6 +512,40 @@ static int cros_typec_enable_tbt(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];
+ u32 eudo;
+
+ eudo = EUDO_USB_MODE_USB4 << EUDO_USB_MODE_SHIFT;
+
+ /* Cable Speed */
+ eudo |= pd_ctrl->cable_speed << EUDO_CABLE_SPEED_SHIFT;
+
+ /* Cable Type */
+ if (pd_ctrl->control_flags & USB_PD_CTRL_OPTICAL_CABLE)
+ eudo |= EUDO_CABLE_TYPE_OPTICAL << EUDO_CABLE_TYPE_SHIFT;
+ else if (pd_ctrl->control_flags & USB_PD_CTRL_ACTIVE_CABLE)
+ eudo |= EUDO_CABLE_TYPE_RE_TIMER << EUDO_CABLE_TYPE_SHIFT;
+
+ /* FIXME: Cable Current */
+
+ /* REVISIT: Claiming unconditionally that all tunnels are supported. */
+ eudo |= EUDO_PCIE_SUPPORT;
+ eudo |= EUDO_DP_SUPPORT;
+
+ eudo |= EUDO_TBT_SUPPORT;
+ eudo |= EUDO_HOST_PRESENT;
+
+ port->state.alt = NULL;
+ port->state.data = &eudo;
+ port->state.mode = TYPEC_MODE_USB4;
+
+ return typec_mux_set(port->mux, &port->state);
+}
+
int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num,
struct ec_response_usb_pd_mux_info *resp,
struct ec_response_usb_pd_control_v2 *pd_ctrl)
@@ -534,7 +569,9 @@ int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num,
port->state.alt = NULL;
port->state.mode = TYPEC_STATE_USB;
- if (resp->flags & USB_PD_MUX_TBT_COMPAT_ENABLED)
+ if (resp->flags & USB_PD_MUX_USB4_ENABLED)
+ ret = cros_typec_enable_usb4(typec, port_num, pd_ctrl);
+ else if (resp->flags & USB_PD_MUX_TBT_COMPAT_ENABLED)
ret = cros_typec_enable_tbt(typec, port_num, pd_ctrl);
else if (resp->flags & USB_PD_MUX_DP_ENABLED)
ret = cros_typec_enable_dp(typec, port_num, pd_ctrl);
--
2.27.0
next prev parent reply other threads:[~2020-06-24 9:15 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-24 8:09 [PATCH 1/2] platform/chrome: cros_ec_typec: Add TBT pd_ctrl fields Prashant Malani
2020-06-24 8:09 ` [PATCH 2/2] platform/chrome: cros_ec_typec: Add TBT compat support Prashant Malani
2020-06-24 9:15 ` Heikki Krogerus [this message]
2020-06-24 9:20 ` Heikki Krogerus
2020-06-24 17:42 ` Prashant Malani
2020-06-25 7:45 ` Heikki Krogerus
2020-06-26 9:10 ` [PATCH 1/2] platform/chrome: cros_ec_typec: Add TBT pd_ctrl fields Enric Balletbo i Serra
2020-06-26 19:04 ` Prashant Malani
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200624091520.GA1487@kuha.fi.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=azhar.shaikh@intel.com \
--cc=bleung@chromium.org \
--cc=broonie@kernel.org \
--cc=casey.g.bowman@intel.com \
--cc=enric.balletbo@collabora.com \
--cc=groeck@chromium.org \
--cc=lee.jones@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pmalani@chromium.org \
--cc=tzungbi@google.com \
--cc=yichengli@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox