usb: pd: Add definition for DFP and UFP1 VDOs
authorHeikki Krogerus <heikki.krogerus@linux.intel.com>
Mon, 30 Dec 2019 14:26:05 +0000 (17:26 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jan 2020 09:48:55 +0000 (10:48 +0100)
The latest version of the USB Power Delivery Specification
R3.0 added UFP and DFP product types for the Discover
Identity message. Both types can be used for example for
checking the USB capability of the partner, which means the
USB modes (USB 2.0, USB 3.0 and USB4) that the partner
device supports.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20191230142611.24921-10-heikki.krogerus@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/linux/usb/pd_vdo.h

index 781f4e9..35b8e15 100644 (file)
 #define PD_PRODUCT_PID(vdo)    (((vdo) >> 16) & 0xffff)
 
 /*
+ * UFP VDO1
+ * --------
+ * <31:29> :: UFP VDO version
+ * <28>    :: Reserved
+ * <27:24> :: Device capability
+ * <23:6>  :: Reserved
+ * <5:3>   :: Alternate modes
+ * <2:0>   :: USB highest speed
+ */
+#define PD_VDO1_UFP_DEVCAP(vdo)        (((vdo) & GENMASK(27, 24)) >> 24)
+
+#define DEV_USB2_CAPABLE       BIT(0)
+#define DEV_USB2_BILLBOARD     BIT(1)
+#define DEV_USB3_CAPABLE       BIT(2)
+#define DEV_USB4_CAPABLE       BIT(3)
+
+/*
+ * DFP VDO
+ * --------
+ * <31:29> :: DFP VDO version
+ * <28:27> :: Reserved
+ * <26:24> :: Host capability
+ * <23:5>  :: Reserved
+ * <4:0>   :: Port number
+ */
+#define PD_VDO_DFP_HOSTCAP(vdo)        (((vdo) & GENMASK(26, 24)) >> 24)
+
+#define HOST_USB2_CAPABLE      BIT(0)
+#define HOST_USB3_CAPABLE      BIT(1)
+#define HOST_USB4_CAPABLE      BIT(2)
+
+/*
  * Cable VDO
  * ---------
  * <31:28> :: Cable HW version