Hi Prashant,
The original discussion [1].
This proposal is in practice a compromise. I came to the conclusion
that we probable should expose the product type separately after all.
The reason for that is because we may in some cases actually know the
product type even when we don't have access to the Discover Identity
response. UCSI for example in practice gives us at least the cable
product type even though it does not let us know the response to the
Discover Identity command.
So my proposal here is that we add an attribute for the product type
itself, showing the product type as a string. Then we also add the
attribute for the product type specific VDOs which we place under the
identity directory more or less the way you originally proposed.
Note. I have not tested these at all.
[1] https://lore.kernel.org/linux-usb/[email protected]/
Heikki Krogerus (2):
usb: pd: DFP product types
usb: typec: Add product_type sysfs attribute file for partners and
cables
Prashant Malani (1):
usb: typec: Expose Product Type VDOs via sysfs
Documentation/ABI/testing/sysfs-class-typec | 55 +++++++
drivers/usb/typec/class.c | 173 +++++++++++++++++++-
include/linux/usb/pd_vdo.h | 16 +-
3 files changed, 234 insertions(+), 10 deletions(-)
--
2.29.2
USB Power Delivery Specification R3.0 introduced separate
field for the DFP product type to the ID Header VDO.
Signed-off-by: Heikki Krogerus <[email protected]>
---
include/linux/usb/pd_vdo.h | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/include/linux/usb/pd_vdo.h b/include/linux/usb/pd_vdo.h
index 68bdc4e2f5a90..704aaf826c5b4 100644
--- a/include/linux/usb/pd_vdo.h
+++ b/include/linux/usb/pd_vdo.h
@@ -103,17 +103,26 @@
* --------------------
* <31> :: data capable as a USB host
* <30> :: data capable as a USB device
- * <29:27> :: product type
+ * <29:27> :: product type (UFP / Cable)
* <26> :: modal operation supported (1b == yes)
- * <25:16> :: Reserved, Shall be set to zero
+ * <25:16> :: product type (DFP)
* <15:0> :: USB-IF assigned VID for this cable vendor
*/
#define IDH_PTYPE_UNDEF 0
#define IDH_PTYPE_HUB 1
#define IDH_PTYPE_PERIPH 2
+#define IDH_PTYPE_PSD 3
+#define IDH_PTYPE_AMA 5
+#define IDH_PTYPE_VPD 6
+
#define IDH_PTYPE_PCABLE 3
#define IDH_PTYPE_ACABLE 4
-#define IDH_PTYPE_AMA 5
+
+#define IDH_PTYPE_DFP_UNDEF 0
+#define IDH_PTYPE_DFP_HUB 1
+#define IDH_PTYPE_DFP_HOST 2
+#define IDH_PTYPE_DFP_PB 3
+#define IDH_PTYPE_DFP_AMC 4
#define VDO_IDH(usbh, usbd, ptype, is_modal, vid) \
((usbh) << 31 | (usbd) << 30 | ((ptype) & 0x7) << 27 \
@@ -122,6 +131,7 @@
#define PD_IDH_PTYPE(vdo) (((vdo) >> 27) & 0x7)
#define PD_IDH_VID(vdo) ((vdo) & 0xffff)
#define PD_IDH_MODAL_SUPP(vdo) ((vdo) & (1 << 26))
+#define PD_IDH_DFP_PTYPE(vdo) (((vdo) >> 23) & 0x7)
/*
* Cert Stat VDO
--
2.29.2
Hi Heikki,
Thanks for developing these patches :)
On Wed, Nov 18, 2020 at 06:00:56PM +0300, Heikki Krogerus wrote:
> Hi Prashant,
>
> The original discussion [1].
>
> This proposal is in practice a compromise. I came to the conclusion
> that we probable should expose the product type separately after all.
> The reason for that is because we may in some cases actually know the
> product type even when we don't have access to the Discover Identity
> response. UCSI for example in practice gives us at least the cable
> product type even though it does not let us know the response to the
> Discover Identity command.
>
> So my proposal here is that we add an attribute for the product type
> itself, showing the product type as a string. Then we also add the
> attribute for the product type specific VDOs which we place under the
> identity directory more or less the way you originally proposed.
Sounds good to me.
Best regards,
-Prashant