Connecting the dots: A practical guide for USB OTG on embedded platforms
USB On-The-GO (OTG) support on Linux 2.6 was initially developed by Texas Instruments for OMAP 16xx and 17xx series processors. Other OTG systems should work in similar ways, but the hardware level details could be very different.
Systems need specialized hardware support to implement OTG, notably including a special Mini-AB jack and associated transceiver to support.
USB OTG can be act as "HOST" or "GADGET"
Dual-Role operation: They can act either as a host, using the standard Linux-USB host side driver stack, or as a peripheral, using this gadget framework. To do that, the system software relies on small additions to those programming interfaces, and on a new internal component (here called an "OTG Controller") affecting which driver stack connects to the OTG port.
The above images explain what type of device can be connected via a USB-OTG port. When OTG behaves as HOST, we can connect devices, which may be input or output devices. When it behaves as a gadget, it mostly uses to communicate between the host PC and the target device.
How to bring up a USB OTG port in an embedded platform
As described in the below image, there are 5 lines connected between the OTG port and the embedded platform.
During the bringup of this USB port, it is very simple; we have to just provide the proper power supply and configure the MUX related to the USB OTG port.
For example dts enrty for USB OTG in NXP:
reg_usb_otg_enable: regulator-usb-otg-enable {
compatible = "regulator-fixed";
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5000000>;
regulator-name = "reg_usb_otg_enable";
gpio = <&gpio1 14 GPIO_ACTIVE_HIGH>;
enable-active-high;
};
&usb3_phy1 {
vbus-supply = <®_usb_otg_enable>;
status = "okay";
};
&usb_dwc3_1 {
dr_mode = "otg";
hnp-disable;
srp-disable;
adp-disable;
usb-role-switch;
role-switch-default-mode = "otg";
snps,dis-u1-entry-quirk;
snps,dis-u2-entry-quirk;
disable-over-current;
status = "okay";
};
Inside the pinmux:
MX8MP_IOMUXC_GPIO1_IO14__GPIO1_IO14 0x1d4 /*USB_OTG_PWR_EN */
MX8MP_IOMUXC_GPIO1_IO11__GPIO1_IO11 0x1d4 /* USB_OTG_ID */
MX8MP_IOMUXC_GPIO1_IO15__GPIO1_IO15 0x1d4 /* USB_OTG_OC_N */
Recommended by LinkedIn
Serial data transfer using USB-OTG Port
The gadget serial driver is a Linux USB gadget driver, a USB device side driver. It runs on a Linux system that has USB device side hardware. The gadget serial driver talks over USB to either a CDC ACM driver or a generic USB serial driver running on a host PC. On the device-side Linux system, the gadget serial driver looks like a serial device.
How to Use USB Gadgets for File storage
The g_mass_storage driver allows a target device to appear as a USB Mass Storage device to a host system. It allows you to choose either a block device (such as a hard drive, MTD partition, or flash card) or a backing file to act as the backing storage for this device.
How to use USB Gadgets Ethernet
An Ethernet controller can add lots of complexity and cost to an embedded board, and consume a large amount of PCB real-estate. Most consumer embedded systems omit an Ethernet port completely, as do some development boards. The Linux USB gadget subsystem provides a way to leverage existing hardware (many devices have a USB device port) to use utilities such as NFS, SSH, and FTP. This is accomplished by using the g_ether driver. It creates an interface called usb0 on the target. Once the USB cable is connected to the host, it creates an interface known as usb0 on the host machine.
The above details talk about the usage and bringup of USB OTG ports in embedded platforms. Hopping this article will help you get a better idea of the USB-OTG port on embedded platforms.
References: