How use USB as both gadget mode and host mode usb USB_OTG?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How use USB as both gadget mode and host mode usb USB_OTG?

6,529 Views
bandarulavanya
Contributor V

Hi All,

I need to use USB as gadget and Host mode also in imx6 sabresd board. by selecting USB_OTG how can do that if any one have an idea kindly share the details.

Thanks & Regards,

Lavanya

Labels (3)
0 Kudos
6 Replies

3,878 Views
nguyenmr
Contributor III

Hi Lavanya,

please show your usb otg diagram. i use this and it's working well

pastedImage_1.png

0 Kudos

3,878 Views
nguyenmr
Contributor III

Hi,

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 = <&reg_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, i can use OTG port for mouse, usb stick in host mode, and gadget mode for ADB...

BR/Nguyen

0 Kudos

3,878 Views
bandarulavanya
Contributor V

Hi Nguyen Mr,

I tried same procedure as you said but it's not working.

usb 1-1: new high-speed USB device number 20 using ci_hdrc
usb 1-1: New USB device found, idVendor=1908, idProduct=0226
usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
usb 1-1: USB disconnect, device number 20
usb 1-1: new high-speed USB device number 21 using ci_hdrc
usb 1-1: New USB device found, idVendor=1908, idProduct=0226
usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
usb 1-1: USB disconnect, device number 21
usb 1-1: new high-speed USB device number 22 using ci_hdrc
usb 1-1: New USB device found, idVendor=1908, idProduct=0226
usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
usb 1-1: USB disconnect, device number 22
usb 1-1: new high-speed USB device number 23 using ci_hdrc
usb 1-1: New USB device found, idVendor=1908, idProduct=0226
usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
usb 1-1: USB disconnect, device number 23

am getting like this continuously. How i can debug this issue.

Thanks

Lavanya

0 Kudos

3,878 Views
igorpadykov
NXP Employee
NXP Employee

Hi Lavanya

please refer to sect.39.3.11 USB OTG HNP and SRP Support

attached Linux Manual.

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

3,878 Views
bandarulavanya
Contributor V

HI igorpadykov ,

I have tried for both Host and Device mode configuration using OTG, In device mode it's working fine but in host mode device(pendrive with OTG cable) continuously disconnecting and reconnecting. For Reference i have attached the log below with my menu configurations and device tree.

LOG:

root@imx6_fs_wcam:~# usb 2-1: New USB device found, idVendor=1908, idProduct=0226
usb 2-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
usb 2-1: USB disconnect, device number 89
usb 2-1: new high-speed USB device number 90 using ci_hdrc
usb 2-1: New USB device found, idVendor=1908, idProduct=0226
usb 2-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0

root@imx6_fs_wcam:~# usb 2-1: USB disconnect, device number 90
usb 2-1: new high-speed USB device number 91 using ci_hdrc
usb 2-1: New USB device found, idVendor=1908, idProduct=0226
usb 2-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
usb 2-1: USB disconnect, device number 91
usb 2-1: new high-speed USB device number 92 using ci_hdrc
usb 2-1: New USB device found, idVendor=1908, idProduct=0226
usb 2-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
usb 2-1: USB disconnect, device number 92
usb 2-1: new high-speed USB device number 93 using ci_hdrc

root@imx6_fs_wcam:~# usb 2-1: New USB device found, idVendor=1908, idProduct=0226
usb 2-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
usb 2-1: USB disconnect, device number 93
usb 2-1: new high-speed USB device number 94 using ci_hdrc
usb 2-1: New USB device found, idVendor=1908, idProduct=0226
usb 2-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
usb 2-1: USB disconnect, device number 94

root@imx6_fs_wcam:~# usb 2-1: new high-speed USB device number 95 using ci_hdrc
usb 2-1: New USB device found, idVendor=1908, idProduct=0226
usb 2-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
usb 2-1: USB disconnect, device number 95

Menuconfig: (kernel - 3.14.28 yocto setup)

CONFIG_IMX_HAVE_PLATFORM_FSL_USB2_UDC=y

CONFIG_USB_HID=y

CONFIG_USB_OHCI_LITTLE_ENDIAN=y
CONFIG_USB_SUPPORT=y
CONFIG_USB_COMMON=y
CONFIG_USB_ARCH_HAS_HCD=y
CONFIG_USB=y

CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
CONFIG_USB_DEFAULT_PERSIST=y

CONFIG_USB_OTG=y

CONFIG_USB_OTG_FSM=y

CONFIG_USB_WUSB=y

CONFIG_USB_EHCI_HCD=y
CONFIG_USB_EHCI_ROOT_HUB_TT=y
CONFIG_USB_EHCI_TT_NEWSCHED=y
CONFIG_USB_FSL_MPH_DR_OF=y
CONFIG_USB_EHCI_PCI=y
CONFIG_USB_EHCI_MXC=y
CONFIG_USB_EHCI_HCD_PLATFORM=y

CONFIG_USB_HWA_HCD=y

CONFIG_USB_STORAGE=m
CONFIG_USB_STORAGE_DEBUG=y

CONFIG_USB_CHIPIDEA=y
CONFIG_USB_CHIPIDEA_UDC=y
CONFIG_USB_CHIPIDEA_HOST=y

CONFIG_USB_PHY=y

CONFIG_USB_MXS_PHY=y

CONFIG_USB_GADGET=y

CONFIG_USB_GADGET_DEBUG_FS=y
CONFIG_USB_GADGET_VBUS_DRAW=2
CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS=2

CONFIG_USB_FSL_USB2=y

CONFIG_USB_LIBCOMPOSITE=m
CONFIG_USB_F_MASS_STORAGE=m

CONFIG_USB_MASS_STORAGE=m

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>;
                        output-high;
                        enable-active-high;
                };

                reg_usb_h1_vbus: regulator@1 {
                        compatible = "regulator-fixed";
                        reg = <1>;
                        regulator-name = "usb_h1_vbus";
                        regulator-min-microvolt = <5000000>;
                        regulator-max-microvolt = <5000000>;
                        gpio = <&gpio1 29 0>;
                        enable-active-high;
                };

   pinctrl_usbotg: usbotggrp {
                        fsl,pins = <
                                MX6QDL_PAD_GPIO_1__USB_OTG_ID           0x17059
                                MX6QDL_PAD_EIM_D21__USB_OTG_OC          0x80000000
                        >;
                };

&usbh1 {
        vbus-supply = <&reg_usb_h1_vbus>;
        status = "okay";
};

&usbotg {
        vbus-supply = <&reg_usb_otg_vbus>;
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_usbotg>;
        dr-mode="otg";
        output-high;
        disable-over-current;
        status = "okay";
};

Kindly help me to resolve this issue.

Thanks

Lavanya

0 Kudos

3,878 Views
igorpadykov
NXP Employee
NXP Employee

Hi Lavanya

 

please try latest L4.1.15 BSPs described on

i.MX 6 / i.MX 7 Series Software and Development Tool|NXP 

 

Best regards
igor

0 Kudos