USB Host/On-The-Go
The i.MX6 universal serial bus (USB) driver implements a standard Linux driver interface to the CHIPIDEA USB-HS On-The-Go (OTG) controller. The CHIPIDEA USB controller is enhanced host controller interface (EHCI) compliant.
The ConnectCore 6 system-on-module has one USB OTG port with integrated PHY and three USB Host ports.
Kernel configuration
You can manage the USB Host support through the kernel configuration options:
- Support for Host-side USB (CONFIG_USB)
- EHCI HCD (USB 2.0) support (CONFIG_USB_EHCI_HCD)
- ChipIdea Highspeed Dual Role Controller (CONFIG_USB_CHIPIDEA)
- ChipIdea device controller (CONFIG_USB_CHIPIDEA_UDC)
- ChipIdea host controller (CONFIG_USB_CHIPIDEA_HOST)
- Freescale MXS USB PHY support (CONFIG_USB_MXS_PHY)
You can manage the USB OTG support through the kernel configuration option:
- OTG support (CONFIG_USB_OTG)
All kernel configuration options are enabled as built-in on the default ConnectCore 6 SBC kernel configuration file.
Platform driver mapping
The i.MX6 USB Host driver is located at drivers/usb/.
File | Description |
---|---|
chipidea/core.c | Chipidea IP core driver |
chipidea/udc.c | Chipidea peripheral driver |
chipidea/host.c | Chipidea host driver |
chipidea/ci_hdrc_imx.c | i.MX glue layer |
chipidea/usbmisc_imx.c | i.MX SoC abstract layer |
phy/phy-mxs-usb.c | i.MX USB physical driver |
The USB OTG driver for the ConnectCore 6 system-on-module includes the USB Host driver sources and the following sources located at driver/usb/chipidea.
File | Description |
---|---|
otg.c | Chipidea OTG driver |
otg_fsm.c | Chipidea OTG HNP and SRP driver |
Device tree bindings and customization
USB Host
The i.MX6 USB Host interface device tree binding is documented at Documentation/devicetree/bindings/usb/fsl-usb.txt.
The USB Host interface is defined in the i.MX6 CPU and ConnectCore 6 SBC device tree files.
Definition of the USB Host
Common i.MX6 device tree
usbh1: usb@02184200 { compatible = "fsl,imx6q-usb", "fsl,imx27-usb"; reg = <0x02184200 0x200>; interrupts = <0 40 IRQ_TYPE_LEVEL_HIGH>; clocks = <&clks IMX6QDL_CLK_USBOH3>; fsl,usbphy = <&usbphy2>; fsl,usbmisc = <&usbmisc 1>; status = "disabled"; };
IOMUX configuration
The USB Host uses dedicated pins for the USB Host interface. No IOMUX configuration is necessary.
USB host enabling and parameters
ConnectCore 6 SBC device tree
&usbh1 { fsl,reset-gpio = <&gpio3 10 0>; status = "okay"; };
USB OTG
The i.MX6 USB OTG interface device tree binding is documented at Documentation/devicetree/bindings/usb/usbmisc-imx.txt.
The USB OTG interface is defined in the i.MX6 CPU, ConnectCore 6 system-on-module, and ConnectCore 6 SBC device tree files.
Definition of the USB OTG
Common i.MX6 device tree
usbotg: usb@02184000 { compatible = "fsl,imx6q-usb", "fsl,imx27-usb"; reg = <0x02184000 0x200>; interrupts = <0 43 IRQ_TYPE_LEVEL_HIGH>; clocks = <&clks IMX6QDL_CLK_USBOH3>; fsl,usbphy = <&usbphy1>; fsl,usbmisc = <&usbmisc 0>; fsl,anatop = <&anatop>; status = "disabled"; };
IOMUX configuration
ConnectCore 6 system-on-module device tree
usbotg { pinctrl_usbotg: usbotg { fsl,pins = < MX6QDL_PAD_GPIO_1__USB_OTG_ID 0x17059 MX6QDL_PAD_EIM_D22__USB_OTG_PWR 0x17059 MX6QDL_PAD_EIM_D21__USB_OTG_OC 0x17059 >; }; };
USB OTG enabling and parameters
ConnectCore 6 SBC device tree
&usbotg { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_usbotg>; fsl,power-line-polarity-active-high; fsl,over-current-polarity-active-low; status = "okay"; };
USB Host/On-The-Go user space usage examples
The USB Host device driver exposes the connected devices through the file system at /dev/bus/usb/.
Linux identifies USB devices as soon as they are plugged in. Depending on the log level, the serial console may display a message reporting that the USB device has been plugged in. For example, plugging in a USB memory stick displays this message:
sd 1:0:0:0: [sda] 1970176 512-byte logical blocks: (1.00 GB/962 MiB) platform fixedregulator.25: Driver reg-fixed-voltage requests probe deferral sd 1:0:0:0: [sda] Write Protect is off sd 1:0:0:0: [sda] Mode Sense: 0b 00 00 08 sd 1:0:0:0: [sda] No Caching mode page found sd 1:0:0:0: [sda] Assuming drive cache: write through sd 1:0:0:0: [sda] No Caching mode page found sd 1:0:0:0: [sda] Assuming drive cache: write through sda: sda1 sd 1:0:0:0: [sda] No Caching mode page found sd 1:0:0:0: [sda] Assuming drive cache: write through sd 1:0:0:0: [sda] Attached SCSI removable disk FAT-fs (sda1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
If no message is displayed on the console, you can view all the system messages by printing the contents of the system log file:
# cat /var/log/messages
To get a list of the connected USB devices on the USB Host port, use the command lsusb:.
# lsusb Bus 001 Device 004: ID 0781:5530 SanDisk Corp. Cruzer Bus 001 Device 002: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
To get more detailed information on the connected USB device, use
# lsusb -D /dev/bus/usb/001/004
where the first numbered folder corresponds to the bus number and the second to the device number.
USB memory sticks
Linux automatically mounts USB memory sticks' partitions as /media/sdxN, where x is a letter and N the index of the partition (starting at 1).
If Linux does not automatically mount a partition, you can mount it manually. Use the mount command, passing the corresponding file system type with -t option and the mount point folder; for example, for a FAT32 file system:
# mkdir /media/myusb # mount -t vfat /dev/sda1 /media/myusb
Other USB input devices
Other USB input devices, such as a mouse or a keyboard, can be used immediately after being connected. For example, connect a keyboard to a USB connector. Then, run the following command to dump the keyboard key events:
# hexdump /dev/input/event0