> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# USB

The Universal Serial Bus (USB) supports data exchange and power supply between electronic devices at speeds from 1.5 Mbps (low speed) up to 10 Gbps (SuperSpeed Plus). The IQ-8275 uses the **Synopsys DesignWare Core SuperSpeed USB 3.x** controller connected to USB2 PHY (UTMI) and USB3 PHY (PIPE) interfaces.

The board features three USB connectors: two Type-C (USB0, USB1) and one micro-USB (USB2).

## Controllers

| Controller | Address   | Max Speed          |
| ---------- | --------- | ------------------ |
| **USB0**   | 0xa600000 | USB 3.x SuperSpeed |
| **USB1**   | 0xa800000 | USB 3.x SuperSpeed |
| **USB2**   | 0xa400000 | USB 2.0 High Speed |

## Features

### Hardware Features

| Feature                    | Description                                       |
| -------------------------- | ------------------------------------------------- |
| **Dual-Role Device (DRD)** | Host and device modes with dynamic role detection |
| **USB 3.1 Gen1**           | SuperSpeed 5 Gbps on USB0 and USB1                |
| **USB 2.0 High Speed**     | 480 Mbps on all controllers                       |
| **xHCI**                   | eXtensible Host Controller Interface compliance   |
| **Transfer types**         | Control, bulk, interrupt, isochronous             |

### Software Features

**Peripheral mode:** Mass Storage, Diagnostics (FunctionFS), RNDIS, NCM

**Host mode:** xHCI, HID/MS/Hub class drivers, UVC (USB camera), Link Power Management

## Configuration

### Runtime Power Management

```bash theme={null}
echo auto > /sys/bus/platform/devices/a600000.usb/power/control
echo 2000 > /sys/bus/platform/devices/a600000.usb/power/autosuspend_delay_ms
cat /sys/bus/platform/devices/a600000.usb/power/runtime_status
```

### Prevent Suspend During Composition Switch

```bash theme={null}
echo on > /sys/bus/platform/devices/a600000.usb/power/control
# Perform composition switch
echo auto > /sys/bus/platform/devices/a600000.usb/power/control
```

## USB Camera

The IQ-8275 supports USB cameras that comply with the USB Video Class (UVC) standard via the `uvcvideo` kernel driver, exposing devices as `/dev/videoX`.

<Steps>
  <Step title="Detect the camera">
    ```bash theme={null}
    lsusb
    v4l2-ctl --list-devices
    ls -l /dev/v4l/by-id/
    ```
  </Step>

  <Step title="Check supported formats">
    ```bash theme={null}
    yavta /dev/video2 --enum-formats
    ```
  </Step>

  <Step title="Stream video">
    <Tabs>
      <Tab title="yavta">
        ```bash theme={null}
        yavta -f MJPEG -s 1280x720 -t 1/30 -c10 -F/home/ubuntu/test.jpeg /dev/video2
        ```
      </Tab>

      <Tab title="GStreamer">
        ```bash theme={null}
        export XDG_RUNTIME_DIR=/dev/socket/weston
        export WAYLAND_DISPLAY=wayland-1


        gst-launch-1.0 -e v4l2src device=/dev/video2 ! \
          video/x-raw,format=YUY2,width=1280,height=720,framerate=30/1 ! \
          videoconvert ! waylandsink fullscreen=true
        ```
      </Tab>
    </Tabs>
  </Step>
</Steps>

## Verification

```bash theme={null}
lsusb                              # List connected USB devices
cat /sys/kernel/debug/usb/devices  # Detailed device info
cat /sys/kernel/debug/usb/a600000.usb/mode        # Check USB mode
cat /sys/kernel/debug/usb/a600000.usb/link_state  # Check link state
```

## Debugging

```bash theme={null}
mount -t debugfs none /sys/kernel/debug
echo 1 > /sys/kernel/debug/tracing/events/dwc3/enable
echo 1 > /sys/kernel/debug/tracing/events/xhci-hcd/enable
cat /sys/kernel/debug/tracing/trace
```

## Troubleshooting

<AccordionGroup>
  <Accordion title="USB Device Not Enumerated">
    ```bash theme={null}
    cat /sys/kernel/debug/usb/a600000.usb/mode
    cat /sys/kernel/debug/usb/a600000.usb/link_state
    dmesg | grep -i usb
    ```

    * Check cable connection and power rails
  </Accordion>

  <Accordion title="USB Camera Not Working">
    ```bash theme={null}
    lsusb
    ls /dev/video*
    dmesg | grep -i uvc
    lsmod | grep uvcvideo
    ```
  </Accordion>
</AccordionGroup>

## Resources

* [DWC3 QCOM Driver](https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/drivers/usb/dwc3/dwc3-qcom.c?h=v6.6.2)
* [UVC Video Driver](https://www.kernel.org/doc/html/v4.19/media/v4l-drivers/uvcvideo.html)
* [LibUVC](https://github.com/libuvc/libuvc)
