| 377 | |
| 378 | |
| 379 | [=#dual-role] |
| 380 | == OTG Mode selection |
| 381 | USB OTG host controllers are 'dual-role' controllers in that they can behave as a {{{USB host}}} or a {{{USB peripheral}}}. The decision on which mode to be in is typically controlled by the state of the OTG ID pin which is grounded on OTG to host cables, and left floating on OTG to device cables. |
| 382 | |
| 383 | Dual-role controllers can be forced into 'host' mode or 'peripheral' mode via the device-tree 'dr_mode' property. For example to force an IMX6 OTG controller to peripheral mode add 'dr_mode = "peripheral";' to the dt such as: |
| 384 | {{{ |
| 385 | &usbotg { |
| 386 | vbus-supply = <®_5p0v>; |
| 387 | pinctrl-names = "default"; |
| 388 | pinctrl-0 = <&pinctrl_usbotg>; |
| 389 | disable-over-current; |
| 390 | dr_mode = "peripheral"; |
| 391 | status = "okay"; |
| 392 | }; |
| 393 | }}} |
| 394 | |
| 395 | Additionally some host controllers such as the Chips and Media controller used on the IMX6 have hooks that allow them to be configured at runtime in Linux Userspace. For example on IMX6 boards: |
| 396 | {{{#!bash |
| 397 | cat /sys/kernel/debug/ci_hdrc.0/role # see current role; default dictated by dr_mode dt property or state of OTG_ID pin if not set |
| 398 | echo gadget > /sys/kernel/debug/ci_hdrc.0/role # specify device mode |
| 399 | echo host > /sys/kernel/debug/ci_hdrc.0/role # specify host mode |
| 400 | }}} |