1 1. How to test OTG FSM(HNP and SRP)
2 -----------------------------------
3 To show how to demo OTG HNP and SRP functions via sys input files
4 with 2 Freescale i.MX6Q sabre SD boards.
6 1.1 How to enable OTG FSM
7 ---------------------------------------
8 1.1.1 Select CONFIG_USB_OTG_FSM in menuconfig, rebuild kernel
9 Image and modules. If you want to check some internal
10 variables for otg fsm, mount debugfs, there are 2 files
11 which can show otg fsm variables and some controller registers value:
12 cat /sys/kernel/debug/ci_hdrc.0/otg
13 cat /sys/kernel/debug/ci_hdrc.0/registers
14 1.1.2 Add below entries in your dts file for your controller node
20 1) Power up 2 Freescale i.MX6Q sabre SD boards with gadget class driver loaded
21 (e.g. g_mass_storage).
23 2) Connect 2 boards with usb cable with one end is micro A plug, the other end
26 The A-device(with micro A plug inserted) should enumerate B-device.
30 echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
32 B-device should take host role and enumerate A-device.
34 4) A-device switch back to host.
36 echo 0 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
38 or, by introducing HNP polling, B-Host can know when A-peripheral wish
39 to be host role, so this role switch also can be trigged in A-peripheral
40 side by answering the polling from B-Host, this can be done on A-device:
41 echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_req
43 A-device should switch back to host and enumerate B-device.
45 5) Remove B-device(unplug micro B plug) and insert again in 10 seconds,
46 A-device should enumerate B-device again.
48 6) Remove B-device(unplug micro B plug) and insert again after 10 seconds,
49 A-device should NOT enumerate B-device.
51 if A-device wants to use bus:
53 echo 0 > /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_drop
54 echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_req
56 if B-device wants to use bus:
58 echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
60 7) A-device power down the bus.
62 echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_drop
64 A-device should disconnect with B-device and power down the bus.
66 8) B-device does data pulse for SRP.
68 echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
70 A-device should resume usb bus and enumerate B-device.
72 1.3 Reference document
73 ----------------------
74 "On-The-Go and Embedded Host Supplement to the USB Revision 2.0 Specification
75 July 27, 2012 Revision 2.0 version 1.1a"
77 2. How to enable USB as system wakeup source
78 -----------------------------------
79 Below is the example for how to enable USB as system wakeup source
82 2.1 Enable core's wakeup
83 echo enabled > /sys/bus/platform/devices/ci_hdrc.0/power/wakeup
84 2.2 Enable glue layer's wakeup
85 echo enabled > /sys/bus/platform/devices/2184000.usb/power/wakeup
86 2.3 Enable PHY's wakeup (optional)
87 echo enabled > /sys/bus/platform/devices/20c9000.usbphy/power/wakeup
88 2.4 Enable roothub's wakeup
89 echo enabled > /sys/bus/usb/devices/usb1/power/wakeup
90 2.5 Enable related device's wakeup
91 echo enabled > /sys/bus/usb/devices/1-1/power/wakeup
93 If the system has only one usb port, and you want usb wakeup at this port, you
94 can use below script to enable usb wakeup.
95 for i in $(find /sys -name wakeup | grep usb);do echo enabled > $i;done;