Enabling USB (tegra.ehci.0) OTG port crashes the kernel

When i disable OTG port as follows , then USB disconnected properly.
But When i Enable OTG port via command line as follows , then kernel crashes.

echo ‘tegra-ehci.0’ > /sys/bus/platform/drivers/tegra-ehci/bind

Kernel crasj log :

509.080190] ------------[ cut here ]------------
[ 1509.083704] WARNING: at /data/sources/PRGCA/1.0.1.A5/PRGCA-1.0.1.A5/src-mep/kernel/linux-avionic-3.10.40/fs/sysfs/dir.c:530 sysfs_add_one+0xa4/0xb4()
[ 1509.097770] sysfs: cannot create duplicate filename ‘/devices/platform/tegra12-i2c.4/i2c-4/4-0040/as3722-regulator.0/regulator/regulator.19/tegra-ehci.0-avdd_pll_utmip’
[ 23.259513] changing wiegand in mode to 0
[ 1509.115796] Modules linked in:
[ 1509.118152] ppp_async option usb_wwan ppp_generic slhc usbserial g_ether libcomposite configfs ecryptfs mep_wiegand ma1000_gpio ov4689_v4l2 mep_tamper ma1000_sdac ma1000_panel_feedback
[ 1509.138072] CPU: 0 PID: 1246 Comm: CmdQueue Not tainted 3.10.40 #2
[ 1509.147269] [] (unwind_backtrace+0x0/0xf4) from [] (show_stack+0x18/0x1c)
[ 1509.158856] [] (show_stack+0x18/0x1c) from [] (warn_slowpath_common+0x5c/0x74)
[ 1509.168270] [] (warn_slowpath_common+0x5c/0x74) from [] (warn_slowpath_fmt+0x38/0x48)
[ 1509.176660] [] (warn_slowpath_fmt+0x38/0x48) from [] (sysfs_add_one+0xa4/0xb4)
[ 1509.184433] [] (sysfs_add_one+0xa4/0xb4) from [] (sysfs_do_create_link_sd+0xe4/0x20c)
[ 1509.192774] [] (sysfs_do_create_link_sd+0xe4/0x20c) from [] (create_regulator+0xbc/0x2a0)
[ 1509.201499] [] (create_regulator+0xbc/0x2a0) from [] (_regulator_get+0x188/0x20c)
[ 1509.209469] [] (_regulator_get+0x188/0x20c) from [] (tegra_usb_phy_open+0x104/0x64c)
[ 1509.217708] [] (tegra_usb_phy_open+0x104/0x64c) from [] (tegra_ehci_probe+0x150/0x9ac)
[ 1509.230255] [] (tegra_ehci_probe+0x150/0x9ac) from [] (driver_probe_device+0x110/0x24c)
[ 1509.242041] [] (driver_probe_device+0x110/0x24c) from [] (driver_bind+0xb4/0x148)
[ 1509.250395] [] (driver_bind+0xb4/0x148) from [] (sysfs_write_file+0x164/0x1c0)
[ 1509.258292] [] (sysfs_write_file+0x164/0x1c0) from [] (vfs_write+0xb8/0x194)
[ 1509.265819] [] (vfs_write+0xb8/0x194) from [] (SyS_write+0x60/0x178)
[ 1509.272654] [] (SyS_write+0x60/0x178) from [] (ret_fast_syscall+0x0/0x30)
[ 1509.279940] —[ end trace 4c0c0ebbbea130ab ]—
[ 1509.283335] +1V8_VDDIO: could not add device link tegra-ehci.0 err -17
[ 1509.288821] +1V8_VDDIO: Failed to create debugfs directory
[ 1509.293191] ------------[ cut here ]------------
[ 1509.296560] WARNING: at …/fs/sysfs/dir.c:530 sysfs_add_one+0xa4/0xb4()
[ 1509.308669] sysfs: cannot create duplicate filename ‘/devices/platform/regulators.4/6.regulator/regulator/regulator.7/tegra-ehci.0-usb_vbus’
[ 1509.320021] Modules linked in: ppp_async option usb_wwan ppp_generic slhc usbserial g_ether libcomposite configfs ecryptfs mep_wiegand ma1000_gpio ov4689_v4l2 mep_tamper ma1000_sdac ma1000_panel_feedback
[ 1509.337002] CPU: 0 PID: 1246 Comm: CmdQueue Tainted: G W 3.10.40 #2
[ 1509.342845] [] (unwind_backtrace+0x0/0xf4) from [] (show_stack+0x18/0x1c)
[ 1509.350062] [] (show_stack+0x18/0x1c) from [] (warn_slowpath_common+0x5c/0x74)
[ 1509.357719] [] (warn_slowpath_common+0x5c/0x74) from [] (warn_slowpath_fmt+0x38/0x48)
[ 1509.366013] [] (warn_slowpath_fmt+0x38/0x48) from [] (sysfs_add_one+0xa4/0xb4)
[ 1509.373675] [] (sysfs_add_one+0xa4/0xb4) from [] (sysfs_do_create_link_sd+0xe4/0x20c)
[ 1509.381933] [] (sysfs_do_create_link_sd+0xe4/0x20c) from [] (create_regulator+0xbc/0x2a0)
[ 1509.390543] [] (create_regulator+0xbc/0x2a0) from [] (_regulator_get+0x188/0x20c)
[ 1509.398484] [] (_regulator_get+0x188/0x20c) from [] (tegra_usb_phy_open+0x454/0x64c)
[ 1509.407460] [] (tegra_usb_phy_open+0x454/0x64c) from [] (tegra_ehci_probe+0x150/0x9ac)
[ 1509.416061] [] (tegra_ehci_probe+0x150/0x9ac) from [] (driver_probe_device+0x110/0x24c)

Did you go through all of the setup needed before trying to enable OTG? There is much involved beyond just turning this on…basically you must give the system details and resources for what the port is to become. Mostly this would be done with the “gadget” framework. See:
http://www.linux-usb.org/gadget/
https://www.kernel.org/doc/Documentation/usb/gadget_configfs.txt

On another note, this catches my eye:

[ 1509.097770] sysfs: <b>cannot create duplicate filename</b> '/devices/platform/tegra12-i2c.4/i2c-4/4-0040/as3722-regulator.0/regulator/regulator.19/tegra-ehci.0-avdd_pll_utmip'

If you cd to “/sys/bus/platform/drivers/tegra-ehci/” and run “ls -F” you will see real files for “bind”, “uevent”, and “unbind”. The rest are symbolic links…those links were created by previous “bind” operations (or removed from previous “unbind” operations). Similar links may be added or removed by drivers for a given operation. It looks like your bind operation tried to bind what was already there…can’t do it. If it was already there, then you might want to research what had it in the first place…you might need to disable something before you can re-bind it…and it might be you don’t need to re-bind it.

PLease also refer to [url]https://devtalk.nvidia.com/default/topic/994397/jetson-tk1/how-to-verify-usb-2-0-device-mode-workable-on-jetson-tk1-/post/5086989/#5086989[/url]