usb: typec: USB4 support to the Intel PMC mux driver
Subsystems (4)
Heikki Krogerus
maintainercover usb: typec: USB4 support to the Intel PMC mux driver
Hi Greg,
These include a couple of USB4 related improvements to the USB Type-C class on top of the driver change.
FYI. I will be on vacation starting from next week (July 6th).
thanks,
Heikki Krogerus (4):
usb: typec: Combine the definitions for Accessory and USB modes
usb: typec: Add data structure for Enter_USB message
usb: typec: intel_pmc_mux: Definitions for response status bits
usb: typec: intel_pmc_mux: Add support for USB4
drivers/usb/typec/mux/intel_pmc_mux.c | 75 +++++++++++++++++++++++---- include/linux/usb/typec.h | 14 +++++ include/linux/usb/typec_altmode.h | 14 ++--- 3 files changed, 83 insertions(+), 20 deletions(-)
Signature · 1 line
2.27.0
Heikki Krogerus
maintainerPATCH 1/4 usb: typec: Combine the definitions for Accessory and USB modes
There is no need to describe them sparately.
--- include/linux/usb/typec_altmode.h | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
include/linux/usb/typec_altmode.h +5 -9
@@ -95,13 +95,7 @@ enum {* * Port drivers can use TYPEC_MODE_AUDIO and TYPEC_MODE_DEBUG as the mode * value for typec_set_mode() when accessory modes are supported. -*/ -enum { -TYPEC_MODE_AUDIO =TYPEC_STATE_MODAL ,/* Audio Accessory */ -TYPEC_MODE_DEBUG ,/* Debug Accessory */ -}; - -/* +* * USB4 also requires that the pins on the connector are repurposed, just like * Alternate Modes. USB4 mode is however not entered with the Enter Mode Command * like the Alternate Modes are, but instead with a special Enter_USB Message.
@@ -112,9 +106,11 @@ enum {* state values, just like the Accessory Modes. */ enum { -TYPEC_MODE_USB2 =TYPEC_MODE_DEBUG ,/* USB 2.0 mode */ +TYPEC_MODE_USB2 =TYPEC_STATE_MODAL ,/* USB 2.0 mode */ TYPEC_MODE_USB3 ,/* USB 3.2 mode */ -TYPEC_MODE_USB4 /* USB4 mode */ +TYPEC_MODE_USB4 ,/* USB4 mode */ +TYPEC_MODE_AUDIO ,/* Audio Accessory */ +TYPEC_MODE_DEBUG ,/* Debug Accessory */ };#define TYPEC_MODAL_STATE (_state_) ((_state_) + TYPEC_STATE_MODAL)
Signature · 1 line
2.27.0
Heikki Krogerus
maintainerPATCH 2/4 usb: typec: Add data structure for Enter_USB message
In reply to Heikki KrogerusThis data structure can be delivered to the mux drivers when Enter_USB Message is used exactly the same way as the Alternate Mode specific data structures are delivered to the mux drivers when Enter Mode Messages are used.
The Enter_USB data structure shall have all details related to the Enter_USB Message, most importantly the Enter_USB Date Object that was used.
--- include/linux/usb/typec.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
include/linux/usb/typec.h +14 -0
@@ -72,6 +72,20 @@ enum typec_orientation { TYPEC_ORIENTATION_REVERSE, }; +/* +* struct enter_usb_data - Enter_USB Message details +* @eudo: Enter_USB Data Object +* @active_link_training: Active Cable Plug Link Training +* +* @active_link_training is a flag that should be set with uni-directional SBRX +* communication, and left 0 with passive cables and with bi-directional SBRX +* communication. +*/ +struct enter_usb_data { +u32 eudo; +unsigned char active_link_training:1 ; +}; +/* * struct usb_pd_identity - USB Power Delivery identity data * @id_header: ID Header VDO
Signature · 1 line
2.27.0
Heikki Krogerus
maintainerPATCH 3/4 usb: typec: intel_pmc_mux: Definitions for response status bits
In reply to Heikki KrogerusAdding definitions for the two status bits that we have in the command response data structure.
Also, from now on only considering the second status bit, which tells was the failure fatal or not, if the first bit is set. If the first bit is not set, then the command was successful, and we need to ignore the second bit.
--- drivers/usb/typec/mux/intel_pmc_mux.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/usb/typec/mux/intel_pmc_mux.c +6 -2
@@ -19,6 +19,10 @@#define PMC_USBC_CMD 0xa7 +/* Response status bits */ +#define PMC_USB_RESP_STATUS_FAILURE BIT(0) +#define PMC_USB_RESP_STATUS_FATAL BIT(1) +/* "Usage" OOB Message field values */ enum {PMC_USB_CONNECT ,
@@ -130,8 +134,8 @@ static int pmc_usb_command(struct pmc_usb_port *port, u8 *msg, u32 len)*/ intel_scu_ipc_dev_command (port->pmc->ipc,PMC_USBC_CMD ,0 , msg, len, response,sizeof (response)); -if (response[2 ]) { -if (response[2 ] &BIT (1 )) +if (response[2 ] &PMC_USB_RESP_STATUS_FAILURE ) { +if (response[2 ] &PMC_USB_RESP_STATUS_FATAL )return -EIO ;return -EBUSY ; }
Signature · 1 line
2.27.0
Heikki Krogerus
maintainerPATCH 4/4 usb: typec: intel_pmc_mux: Add support for USB4
In reply to Heikki KrogerusThe PMC mux-agent can be used also to enter USB4 mode. The mux-agent does not have USB4 specific message, but it can be put into the TBT3 alternate mode also with USB4. That is OK because the controller is in any case the same with TBT3 and USB4.
--- drivers/usb/typec/mux/intel_pmc_mux.c | 67 +++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 9 deletions(-)
drivers/usb/typec/mux/intel_pmc_mux.c +58 -9
@@ -10,6 +10,7 @@#include <linux/module.h> #include <linux/platform_device.h> #include <linux/property.h> +#include <linux/usb/pd.h> #include <linux/usb/role.h> #include <linux/usb/typec_mux.h> #include <linux/usb/typec_dp.h>
@@ -231,6 +232,43 @@ pmc_usb_mux_tbt(struct pmc_usb_port *port, struct typec_mux_state *state)return pmc_usb_command (port, (void *)&req,sizeof (req)); } +static int +pmc_usb_mux_usb4 (struct pmc_usb_port *port,struct typec_mux_state *state) +{ +struct enter_usb_data *data = state->data; +struct altmode_req req = { }; +u8 cable_speed; + + req.usage =PMC_USB_ALT_MODE ; + req.usage |= port->usb3_port <<PMC_USB_MSG_USB3_PORT_SHIFT ; + req.mode_type =PMC_USB_MODE_TYPE_TBT <<PMC_USB_MODE_TYPE_SHIFT ; + +/* USB4 Mode */ + req.mode_data =PMC_USB_ALTMODE_FORCE_LSR ; + +if (data->active_link_training) + req.mode_data |=PMC_USB_ALTMODE_ACTIVE_LINK ; + + req.mode_data |= (port->orientation -1 ) <<PMC_USB_ALTMODE_ORI_SHIFT ; + req.mode_data |= (port->role -1 ) <<PMC_USB_ALTMODE_UFP_SHIFT ; + +switch ((data->eudo &EUDO_CABLE_TYPE_MASK ) >>EUDO_CABLE_TYPE_SHIFT ) { +case EUDO_CABLE_TYPE_PASSIVE : +break ; +case EUDO_CABLE_TYPE_OPTICAL : + req.mode_data |=PMC_USB_ALTMODE_CABLE_TYPE ; + fallthrough; +default : + req.mode_data |=PMC_USB_ALTMODE_ACTIVE_CABLE ; +break ; + } + + cable_speed = (data->eudo &EUDO_CABLE_SPEED_MASK ) >>EUDO_CABLE_SPEED_SHIFT ; + req.mode_data |=PMC_USB_ALTMODE_CABLE_SPD (cable_speed); + +return pmc_usb_command (port, (void *)&req,sizeof (req)); +} +static int pmc_usb_mux_safe_state (struct pmc_usb_port *port) {u8 msg;
@@ -272,17 +310,28 @@ pmc_usb_mux_set(struct typec_mux *mux, struct typec_mux_state *state) {struct pmc_usb_port *port =typec_mux_get_drvdata (mux); -if (!state->alt) -return 0 ; -if (state->mode ==TYPEC_STATE_SAFE )return pmc_usb_mux_safe_state (port); - -switch (state->alt->svid) { -case USB_TYPEC_TBT_SID : -return pmc_usb_mux_tbt (port, state); -case USB_TYPEC_DP_SID : -return pmc_usb_mux_dp (port, state); +if (state->mode ==TYPEC_STATE_USB ) +return pmc_usb_connect (port); + +if (state->alt) { +switch (state->alt->svid) { +case USB_TYPEC_TBT_SID : +return pmc_usb_mux_tbt (port, state); +case USB_TYPEC_DP_SID : +return pmc_usb_mux_dp (port, state); + } + }else { +switch (state->mode) { +case TYPEC_MODE_USB2 : +/* REVISIT: Try with usb3_port set to 0? */ +break ; +case TYPEC_MODE_USB3 : +return pmc_usb_connect (port); +case TYPEC_MODE_USB4 : +return pmc_usb_mux_usb4 (port, state); + } }return -EOPNOTSUPP ;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerQuoted 6 lines · Heikki Krogerus
Hi Greg,
These include a couple of USB4 related improvements to the USB Type-C class on top of the driver change.
FYI. I will be on vacation starting from next week (July 6th).
All look good, thanks, enjoy your vacation!
greg k-h