blob: edf7cdfddc88a1b35443959e6707dc04201ec78c [file] [log] [blame]
Li Jun9159e042014-04-23 15:56:54 +080011. How to test OTG FSM(HNP and SRP)
2-----------------------------------
3To show how to demo OTG HNP and SRP functions via sys input files
4with 2 Freescale i.MX6Q sabre SD boards.
5
Peter Chen764763f2016-04-13 15:16:52 +080061.1 How to enable OTG FSM
Li Jun9159e042014-04-23 15:56:54 +08007---------------------------------------
Peter Chen764763f2016-04-13 15:16:52 +080081.1.1 Select CONFIG_USB_OTG_FSM in menuconfig, rebuild kernel
9Image and modules. If you want to check some internal
10variables for otg fsm, mount debugfs, there are 2 files
11which can show otg fsm variables and some controller registers value:
Li Jun9159e042014-04-23 15:56:54 +080012cat /sys/kernel/debug/ci_hdrc.0/otg
13cat /sys/kernel/debug/ci_hdrc.0/registers
Peter Chen764763f2016-04-13 15:16:52 +0800141.1.2 Add below entries in your dts file for your controller node
15 otg-rev = <0x0200>;
16 adp-disable;
Li Jun9159e042014-04-23 15:56:54 +080017
181.2 Test operations
19-------------------
201) Power up 2 Freescale i.MX6Q sabre SD boards with gadget class driver loaded
21 (e.g. g_mass_storage).
22
232) Connect 2 boards with usb cable with one end is micro A plug, the other end
24 is micro B plug.
25
26 The A-device(with micro A plug inserted) should enumrate B-device.
27
283) Role switch
29 On B-device:
30 echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
31
Li Jun9159e042014-04-23 15:56:54 +080032 B-device should take host role and enumrate A-device.
33
344) A-device switch back to host.
35 On B-device:
36 echo 0 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
37
Li Jundfbae332016-02-19 10:04:47 +080038 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
42
Li Jun9159e042014-04-23 15:56:54 +080043 A-device should switch back to host and enumrate B-device.
44
455) Remove B-device(unplug micro B plug) and insert again in 10 seconds,
46 A-device should enumrate B-device again.
47
486) Remove B-device(unplug micro B plug) and insert again after 10 seconds,
49 A-device should NOT enumrate B-device.
50
51 if A-device wants to use bus:
52 On A-device:
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
55
56 if B-device wants to use bus:
57 On B-device:
58 echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
59
607) A-device power down the bus.
61 On A-device:
62 echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_drop
63
64 A-device should disconnect with B-device and power down the bus.
65
668) B-device does data pulse for SRP.
67 On B-device:
68 echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
69
70 A-device should resume usb bus and enumrate B-device.
71
721.3 Reference document
73----------------------
74"On-The-Go and Embedded Host Supplement to the USB Revision 2.0 Specification
75July 27, 2012 Revision 2.0 version 1.1a"
Peter Chen01e3ad82015-02-11 12:44:50 +080076
772. How to enable USB as system wakeup source
78-----------------------------------
79Below is the example for how to enable USB as system wakeup source
80at imx6 platform.
81
822.1 Enable core's wakeup
83echo enabled > /sys/bus/platform/devices/ci_hdrc.0/power/wakeup
842.2 Enable glue layer's wakeup
85echo enabled > /sys/bus/platform/devices/2184000.usb/power/wakeup
862.3 Enable PHY's wakeup (optional)
87echo enabled > /sys/bus/platform/devices/20c9000.usbphy/power/wakeup
882.4 Enable roothub's wakeup
89echo enabled > /sys/bus/usb/devices/usb1/power/wakeup
902.5 Enable related device's wakeup
91echo enabled > /sys/bus/usb/devices/1-1/power/wakeup
92
93If the system has only one usb port, and you want usb wakeup at this port, you
94can use below script to enable usb wakeup.
95for i in $(find /sys -name wakeup | grep usb);do echo enabled > $i;done;
96