aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/driver-api/usb/usb.rst439
-rw-r--r--Documentation/usb/proc_usb_info.txt390
2 files changed, 405 insertions, 424 deletions
diff --git a/Documentation/driver-api/usb/usb.rst b/Documentation/driver-api/usb/usb.rst
index a98f78c91ab6..dba0f876b36f 100644
--- a/Documentation/driver-api/usb/usb.rst
+++ b/Documentation/driver-api/usb/usb.rst
@@ -212,9 +212,14 @@ This chapter presents the Linux character device nodes. You may prefer
212to avoid writing new kernel code for your USB driver. User mode device 212to avoid writing new kernel code for your USB driver. User mode device
213drivers are usually packaged as applications or libraries, and may use 213drivers are usually packaged as applications or libraries, and may use
214character devices through some programming library that wraps it. 214character devices through some programming library that wraps it.
215Such libraries include 215Such libraries include:
216`libusb <http://libusb.sourceforge.net>`__ for C/C++, and 216
217`jUSB <http://jUSB.sourceforge.net>`__ for Java. 217 - `libusb <http://libusb.sourceforge.net>`__ for C/C++, and
218 - `jUSB <http://jUSB.sourceforge.net>`__ for Java.
219
220Some old information about it can be seen at the "USB Device Filesystem"
221section of the USB Guide. The latest copy of the USB Guide can be found
222at http://www.linux-usb.org/
218 223
219.. note:: 224.. note::
220 225
@@ -230,45 +235,80 @@ What files are in "devtmpfs"?
230 235
231Conventionally mounted at ``/dev/bus/usb/``, usbfs features include: 236Conventionally mounted at ``/dev/bus/usb/``, usbfs features include:
232 237
233- ``/dev/bus/usb//BBB/DDD`` ... magic files exposing the each device's 238- ``/dev/bus/usb/BBB/DDD`` ... magic files exposing the each device's
234 configuration descriptors, and supporting a series of ioctls for 239 configuration descriptors, and supporting a series of ioctls for
235 making device requests, including I/O to devices. (Purely for access 240 making device requests, including I/O to devices. (Purely for access
236 by programs.) 241 by programs.)
237 242
238Each bus is given a number (BBB) based on when it was enumerated; within 243Each bus is given a number (``BBB``) based on when it was enumerated; within
239each bus, each device is given a similar number (DDD). Those BBB/DDD 244each bus, each device is given a similar number (``DDD``). Those ``BBB/DDD``
240paths are not "stable" identifiers; expect them to change even if you 245paths are not "stable" identifiers; expect them to change even if you
241always leave the devices plugged in to the same hub port. *Don't even 246always leave the devices plugged in to the same hub port. *Don't even
242think of saving these in application configuration files.* Stable 247think of saving these in application configuration files.* Stable
243identifiers are available, for user mode applications that want to use 248identifiers are available, for user mode applications that want to use
244them. HID and networking devices expose these stable IDs, so that for 249them. HID and networking devices expose these stable IDs, so that for
245example you can be sure that you told the right UPS to power down its 250example you can be sure that you told the right UPS to power down its
246second server. "usbfs" doesn't (yet) expose those IDs. 251second server. Pleast note that it doesn't (yet) expose those IDs.
247 252
248/dev/bus/usb//BBB/DDD 253/dev/bus/usb/BBB/DDD
249--------------------- 254--------------------
250 255
251Use these files in one of these basic ways: 256Use these files in one of these basic ways:
252 257
253*They can be read,* producing first the device descriptor (18 bytes) and 258- *They can be read,* producing first the device descriptor (18 bytes) and
254then the descriptors for the current configuration. See the USB 2.0 spec 259 then the descriptors for the current configuration. See the USB 2.0 spec
255for details about those binary data formats. You'll need to convert most 260 for details about those binary data formats. You'll need to convert most
256multibyte values from little endian format to your native host byte 261 multibyte values from little endian format to your native host byte
257order, although a few of the fields in the device descriptor (both of 262 order, although a few of the fields in the device descriptor (both of
258the BCD-encoded fields, and the vendor and product IDs) will be 263 the BCD-encoded fields, and the vendor and product IDs) will be
259byteswapped for you. Note that configuration descriptors include 264 byteswapped for you. Note that configuration descriptors include
260descriptors for interfaces, altsettings, endpoints, and maybe additional 265 descriptors for interfaces, altsettings, endpoints, and maybe additional
261class descriptors. 266 class descriptors.
262 267
263*Perform USB operations* using *ioctl()* requests to make endpoint I/O 268- *Perform USB operations* using *ioctl()* requests to make endpoint I/O
264requests (synchronously or asynchronously) or manage the device. These 269 requests (synchronously or asynchronously) or manage the device. These
265requests need the CAP_SYS_RAWIO capability, as well as filesystem 270 requests need the ``CAP_SYS_RAWIO`` capability, as well as filesystem
266access permissions. Only one ioctl request can be made on one of these 271 access permissions. Only one ioctl request can be made on one of these
267device files at a time. This means that if you are synchronously reading 272 device files at a time. This means that if you are synchronously reading
268an endpoint from one thread, you won't be able to write to a different 273 an endpoint from one thread, you won't be able to write to a different
269endpoint from another thread until the read completes. This works for 274 endpoint from another thread until the read completes. This works for
270*half duplex* protocols, but otherwise you'd use asynchronous i/o 275 *half duplex* protocols, but otherwise you'd use asynchronous i/o
271requests. 276 requests.
277
278Each connected USB device has one file. The ``BBB`` indicates the bus
279number. The ``DDD`` indicates the device address on that bus. Both
280of these numbers are assigned sequentially, and can be reused, so
281you can't rely on them for stable access to devices. For example,
282it's relatively common for devices to re-enumerate while they are
283still connected (perhaps someone jostled their power supply, hub,
284or USB cable), so a device might be ``002/027`` when you first connect
285it and ``002/048`` sometime later.
286
287These files can be read as binary data. The binary data consists
288of first the device descriptor, then the descriptors for each
289configuration of the device. Multi-byte fields in the device descriptor
290are converted to host endianness by the kernel. The configuration
291descriptors are in bus endian format! The configuration descriptor
292are wTotalLength bytes apart. If a device returns less configuration
293descriptor data than indicated by wTotalLength there will be a hole in
294the file for the missing bytes. This information is also shown
295in text form by the ``/sys/kernel/debug/usb/devices`` file, described later.
296
297These files may also be used to write user-level drivers for the USB
298devices. You would open the ``/dev/bus/usb/BBB/DDD`` file read/write,
299read its descriptors to make sure it's the device you expect, and then
300bind to an interface (or perhaps several) using an ioctl call. You
301would issue more ioctls to the device to communicate to it using
302control, bulk, or other kinds of USB transfers. The IOCTLs are
303listed in the ``<linux/usbdevice_fs.h>`` file, and at this writing the
304source code (``linux/drivers/usb/core/devio.c``) is the primary reference
305for how to access devices through those files.
306
307Note that since by default these ``BBB/DDD`` files are writable only by
308root, only root can write such user mode drivers. You can selectively
309grant read/write permissions to other users by using ``chmod``. Also,
310usbfs mount options such as ``devmode=0666`` may be helpful.
311
272 312
273Life Cycle of User Mode Drivers 313Life Cycle of User Mode Drivers
274------------------------------- 314-------------------------------
@@ -276,7 +316,7 @@ Life Cycle of User Mode Drivers
276Such a driver first needs to find a device file for a device it knows 316Such a driver first needs to find a device file for a device it knows
277how to handle. Maybe it was told about it because a ``/sbin/hotplug`` 317how to handle. Maybe it was told about it because a ``/sbin/hotplug``
278event handling agent chose that driver to handle the new device. Or 318event handling agent chose that driver to handle the new device. Or
279maybe it's an application that scans all the /dev/bus/usb/ device files, 319maybe it's an application that scans all the ``/dev/bus/usb`` device files,
280and ignores most devices. In either case, it should :c:func:`read()` 320and ignores most devices. In either case, it should :c:func:`read()`
281all the descriptors from the device file, and check them against what it 321all the descriptors from the device file, and check them against what it
282knows how to handle. It might just reject everything except a particular 322knows how to handle. It might just reject everything except a particular
@@ -430,7 +470,7 @@ USBDEVFS_RELEASEINTERFACE
430 the number of the interface (bInterfaceNumber from descriptor); File 470 the number of the interface (bInterfaceNumber from descriptor); File
431 modification time is not updated by this request. 471 modification time is not updated by this request.
432 472
433.. warning:: 473 .. warning::
434 474
435 *No security check is made to ensure that the task which made 475 *No security check is made to ensure that the task which made
436 the claim is the one which is releasing it. This means that user 476 the claim is the one which is releasing it. This means that user
@@ -442,7 +482,7 @@ USBDEVFS_RESETEP
442 as identified in the endpoint descriptor), with USB_DIR_IN added 482 as identified in the endpoint descriptor), with USB_DIR_IN added
443 if the device's endpoint sends data to the host. 483 if the device's endpoint sends data to the host.
444 484
445 **Warning** 485 .. Warning::
446 486
447 *Avoid using this request. It should probably be removed.* Using 487 *Avoid using this request. It should probably be removed.* Using
448 it typically means the device and driver will lose toggle 488 it typically means the device and driver will lose toggle
@@ -479,10 +519,10 @@ USBDEVFS_BULK
479 void *data; 519 void *data;
480 }; 520 };
481 521
482 The "ep" value identifies a bulk endpoint number (1 to 15, as 522 The ``ep`` value identifies a bulk endpoint number (1 to 15, as
483 identified in an endpoint descriptor), masked with USB_DIR_IN when 523 identified in an endpoint descriptor), masked with USB_DIR_IN when
484 referring to an endpoint which sends data to the host from the 524 referring to an endpoint which sends data to the host from the
485 device. The length of the data buffer is identified by "len"; Recent 525 device. The length of the data buffer is identified by ``len``; Recent
486 kernels support requests up to about 128KBytes. *FIXME say how read 526 kernels support requests up to about 128KBytes. *FIXME say how read
487 length is returned, and how short reads are handled.*. 527 length is returned, and how short reads are handled.*.
488 528
@@ -494,7 +534,7 @@ USBDEVFS_CLEAR_HALT
494 which sends data to the host from the device. 534 which sends data to the host from the device.
495 535
496 Use this on bulk or interrupt endpoints which have stalled, 536 Use this on bulk or interrupt endpoints which have stalled,
497 returning *-EPIPE* status to a data transfer request. Do not issue 537 returning ``-EPIPE`` status to a data transfer request. Do not issue
498 the control request directly, since that could invalidate the host's 538 the control request directly, since that could invalidate the host's
499 record of the data toggle. 539 record of the data toggle.
500 540
@@ -674,3 +714,334 @@ Note that this behavior is intended to be used for informational and
674debug purposes. It would be more appropriate to use programs such as 714debug purposes. It would be more appropriate to use programs such as
675udev or HAL to initialize a device or start a user-mode helper program, 715udev or HAL to initialize a device or start a user-mode helper program,
676for instance. 716for instance.
717
718In this file, each device's output has multiple lines of ASCII output.
719
720I made it ASCII instead of binary on purpose, so that someone
721can obtain some useful data from it without the use of an
722auxiliary program. However, with an auxiliary program, the numbers
723in the first 4 columns of each ``T:`` line (topology info:
724Lev, Prnt, Port, Cnt) can be used to build a USB topology diagram.
725
726Each line is tagged with a one-character ID for that line::
727
728 T = Topology (etc.)
729 B = Bandwidth (applies only to USB host controllers, which are
730 virtualized as root hubs)
731 D = Device descriptor info.
732 P = Product ID info. (from Device descriptor, but they won't fit
733 together on one line)
734 S = String descriptors.
735 C = Configuration descriptor info. (* = active configuration)
736 I = Interface descriptor info.
737 E = Endpoint descriptor info.
738
739/sys/kernel/debug/usb/devices output format
740~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
741
742Legend::
743 d = decimal number (may have leading spaces or 0's)
744 x = hexadecimal number (may have leading spaces or 0's)
745 s = string
746
747
748
749Topology info
750^^^^^^^^^^^^^
751
752::
753
754 T: Bus=dd Lev=dd Prnt=dd Port=dd Cnt=dd Dev#=ddd Spd=dddd MxCh=dd
755 | | | | | | | | |__MaxChildren
756 | | | | | | | |__Device Speed in Mbps
757 | | | | | | |__DeviceNumber
758 | | | | | |__Count of devices at this level
759 | | | | |__Connector/Port on Parent for this device
760 | | | |__Parent DeviceNumber
761 | | |__Level in topology for this bus
762 | |__Bus number
763 |__Topology info tag
764
765Speed may be:
766
767 ======= ======================================================
768 1.5 Mbit/s for low speed USB
769 12 Mbit/s for full speed USB
770 480 Mbit/s for high speed USB (added for USB 2.0);
771 also used for Wireless USB, which has no fixed speed
772 5000 Mbit/s for SuperSpeed USB (added for USB 3.0)
773 ======= ======================================================
774
775For reasons lost in the mists of time, the Port number is always
776too low by 1. For example, a device plugged into port 4 will
777show up with ``Port=03``.
778
779Bandwidth info
780^^^^^^^^^^^^^^
781
782::
783
784 B: Alloc=ddd/ddd us (xx%), #Int=ddd, #Iso=ddd
785 | | | |__Number of isochronous requests
786 | | |__Number of interrupt requests
787 | |__Total Bandwidth allocated to this bus
788 |__Bandwidth info tag
789
790Bandwidth allocation is an approximation of how much of one frame
791(millisecond) is in use. It reflects only periodic transfers, which
792are the only transfers that reserve bandwidth. Control and bulk
793transfers use all other bandwidth, including reserved bandwidth that
794is not used for transfers (such as for short packets).
795
796The percentage is how much of the "reserved" bandwidth is scheduled by
797those transfers. For a low or full speed bus (loosely, "USB 1.1"),
79890% of the bus bandwidth is reserved. For a high speed bus (loosely,
799"USB 2.0") 80% is reserved.
800
801
802Device descriptor info & Product ID info
803^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
804
805::
806
807 D: Ver=x.xx Cls=xx(s) Sub=xx Prot=xx MxPS=dd #Cfgs=dd
808 P: Vendor=xxxx ProdID=xxxx Rev=xx.xx
809
810where::
811
812 D: Ver=x.xx Cls=xx(sssss) Sub=xx Prot=xx MxPS=dd #Cfgs=dd
813 | | | | | | |__NumberConfigurations
814 | | | | | |__MaxPacketSize of Default Endpoint
815 | | | | |__DeviceProtocol
816 | | | |__DeviceSubClass
817 | | |__DeviceClass
818 | |__Device USB version
819 |__Device info tag #1
820
821where::
822
823 P: Vendor=xxxx ProdID=xxxx Rev=xx.xx
824 | | | |__Product revision number
825 | | |__Product ID code
826 | |__Vendor ID code
827 |__Device info tag #2
828
829
830String descriptor info
831^^^^^^^^^^^^^^^^^^^^^^
832::
833
834 S: Manufacturer=ssss
835 | |__Manufacturer of this device as read from the device.
836 | For USB host controller drivers (virtual root hubs) this may
837 | be omitted, or (for newer drivers) will identify the kernel
838 | version and the driver which provides this hub emulation.
839 |__String info tag
840
841 S: Product=ssss
842 | |__Product description of this device as read from the device.
843 | For older USB host controller drivers (virtual root hubs) this
844 | indicates the driver; for newer ones, it's a product (and vendor)
845 | description that often comes from the kernel's PCI ID database.
846 |__String info tag
847
848 S: SerialNumber=ssss
849 | |__Serial Number of this device as read from the device.
850 | For USB host controller drivers (virtual root hubs) this is
851 | some unique ID, normally a bus ID (address or slot name) that
852 | can't be shared with any other device.
853 |__String info tag
854
855
856
857Configuration descriptor info
858^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
859::
860
861 C:* #Ifs=dd Cfg#=dd Atr=xx MPwr=dddmA
862 | | | | | |__MaxPower in mA
863 | | | | |__Attributes
864 | | | |__ConfiguratioNumber
865 | | |__NumberOfInterfaces
866 | |__ "*" indicates the active configuration (others are " ")
867 |__Config info tag
868
869USB devices may have multiple configurations, each of which act
870rather differently. For example, a bus-powered configuration
871might be much less capable than one that is self-powered. Only
872one device configuration can be active at a time; most devices
873have only one configuration.
874
875Each configuration consists of one or more interfaces. Each
876interface serves a distinct "function", which is typically bound
877to a different USB device driver. One common example is a USB
878speaker with an audio interface for playback, and a HID interface
879for use with software volume control.
880
881Interface descriptor info (can be multiple per Config)
882^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
883::
884
885 I:* If#=dd Alt=dd #EPs=dd Cls=xx(sssss) Sub=xx Prot=xx Driver=ssss
886 | | | | | | | | |__Driver name
887 | | | | | | | | or "(none)"
888 | | | | | | | |__InterfaceProtocol
889 | | | | | | |__InterfaceSubClass
890 | | | | | |__InterfaceClass
891 | | | | |__NumberOfEndpoints
892 | | | |__AlternateSettingNumber
893 | | |__InterfaceNumber
894 | |__ "*" indicates the active altsetting (others are " ")
895 |__Interface info tag
896
897A given interface may have one or more "alternate" settings.
898For example, default settings may not use more than a small
899amount of periodic bandwidth. To use significant fractions
900of bus bandwidth, drivers must select a non-default altsetting.
901
902Only one setting for an interface may be active at a time, and
903only one driver may bind to an interface at a time. Most devices
904have only one alternate setting per interface.
905
906
907Endpoint descriptor info (can be multiple per Interface)
908^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
909
910::
911
912 E: Ad=xx(s) Atr=xx(ssss) MxPS=dddd Ivl=dddss
913 | | | | |__Interval (max) between transfers
914 | | | |__EndpointMaxPacketSize
915 | | |__Attributes(EndpointType)
916 | |__EndpointAddress(I=In,O=Out)
917 |__Endpoint info tag
918
919The interval is nonzero for all periodic (interrupt or isochronous)
920endpoints. For high speed endpoints the transfer interval may be
921measured in microseconds rather than milliseconds.
922
923For high speed periodic endpoints, the ``EndpointMaxPacketSize`` reflects
924the per-microframe data transfer size. For "high bandwidth"
925endpoints, that can reflect two or three packets (for up to
9263KBytes every 125 usec) per endpoint.
927
928With the Linux-USB stack, periodic bandwidth reservations use the
929transfer intervals and sizes provided by URBs, which can be less
930than those found in endpoint descriptor.
931
932Usage examples
933~~~~~~~~~~~~~~
934
935If a user or script is interested only in Topology info, for
936example, use something like ``grep ^T: /sys/kernel/debug/usb/devices``
937for only the Topology lines. A command like
938``grep -i ^[tdp]: /sys/kernel/debug/usb/devices`` can be used to list
939only the lines that begin with the characters in square brackets,
940where the valid characters are TDPCIE. With a slightly more able
941script, it can display any selected lines (for example, only T, D,
942and P lines) and change their output format. (The ``procusb``
943Perl script is the beginning of this idea. It will list only
944selected lines [selected from TBDPSCIE] or "All" lines from
945``/sys/kernel/debug/usb/devices``.)
946
947The Topology lines can be used to generate a graphic/pictorial
948of the USB devices on a system's root hub. (See more below
949on how to do this.)
950
951The Interface lines can be used to determine what driver is
952being used for each device, and which altsetting it activated.
953
954The Configuration lines could be used to list maximum power
955(in milliamps) that a system's USB devices are using.
956For example, ``grep ^C: /sys/kernel/debug/usb/devices``.
957
958
959Here's an example, from a system which has a UHCI root hub,
960an external hub connected to the root hub, and a mouse and
961a serial converter connected to the external hub.
962
963::
964
965 T: Bus=00 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=12 MxCh= 2
966 B: Alloc= 28/900 us ( 3%), #Int= 2, #Iso= 0
967 D: Ver= 1.00 Cls=09(hub ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
968 P: Vendor=0000 ProdID=0000 Rev= 0.00
969 S: Product=USB UHCI Root Hub
970 S: SerialNumber=dce0
971 C:* #Ifs= 1 Cfg#= 1 Atr=40 MxPwr= 0mA
972 I: If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
973 E: Ad=81(I) Atr=03(Int.) MxPS= 8 Ivl=255ms
974
975 T: Bus=00 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=12 MxCh= 4
976 D: Ver= 1.00 Cls=09(hub ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
977 P: Vendor=0451 ProdID=1446 Rev= 1.00
978 C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=100mA
979 I: If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
980 E: Ad=81(I) Atr=03(Int.) MxPS= 1 Ivl=255ms
981
982 T: Bus=00 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#= 3 Spd=1.5 MxCh= 0
983 D: Ver= 1.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
984 P: Vendor=04b4 ProdID=0001 Rev= 0.00
985 C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA
986 I: If#= 0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=01 Prot=02 Driver=mouse
987 E: Ad=81(I) Atr=03(Int.) MxPS= 3 Ivl= 10ms
988
989 T: Bus=00 Lev=02 Prnt=02 Port=02 Cnt=02 Dev#= 4 Spd=12 MxCh= 0
990 D: Ver= 1.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
991 P: Vendor=0565 ProdID=0001 Rev= 1.08
992 S: Manufacturer=Peracom Networks, Inc.
993 S: Product=Peracom USB to Serial Converter
994 C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=100mA
995 I: If#= 0 Alt= 0 #EPs= 3 Cls=00(>ifc ) Sub=00 Prot=00 Driver=serial
996 E: Ad=81(I) Atr=02(Bulk) MxPS= 64 Ivl= 16ms
997 E: Ad=01(O) Atr=02(Bulk) MxPS= 16 Ivl= 16ms
998 E: Ad=82(I) Atr=03(Int.) MxPS= 8 Ivl= 8ms
999
1000
1001Selecting only the ``T:`` and ``I:`` lines from this (for example, by using
1002``procusb ti``), we have
1003
1004::
1005
1006 T: Bus=00 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=12 MxCh= 2
1007 T: Bus=00 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=12 MxCh= 4
1008 I: If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
1009 T: Bus=00 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#= 3 Spd=1.5 MxCh= 0
1010 I: If#= 0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=01 Prot=02 Driver=mouse
1011 T: Bus=00 Lev=02 Prnt=02 Port=02 Cnt=02 Dev#= 4 Spd=12 MxCh= 0
1012 I: If#= 0 Alt= 0 #EPs= 3 Cls=00(>ifc ) Sub=00 Prot=00 Driver=serial
1013
1014
1015Physically this looks like (or could be converted to)::
1016
1017 +------------------+
1018 | PC/root_hub (12)| Dev# = 1
1019 +------------------+ (nn) is Mbps.
1020 Level 0 | CN.0 | CN.1 | [CN = connector/port #]
1021 +------------------+
1022 /
1023 /
1024 +-----------------------+
1025 Level 1 | Dev#2: 4-port hub (12)|
1026 +-----------------------+
1027 |CN.0 |CN.1 |CN.2 |CN.3 |
1028 +-----------------------+
1029 \ \____________________
1030 \_____ \
1031 \ \
1032 +--------------------+ +--------------------+
1033 Level 2 | Dev# 3: mouse (1.5)| | Dev# 4: serial (12)|
1034 +--------------------+ +--------------------+
1035
1036
1037
1038Or, in a more tree-like structure (ports [Connectors] without
1039connections could be omitted)::
1040
1041 PC: Dev# 1, root hub, 2 ports, 12 Mbps
1042 |_ CN.0: Dev# 2, hub, 4 ports, 12 Mbps
1043 |_ CN.0: Dev #3, mouse, 1.5 Mbps
1044 |_ CN.1:
1045 |_ CN.2: Dev #4, serial, 12 Mbps
1046 |_ CN.3:
1047 |_ CN.1:
diff --git a/Documentation/usb/proc_usb_info.txt b/Documentation/usb/proc_usb_info.txt
deleted file mode 100644
index 06d7960e9ae6..000000000000
--- a/Documentation/usb/proc_usb_info.txt
+++ /dev/null
@@ -1,390 +0,0 @@
1/proc/bus/usb filesystem output
2===============================
3(version 2010.09.13)
4
5
6The usbfs filesystem for USB devices is traditionally mounted at
7/proc/bus/usb. It provides the /sys/kernel/debug/usb/devices file, as well as
8the /proc/bus/usb/BBB/DDD files.
9
10In many modern systems the usbfs filesystem isn't used at all. Instead
11USB device nodes are created under /dev/usb/ or someplace similar. The
12"devices" file is available in debugfs, typically as
13/sys/kernel/debug/usb/devices.
14
15
16**NOTE**: If /proc/bus/usb appears empty, and a host controller
17 driver has been linked, then you need to mount the
18 filesystem. Issue the command (as root):
19
20 mount -t usbfs none /proc/bus/usb
21
22 An alternative and more permanent method would be to add
23
24 none /proc/bus/usb usbfs defaults 0 0
25
26 to /etc/fstab. This will mount usbfs at each reboot.
27 You can then issue `cat /sys/kernel/debug/usb/devices` to extract
28 USB device information, and user mode drivers can use usbfs
29 to interact with USB devices.
30
31 There are a number of mount options supported by usbfs.
32 Consult the source code (linux/drivers/usb/core/inode.c) for
33 information about those options.
34
35**NOTE**: The filesystem has been renamed from "usbdevfs" to
36 "usbfs", to reduce confusion with "devfs". You may
37 still see references to the older "usbdevfs" name.
38
39For more information on mounting the usbfs file system, see the
40"USB Device Filesystem" section of the USB Guide. The latest copy
41of the USB Guide can be found at http://www.linux-usb.org/
42
43
44THE /proc/bus/usb/BBB/DDD FILES:
45--------------------------------
46Each connected USB device has one file. The BBB indicates the bus
47number. The DDD indicates the device address on that bus. Both
48of these numbers are assigned sequentially, and can be reused, so
49you can't rely on them for stable access to devices. For example,
50it's relatively common for devices to re-enumerate while they are
51still connected (perhaps someone jostled their power supply, hub,
52or USB cable), so a device might be 002/027 when you first connect
53it and 002/048 sometime later.
54
55These files can be read as binary data. The binary data consists
56of first the device descriptor, then the descriptors for each
57configuration of the device. Multi-byte fields in the device descriptor
58are converted to host endianness by the kernel. The configuration
59descriptors are in bus endian format! The configuration descriptor
60are wTotalLength bytes apart. If a device returns less configuration
61descriptor data than indicated by wTotalLength there will be a hole in
62the file for the missing bytes. This information is also shown
63in text form by the /sys/kernel/debug/usb/devices file, described later.
64
65These files may also be used to write user-level drivers for the USB
66devices. You would open the /proc/bus/usb/BBB/DDD file read/write,
67read its descriptors to make sure it's the device you expect, and then
68bind to an interface (or perhaps several) using an ioctl call. You
69would issue more ioctls to the device to communicate to it using
70control, bulk, or other kinds of USB transfers. The IOCTLs are
71listed in the <linux/usbdevice_fs.h> file, and at this writing the
72source code (linux/drivers/usb/core/devio.c) is the primary reference
73for how to access devices through those files.
74
75Note that since by default these BBB/DDD files are writable only by
76root, only root can write such user mode drivers. You can selectively
77grant read/write permissions to other users by using "chmod". Also,
78usbfs mount options such as "devmode=0666" may be helpful.
79
80
81
82THE /sys/kernel/debug/usb/devices FILE:
83-------------------------------
84In /sys/kernel/debug/usb/devices, each device's output has multiple
85lines of ASCII output.
86I made it ASCII instead of binary on purpose, so that someone
87can obtain some useful data from it without the use of an
88auxiliary program. However, with an auxiliary program, the numbers
89in the first 4 columns of each "T:" line (topology info:
90Lev, Prnt, Port, Cnt) can be used to build a USB topology diagram.
91
92Each line is tagged with a one-character ID for that line:
93
94T = Topology (etc.)
95B = Bandwidth (applies only to USB host controllers, which are
96 virtualized as root hubs)
97D = Device descriptor info.
98P = Product ID info. (from Device descriptor, but they won't fit
99 together on one line)
100S = String descriptors.
101C = Configuration descriptor info. (* = active configuration)
102I = Interface descriptor info.
103E = Endpoint descriptor info.
104
105=======================================================================
106
107/sys/kernel/debug/usb/devices output format:
108
109Legend:
110 d = decimal number (may have leading spaces or 0's)
111 x = hexadecimal number (may have leading spaces or 0's)
112 s = string
113
114
115Topology info:
116
117T: Bus=dd Lev=dd Prnt=dd Port=dd Cnt=dd Dev#=ddd Spd=dddd MxCh=dd
118| | | | | | | | |__MaxChildren
119| | | | | | | |__Device Speed in Mbps
120| | | | | | |__DeviceNumber
121| | | | | |__Count of devices at this level
122| | | | |__Connector/Port on Parent for this device
123| | | |__Parent DeviceNumber
124| | |__Level in topology for this bus
125| |__Bus number
126|__Topology info tag
127
128 Speed may be:
129 1.5 Mbit/s for low speed USB
130 12 Mbit/s for full speed USB
131 480 Mbit/s for high speed USB (added for USB 2.0);
132 also used for Wireless USB, which has no fixed speed
133 5000 Mbit/s for SuperSpeed USB (added for USB 3.0)
134
135 For reasons lost in the mists of time, the Port number is always
136 too low by 1. For example, a device plugged into port 4 will
137 show up with "Port=03".
138
139Bandwidth info:
140B: Alloc=ddd/ddd us (xx%), #Int=ddd, #Iso=ddd
141| | | |__Number of isochronous requests
142| | |__Number of interrupt requests
143| |__Total Bandwidth allocated to this bus
144|__Bandwidth info tag
145
146 Bandwidth allocation is an approximation of how much of one frame
147 (millisecond) is in use. It reflects only periodic transfers, which
148 are the only transfers that reserve bandwidth. Control and bulk
149 transfers use all other bandwidth, including reserved bandwidth that
150 is not used for transfers (such as for short packets).
151
152 The percentage is how much of the "reserved" bandwidth is scheduled by
153 those transfers. For a low or full speed bus (loosely, "USB 1.1"),
154 90% of the bus bandwidth is reserved. For a high speed bus (loosely,
155 "USB 2.0") 80% is reserved.
156
157
158Device descriptor info & Product ID info:
159
160D: Ver=x.xx Cls=xx(s) Sub=xx Prot=xx MxPS=dd #Cfgs=dd
161P: Vendor=xxxx ProdID=xxxx Rev=xx.xx
162
163where
164D: Ver=x.xx Cls=xx(sssss) Sub=xx Prot=xx MxPS=dd #Cfgs=dd
165| | | | | | |__NumberConfigurations
166| | | | | |__MaxPacketSize of Default Endpoint
167| | | | |__DeviceProtocol
168| | | |__DeviceSubClass
169| | |__DeviceClass
170| |__Device USB version
171|__Device info tag #1
172
173where
174P: Vendor=xxxx ProdID=xxxx Rev=xx.xx
175| | | |__Product revision number
176| | |__Product ID code
177| |__Vendor ID code
178|__Device info tag #2
179
180
181String descriptor info:
182
183S: Manufacturer=ssss
184| |__Manufacturer of this device as read from the device.
185| For USB host controller drivers (virtual root hubs) this may
186| be omitted, or (for newer drivers) will identify the kernel
187| version and the driver which provides this hub emulation.
188|__String info tag
189
190S: Product=ssss
191| |__Product description of this device as read from the device.
192| For older USB host controller drivers (virtual root hubs) this
193| indicates the driver; for newer ones, it's a product (and vendor)
194| description that often comes from the kernel's PCI ID database.
195|__String info tag
196
197S: SerialNumber=ssss
198| |__Serial Number of this device as read from the device.
199| For USB host controller drivers (virtual root hubs) this is
200| some unique ID, normally a bus ID (address or slot name) that
201| can't be shared with any other device.
202|__String info tag
203
204
205
206Configuration descriptor info:
207
208C:* #Ifs=dd Cfg#=dd Atr=xx MPwr=dddmA
209| | | | | |__MaxPower in mA
210| | | | |__Attributes
211| | | |__ConfiguratioNumber
212| | |__NumberOfInterfaces
213| |__ "*" indicates the active configuration (others are " ")
214|__Config info tag
215
216 USB devices may have multiple configurations, each of which act
217 rather differently. For example, a bus-powered configuration
218 might be much less capable than one that is self-powered. Only
219 one device configuration can be active at a time; most devices
220 have only one configuration.
221
222 Each configuration consists of one or more interfaces. Each
223 interface serves a distinct "function", which is typically bound
224 to a different USB device driver. One common example is a USB
225 speaker with an audio interface for playback, and a HID interface
226 for use with software volume control.
227
228
229Interface descriptor info (can be multiple per Config):
230
231I:* If#=dd Alt=dd #EPs=dd Cls=xx(sssss) Sub=xx Prot=xx Driver=ssss
232| | | | | | | | |__Driver name
233| | | | | | | | or "(none)"
234| | | | | | | |__InterfaceProtocol
235| | | | | | |__InterfaceSubClass
236| | | | | |__InterfaceClass
237| | | | |__NumberOfEndpoints
238| | | |__AlternateSettingNumber
239| | |__InterfaceNumber
240| |__ "*" indicates the active altsetting (others are " ")
241|__Interface info tag
242
243 A given interface may have one or more "alternate" settings.
244 For example, default settings may not use more than a small
245 amount of periodic bandwidth. To use significant fractions
246 of bus bandwidth, drivers must select a non-default altsetting.
247
248 Only one setting for an interface may be active at a time, and
249 only one driver may bind to an interface at a time. Most devices
250 have only one alternate setting per interface.
251
252
253Endpoint descriptor info (can be multiple per Interface):
254
255E: Ad=xx(s) Atr=xx(ssss) MxPS=dddd Ivl=dddss
256| | | | |__Interval (max) between transfers
257| | | |__EndpointMaxPacketSize
258| | |__Attributes(EndpointType)
259| |__EndpointAddress(I=In,O=Out)
260|__Endpoint info tag
261
262 The interval is nonzero for all periodic (interrupt or isochronous)
263 endpoints. For high speed endpoints the transfer interval may be
264 measured in microseconds rather than milliseconds.
265
266 For high speed periodic endpoints, the "MaxPacketSize" reflects
267 the per-microframe data transfer size. For "high bandwidth"
268 endpoints, that can reflect two or three packets (for up to
269 3KBytes every 125 usec) per endpoint.
270
271 With the Linux-USB stack, periodic bandwidth reservations use the
272 transfer intervals and sizes provided by URBs, which can be less
273 than those found in endpoint descriptor.
274
275
276=======================================================================
277
278
279If a user or script is interested only in Topology info, for
280example, use something like "grep ^T: /sys/kernel/debug/usb/devices"
281for only the Topology lines. A command like
282"grep -i ^[tdp]: /sys/kernel/debug/usb/devices" can be used to list
283only the lines that begin with the characters in square brackets,
284where the valid characters are TDPCIE. With a slightly more able
285script, it can display any selected lines (for example, only T, D,
286and P lines) and change their output format. (The "procusb"
287Perl script is the beginning of this idea. It will list only
288selected lines [selected from TBDPSCIE] or "All" lines from
289/sys/kernel/debug/usb/devices.)
290
291The Topology lines can be used to generate a graphic/pictorial
292of the USB devices on a system's root hub. (See more below
293on how to do this.)
294
295The Interface lines can be used to determine what driver is
296being used for each device, and which altsetting it activated.
297
298The Configuration lines could be used to list maximum power
299(in milliamps) that a system's USB devices are using.
300For example, "grep ^C: /sys/kernel/debug/usb/devices".
301
302
303Here's an example, from a system which has a UHCI root hub,
304an external hub connected to the root hub, and a mouse and
305a serial converter connected to the external hub.
306
307T: Bus=00 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=12 MxCh= 2
308B: Alloc= 28/900 us ( 3%), #Int= 2, #Iso= 0
309D: Ver= 1.00 Cls=09(hub ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
310P: Vendor=0000 ProdID=0000 Rev= 0.00
311S: Product=USB UHCI Root Hub
312S: SerialNumber=dce0
313C:* #Ifs= 1 Cfg#= 1 Atr=40 MxPwr= 0mA
314I: If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
315E: Ad=81(I) Atr=03(Int.) MxPS= 8 Ivl=255ms
316
317T: Bus=00 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=12 MxCh= 4
318D: Ver= 1.00 Cls=09(hub ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
319P: Vendor=0451 ProdID=1446 Rev= 1.00
320C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=100mA
321I: If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
322E: Ad=81(I) Atr=03(Int.) MxPS= 1 Ivl=255ms
323
324T: Bus=00 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#= 3 Spd=1.5 MxCh= 0
325D: Ver= 1.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
326P: Vendor=04b4 ProdID=0001 Rev= 0.00
327C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA
328I: If#= 0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=01 Prot=02 Driver=mouse
329E: Ad=81(I) Atr=03(Int.) MxPS= 3 Ivl= 10ms
330
331T: Bus=00 Lev=02 Prnt=02 Port=02 Cnt=02 Dev#= 4 Spd=12 MxCh= 0
332D: Ver= 1.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
333P: Vendor=0565 ProdID=0001 Rev= 1.08
334S: Manufacturer=Peracom Networks, Inc.
335S: Product=Peracom USB to Serial Converter
336C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=100mA
337I: If#= 0 Alt= 0 #EPs= 3 Cls=00(>ifc ) Sub=00 Prot=00 Driver=serial
338E: Ad=81(I) Atr=02(Bulk) MxPS= 64 Ivl= 16ms
339E: Ad=01(O) Atr=02(Bulk) MxPS= 16 Ivl= 16ms
340E: Ad=82(I) Atr=03(Int.) MxPS= 8 Ivl= 8ms
341
342
343Selecting only the "T:" and "I:" lines from this (for example, by using
344"procusb ti"), we have:
345
346T: Bus=00 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=12 MxCh= 2
347T: Bus=00 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=12 MxCh= 4
348I: If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
349T: Bus=00 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#= 3 Spd=1.5 MxCh= 0
350I: If#= 0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=01 Prot=02 Driver=mouse
351T: Bus=00 Lev=02 Prnt=02 Port=02 Cnt=02 Dev#= 4 Spd=12 MxCh= 0
352I: If#= 0 Alt= 0 #EPs= 3 Cls=00(>ifc ) Sub=00 Prot=00 Driver=serial
353
354
355Physically this looks like (or could be converted to):
356
357 +------------------+
358 | PC/root_hub (12)| Dev# = 1
359 +------------------+ (nn) is Mbps.
360 Level 0 | CN.0 | CN.1 | [CN = connector/port #]
361 +------------------+
362 /
363 /
364 +-----------------------+
365 Level 1 | Dev#2: 4-port hub (12)|
366 +-----------------------+
367 |CN.0 |CN.1 |CN.2 |CN.3 |
368 +-----------------------+
369 \ \____________________
370 \_____ \
371 \ \
372 +--------------------+ +--------------------+
373 Level 2 | Dev# 3: mouse (1.5)| | Dev# 4: serial (12)|
374 +--------------------+ +--------------------+
375
376
377
378Or, in a more tree-like structure (ports [Connectors] without
379connections could be omitted):
380
381PC: Dev# 1, root hub, 2 ports, 12 Mbps
382|_ CN.0: Dev# 2, hub, 4 ports, 12 Mbps
383 |_ CN.0: Dev #3, mouse, 1.5 Mbps
384 |_ CN.1:
385 |_ CN.2: Dev #4, serial, 12 Mbps
386 |_ CN.3:
387|_ CN.1:
388
389
390 ### END ###