Switch USB role on imx6 without ID pin

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

Switch USB role on imx6 without ID pin

1,533 Views
crudo
Contributor I
Is it possible to switch USB roles on i.MX6 purely via SW without defining the OTG ID pin in the device tree?
 
I have the following device tree configuration on my board.
 
&usbotg1 {
    pinctrl-names = "default";
    dr_mode = "otg";
    status = "okay";
};
 
After I boot the board, it's operating on gadget mode (initial state) without issues. And I can switch to host mode using the command below.
 
echo host > /sys/kernel/debug/ci_hdrc.0/role
In host mode, everything work as expected. However, when I try to switch back to gadget mode using the same command it doesn't work anymore.
 
echo gadget > /sys/kernel/debug/ci_hdrc.0/role

Switching to host again, works.

Questions

  • Do I necessarily need to define the USB OTG ID pin on the device tree or can I switch via software?
  • Why gadget mode works once after a fresh boot?
  • What happens when no ID pin is defined?
Labels (1)
Tags (2)
0 Kudos
Reply
4 Replies

1,453 Views
rudi_cyber
Contributor III

You can refer to the document to finish configuration and setting. 

linux-imx\Documentation\usb\chipidea.rst

The chipidea.rst has very detailed steps. 

usb id pin is no needed. Or it could not be called "role switch".

has usb id is called "otg" mode. 

 

linux-imx\Documentation\usb\chipidea.rst

 

0 Kudos
Reply

1,427 Views
crudo
Contributor I

Thanks for pointing me to the documentation @rudi_cyber. I added CONFIG_USB_OTG_FSM=y to the kernel config as described in https://www.kernel.org/doc/html/latest/usb/chipidea.html but I get a compilation error.

|   CC      drivers/usb/host/ehci-hcd.o
| In file included from /kernel-source/drivers/usb/chipidea/trace.h:18,
|                  from /kernel-source/drivers/usb/chipidea/trace.c:11:
| /kernel-source/drivers/usb/chipidea/ci.h: In function 'ci_otg_is_fsm_mode':
| /kernel-source/drivers/usb/chipidea/ci.h:476:47: error: dereferencing pointer to incomplete type 'struct ci_hdrc_platform_data'
|   476 |  struct usb_otg_caps *otg_caps = &ci->platdata->ci_otg_caps;
|       |                                               ^~
|   CC      drivers/usb/chipidea/host.o
| make[4]: *** [/kernel-source/scripts/Makefile.build:266: drivers/usb/chipidea/trace.o] Error 1

 

Do you know why that is happening? Do I need a specific kernel version or a patch?

0 Kudos
Reply

929 Views
ajita02
Contributor IV

Hi,

I want to achieve USB detection without ID pin. I am getting same error while compilation. Can you provide me a lead?

Thanks,

Ajita

0 Kudos
Reply

1,484 Views
Harvey021
NXP TechSupport
NXP TechSupport

Hi @crudo 

You can try echo peripheral > /sys/kernel/debug/ci_hdrc.0/role. 

OTG ID PIN needs to be configured, otherwise, which mostly cause operations either in host or peripheral mode.

 

Best regards

Harvey

 

Best regards

Harvey

0 Kudos
Reply