1.\" $FreeBSD$ 2.\" 3.\" Copyright (c) 2008-2019 Hans Petter Selasky. All rights reserved. 4.\" 5.\" Redistribution and use in source and binary forms, with or without 6.\" modification, are permitted provided that the following conditions 7.\" are met: 8.\" 1. Redistributions of source code must retain the above copyright 9.\" notice, this list of conditions and the following disclaimer. 10.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" notice, this list of conditions and the following disclaimer in the 12.\" documentation and/or other materials provided with the distribution. 13.\" 14.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24.\" SUCH DAMAGE. 25.\" 26.Dd December 21, 2021 27.Dt USBCONFIG 8 28.Os 29.Sh NAME 30.Nm usbconfig 31.Nd configure the USB subsystem 32.Sh SYNOPSIS 33.Nm 34.Op Fl u Ar unit 35.Op Fl a Ar addr 36.Op Fl i Ar interface_index 37.Op Fl v 38.Op cmds... 39.Nm 40.Fl d Ar [[/dev/]ugen]<unit>.<addr> 41.Op Fl i Ar interface_index 42.Op Fl v 43.Op cmds... 44.Sh DESCRIPTION 45The 46.Nm 47utility is used to configure and dump information about the USB subsystem. 48.Pp 49The options are as follows: 50.Bl -tag -width " " 51.It Fl u Ar unit 52Limit device range to USB devices connected to the given USBUS unit. 53.It Fl a Ar addr 54Limit device range to the given USB device index. 55Should only be used in conjunction with the unit argument. 56.It Fl d Ar [[/dev/]ugen]<unit>.<addr> 57Limit device range to USB devices connected to the given unit and address. 58The unit and address coordinates may be prefixed by the lowercased word "ugen", 59or the full path name 60.Pa /dev/ugen . 61.It Fl h 62Show help and available commands. 63.It Fl i Ar interface_index 64Specify interface index as indicated by the command description. 65If this argument is not specified a value of zero will be used for the interface index. 66.It Fl v 67Shortcut to activate the 68.Cm dump_device_desc , 69.Cm dump_curr_config_desc , 70and 71.Cm show_ifdrv 72commands 73.Pq Dq verbose mode . 74.El 75.Pp 76The following commands may be used with 77.Nm : 78.Bl -tag -width indent 79.It Cm set_config Ar cfg_index 80Choose the configuration for the USB device. 81Valid values range from zero to the number reported as the 82.Ar bNumConfigurations 83in 84.Cm dump_device_desc 85output. 86The special value of 255 unconfigures the device, detaching 87the interface drivers and reducing the power consumption to minimum, 88but without going into power saving mode or detaching from the bus. 89In some cases, it prevents the device from charging. 90.It Cm set_alt Ar alt_index 91Choose the alternate interface for the selected interface and USB device. 92Alternative settings for the current configuration are available as the 93.Ar bAlternateSetting 94in 95.Cm dump_curr_config_desc 96output. 97Usually there is no need to adjust this setting. 98This command uses the 99.Fl i Ar interface_index 100option. 101.It Cm set_template Ar template 102Set the global USB device side template. 103See 104.Xr usb_template 4 105for more information. 106.It Cm get_template 107Get the current USB device side template. 108.It Cm add_dev_quirk_vplh Ar vid Ar pid Ar lo_rev Ar hi_rev Ar quirk_name 109Add a quirk by specifying the Vendor ID, Product ID, low and high 110revision numbers, and the quirk name. 111See 112.Xr usb_quirk 4 113for more information. 114.It Cm remove_dev_quirk_vplh Ar vid Ar pid Ar lo_rev Ar hi_rev Ar quirk_name 115Remove a quirk. 116.It Cm add_quirk Ar quirk_name 117Add quirk for the currently selected USB device. 118.It Cm remove_quirk Ar quirk_name 119Remove a quirk for the currently selected USB device. 120.It Cm dump_all_desc 121Display the device and configuration descriptors. 122.It Cm dump_quirk_names 123Display the list of supported quirk names. 124.It Cm dump_device_quirks 125Display the list of current device quirks. 126.It Cm dump_device_desc 127Display the device descriptor. 128.It Cm dump_curr_config_desc 129Display current configuration descriptor. 130.It Cm dump_all_config_desc 131Display all the configuration descriptors. 132.It Cm dump_string Ar index 133Display string descriptor at selected index. 134.It Cm dump_info 135Display summary information about the device. 136.It Cm dump_stats 137Display USB transfer statistics. 138.It Cm show_ifdrv 139Display the list of interface drivers (such as 140.Xr ukbd 4 141or 142.Xr u3g 4 ) 143currently attached to the device. 144.It Cm detach_kernel_driver 145Detach kernel driver for the selected interface and USB device. 146This command uses the 147.Fl i Ar interface_index 148option. 149.It Cm suspend 150Force the device to suspend. 151.It Cm resume 152Force the device to resume. 153.It Cm power_off 154Turn the device off. 155.It Cm power_save 156Turn the automatic suspend and resume on. 157This is the default for USB hubs. 158.It Cm power_on 159Turn the device on and disable automatic suspend and resume. 160This is the default for non-hub devices. 161.It Cm reset 162Reset the device. 163This forces the USB stack to reenumerate the bus. 164.It Cm list 165List all available USB devices. 166This is the default if 167.Nm 168is called without specifying a command. 169.It Cm do_request Ar bmReqTyp Ar bReq Ar wVal Ar wIdx Ar wLen Ar data... 170Perform a synchronous control request on the specified device. 171See 172.Xr libusb20_dev_request_sync 3 173for more information. 174.El 175.Sh EXAMPLES 176List all connected USB devices and their attached interface drivers: 177.Pp 178.Dl usbconfig show_ifdrv 179.Pp 180Dump device and configuration descriptors for device on USB bus 1 at address 2: 181.Pp 182.Dl usbconfig ugen1.2 dump_all_desc 183.Pp 184Dump HID descriptor for device on USB bus 1 at address 2: 185.Pp 186.Dl usbconfig ugen1.2 do_request 0x81 0x06 0x2200 0 0x100 187.Pp 188Power off the device on USB bus 1 at address 2: 189.Pp 190.Dl usbconfig ugen1.2 power_off 191.Sh SEE ALSO 192.Xr usb 4 , 193.Xr usb_quirk 4 , 194.Xr usb_template 4 195