USB On-The-Go, normally abbreviated USB OTG, is a supplement to the USB 2.0 specification.
The standard USB uses a master/slave architecture; a USB host acts as a master
and a USB peripheral acts as a slave. Only the USB host can schedule the configuration and data transfers over the link. The USB peripherals cannot initiate data transfers, they only respond to instructions given by a host.
USB OTG changes that situation. Gadgets don't need to be pure peripherals; they can sometimes act as hosts. An example might be connecting a USB keyboard or printer to a handheld wireless device; or a USB printer that knows how to grab documents from certain peripherals and print them. The USB OTG compatible devices are able to initiate the session, control the connection and exchange Host/Peripheral roles between each other.
The USB OTG supplement does not preclude using a hub, however it describes role swapping only in the case of a one-to-one connection where two OTG devices are directly connected. If a standard hub is used, the supplement notes that using it will lead to losing USB OTG role-swap capabilities, locking one device as the Default-Host and the other as the Default-Peripheral until the hub is disconnected.
The USB On-The-Go introduces two new protocols
(Session Request Protocol) and HNP
(Host Negotiation Protocol).
- SRP allows both communicating devices to control when the link's power session is active; in standard USB, only the host is capable of doing so. That allows fine control over the power consumption, which is very important for portable devices such as photo/video cameras and mobile phones. The OTG host can leave the USB link unpowered, and the peripheral asks it to start delivering power. OTG hosts may not have much power to spare from their batteries, and leaving the USB link unpowered helps stretch battery life.
- HNP allows the two devices to exchange their host/slave roles, provided both are OTG dual-role devices. By using HNP for reversing host/slave roles, the USB OTG peripheral is capable of acquiring the control over the data scheduling of the USB. Thus, any device is capable of initiating the data transfer over USB OTG bus.
The main purpose of HNP is to accommodate users who have connected the A and B devices (see below) in the wrong direction for the task they want to perform. For example, maybe the printer is serving as the A-host, but it can't work that way for a particular camera since it doesn't understand its representation of print jobs. But when that camera knows how to talk to the printer, that won't be a problem; the printer will use HNP to switch roles, the camera will act as a host to the printer, and the user will get her pictures printed without juggling cables.
It must be noted that these new OTG protocols cannot pass through a standard hub since they are based on physical signalling.
USB OTG defines two roles of devices: OTG A-device and OTG B-device. This terminology defines which side supplies power to the link, and which is initially the host. The OTG A-device is a power supplier, and an OTG B-device is a power consumer. The default link configuration is that A-device is Host and B-device is a Peripheral. The host and peripheral modes may be exchanged later by using HNP.
Because every OTG controller supports both roles, they are often called "Dual-Role" controllers rather than "OTG controllers". From the perspective of a silicon vendor, one of the attractions of USB OTG is the ability to get more USB capabilities with fewer gates.
A "traditional" approach includes a high speed host controller based on
EHCI (a register interface), a full/low speed host controller based on
OHCI (another register interface), a third peripheral-only controller supporting both high and full speeds, and a fourth controller to switch the OTG root port between host and peripheral controllers.
That's a lot of gates to test and debug.
Plus, most current customers want just a host, or just a peripheral. A simpler hardware design will merge all of those into one Dual-Role controller, somewhat more complex than the peripheral controller alone.
The USB On-The-Go standard introduces a new plug receptacle called micro-AB. It can accept either a micro-A plug or a micro-B plug. Micro-A Adapters allow connection to standard-A USB cables, coming from peripherals. The standard OTG cable has a micro-A plug on one side and a micro-B plug on the other (it cannot have two plugs of the same type). OTG adds a fifth pin to the USB micro connector, called the ID-pin; the micro-A plug has the ID pin grounded
while the ID in the micro-B plug is floating
The device that has a micro-A plugged in becomes an OTG A-device, and the one that has micro-B plugged becomes a B-device (see above). The type of the plug inserted is detected by the state of the pin ID .
There are also pure Micro-A sockets, used where a compact host port is needed but OTG is not supported. In this case, the socket will only accept a Micro-A plug based on the A and B connectors being mechanically slightly different.
USB OTG devices are backward compliant with USB 2.0 and will behave as standard USB Hosts or Peripherals when connected to standard (no OTG) USB devices.
The main exception is that OTG hosts are only required to provide a small amount of power, which may not be enough to connect to a non-OTG peripheral. This can sometimes be worked around by connecting the non-OTG peripheral through an externally powered hub if that OTG host supports hubs. (Such support is not required.)