common SVDM version and VDO from dt
Subsystems (5)
v4 cover common SVDM version and VDO from dt
v3 is here:
https://patchwork.kernel.org/project/linux-usb/cover/[email protected]/
no changes except for separating the patch "[v3,1/3] usb: typec: Determine common SVDM Versions" into the first 6 patches in this patch set.
Kyle Tso (8):
usb: typec: Manage SVDM version
usb: pd: Update VDO definitions
usb: pd: Make SVDM Version configurable in VDM header
usb: typec: tcpm: Detemine common SVDM Version
usb: typec: ucsi: Detemine common SVDM Version
usb: typec: displayport: Fill the negotiated SVDM Version in the header
dt-bindings: connector: Add SVDM VDO properties
usb: typec: tcpm: Get Sink VDO from fwnode
.../bindings/connector/usb-connector.yaml | 11 + drivers/usb/typec/altmodes/displayport.c | 8 +- drivers/usb/typec/class.c | 21 +- drivers/usb/typec/tcpm/tcpm.c | 61 +++- drivers/usb/typec/ucsi/displayport.c | 12 +- drivers/usb/typec/ucsi/ucsi.c | 2 + include/dt-bindings/usb/pd.h | 311 ++++++++++++++++- include/linux/usb/pd_vdo.h | 315 ++++++++++++++---- include/linux/usb/typec.h | 10 + 9 files changed, 661 insertions(+), 90 deletions(-)
Signature · 1 line
2.30.0.365.g02bc693789-goog
PATCH v4 1/8 usb: typec: Manage SVDM version
PD Spec Revision 3.0 Version 2.0 + ECNs 2020-12-10
6.4.4.2.3 Structured VDM Version
"The Structured VDM Version field of the Discover Identity Command sent and received during VDM discovery Shall be used to determine the lowest common Structured VDM Version supported by the Port Partners or Cable Plug and Shall continue to operate using this Specification Revision until they are Detached."
Add a variable in typec_capability to specify the highest SVDM version supported by the port and another variable in typec_port to cache the negotiated SVDM version between the port partners.
Also add setter/getter functions for the negotiated SVDM version.
--- drivers/usb/typec/class.c | 13 +++++++++++++ include/linux/usb/typec.h | 10 ++++++++++ 2 files changed, 23 insertions(+)
drivers/usb/typec/class.c +13 -0
@@ -51,6 +51,7 @@ struct typec_port {enum typec_role vconn_role;enum typec_pwr_opmode pwr_opmode;enum typec_port_type port_type; +enum usb_pd_svdm_ver svdm_version;struct mutex port_type_lock;enum typec_orientation orientation;
@@ -1841,6 +1842,18 @@ int typec_find_port_data_role(const char *name) }EXPORT_SYMBOL_GPL (typec_find_port_data_role); +void typec_set_svdm_version (struct typec_port *port,enum usb_pd_svdm_ver ver) +{ + port->svdm_version = ver; +} +EXPORT_SYMBOL_GPL (typec_set_svdm_version); + +enum usb_pd_svdm_ver typec_get_svdm_version (struct typec_port *port) +{ +return port->svdm_version; +} +EXPORT_SYMBOL_GPL (typec_get_svdm_version); +/* ------------------------------------------ */ /* API for Multiplexer/DeMultiplexer Switches */
include/linux/usb/typec.h +10 -0
@@ -217,12 +217,19 @@ struct typec_operations { enum typec_port_type type); }; +enum usb_pd_svdm_ver { +SVDM_VER_1_0 =0 , +SVDM_VER_2_0 =1 , +SVDM_VER_MAX =SVDM_VER_2_0 , +}; +/* * struct typec_capability - USB Type-C Port Capabilities * @type: Supported power role of the port * @data: Supported data role of the port * @revision: USB Type-C Specification release. Binary coded decimal * @pd_revision: USB Power Delivery Specification revision if supported +* @svdm_version: USB PD Structured VDM version if supported * @prefer_role: Initial role preference (DRP ports). * @accessory: Supported Accessory Modes * @fwnode: Optional fwnode of the port
@@ -236,6 +243,7 @@ struct typec_capability {enum typec_port_data data;u16 revision;/* 0120H = "1.2" */ u16 pd_revision;/* 0300H = "3.0" */ +enum usb_pd_svdm_ver svdm_version;int prefer_role;enum typec_accessory accessory[TYPEC_MAX_ACCESSORY ]; unsigned int orientation_aware:1;
@@ -286,4 +294,6 @@ int typec_find_orientation(const char *name);int typec_find_port_power_role (const char *name);int typec_find_power_role (const char *name);int typec_find_port_data_role (const char *name); +void typec_set_svdm_version (struct typec_port *port,enum usb_pd_svdm_ver ); +enum usb_pd_svdm_ver typec_get_svdm_version (struct typec_port *port);#endif /* __LINUX_USB_TYPEC_H */
Signature · 1 line
2.30.0.365.g02bc693789-goog
PATCH v4 2/8 usb: pd: Update VDO definitions
In reply to Kyle Tso"PD Spec Revision 3.0 Version 2.0 + ECNs 2020-12-10" introduces several changes regarding the ID Header VDO and the Product Type VDOs.
--- drivers/usb/typec/class.c | 8 +- include/linux/usb/pd_vdo.h | 308 ++++++++++++++++++++++++++++--------- 2 files changed, 242 insertions(+), 74 deletions(-)
drivers/usb/typec/class.c +4 -4
@@ -89,7 +89,7 @@ static const char * const typec_accessory_modes[] = {/* Product types defined in USB PD Specification R3.0 V2.0 */ static const char *const product_type_ufp[8 ] = { - [IDH_PTYPE_UNDEF ] ="undefined" , + [IDH_PTYPE_NOT_UFP ] ="not_ufp" , [IDH_PTYPE_HUB ] ="hub" , [IDH_PTYPE_PERIPH ] ="peripheral" , [IDH_PTYPE_PSD ] ="psd" ,
@@ -97,17 +97,17 @@ static const char * const product_type_ufp[8] = { };static const char *const product_type_dfp[8 ] = { - [IDH_PTYPE_DFP_UNDEF ] ="undefined" , + [IDH_PTYPE_NOT_DFP ] ="not_dfp" , [IDH_PTYPE_DFP_HUB ] ="hub" , [IDH_PTYPE_DFP_HOST ] ="host" , [IDH_PTYPE_DFP_PB ] ="power_brick" , - [IDH_PTYPE_DFP_AMC ] ="amc" , };static const char *const product_type_cable[8 ] = { - [IDH_PTYPE_UNDEF ] ="undefined" , + [IDH_PTYPE_NOT_CABLE ] ="not_cable" , [IDH_PTYPE_PCABLE ] ="passive" , [IDH_PTYPE_ACABLE ] ="active" , + [IDH_PTYPE_VPD ] ="vpd" , };static struct usb_pd_identity *get_pd_identity (struct device *dev)
include/linux/usb/pd_vdo.h +238 -70
390 lines not on this page · raw message
Signature · 1 line
2.30.0.365.g02bc693789-goog
PATCH v4 3/8 usb: pd: Make SVDM Version configurable in VDM header
In reply to Kyle TsoPD Rev 3.0 introduces SVDM Version 2.0. This patch makes the field configuable in the header in order to be able to be compatible with older SVDM version.
--- include/linux/usb/pd_vdo.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
include/linux/usb/pd_vdo.h +5 -2
@@ -21,22 +21,24 @@* ---------- * <31:16> :: SVID * <15> :: VDM type ( 1b == structured, 0b == unstructured ) -* <14:13> :: Structured VDM version (can only be 00 == 1.0 currently) +* <14:13> :: Structured VDM version * <12:11> :: reserved * <10:8> :: object position (1-7 valid ... used for enter/exit mode only) * <7:6> :: command type (SVDM only?) * <5> :: reserved (SVDM), command type (UVDM) * <4:0> :: command */ -#define VDO (vid, type, custom) \ +#define VDO (vid, type, ver, custom) \ (((vid) << 16) | \ ((type) << 15) | \ + ((ver) << 13) | \ ((custom) & 0x7FFF))#define VDO_SVDM_TYPE (1 << 15)#define VDO_SVDM_VERS (x) ((x) << 13)#define VDO_OPOS (x) ((x) << 8)#define VDO_CMDT (x) ((x) << 6) +#define VDO_SVDM_VERS_MASK VDO_SVDM_VERS(0x3)#define VDO_OPOS_MASK VDO_OPOS(0x7)#define VDO_CMDT_MASK VDO_CMDT(0x3)
@@ -74,6 +76,7 @@#define PD_VDO_VID (vdo) ((vdo) >> 16)#define PD_VDO_SVDM (vdo) (((vdo) >> 15) & 1) +#define PD_VDO_SVDM_VER (vdo) (((vdo) >> 13) & 0x3)#define PD_VDO_OPOS (vdo) (((vdo) >> 8) & 0x7)#define PD_VDO_CMD (vdo) ((vdo) & 0x1f)#define PD_VDO_CMDT (vdo) (((vdo) >> 6) & 0x3)
Signature · 1 line
2.30.0.365.g02bc693789-goog
Re: [PATCH v4 3/8] usb: pd: Make SVDM Version configurable in VDM header
Quoted 22 lines · Kyle Tso
PD Rev 3.0 introduces SVDM Version 2.0. This patch makes the field configuable in the header in order to be able to be compatible with older SVDM version.
Signed-off-by Kyle Tso <[email protected]>--- include/linux/usb/pd_vdo.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)include/linux/usb/pd_vdo.h +1
-1@@ -21,22 +21,24 @@* ---------- * <31:16> :: SVID * <15> :: VDM type ( 1b == structured, 0b == unstructured ) -* <14:13> :: Structured VDM version (can only be 00 == 1.0 currently) +* <14:13> :: Structured VDM version * <12:11> :: reserved * <10:8> :: object position (1-7 valid ... used for enter/exit mode only) * <7:6> :: command type (SVDM only?)
include/linux/usb/pd_vdo.h line 36
Quoted 10 lines
include/linux/usb/pd_vdo.h +2
-1* <5> :: reserved (SVDM), command type (UVDM) * <4:0> :: command */ -#define VDO (vid, type, custom) \ +#define VDO (vid, type, ver, custom) \ (((vid) << 16) | \ ((type) << 15) | \ + ((ver) << 13) | \ ((custom) & 0x7FFF))
Yu have to fix all users of VDO() as well, or the code will no longer compile after this patch.
Guenter
Quoted 17 lines
include/linux/usb/pd_vdo.h +2
-0#define VDO_SVDM_TYPE (1 << 15)#define VDO_SVDM_VERS (x) ((x) << 13)#define VDO_OPOS (x) ((x) << 8)#define VDO_CMDT (x) ((x) << 6) +#define VDO_SVDM_VERS_MASK VDO_SVDM_VERS(0x3)#define VDO_OPOS_MASK VDO_OPOS(0x7)#define VDO_CMDT_MASK VDO_CMDT(0x3)@@ -74,6 +76,7 @@#define PD_VDO_VID (vdo) ((vdo) >> 16)#define PD_VDO_SVDM (vdo) (((vdo) >> 15) & 1) +#define PD_VDO_SVDM_VER (vdo) (((vdo) >> 13) & 0x3)#define PD_VDO_OPOS (vdo) (((vdo) >> 8) & 0x7)#define PD_VDO_CMD (vdo) ((vdo) & 0x1f)#define PD_VDO_CMDT (vdo) (((vdo) >> 6) & 0x3)
Re: [PATCH v4 3/8] usb: pd: Make SVDM Version configurable in VDM header
Quoted 38 lines · Guenter Roeck
Quoted 22 lines · Kyle Tso
PD Rev 3.0 introduces SVDM Version 2.0. This patch makes the field configuable in the header in order to be able to be compatible with older SVDM version.
Signed-off-by Kyle Tso <[email protected]>--- include/linux/usb/pd_vdo.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)include/linux/usb/pd_vdo.h +1
-1@@ -21,22 +21,24 @@* ---------- * <31:16> :: SVID * <15> :: VDM type ( 1b == structured, 0b == unstructured ) -* <14:13> :: Structured VDM version (can only be 00 == 1.0 currently) +* <14:13> :: Structured VDM version * <12:11> :: reserved * <10:8> :: object position (1-7 valid ... used for enter/exit mode only) * <7:6> :: command type (SVDM only?) include/linux/usb/pd_vdo.h line 36
Quoted 10 lines
include/linux/usb/pd_vdo.h +2
-1* <5> :: reserved (SVDM), command type (UVDM) * <4:0> :: command */ -#define VDO (vid, type, custom) \ +#define VDO (vid, type, ver, custom) \ (((vid) << 16) | \ ((type) << 15) | \ + ((ver) << 13) | \ ((custom) & 0x7FFF))Yu have to fix all users of
VDO()as well, or the code will no longer compile after this patch.
Quoted 2 lines
Guenter
That's right!
Fix incoming...
thanks,
Kyle
PATCH v4 4/8 usb: typec: tcpm: Detemine common SVDM Version
In reply to Kyle TsoPD Spec Revision 3.0 Version 2.0 + ECNs 2020-12-10
6.4.4.2.3 Structured VDM Version
"The Structured VDM Version field of the Discover Identity Command sent and received during VDM discovery Shall be used to determine the lowest common Structured VDM Version supported by the Port Partners or Cable Plug and Shall continue to operate using this Specification Revision until they are Detached."
Also clear the fields newly defined in SVDM version 2.0 for compatibilities.
--- drivers/usb/typec/tcpm/tcpm.c | 47 +++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 8 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +39 -8
@@ -1475,6 +1475,7 @@ static int tcpm_pd_svdm(struct tcpm_port *port, struct typec_altmode *adev, const u32 *p, int cnt, u32 *response, enum adev_actions *adev_action) { + struct typec_port *typec = port->typec_port;struct typec_altmode *pdev;struct pd_mode_data *modep;int rlen =0 ;
@@ -1500,10 +1501,21 @@ static int tcpm_pd_svdm(struct tcpm_port *port, struct typec_altmode *adev,if (PD_VDO_VID (p[0 ]) !=USB_SID_PD )break ; +if (PD_VDO_SVDM_VER (p[0 ]) <typec_get_svdm_version (typec)) +typec_set_svdm_version (typec,PD_VDO_SVDM_VER (p[0 ]));/* 6.4.4.3.1: Only respond as UFP (device) */ if (port->data_role ==TYPEC_DEVICE && port->nr_snk_vdo) { -for (i =0 ; i < port->nr_snk_vdo; i++) +/* +* Product Type DFP and Connector Type are not defined in SVDM +* version 1.0 and shall be set to zero. +*/ +if (typec_get_svdm_version (typec) <SVDM_VER_2_0 ) + response[1 ] = port->snk_vdo[0 ] & ~IDH_DFP_MASK + & ~IDH_CONN_MASK ; +else + response[1 ] = port->snk_vdo[0 ]; +for (i =1 ; i < port->nr_snk_vdo; i++) response[i +1 ] = port->snk_vdo[i]; rlen = port->nr_snk_vdo +1 ; }
@@ -1532,6 +1544,8 @@ static int tcpm_pd_svdm(struct tcpm_port *port, struct typec_altmode *adev, response[0 ] = p[0 ] |VDO_CMDT (CMDT_RSP_BUSY ); rlen =1 ; } + response[0 ] = (response[0 ] & ~VDO_SVDM_VERS_MASK ) | + (VDO_SVDM_VERS (typec_get_svdm_version (typec)));break ;case CMDT_RSP_ACK :/* silently drop message if we are not connected */
@@ -1542,19 +1556,23 @@ static int tcpm_pd_svdm(struct tcpm_port *port, struct typec_altmode *adev,switch (cmd) {case CMD_DISCOVER_IDENT : +if (PD_VDO_SVDM_VER (p[0 ]) <typec_get_svdm_version (typec)) +typec_set_svdm_version (typec,PD_VDO_SVDM_VER (p[0 ]));/* 6.4.4.3.1 */ svdm_consume_identity (port, p, cnt); - response[0 ] =VDO (USB_SID_PD ,1 ,CMD_DISCOVER_SVID ); + response[0 ] =VDO (USB_SID_PD ,1 ,typec_get_svdm_version (typec), +CMD_DISCOVER_SVID ); rlen =1 ;break ;case CMD_DISCOVER_SVID :/* 6.4.4.3.2 */ if (svdm_consume_svids (port, p, cnt)) { - response[0 ] =VDO (USB_SID_PD ,1 , + response[0 ] =VDO (USB_SID_PD ,1 ,typec_get_svdm_version (typec),CMD_DISCOVER_SVID ); rlen =1 ; }else if (modep->nsvids &&supports_modal (port)) { response[0 ] =VDO (modep->svids[0 ],1 , +typec_get_svdm_version (typec),CMD_DISCOVER_MODES ); rlen =1 ; }
@@ -1565,7 +1583,8 @@ static int tcpm_pd_svdm(struct tcpm_port *port, struct typec_altmode *adev, modep->svid_index++;if (modep->svid_index < modep->nsvids) {u16 svid = modep->svids[modep->svid_index]; - response[0 ] =VDO (svid,1 ,CMD_DISCOVER_MODES ); + response[0 ] =VDO (svid,1 ,typec_get_svdm_version (typec), +CMD_DISCOVER_MODES ); rlen =1 ; }else {tcpm_register_partner_altmodes (port);
@@ -1592,6 +1611,8 @@ static int tcpm_pd_svdm(struct tcpm_port *port, struct typec_altmode *adev,/* Unrecognized SVDM */ response[0 ] = p[0 ] |VDO_CMDT (CMDT_RSP_NAK ); rlen =1 ; + response[0 ] = (response[0 ] & ~VDO_SVDM_VERS_MASK ) | + (VDO_SVDM_VERS (typec_get_svdm_version (typec)));break ; }break ;
@@ -1611,6 +1632,8 @@ static int tcpm_pd_svdm(struct tcpm_port *port, struct typec_altmode *adev,/* Unrecognized SVDM */ response[0 ] = p[0 ] |VDO_CMDT (CMDT_RSP_NAK ); rlen =1 ; + response[0 ] = (response[0 ] & ~VDO_SVDM_VERS_MASK ) | + (VDO_SVDM_VERS (typec_get_svdm_version (typec)));break ; } port->vdm_sm_running = false;
@@ -1618,6 +1641,8 @@ static int tcpm_pd_svdm(struct tcpm_port *port, struct typec_altmode *adev,default : response[0 ] = p[0 ] |VDO_CMDT (CMDT_RSP_NAK ); rlen =1 ; + response[0 ] = (response[0 ] & ~VDO_SVDM_VERS_MASK ) | + (VDO_SVDM_VERS (typec_get_svdm_version (typec))); port->vdm_sm_running = false;break ; }
@@ -1695,7 +1720,9 @@ static void tcpm_handle_vdm_request(struct tcpm_port *port,break ;case ADEV_QUEUE_VDM_SEND_EXIT_MODE_ON_FAIL :if (typec_altmode_vdm (adev, p[0 ], &p[1 ], cnt)) { - response[0 ] =VDO (adev->svid,1 ,CMD_EXIT_MODE ); + response[0 ] =VDO (adev->svid,1 , +typec_get_svdm_version (port->typec_port), +CMD_EXIT_MODE ); response[0 ] |=VDO_OPOS (adev->mode); rlen =1 ; }
@@ -1729,7 +1756,8 @@ static void tcpm_send_vdm(struct tcpm_port *port, u32 vid, int cmd,/* set VDM header with VID & CMD */ header =VDO (vid, ((vid &USB_SID_PD ) ==USB_SID_PD ) ? -1 : (PD_VDO_CMD (cmd) <=CMD_ATTENTION ), cmd); +1 : (PD_VDO_CMD (cmd) <=CMD_ATTENTION ), +typec_get_svdm_version (port->typec_port), cmd);tcpm_queue_vdm (port, header, data, count); }
@@ -2024,7 +2052,8 @@ static int tcpm_altmode_enter(struct typec_altmode *altmode, u32 *vdo)struct tcpm_port *port =typec_altmode_get_drvdata (altmode);u32 header; - header =VDO (altmode->svid, vdo ?2 :1 ,CMD_ENTER_MODE ); + header =VDO (altmode->svid, vdo ?2 :1 ,typec_get_svdm_version (port->typec_port), +CMD_ENTER_MODE ); header |=VDO_OPOS (altmode->mode);tcpm_queue_vdm_unlocked (port, header, vdo, vdo ?1 :0 );
@@ -2036,7 +2065,7 @@ static int tcpm_altmode_exit(struct typec_altmode *altmode)struct tcpm_port *port =typec_altmode_get_drvdata (altmode);u32 header; - header =VDO (altmode->svid,1 ,CMD_EXIT_MODE ); + header =VDO (altmode->svid,1 ,typec_get_svdm_version (port->typec_port),CMD_EXIT_MODE ); header |=VDO_OPOS (altmode->mode);tcpm_queue_vdm_unlocked (port, header,NULL ,0 );
@@ -3445,6 +3474,7 @@ static void tcpm_reset_port(struct tcpm_port *port) port->attached = false; port->pd_capable = false; port->pps_data.supported = false; +typec_set_svdm_version (port->typec_port, port->typec_caps.svdm_version);/* * First Rx ID should be 0; set this to a sentinel of -1 so that
@@ -5952,6 +5982,7 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) port->typec_caps.fwnode = tcpc->fwnode; port->typec_caps.revision =0x0120 ;/* Type-C spec release 1.2 */ port->typec_caps.pd_revision =0x0300 ;/* USB-PD spec release 3.0 */ + port->typec_caps.svdm_version =SVDM_VER_2_0 ; port->typec_caps.driver_data = port; port->typec_caps.ops = &tcpm_ops; port->typec_caps.orientation_aware =1 ;
Signature · 1 line
2.30.0.365.g02bc693789-goog
PATCH v4 5/8 usb: typec: ucsi: Detemine common SVDM Version
In reply to Kyle TsoThis patch implements the following requirement in the Spec.
PD Spec Revision 3.0 Version 2.0 + ECNs 2020-12-10
6.4.4.2.3 Structured VDM Version
"The Structured VDM Version field of the Discover Identity Command sent and received during VDM discovery Shall be used to determine the lowest common Structured VDM Version supported by the Port Partners or Cable Plug and Shall continue to operate using this Specification Revision until they are Detached."
--- drivers/usb/typec/ucsi/displayport.c | 12 +++++++++--- drivers/usb/typec/ucsi/ucsi.c | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-)
drivers/usb/typec/ucsi/displayport.c +9 -3
@@ -48,6 +48,7 @@ struct ucsi_dp {static int ucsi_displayport_enter (struct typec_altmode *alt,u32 *vdo) {struct ucsi_dp *dp =typec_altmode_get_drvdata (alt); +struct typec_port *port = dp->con->port;struct ucsi *ucsi = dp->con->ucsi;u64 command;u8 cur =0 ;
@@ -83,7 +84,7 @@ static int ucsi_displayport_enter(struct typec_altmode *alt, u32 *vdo)* mode, and letting the alt mode driver continue. */ - dp->header =VDO (USB_TYPEC_DP_SID ,1 ,CMD_ENTER_MODE ); + dp->header =VDO (USB_TYPEC_DP_SID ,1 ,typec_get_svdm_version (port),CMD_ENTER_MODE ); dp->header |=VDO_OPOS (USB_TYPEC_DP_MODE ); dp->header |=VDO_CMDT (CMDT_RSP_ACK );
@@ -101,6 +102,7 @@ static int ucsi_displayport_enter(struct typec_altmode *alt, u32 *vdo)static int ucsi_displayport_exit (struct typec_altmode *alt) {struct ucsi_dp *dp =typec_altmode_get_drvdata (alt); +struct typec_port *port = dp->con->port;u64 command;int ret =0 ;
@@ -120,7 +122,7 @@ static int ucsi_displayport_exit(struct typec_altmode *alt)if (ret <0 ) goto out_unlock; - dp->header =VDO (USB_TYPEC_DP_SID ,1 ,CMD_EXIT_MODE ); + dp->header =VDO (USB_TYPEC_DP_SID ,1 ,typec_get_svdm_version (port),CMD_EXIT_MODE ); dp->header |=VDO_OPOS (USB_TYPEC_DP_MODE ); dp->header |=VDO_CMDT (CMDT_RSP_ACK );
@@ -184,6 +186,7 @@ static int ucsi_displayport_vdm(struct typec_altmode *alt, u32 header, const u32 *data, int count) { struct ucsi_dp *dp = typec_altmode_get_drvdata(alt); +struct typec_port *port = dp->con->port;int cmd_type =PD_VDO_CMDT (header);int cmd =PD_VDO_CMD (header);
@@ -200,7 +203,10 @@ static int ucsi_displayport_vdm(struct typec_altmode *alt,switch (cmd_type) {case CMDT_INIT : - dp->header =VDO (USB_TYPEC_DP_SID ,1 , cmd); +if (PD_VDO_SVDM_VER (header) <typec_get_svdm_version (port)) +typec_set_svdm_version (port,PD_VDO_SVDM_VER (header)); + + dp->header =VDO (USB_TYPEC_DP_SID ,1 ,typec_get_svdm_version (port), cmd); dp->header |=VDO_OPOS (USB_TYPEC_DP_MODE );switch (cmd) {
drivers/usb/typec/ucsi/ucsi.c +2 -0
@@ -764,6 +764,7 @@ static void ucsi_handle_connector_change(struct work_struct *work)if (con->status.change &UCSI_CONSTAT_CONNECT_CHANGE ) {typec_set_pwr_role (con->port, role); +typec_set_svdm_version (con->port, con->typec_cap.svdm_version);switch (UCSI_CONSTAT_PARTNER_TYPE (con->status.flags)) {case UCSI_CONSTAT_PARTNER_TYPE_UFP :
@@ -1052,6 +1053,7 @@ static int ucsi_register_port(struct ucsi *ucsi, int index) cap->revision = ucsi->cap.typec_version; cap->pd_revision = ucsi->cap.pd_version; + cap->svdm_version =SVDM_VER_2_0 ; cap->prefer_role =TYPEC_NO_PREFERRED_ROLE ;if (con->cap.op_mode &UCSI_CONCAP_OPMODE_AUDIO_ACCESSORY )
Signature · 1 line
2.30.0.365.g02bc693789-goog
PATCH v4 6/8 usb: typec: displayport: Fill the negotiated SVDM Version in the header
In reply to Kyle TsoVDM header now requires SVDM Version. Get it from typec_port.
--- drivers/usb/typec/altmodes/displayport.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/usb/typec/altmodes/displayport.c +6 -2
@@ -15,8 +15,10 @@#include <linux/usb/typec_dp.h> #include "displayport.h" -#define DP_HEADER (_dp, cmd) (VDO((_dp)->alt->svid, 1, cmd) | \ - VDO_OPOS(USB_TYPEC_DP_MODE)) +#define DP_HEADER (_dp, cmd) (VDO((_dp)->alt->svid, 1, \ + typec_get_svdm_version((_dp)->typec), \ + cmd) \ + | VDO_OPOS(USB_TYPEC_DP_MODE))enum {DP_CONF_USB ,
@@ -62,6 +64,7 @@ struct dp_altmode {struct work_struct work;struct typec_altmode *alt;const struct typec_altmode *port; +struct typec_port *typec; };static int dp_altmode_notify (struct dp_altmode *dp)
@@ -536,6 +539,7 @@ int dp_altmode_probe(struct typec_altmode *alt)mutex_init (&dp->lock); dp->port = port; dp->alt = alt; + dp->typec =typec_altmode2port (alt); alt->desc ="DisplayPort" ; alt->ops = &dp_altmode_ops;
Signature · 1 line
2.30.0.365.g02bc693789-goog
PATCH v4 7/8 dt-bindings: connector: Add SVDM VDO properties
In reply to Kyle TsoAdd bindings of VDO properties of USB PD SVDM so that they can be used in device tree.
--- .../bindings/connector/usb-connector.yaml | 11 + include/dt-bindings/usb/pd.h | 311 +++++++++++++++++- 2 files changed, 321 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/connector/usb-connector.yaml +11 -0
@@ -137,6 +137,17 @@ properties: maxItems: 7 $ref: /schemas/types.yaml#/definitions/uint32-array + sink-vdos: + description: An array of u32 with each entry (VDM Objects) providing additional information + corresponding to the product, the detailed bit definitions and the order of each VDO can be + found in "USB Power Delivery Specification Revision 3.0, Version 2.0 + ECNs 2020-12-10" + chapter 6.4.4.3.1 Discover Identity. User can specify the VDO array via + VDO_IDH/_CERT/_PRODUCT/_UFP/_DFP/_PCABLE/_ACABLE(1/2)/_VPD() defined in + dt-bindings/usb/pd.h. + minItems: 3 + maxItems: 6 + $ref: /schemas/types.yaml#/definitions/uint32-array + op-sink-microwatt: description: Sink required operating power in microwatt, if source can't offer the power, Capability Mismatch is set. Required for power sink and
include/dt-bindings/usb/pd.h +310 -1
314 lines not on this page · raw message
Signature · 1 line
2.30.0.365.g02bc693789-goog
PATCH v4 8/8 usb: typec: tcpm: Get Sink VDO from fwnode
In reply to Kyle TsoCommit a079973f462a ("usb: typec: tcpm: Remove tcpc_config configuration mechanism") removed the tcpc_config which includes the Sink VDO and it is not yet added back with fwnode. Add it now.
--- drivers/usb/typec/tcpm/tcpm.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/usb/typec/tcpm/tcpm.c +14 -0
@@ -5677,6 +5677,20 @@ static int tcpm_fw_get_caps(struct tcpm_port *port, port->new_source_frs_current = frs_current; } +/* sink-vdos is optional */ + ret =fwnode_property_count_u32 (fwnode,"sink-vdos" ); +if (ret <0 ) + ret =0 ; + + port->nr_snk_vdo =min (ret,VDO_MAX_OBJECTS ); +if (port->nr_snk_vdo) { + ret =fwnode_property_read_u32_array (fwnode,"sink-vdos" , + port->snk_vdo, + port->nr_snk_vdo); +if (ret <0 ) +return ret; + } +return 0 ; }
Signature · 1 line
2.30.0.365.g02bc693789-goog