OTG Apalis TK1 with Mainline Kernel

Hi,

I have managed to get the Apalis iMX6 working with OTG on the Apalis Evaluation Board V1.1A

I am now trying to get the Apalis TK1 module to work in the same way. Due to kernel 3.10 limitations I need to use the mainline kernel. I have successfully compiled 4.8.1 and USB is working.

  1. Do USB3 ports allow for host and device mode at the same time?
  2. Does the mainline kernel support USB device mode?
  3. Does the mainline kernel have temperature issues with the Apalis TK1 module?

Thank you,
Shaun

I have managed to get the Apalis iMX6 working with OTG on the Apalis Evaluation Board V1.1A.

And with what kind of kernel that was, our downstream or mainline?

I am now trying to get the Apalis TK1 module to work in the same way. Due to kernel 3.10 limitations I need to use the mainline kernel. I have successfully compiled 4.8.1 and USB is working.

  1. Do USB3 ports allow for host and device mode at the same time?

If by USB3 you mean USB 3.0 SuperSpeed no the TK1 SoC exclusively supports this in host mode only. Device mode is only possible with USB 2.0 High Speed.

  1. Does the mainline kernel support USB device mode?

Good question. I do know that patches for this where floating around on the mailing lists however whether or not those made it in already I will have to check.

  1. Does the mainline kernel have temperature issues with the Apalis TK1 module?

Not that we are aware of however please note that our current V1.0 samples do have hardware issues when it comes to power consumption which ultimately may lead to temperature issues as outlined in the errata.

Concerning 2) that patch set I mentioned above was just an RFC and now as I look at it again it was also still missing the whole automatic switching part.

Hi Marcel,

Thank you for your help.

And with what kind of kernel that was, our downstream or mainline?

The Toradex downstream kernel with HID and UVC configfs gadgets ported from a newer kernel.

Good question. I do know that patches for this where floating around on the
mailing lists however whether or not
those made it in already I will have
to check.

I have managed to get the patches you linked to applied and compiled. Thank you for this!

The driver ci_hdrc_tegra.ko loads and seems to attach to the USB device.
I can successfully create a HID gadget in /sys/kernel/config/usb_gadget/ using configfs.

The problem is that when I connect the Apalis Eval 1.1A borad to my PC the HID gadget does not appear.

My device tree contains the following:

/* EHCI instance 0: USB1_DP/N -> USBO1_DP/N */
usb@7d000000 {
	compatible = "nvidia,tegra124-udc";
	status = "okay";
	dr_mode = "otg";
};

usb-phy@7d000000 {
	status = "okay";
	vbus-supply = <&reg_usbo1_vbus>;
};

Error from hid_gadget_test:
configfs-gadget gadget: usb_ep_queue error on int endpoint -108

Kind regards,
Shaun

It seems that the physical layer has stalled. If anyone can offer assistance it will be appreciated.

hid_gadget_test stack trace:

[  154.737792] WARNING: CPU: 0 PID: 544 at drivers/usb/gadget/udc/core.c:264 usb_ep_queue+0x5c/0x64
[  154.749178] Modules linked in: usb_f_hid libcomposite configfs nouveau ehci_tegra ci_hdrc_tegra ci_hdrc ehci_hcd phy_tegra_usb xhci_tegra ttm
[  154.762378] CPU: 0 PID: 544 Comm: hid_gadget_test Not tainted 4.8.1-00004-gb83786b-dirty #22
[  154.770840] Hardware name: NVIDIA Tegra SoC (Flattened Device Tree)
[  154.777194] [] (unwind_backtrace) from [] (show_stack+0x10/0x14)
[  154.785011] [] (show_stack) from [] (dump_stack+0x94/0xa8)
[  154.792268] [] (dump_stack) from [] (__warn+0xe8/0x100)
[  154.799299] [] (__warn) from [] (warn_slowpath_null+0x20/0x28)
[  154.806947] [] (warn_slowpath_null) from [] (usb_ep_queue+0x5c/0x64)
[  154.815117] [] (usb_ep_queue) from [] (f_hidg_write+0x16c/0x26c [usb_f_hid])
[  154.823952] [] (f_hidg_write [usb_f_hid]) from [] (__vfs_write+0x20/0x118)
[  154.832622] [] (__vfs_write) from [] (vfs_write+0xa4/0x164)
[  154.839997] [] (vfs_write) from [] (SyS_write+0x40/0x94)
[  154.847120] [] (SyS_write) from [] (ret_fast_syscall+0x0/0x3c)
[  154.861471] ---[ end trace 2b7134df4f5e61c8 ]---
[  154.866245] configfs-gadget gadget: usb_ep_queue error on int endpoint -108
[  186.019610] random: crng init done

I have noticed the following boot message error:
7d000000.usb supply vbus not found, using dummy regulator

If CONFIG_USB_CHIPIDEA_HOST is enabled in the kernel config file the TK1 fails to complete the boot process and ends with:

[   10.285986] 7d000000.usb supply vbus not found, using dummy regulator
[   10.295645] ci_hdrc ci_hdrc.0: EHCI Host Controller
[   10.300584] ci_hdrc ci_hdrc.0: new USB bus registered, assigned bus number 1
[   10.333894] ci_hdrc ci_hdrc.0: USB 2.0 started, EHCI 1.10
[   10.340400] hub 1-0:1.0: USB hub found
[   10.344302] hub 1-0:1.0: 1 port detected

ChipIdea config:

  CONFIG_USB_CHIPIDEA=m
    CONFIG_USB_CHIPIDEA_OF=m
    CONFIG_USB_CHIPIDEA_UDC=y
    CONFIG_USB_CHIPIDEA_HOST=y

Thanks, Shaun

UPDATE:
I have not managed to get OTG working with the mainline kernel.
My solution was to backport gadget functionality and integrate it with the existing Android Gadget Driver.