The Kumquat board features a USB On-The-Go (OTG) port via a USB-C connector that supports USB 2.0 dual-role functionality. This means the port can act either as a USB host or a USB device, depending on the mode selected. The mode switching is handled by the TUSB320 controller, which is managed directly by the Linux kernel.
- **Dual Role Support**: Can function as both a USB host (for peripherals) and a USB device.
- **Power Supply**: In host mode, the port can supply 5V at 500mA to connected devices.
- **Mode Switching**: Automatically managed by the Linux kernel via the TUSB320 controller.
## Mode Switching with TUSB320
The TUSB320 controller allows the system to dynamically switch between USB host mode and USB device mode. In host mode, the Kumquat board can connect and power peripherals like keyboards, mice, or flash drives. In device mode, the board can act as a USB peripheral, such as a mass storage device or a serial device.
The Linux kernel automatically handles the negotiation between device and host modes based on the connected device.
## Sysfs Interface
The USB controller on the Kumquat board is the **Allwinner V3s MUSB** controller, which uses the Linux kernel's MUSB driver. You can access and manage USB OTG settings via the sysfs interface.
The typical path for the MUSB controller's sysfs interface will look something like:
After loading the module, the board will create a new serial device that the host PC can detect. You can check the created device by looking at `/dev`:
This command connects to the USB-serial device at a baud rate of 115200. You should now be able to send and receive data between the Kumquat board and the host PC.
6.**Stop the USB Serial Device**
To stop the USB-serial device and return to the previous configuration, unload the `g_serial` module:
When the Kumquat board operates in host mode, it can supply up to **500mA of current at 5V** to the connected device. This power is supplied directly via the USB-C connector, making it suitable for low-power USB devices.
However, ensure that the total current consumption of all connected devices does not exceed 500mA, as the board may become unstable or fail to power high-demand devices.
## Summary
The USB-OTG port on the Kumquat board provides flexible connectivity for both host and device roles, controlled by the TUSB320 IC. In host mode, the board can connect to and power external devices like USB sticks, while in device mode, it can function as a USB peripheral such as a serial interface. Mode switching is automatic, making the port versatile for a variety of embedded use cases.
For more advanced use cases, such as creating custom USB gadgets, consult the [Linux USB Gadget API documentation](https://www.kernel.org/doc/Documentation/usb/gadget_configfs.txt).