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