mbox series

[0/3] common SVDM version and VDO from dt

Message ID 20210126084544.682641-1-kyletso@google.com
Headers show
Series common SVDM version and VDO from dt | expand

Message

Kyle Tso Jan. 26, 2021, 8:45 a.m. UTC
The correct SVDM version we should use is the lowest common version             
between the port partners (plug) as stated in the PD3 Spec 6.4.4.2.3.           
It is determined in the Discovery Identity command so cache it and set          
the value to the version field of the VDM header in every later SVDM.           
                                                                                
Like the previous patch "usb: typec: tcpm: Create legacy PDOs for PD2           
connection"                                                                     
(https://lore.kernel.org/linux-usb/20210115163311.391332-1-kyletso@google.com/) 
The field is changed before sending it out of the port. I know this is          
not a good idea but at least it works.                                          
                                                                                
The other two patches are about to get the VDO from fwnode so as to give         
more flexibility.

Kyle Tso (3):
  usb: typec: Determine common SVDM Versions
  dt-bindings: connector: Add SVDM VDO properties
  usb: typec: tcpm: Get Sink VDO from fwnode

 drivers/usb/typec/altmodes/displayport.c |  6 ++-
 drivers/usb/typec/class.c                |  8 ++--
 drivers/usb/typec/tcpm/tcpm.c            | 56 ++++++++++++++++++++----
 drivers/usb/typec/ucsi/displayport.c     | 12 +++--
 include/dt-bindings/usb/pd.h             | 53 +++++++++++++++++++++-
 include/linux/usb/pd_vdo.h               | 40 ++++++++++++-----
 6 files changed, 147 insertions(+), 28 deletions(-)

Comments

Guenter Roeck Jan. 26, 2021, 3:15 p.m. UTC | #1
On 1/26/21 12:45 AM, Kyle Tso wrote:
> Add bindings of VDO properties of USB PD SVDM so that they can be
> defined in device tree.
> 
> Signed-off-by: Kyle Tso <kyletso@google.com>

Are you also going to update
Documentation/devicetree/bindings/connector/usb-connector.yaml ?

Thanks,
Guenter

> ---
>  include/dt-bindings/usb/pd.h | 53 +++++++++++++++++++++++++++++++++++-
>  1 file changed, 52 insertions(+), 1 deletion(-)
> 
> diff --git a/include/dt-bindings/usb/pd.h b/include/dt-bindings/usb/pd.h
> index 0352893697f0..b99cb4a0cd12 100644
> --- a/include/dt-bindings/usb/pd.h
> +++ b/include/dt-bindings/usb/pd.h
> @@ -93,4 +93,55 @@
>  #define FRS_DEFAULT_POWER      1
>  #define FRS_5V_1P5A            2
>  #define FRS_5V_3A              3
> - #endif /* __DT_POWER_DELIVERY_H */
> +
> +/*
> + * SVDM Identity Header
> + * --------------------
> + * <31>     :: data capable as a USB host
> + * <30>     :: data capable as a USB device
> + * <29:27>  :: product type (UFP / Cable / VPD)
> + * <26>     :: modal operation supported (1b == yes)
> + * <25:23>  :: product type (DFP) (SVDM version 2.0+ only; set to zero in version 1.0)
> + * <22:21>  :: connector type (SVDM version 2.0+ only; set to zero in version 1.0)
> + * <20:16>  :: Reserved, Shall be set to zero
> + * <15:0>   :: USB-IF assigned VID for this cable vendor
> + */
> +/* SOP Product Type (UFP) */
> +#define IDH_PTYPE_NOT_UFP       0
> +#define IDH_PTYPE_HUB           1
> +#define IDH_PTYPE_PERIPH        2
> +#define IDH_PTYPE_PSD           3
> +#define IDH_PTYPE_AMA           5
> +
> +/* SOP' Product Type (Cable Plug / VPD) */
> +#define IDH_PTYPE_NOT_CABLE     0
> +#define IDH_PTYPE_PCABLE        3
> +#define IDH_PTYPE_ACABLE        4
> +#define IDH_PTYPE_VPD           6
> +
> +/* SOP Product Type (DFP) */
> +#define IDH_PTYPE_NOT_DFP       0
> +#define IDH_PTYPE_DFP_HUB       1
> +#define IDH_PTYPE_DFP_HOST      2
> +#define IDH_PTYPE_DFP_PB        3
> +
> +#define VDO_IDH(usbh, usbd, ufp_cable, is_modal, dfp, conn, vid)                \
> +	((usbh) << 31 | (usbd) << 30 | ((ufp_cable) & 0x7) << 27                \
> +	 | (is_modal) << 26 | ((dfp) & 0x7) << 23 | ((conn) & 0x3) << 21        \
> +	 | ((vid) & 0xffff))
> +
> +/*
> + * Cert Stat VDO
> + * -------------
> + * <31:0>  : USB-IF assigned XID for this cable
> + */
> +#define VDO_CERT(xid)		((xid) & 0xffffffff)
> +
> +/*
> + * Product VDO
> + * -----------
> + * <31:16> : USB Product ID
> + * <15:0>  : USB bcdDevice
> + */
> +#define VDO_PRODUCT(pid, bcd)   (((pid) & 0xffff) << 16 | ((bcd) & 0xffff))
> +#endif /* __DT_POWER_DELIVERY_H */
>