blob: 68473abe2823e9da26f97f4c9250811429162362 [file] [log] [blame]
Mauro Carvalho Chehabd80b5002019-04-15 23:56:01 -03001==============================================
2ChipIdea Highspeed Dual Role Controller Driver
3==============================================
4
Li Jun9159e042014-04-23 15:56:54 +080051. How to test OTG FSM(HNP and SRP)
6-----------------------------------
Mauro Carvalho Chehabd80b5002019-04-15 23:56:01 -03007
Li Jun9159e042014-04-23 15:56:54 +08008To show how to demo OTG HNP and SRP functions via sys input files
9with 2 Freescale i.MX6Q sabre SD boards.
10
Peter Chen764763f2016-04-13 15:16:52 +0800111.1 How to enable OTG FSM
Mauro Carvalho Chehabd80b5002019-04-15 23:56:01 -030012-------------------------
13
Peter Chen764763f2016-04-13 15:16:52 +0800141.1.1 Select CONFIG_USB_OTG_FSM in menuconfig, rebuild kernel
Mauro Carvalho Chehabd80b5002019-04-15 23:56:01 -030015^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
16
Peter Chen764763f2016-04-13 15:16:52 +080017Image and modules. If you want to check some internal
18variables for otg fsm, mount debugfs, there are 2 files
Mauro Carvalho Chehabd80b5002019-04-15 23:56:01 -030019which can show otg fsm variables and some controller registers value::
20
21 cat /sys/kernel/debug/ci_hdrc.0/otg
22 cat /sys/kernel/debug/ci_hdrc.0/registers
23
Peter Chen764763f2016-04-13 15:16:52 +0800241.1.2 Add below entries in your dts file for your controller node
Mauro Carvalho Chehabd80b5002019-04-15 23:56:01 -030025^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
26
27::
28
Peter Chen764763f2016-04-13 15:16:52 +080029 otg-rev = <0x0200>;
30 adp-disable;
Li Jun9159e042014-04-23 15:56:54 +080031
321.2 Test operations
33-------------------
Mauro Carvalho Chehabd80b5002019-04-15 23:56:01 -030034
Li Jun9159e042014-04-23 15:56:54 +0800351) Power up 2 Freescale i.MX6Q sabre SD boards with gadget class driver loaded
36 (e.g. g_mass_storage).
37
382) Connect 2 boards with usb cable with one end is micro A plug, the other end
39 is micro B plug.
40
Fabio Estevamaa73f282017-12-08 11:53:37 -020041 The A-device(with micro A plug inserted) should enumerate B-device.
Li Jun9159e042014-04-23 15:56:54 +080042
433) Role switch
Mauro Carvalho Chehabd80b5002019-04-15 23:56:01 -030044
45 On B-device::
46
47 echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
Li Jun9159e042014-04-23 15:56:54 +080048
Fabio Estevamaa73f282017-12-08 11:53:37 -020049 B-device should take host role and enumerate A-device.
Li Jun9159e042014-04-23 15:56:54 +080050
514) A-device switch back to host.
Mauro Carvalho Chehabd80b5002019-04-15 23:56:01 -030052
53 On B-device::
54
55 echo 0 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
Li Jun9159e042014-04-23 15:56:54 +080056
Li Jundfbae332016-02-19 10:04:47 +080057 or, by introducing HNP polling, B-Host can know when A-peripheral wish
58 to be host role, so this role switch also can be trigged in A-peripheral
Mauro Carvalho Chehabd80b5002019-04-15 23:56:01 -030059 side by answering the polling from B-Host, this can be done on A-device::
60
61 echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_req
Li Jundfbae332016-02-19 10:04:47 +080062
Fabio Estevamaa73f282017-12-08 11:53:37 -020063 A-device should switch back to host and enumerate B-device.
Li Jun9159e042014-04-23 15:56:54 +080064
655) Remove B-device(unplug micro B plug) and insert again in 10 seconds,
Fabio Estevamaa73f282017-12-08 11:53:37 -020066 A-device should enumerate B-device again.
Li Jun9159e042014-04-23 15:56:54 +080067
686) Remove B-device(unplug micro B plug) and insert again after 10 seconds,
Fabio Estevamaa73f282017-12-08 11:53:37 -020069 A-device should NOT enumerate B-device.
Li Jun9159e042014-04-23 15:56:54 +080070
71 if A-device wants to use bus:
Mauro Carvalho Chehabd80b5002019-04-15 23:56:01 -030072
73 On A-device::
74
75 echo 0 > /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_drop
76 echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_req
Li Jun9159e042014-04-23 15:56:54 +080077
78 if B-device wants to use bus:
Mauro Carvalho Chehabd80b5002019-04-15 23:56:01 -030079
80 On B-device::
81
82 echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
Li Jun9159e042014-04-23 15:56:54 +080083
847) A-device power down the bus.
Mauro Carvalho Chehabd80b5002019-04-15 23:56:01 -030085
86 On A-device::
87
88 echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_drop
Li Jun9159e042014-04-23 15:56:54 +080089
90 A-device should disconnect with B-device and power down the bus.
91
928) B-device does data pulse for SRP.
Mauro Carvalho Chehabd80b5002019-04-15 23:56:01 -030093
94 On B-device::
95
96 echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
Li Jun9159e042014-04-23 15:56:54 +080097
Fabio Estevamaa73f282017-12-08 11:53:37 -020098 A-device should resume usb bus and enumerate B-device.
Li Jun9159e042014-04-23 15:56:54 +080099
1001.3 Reference document
101----------------------
102"On-The-Go and Embedded Host Supplement to the USB Revision 2.0 Specification
103July 27, 2012 Revision 2.0 version 1.1a"
Peter Chen01e3ad82015-02-11 12:44:50 +0800104
1052. How to enable USB as system wakeup source
Mauro Carvalho Chehabd80b5002019-04-15 23:56:01 -0300106--------------------------------------------
Peter Chen01e3ad82015-02-11 12:44:50 +0800107Below is the example for how to enable USB as system wakeup source
108at imx6 platform.
109
Mauro Carvalho Chehabd80b5002019-04-15 23:56:01 -03001102.1 Enable core's wakeup::
111
112 echo enabled > /sys/bus/platform/devices/ci_hdrc.0/power/wakeup
113
1142.2 Enable glue layer's wakeup::
115
116 echo enabled > /sys/bus/platform/devices/2184000.usb/power/wakeup
117
1182.3 Enable PHY's wakeup (optional)::
119
120 echo enabled > /sys/bus/platform/devices/20c9000.usbphy/power/wakeup
121
1222.4 Enable roothub's wakeup::
123
124 echo enabled > /sys/bus/usb/devices/usb1/power/wakeup
125
1262.5 Enable related device's wakeup::
127
128 echo enabled > /sys/bus/usb/devices/1-1/power/wakeup
Peter Chen01e3ad82015-02-11 12:44:50 +0800129
130If the system has only one usb port, and you want usb wakeup at this port, you
Mauro Carvalho Chehabd80b5002019-04-15 23:56:01 -0300131can use below script to enable usb wakeup::
Peter Chen01e3ad82015-02-11 12:44:50 +0800132
Mauro Carvalho Chehabd80b5002019-04-15 23:56:01 -0300133 for i in $(find /sys -name wakeup | grep usb);do echo enabled > $i;done;