The universal serial bus (USB) On-the-Go (OTG) specification, a supplement to the USB 2.0 . USB host capability that enables point-to-point communication. Such a setup allows embedded devices such as digital cameras, mobile phones, and printers to connect to each other directly.
An embedded USB device that switches roles, referred as dual role device, has features that include minimal USB host capability, Session Request Protocol (SRP), Host Negotiation Protocol (HNP), and 8mA on VBUS.
Linux has a simple infrastructure to support OTG devices. The OTG infrastructure is much closer to the hardware, similar to the peripheral device controller (PDC) driver, the OTG framework is responsible for handling
and responding to the OTG protocol negotiations such as SRP and HNP.broad level, the functionality of the OTG framework controls the USB transceiver hardware to meet the OTG requirement.
OTG Driver Framework
The OTG framework is not clearly defined like the gadget framework is sometimes the OTG implementation is mixed with the other frameworks. The Linux USB subsystem source code of OTG framework is maintained in the
/drivers/usb/otg/ folder. Some part of the usbcore module plays a key role (drivers/usb/core/hub.c). Most of the OTG activities are based on the physical layer activity and the timing of the electrical signals. The role of OTG software framework is minimal .It is responsible for setting up the signal and switching to different states defined by the OTG specification .
The OTG framework is divided into two major parts: callback methods and utility functions. The methods provided by struct otg_tranceiver are extended to the other Linux USB frameworks using wrapper functions. The OTG
framework also helps save and retrieve the struct otg_transceiver object using utility functions. The other main part is interface methods of the transceiver to platform.
The OTG driver flow consists of both the host and the device driver framework, taking its part to switch the role by using the OTG framework. Like the PDC driver, the OTG driver is specific to the hardware and the platform
for which the transceiver is developed. OTG driver starts by registering itself successfully with the Linux platform, along with the platform callbacks such as probe routine. The platform calls the registered probe routine when it detects transceiver. The probe routine maps the platform resource and creates the struct otg_transceiver object. The probe routine also sets the callbacks of otg_transceiver. Once the probe is successful, the OTG framework is functionally ready for the host and gadget framework to use it.