There are 3 types of USB hardware ports.

  1. USB Client/Device port (Webcam, Mouse, Keyboard, Storage devices)
  2. USB Host port (Host controlls the client)
  3. USB On-The-Go port (USB OTG)

When two devices have a USB Connection, one device will have the host role and the other will have the device role. The host device controls the connection.

There are two basic ways the hardware can provide the device mode functionality:

  1. a separate “client port”, which only supports the device mode, and
  2. a USB OTG port, which can provide both device and host mode.

Device mode makes it possible for the computer to present itself as different kinds of USB device classes, including serial ports, network adapters, and mass storage, or a combination thereof. A USB host like a laptop or desktop computer is able to access them just like physical USB devices.

The USB OTG port is special because it can act as both device and host port. For USB OTG ports, the USB stack switches between host-side and device-side automatically, depending on what is connected to the port.

For example, newer smartphones

  • When connected to a computer - it’ll present itself as a storage device to the computer.
  • When a USB Flash drive is connected to the phone - it’ll act as a host device and access the flash drive.

References

FreeBSD Handbook
Android Guide
Wikipedia