Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 1 | ============================================== |
| 2 | ChipIdea Highspeed Dual Role Controller Driver |
| 3 | ============================================== |
| 4 | |
Li Jun | 9159e04 | 2014-04-23 15:56:54 +0800 | [diff] [blame] | 5 | 1. How to test OTG FSM(HNP and SRP) |
| 6 | ----------------------------------- |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 7 | |
Li Jun | 9159e04 | 2014-04-23 15:56:54 +0800 | [diff] [blame] | 8 | To show how to demo OTG HNP and SRP functions via sys input files |
| 9 | with 2 Freescale i.MX6Q sabre SD boards. |
| 10 | |
Peter Chen | 764763f | 2016-04-13 15:16:52 +0800 | [diff] [blame] | 11 | 1.1 How to enable OTG FSM |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 12 | ------------------------- |
| 13 | |
Peter Chen | 764763f | 2016-04-13 15:16:52 +0800 | [diff] [blame] | 14 | 1.1.1 Select CONFIG_USB_OTG_FSM in menuconfig, rebuild kernel |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 15 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 16 | |
Peter Chen | 764763f | 2016-04-13 15:16:52 +0800 | [diff] [blame] | 17 | Image and modules. If you want to check some internal |
| 18 | variables for otg fsm, mount debugfs, there are 2 files |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 19 | which 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 Chen | 764763f | 2016-04-13 15:16:52 +0800 | [diff] [blame] | 24 | 1.1.2 Add below entries in your dts file for your controller node |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 25 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 26 | |
| 27 | :: |
| 28 | |
Peter Chen | 764763f | 2016-04-13 15:16:52 +0800 | [diff] [blame] | 29 | otg-rev = <0x0200>; |
| 30 | adp-disable; |
Li Jun | 9159e04 | 2014-04-23 15:56:54 +0800 | [diff] [blame] | 31 | |
| 32 | 1.2 Test operations |
| 33 | ------------------- |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 34 | |
Li Jun | 9159e04 | 2014-04-23 15:56:54 +0800 | [diff] [blame] | 35 | 1) Power up 2 Freescale i.MX6Q sabre SD boards with gadget class driver loaded |
| 36 | (e.g. g_mass_storage). |
| 37 | |
| 38 | 2) Connect 2 boards with usb cable with one end is micro A plug, the other end |
| 39 | is micro B plug. |
| 40 | |
Fabio Estevam | aa73f28 | 2017-12-08 11:53:37 -0200 | [diff] [blame] | 41 | The A-device(with micro A plug inserted) should enumerate B-device. |
Li Jun | 9159e04 | 2014-04-23 15:56:54 +0800 | [diff] [blame] | 42 | |
| 43 | 3) Role switch |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 44 | |
| 45 | On B-device:: |
| 46 | |
| 47 | echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req |
Li Jun | 9159e04 | 2014-04-23 15:56:54 +0800 | [diff] [blame] | 48 | |
Fabio Estevam | aa73f28 | 2017-12-08 11:53:37 -0200 | [diff] [blame] | 49 | B-device should take host role and enumerate A-device. |
Li Jun | 9159e04 | 2014-04-23 15:56:54 +0800 | [diff] [blame] | 50 | |
| 51 | 4) A-device switch back to host. |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 52 | |
| 53 | On B-device:: |
| 54 | |
| 55 | echo 0 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req |
Li Jun | 9159e04 | 2014-04-23 15:56:54 +0800 | [diff] [blame] | 56 | |
Li Jun | dfbae33 | 2016-02-19 10:04:47 +0800 | [diff] [blame] | 57 | 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 Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 59 | 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 Jun | dfbae33 | 2016-02-19 10:04:47 +0800 | [diff] [blame] | 62 | |
Fabio Estevam | aa73f28 | 2017-12-08 11:53:37 -0200 | [diff] [blame] | 63 | A-device should switch back to host and enumerate B-device. |
Li Jun | 9159e04 | 2014-04-23 15:56:54 +0800 | [diff] [blame] | 64 | |
| 65 | 5) Remove B-device(unplug micro B plug) and insert again in 10 seconds, |
Fabio Estevam | aa73f28 | 2017-12-08 11:53:37 -0200 | [diff] [blame] | 66 | A-device should enumerate B-device again. |
Li Jun | 9159e04 | 2014-04-23 15:56:54 +0800 | [diff] [blame] | 67 | |
| 68 | 6) Remove B-device(unplug micro B plug) and insert again after 10 seconds, |
Fabio Estevam | aa73f28 | 2017-12-08 11:53:37 -0200 | [diff] [blame] | 69 | A-device should NOT enumerate B-device. |
Li Jun | 9159e04 | 2014-04-23 15:56:54 +0800 | [diff] [blame] | 70 | |
| 71 | if A-device wants to use bus: |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 72 | |
| 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 Jun | 9159e04 | 2014-04-23 15:56:54 +0800 | [diff] [blame] | 77 | |
| 78 | if B-device wants to use bus: |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 79 | |
| 80 | On B-device:: |
| 81 | |
| 82 | echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req |
Li Jun | 9159e04 | 2014-04-23 15:56:54 +0800 | [diff] [blame] | 83 | |
| 84 | 7) A-device power down the bus. |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 85 | |
| 86 | On A-device:: |
| 87 | |
| 88 | echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_drop |
Li Jun | 9159e04 | 2014-04-23 15:56:54 +0800 | [diff] [blame] | 89 | |
| 90 | A-device should disconnect with B-device and power down the bus. |
| 91 | |
| 92 | 8) B-device does data pulse for SRP. |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 93 | |
| 94 | On B-device:: |
| 95 | |
| 96 | echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req |
Li Jun | 9159e04 | 2014-04-23 15:56:54 +0800 | [diff] [blame] | 97 | |
Fabio Estevam | aa73f28 | 2017-12-08 11:53:37 -0200 | [diff] [blame] | 98 | A-device should resume usb bus and enumerate B-device. |
Li Jun | 9159e04 | 2014-04-23 15:56:54 +0800 | [diff] [blame] | 99 | |
| 100 | 1.3 Reference document |
| 101 | ---------------------- |
| 102 | "On-The-Go and Embedded Host Supplement to the USB Revision 2.0 Specification |
| 103 | July 27, 2012 Revision 2.0 version 1.1a" |
Peter Chen | 01e3ad8 | 2015-02-11 12:44:50 +0800 | [diff] [blame] | 104 | |
| 105 | 2. How to enable USB as system wakeup source |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 106 | -------------------------------------------- |
Peter Chen | 01e3ad8 | 2015-02-11 12:44:50 +0800 | [diff] [blame] | 107 | Below is the example for how to enable USB as system wakeup source |
| 108 | at imx6 platform. |
| 109 | |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 110 | 2.1 Enable core's wakeup:: |
| 111 | |
| 112 | echo enabled > /sys/bus/platform/devices/ci_hdrc.0/power/wakeup |
| 113 | |
| 114 | 2.2 Enable glue layer's wakeup:: |
| 115 | |
| 116 | echo enabled > /sys/bus/platform/devices/2184000.usb/power/wakeup |
| 117 | |
| 118 | 2.3 Enable PHY's wakeup (optional):: |
| 119 | |
| 120 | echo enabled > /sys/bus/platform/devices/20c9000.usbphy/power/wakeup |
| 121 | |
| 122 | 2.4 Enable roothub's wakeup:: |
| 123 | |
| 124 | echo enabled > /sys/bus/usb/devices/usb1/power/wakeup |
| 125 | |
| 126 | 2.5 Enable related device's wakeup:: |
| 127 | |
| 128 | echo enabled > /sys/bus/usb/devices/1-1/power/wakeup |
Peter Chen | 01e3ad8 | 2015-02-11 12:44:50 +0800 | [diff] [blame] | 129 | |
| 130 | If the system has only one usb port, and you want usb wakeup at this port, you |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 131 | can use below script to enable usb wakeup:: |
Peter Chen | 01e3ad8 | 2015-02-11 12:44:50 +0800 | [diff] [blame] | 132 | |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 133 | for i in $(find /sys -name wakeup | grep usb);do echo enabled > $i;done; |