* [PATCH] platform/chrome: cros_ec_typec: USB4 support
@ 2020-07-03 8:17 Heikki Krogerus
2020-07-06 22:16 ` Prashant Malani
2020-07-08 23:21 ` Prashant Malani
0 siblings, 2 replies; 3+ messages in thread
From: Heikki Krogerus @ 2020-07-03 8:17 UTC (permalink / raw)
To: Prashant Malani, Benson Leung
Cc: Enric Balletbo i Serra, Guenter Roeck, Mani, Rajmohan, linux-kernel
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 <heikki.krogerus@linux.intel.com>
---
Hi,
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
Prashant, can you take over the development of this patch (in case it
still needs work)? I will take a few weeks vacation starting from next
week (July 6th). I was hoping to get this feature into v5.9 if that's
possible. But if you guys think there is no hurry, let's forget about
it. Then we can just wait for 5.9-rc1 and not worry about the
dependency on Greg's usb-next.
thanks,
---
drivers/platform/chrome/cros_ec_typec.c | 42 ++++++++++++++++++++++++-
1 file changed, 41 insertions(+), 1 deletion(-)
diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index 0c041b79cbbac..c9713aab9b6b0 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>
@@ -494,6 +495,43 @@ 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;
+
+ /* REVISIT: Cable Current? */
+
+ /* REVISIT: Claiming unconditionally that all tunnels are supported. */
+ data.eudo |= EUDO_PCIE_SUPPORT;
+ data.eudo |= EUDO_DP_SUPPORT;
+
+ data.eudo |= EUDO_TBT_SUPPORT;
+ data.eudo |= EUDO_HOST_PRESENT;
+
+ 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 +552,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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] platform/chrome: cros_ec_typec: USB4 support
2020-07-03 8:17 [PATCH] platform/chrome: cros_ec_typec: USB4 support Heikki Krogerus
@ 2020-07-06 22:16 ` Prashant Malani
2020-07-08 23:21 ` Prashant Malani
1 sibling, 0 replies; 3+ messages in thread
From: Prashant Malani @ 2020-07-06 22:16 UTC (permalink / raw)
To: Heikki Krogerus
Cc: Benson Leung, Enric Balletbo i Serra, Guenter Roeck, Mani,
Rajmohan, linux-kernel
Hi Heikki,
On Fri, Jul 03, 2020 at 11:17:03AM +0300, Heikki Krogerus wrote:
> 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 <heikki.krogerus@linux.intel.com>
> ---
> Hi,
>
> 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
>
> Prashant, can you take over the development of this patch (in case it
> still needs work)? I will take a few weeks vacation starting from next
> week (July 6th).
Sure. Have a nice vacation! :)
> I was hoping to get this feature into v5.9 if that's
> possible. But if you guys think there is no hurry, let's forget about
> it. Then we can just wait for 5.9-rc1 and not worry about the
> dependency on Greg's usb-next.
>
> thanks,
>
> ---
> drivers/platform/chrome/cros_ec_typec.c | 42 ++++++++++++++++++++++++-
> 1 file changed, 41 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
> index 0c041b79cbbac..c9713aab9b6b0 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>
> @@ -494,6 +495,43 @@ 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;
> +
> + /* REVISIT: Cable Current? */
> +
> + /* REVISIT: Claiming unconditionally that all tunnels are supported. */
> + data.eudo |= EUDO_PCIE_SUPPORT;
> + data.eudo |= EUDO_DP_SUPPORT;
> +
> + data.eudo |= EUDO_TBT_SUPPORT;
> + data.eudo |= EUDO_HOST_PRESENT;
> +
> + 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 +552,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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] platform/chrome: cros_ec_typec: USB4 support
2020-07-03 8:17 [PATCH] platform/chrome: cros_ec_typec: USB4 support Heikki Krogerus
2020-07-06 22:16 ` Prashant Malani
@ 2020-07-08 23:21 ` Prashant Malani
1 sibling, 0 replies; 3+ messages in thread
From: Prashant Malani @ 2020-07-08 23:21 UTC (permalink / raw)
To: Heikki Krogerus
Cc: Benson Leung, Enric Balletbo i Serra, Guenter Roeck, Mani,
Rajmohan, linux-kernel
Hi,
On Fri, Jul 03, 2020 at 11:17:03AM +0300, Heikki Krogerus wrote:
> +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;
> +
> +
> + /* REVISIT: Cable Current? */
Since we don't pull this data out of the EC currently, I think we can just drop
this for now (the "Mux" drivers aren't using this data at the moment
either).
> +
> + /* REVISIT: Claiming unconditionally that all tunnels are supported. */
> + data.eudo |= EUDO_PCIE_SUPPORT;
> + data.eudo |= EUDO_DP_SUPPORT;
> +
> + data.eudo |= EUDO_TBT_SUPPORT;
> + data.eudo |= EUDO_HOST_PRESENT;
I think it's fine to drop this block altogether. I don't think any of
the current "Mux" drivers parse this information, and we aren't surfacing
it from the Chrome EC.
> +
> } else if (mux_flags & USB_PD_MUX_DP_ENABLED) {
> ret = cros_typec_enable_dp(typec, port_num, pd_ctrl);
> --
> 2.27.0
>
I'll wait for a day for any comments for the maintainers, and if not,
I'll upload v2 of this patch with the "REVISIT" comments omitted.
Thanks,
-Prashant
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-07-08 23:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-03 8:17 [PATCH] platform/chrome: cros_ec_typec: USB4 support Heikki Krogerus
2020-07-06 22:16 ` Prashant Malani
2020-07-08 23:21 ` Prashant Malani
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).