From 43a029724d1c8219cc4e58e9fafbeedd1bc283fa Mon Sep 17 00:00:00 2001 From: Peter Korsgaard Date: Fri, 26 Jan 2024 21:32:08 +0100 Subject: usb: gadget: f_fs: expose ready state in configfs When a USB gadget is configured through configfs with 1 or more f_fs functions, then the logic setting up the gadget configuration has to wait until the user space code (typically separate applications) responsible for those functions have written their descriptors before the gadget can be activated. The f_fs instance already knows if this has been done, so expose it through a "ready" attribute in configfs for easier synchronization. Signed-off-by: Peter Korsgaard Link: https://lore.kernel.org/r/20240126203208.2482573-1-peter@korsgaard.com Signed-off-by: Greg Kroah-Hartman --- Documentation/ABI/testing/configfs-usb-gadget-ffs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'Documentation/ABI') diff --git a/Documentation/ABI/testing/configfs-usb-gadget-ffs b/Documentation/ABI/testing/configfs-usb-gadget-ffs index e39b27653c65..bf8936ff6d38 100644 --- a/Documentation/ABI/testing/configfs-usb-gadget-ffs +++ b/Documentation/ABI/testing/configfs-usb-gadget-ffs @@ -4,6 +4,14 @@ KernelVersion: 3.13 Description: The purpose of this directory is to create and remove it. A corresponding USB function instance is created/removed. - There are no attributes here. - All parameters are set through FunctionFS. + All attributes are read only: + + ============= ============================================ + ready 1 if the function is ready to be used, E.G. + if userspace has written descriptors and + strings to ep0, so the gadget can be + enabled - 0 otherwise. + ============= ============================================ + + All other parameters are set through FunctionFS. -- cgit v1.2.3 From 9a270ec7bfb0b928ff7c11a4b1f8a026cd20e6b4 Mon Sep 17 00:00:00 2001 From: Heikki Krogerus Date: Tue, 13 Feb 2024 15:00:17 +0200 Subject: usb: roles: Link the switch to its connector This is probable useful information to have in user space in general, but it's primarily needed for the xHCI DbC (Debug Capability). When xHCI DbC is being used, the USB port needs to be muxed to the xHCI even in device role. In xHCI DbC mode, the xHCI is the USB device controller. Tested-by: Uday Bhat Signed-off-by: Heikki Krogerus Reviewed-by: Prashant Malani Link: https://lore.kernel.org/r/20240213130018.3029991-2-heikki.krogerus@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- Documentation/ABI/testing/sysfs-class-usb_role | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Documentation/ABI') diff --git a/Documentation/ABI/testing/sysfs-class-usb_role b/Documentation/ABI/testing/sysfs-class-usb_role index 3b810a425a52..9fab3f06679e 100644 --- a/Documentation/ABI/testing/sysfs-class-usb_role +++ b/Documentation/ABI/testing/sysfs-class-usb_role @@ -19,3 +19,9 @@ Description: - none - host - device + +What: /sys/class/usb_role//connector +Date: Feb 2024 +Contact: Heikki Krogerus +Description: + Optional symlink to the USB Type-C connector. -- cgit v1.2.3 From 12fc84e8c4288cc8ed5f14a35e077130c2cfece2 Mon Sep 17 00:00:00 2001 From: Elbert Mai Date: Mon, 4 Mar 2024 16:23:01 -0800 Subject: usb: Export BOS descriptor to sysfs Motivation ---------- The binary device object store (BOS) of a USB device consists of the BOS descriptor followed by a set of device capability descriptors. One that is of interest to users is the platform descriptor. This contains a 128-bit UUID and arbitrary data, and it allows parties outside of USB-IF to add additional metadata about a USB device in a standards-compliant manner. Notable examples include the WebUSB and Microsoft OS 2.0 descriptors. The kernel already retrieves and caches the BOS from USB devices if its bcdUSB is >= 0x0201. Because the BOS is flexible and extensible, we export the entire BOS to sysfs so users can retrieve whatever device capabilities they desire, without requiring USB I/O or elevated permissions. Implementation -------------- Add bos_descriptors attribute to sysfs. This is a binary file and it works the same way as the existing descriptors attribute. The file exists only if the BOS is present in the USB device. Also create a binary attribute group, so the driver core can handle the creation of both the descriptors and bos_descriptors attributes in sysfs. Signed-off-by: Elbert Mai Link: https://lore.kernel.org/r/20240305002301.95323-1-code@elbertmai.com Signed-off-by: Greg Kroah-Hartman --- Documentation/ABI/testing/sysfs-bus-usb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'Documentation/ABI') diff --git a/Documentation/ABI/testing/sysfs-bus-usb b/Documentation/ABI/testing/sysfs-bus-usb index 2b7108e21977..af9b653422f1 100644 --- a/Documentation/ABI/testing/sysfs-bus-usb +++ b/Documentation/ABI/testing/sysfs-bus-usb @@ -442,6 +442,16 @@ What: /sys/bus/usb/devices/usbX/descriptors Description: Contains the interface descriptors, in binary. +What: /sys/bus/usb/devices/usbX/bos_descriptors +Date: March 2024 +Contact: Elbert Mai +Description: + Binary file containing the cached binary device object store (BOS) + of the device. This consists of the BOS descriptor followed by the + set of device capability descriptors. All descriptors read from + this file are in bus-endian format. Note that the kernel will not + request the BOS from a device if its bcdUSB is less than 0x0201. + What: /sys/bus/usb/devices/usbX/idProduct Description: Product ID, in hexadecimal. -- cgit v1.2.3