Q:How use USB as both gadget mode and host mode usb USB_OTG?
A:
Hardware:
imx6 sabresd board
usb otg diagram, as follow
Software:
You can use USB OTG port for both host mode and device gadget mode. There are 2 signals you should care:
- USB_OTG_ID
- USB_OTG_MODE (control power for usb vbus in host mode, this is EIM_D22 pin)
In device tree:
reg_usb_otg_vbus: regulator@0 {
compatible = "regulator-fixed";
reg = <0>;
regulator-name = "usb_otg_vbus";
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5000000>;
gpio = <&gpio3 22 0>;
enable-active-high;
};
pinctrl_usbotg: usbotggrp {
fsl,pins = <
MX6QDL_PAD_GPIO_1__USB_OTG_ID 0x17059
MX6QDL_PAD_EIM_D22__GPIO3_IO22 0x80000000
>;
};
&usbotg {
vbus-supply = <®_usb_otg_vbus>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_usbotg>;
disable-over-current;
srp-disable;
hnp-disable;
adp-disable;
dr_mode = "otg";
status = "okay";
};
With above config, one can use OTG port for mouse, usb stick in host mode, and gadget mode for ADB...