Skip site navigation (1)Skip section navigation (2)

FreeBSD Man Pages

Man Page or Keyword Search:
Man Architecture
Apropos Keyword Search (all sections) Output format
home | help
USB(4)		       FreeBSD Kernel Interfaces Manual			USB(4)

NAME
     usb -- Universal Serial Bus

SYNOPSIS
     device usb

DESCRIPTION
     FreeBSD provides machine-independent bus support and drivers for USB
     devices.

     The usb driver has	three layers: the controller, the bus, and the device
     layer.  The controller attaches to	a physical bus (like pci(4)).  The USB
     bus attaches to the controller and	the root hub attaches to the con-
     troller.  Any devices attached to the bus will attach to the root hub or
     another hub attached to the USB bus.

     The uhub device will always be present as it is needed for	the root hub.

INTRODUCTION TO	USB
     The USB is	a 12 Mb/s serial bus (1.5 Mb/s for low speed devices).	Each
     USB has a host controller that is the master of the bus; all other
     devices on	the bus	only speak when	spoken to.

     There can be up to	127 devices (apart from	the host controller) on	a bus,
     each with its own address.	 The addresses are assigned dynamically	by the
     host when each device is attached to the bus.

     Within each device	there can be up	to 16 endpoints.  Each endpoint	is
     individually addressed and	the addresses are static.  Each	of these end-
     points will communicate in	one of four different modes: control,
     isochronous, bulk,	or interrupt.  A device	always has at least one	end-
     point.  This endpoint has address 0 and is	a control endpoint and is used
     to	give commands to and extract basic data, such as descriptors, from the
     device.  Each endpoint, except the	control	endpoint, is unidirectional.

     The endpoints in a	device are grouped into	interfaces.  An	interface is a
     logical unit within a device; e.g.	a compound device with both a keyboard
     and a trackball would present one interface for each.  An interface can
     sometimes be set into different modes, called alternate settings, which
     affects how it operates.  Different alternate settings can	have different
     endpoints within it.

     A device may operate in different configurations.	Depending on the con-
     figuration	the device may present different sets of endpoints and inter-
     faces.

     Each device located on a hub has several config(8)	locators:
     port    this is the number	of the port on the closest upstream hub.
     configuration
	     this is the configuration the device must be in for this driver
	     to	attach.	 This locator does not set the configuration; it is
	     iterated by the bus enumeration.
     interface
	     this is the interface number within a device that an interface
	     driver attaches to.

     The bus enumeration of the	USB bus	proceeds in several steps:

     1.	  Any device specific driver can to attach to the device.

     2.	  If none is found, any	device class specific driver can attach.

     3.	  If none is found, all	configurations are iterated over.  For each
	  configuration	all the	interface are iterated over and	interface
	  drivers can attach.  If any interface	driver attached	in a certain
	  configuration	the iteration over configurations is stopped.

     4.	  If still no drivers have been	found, the generic USB driver can
	  attach.

USB CONTROLLER INTERFACE
     Use the following to get access to	the USB	specific structurs and
     defines.

     #include <sys/dev/usb.h>

     The /dev/usbN can be opened and a few operations can be performed on it.
     The poll(2) system	call will say that I/O is possible on the controller
     device when a USB device has been connected or disconnected to the	bus.

     The following ioctl(2) commands are supported on the controller device:

     USB_DISCOVER
	     This command will cause a complete	bus discovery to be initiated.
	     If	any devices attached or	detached from the bus they will	be
	     processed during this command.  This is the only way that new
	     devices are found on the bus.

     USB_DEVICEINFO struct usb_device_info
	     This command can be used to retrieve some information about a
	     device on the bus.	 The addr field	should be filled before	the
	     call and the other	fields will be filled by information about the
	     device on that address.  Should no	such device exist an error is
	     reported.

	     struct usb_device_info {
		     u_int8_t	     bus;
		     u_int8_t	     addr;
	     #	     define USBDEVNAME_NR  4
	     #	     define USBDEVNAME_LEN 10
		     char	     devnames[USBDEVNAME_NR][USBDEVNAME_LEN];
		     char	     product[USB_MAX_STRING_LEN];
		     char	     vendor[USB_MAX_STRING_LEN];
		     char	     release[8];
		     u_int16_t	     productNo;
		     u_int16_t	     vendorNo;
		     u_int16_t	     releaseNo;
		     u_int8_t	     class;
		     u_int8_t	     subclass;
		     u_int8_t	     protocol;
		     u_int8_t	     config;
		     u_int8_t	     lowspeed;
		     int	     power;
		     int	     nports;
		     u_int8_t	     ports[16];
	     #define USB_PORT_ENABLED	   0xff
	     #define USB_PORT_SUSPENDED	   0xfe
	     #define USB_PORT_POWERED	   0xfd
	     #define USB_PORT_DISABLED	   0xfc
	     };

	     bus and addr contain the topological information for the device.
	     devnames contains the device names	of the connected drivers.  For
	     example the third USB Zip drive connected will be umass2.	The
	     product, vendor and release fields	contain	self-explanatory
	     descriptions of the device.  productNo, vendorNo, releaseNo,
	     class, subclass and protocol contain the corresponding values
	     from the device descriptors.  The config field shows the current
	     configuration of the device.

	     lowspeed indicates	whether	the device is a	full speed (0) or low
	     speed (1) device.	The power field	shows the power	consumption in
	     milli-amps	drawn at 5 volts, or zero if the device	is self	pow-
	     ered.

	     If	the device is a	hub the	nports field is	non-zero and the ports
	     field contains the	addresses of the connected devices.  If	no
	     device is connected to a port one of the USB_PORT_* values	indi-
	     cates its status.

     USB_DEVICESTATS struct usb_device_stats
	     This command retrieves statistics about the controller.

	     struct usb_device_stats {
		     u_long  requests[4];
	     };

	     The requests field	is indexed by the transfer kind, i.e. UE_*,
	     and indicates how many transfers of each kind that	has been com-
	     pleted by the controller.

     USB_REQUEST struct	usb_ctl_request
	     This command can be used to execute arbitrary requests on the
	     control pipe.  This is DANGEROUS and should be used with great
	     care since	it can destroy the bus integrity.

     The include file <dev/usb/usb.h> contains definitions for the types used
     by	the various ioctl(2) calls.  The naming	convention of the fields for
     the various USB descriptors exactly follows the naming in the USB speci-
     fication.	Byte sized fields can be accessed directly, but	word (16 bit)
     sized fields must be access by the	UGETW(field) and USETW(field, value)
     macros to handle byte order and alignment properly.

     The include file <dev/usb/usbhid.h> similarly contains the	definitions
     for Human Interface Devices (HID).

SEE ALSO
     The USB specifications can	be found at
     http://www.usb.org/developers/docs.htm.

     ohci(4), pci(4), uhci(4), uhid(4),	ukbd(4), ums(4), usbd(8), usbdevs(8)

HISTORY
     The usb driver first appeared in FreeBSD 3.0.

AUTHORS
     The usb driver was	written	by Lennart Augustsson <augustss@carlstedt.se>
     for the NetBSD project.

FreeBSD	10.1		       February	21, 1999		  FreeBSD 10.1

NAME | SYNOPSIS | DESCRIPTION | INTRODUCTION TO USB | USB CONTROLLER INTERFACE | SEE ALSO | HISTORY | AUTHORS

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=usb&sektion=4&manpath=FreeBSD+4.5-RELEASE>

home | help