| 
									
										
										
										
											2019-04-15 23:56:01 -03:00
										 |  |  | ==============================================
 | 
					
						
							|  |  |  | ChipIdea Highspeed Dual Role Controller Driver
 | 
					
						
							|  |  |  | ==============================================
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-23 15:56:54 +08:00
										 |  |  | 1. How to test OTG FSM(HNP and SRP)
 | 
					
						
							|  |  |  | -----------------------------------
 | 
					
						
							| 
									
										
										
										
											2019-04-15 23:56:01 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-23 15:56:54 +08:00
										 |  |  | To show how to demo OTG HNP and SRP functions via sys input files
 | 
					
						
							|  |  |  | with 2 Freescale i.MX6Q sabre SD boards.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-13 15:16:52 +08:00
										 |  |  | 1.1 How to enable OTG FSM
 | 
					
						
							| 
									
										
										
										
											2019-04-15 23:56:01 -03:00
										 |  |  | -------------------------
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-13 15:16:52 +08:00
										 |  |  | 1.1.1 Select CONFIG_USB_OTG_FSM in menuconfig, rebuild kernel
 | 
					
						
							| 
									
										
										
										
											2019-04-15 23:56:01 -03:00
										 |  |  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-13 15:16:52 +08:00
										 |  |  | Image and modules. If you want to check some internal
 | 
					
						
							|  |  |  | variables for otg fsm, mount debugfs, there are 2 files
 | 
					
						
							| 
									
										
										
										
											2019-04-15 23:56:01 -03:00
										 |  |  | which can show otg fsm variables and some controller registers value::
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	cat /sys/kernel/debug/ci_hdrc.0/otg
 | 
					
						
							|  |  |  | 	cat /sys/kernel/debug/ci_hdrc.0/registers
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-13 15:16:52 +08:00
										 |  |  | 1.1.2 Add below entries in your dts file for your controller node
 | 
					
						
							| 
									
										
										
										
											2019-04-15 23:56:01 -03:00
										 |  |  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ::
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-13 15:16:52 +08:00
										 |  |  | 	otg-rev = <0x0200>;
 | 
					
						
							|  |  |  | 	adp-disable;
 | 
					
						
							| 
									
										
										
										
											2014-04-23 15:56:54 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 1.2 Test operations
 | 
					
						
							|  |  |  | -------------------
 | 
					
						
							| 
									
										
										
										
											2019-04-15 23:56:01 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-23 15:56:54 +08:00
										 |  |  | 1) Power up 2 Freescale i.MX6Q sabre SD boards with gadget class driver loaded
 | 
					
						
							|  |  |  |    (e.g. g_mass_storage).
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-26 22:40:02 -08:00
										 |  |  | 2) Connect 2 boards with usb cable: one end is micro A plug, the other end
 | 
					
						
							| 
									
										
										
										
											2014-04-23 15:56:54 +08:00
										 |  |  |    is micro B plug.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-26 22:40:02 -08:00
										 |  |  |    The A-device (with micro A plug inserted) should enumerate B-device.
 | 
					
						
							| 
									
										
										
										
											2014-04-23 15:56:54 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 3) Role switch
 | 
					
						
							| 
									
										
										
										
											2019-04-15 23:56:01 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  |    On B-device::
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
 | 
					
						
							| 
									
										
										
										
											2014-04-23 15:56:54 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-08 11:53:37 -02:00
										 |  |  |    B-device should take host role and enumerate A-device.
 | 
					
						
							| 
									
										
										
										
											2014-04-23 15:56:54 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 4) A-device switch back to host.
 | 
					
						
							| 
									
										
										
										
											2019-04-15 23:56:01 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  |    On B-device::
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	echo 0 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
 | 
					
						
							| 
									
										
										
										
											2014-04-23 15:56:54 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-26 22:40:02 -08:00
										 |  |  |    or, by introducing HNP polling, B-Host can know when A-peripheral wishes to
 | 
					
						
							|  |  |  |    be in the host role, so this role switch also can be triggered in
 | 
					
						
							|  |  |  |    A-peripheral side by answering the polling from B-Host. This can be done on
 | 
					
						
							|  |  |  |    A-device::
 | 
					
						
							| 
									
										
										
										
											2019-04-15 23:56:01 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_req
 | 
					
						
							| 
									
										
										
										
											2016-02-19 10:04:47 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-08 11:53:37 -02:00
										 |  |  |    A-device should switch back to host and enumerate B-device.
 | 
					
						
							| 
									
										
										
										
											2014-04-23 15:56:54 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-26 22:40:02 -08:00
										 |  |  | 5) Remove B-device (unplug micro B plug) and insert again in 10 seconds;
 | 
					
						
							| 
									
										
										
										
											2017-12-08 11:53:37 -02:00
										 |  |  |    A-device should enumerate B-device again.
 | 
					
						
							| 
									
										
										
										
											2014-04-23 15:56:54 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-26 22:40:02 -08:00
										 |  |  | 6) Remove B-device (unplug micro B plug) and insert again after 10 seconds;
 | 
					
						
							| 
									
										
										
										
											2017-12-08 11:53:37 -02:00
										 |  |  |    A-device should NOT enumerate B-device.
 | 
					
						
							| 
									
										
										
										
											2014-04-23 15:56:54 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |    if A-device wants to use bus:
 | 
					
						
							| 
									
										
										
										
											2019-04-15 23:56:01 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  |    On A-device::
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	echo 0 > /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_drop
 | 
					
						
							|  |  |  | 	echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_req
 | 
					
						
							| 
									
										
										
										
											2014-04-23 15:56:54 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |    if B-device wants to use bus:
 | 
					
						
							| 
									
										
										
										
											2019-04-15 23:56:01 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  |    On B-device::
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
 | 
					
						
							| 
									
										
										
										
											2014-04-23 15:56:54 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 7) A-device power down the bus.
 | 
					
						
							| 
									
										
										
										
											2019-04-15 23:56:01 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  |    On A-device::
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_drop
 | 
					
						
							| 
									
										
										
										
											2014-04-23 15:56:54 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |    A-device should disconnect with B-device and power down the bus.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 8) B-device does data pulse for SRP.
 | 
					
						
							| 
									
										
										
										
											2019-04-15 23:56:01 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  |    On B-device::
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
 | 
					
						
							| 
									
										
										
										
											2014-04-23 15:56:54 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-08 11:53:37 -02:00
										 |  |  |    A-device should resume usb bus and enumerate B-device.
 | 
					
						
							| 
									
										
										
										
											2014-04-23 15:56:54 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 1.3 Reference document
 | 
					
						
							|  |  |  | ----------------------
 | 
					
						
							|  |  |  | "On-The-Go and Embedded Host Supplement to the USB Revision 2.0 Specification
 | 
					
						
							|  |  |  | July 27, 2012 Revision 2.0 version 1.1a"
 | 
					
						
							| 
									
										
										
										
											2015-02-11 12:44:50 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 2. How to enable USB as system wakeup source
 | 
					
						
							| 
									
										
										
										
											2019-04-15 23:56:01 -03:00
										 |  |  | --------------------------------------------
 | 
					
						
							| 
									
										
										
										
											2015-02-11 12:44:50 +08:00
										 |  |  | Below is the example for how to enable USB as system wakeup source
 | 
					
						
							| 
									
										
										
										
											2023-01-26 22:40:02 -08:00
										 |  |  | on an imx6 platform.
 | 
					
						
							| 
									
										
										
										
											2015-02-11 12:44:50 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-15 23:56:01 -03:00
										 |  |  | 2.1 Enable core's wakeup::
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	echo enabled > /sys/bus/platform/devices/ci_hdrc.0/power/wakeup
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 2.2 Enable glue layer's wakeup::
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	echo enabled > /sys/bus/platform/devices/2184000.usb/power/wakeup
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 2.3 Enable PHY's wakeup (optional)::
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	echo enabled > /sys/bus/platform/devices/20c9000.usbphy/power/wakeup
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 2.4 Enable roothub's wakeup::
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	echo enabled > /sys/bus/usb/devices/usb1/power/wakeup
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 2.5 Enable related device's wakeup::
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	echo enabled > /sys/bus/usb/devices/1-1/power/wakeup
 | 
					
						
							| 
									
										
										
										
											2015-02-11 12:44:50 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | If the system has only one usb port, and you want usb wakeup at this port, you
 | 
					
						
							| 
									
										
										
										
											2023-01-26 22:40:02 -08:00
										 |  |  | can use the below script to enable usb wakeup::
 | 
					
						
							| 
									
										
										
										
											2015-02-11 12:44:50 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-15 23:56:01 -03:00
										 |  |  | 	for i in $(find /sys -name wakeup | grep usb);do echo enabled > $i;done;
 |