Usb otg Study Notes

Source: Internet
Author: User
I only read the notes written by Spec for half a day, but it is a bit messy. After debugging is completed, the idea is not very mature. I guess there are many components and there may be something wrong. You are welcome to make a brick and then correct them. 1. the OTG device uses the ID pin in the plug to distinguish a/B device. The ID grounding is called a-device, which is the USB host during connection. A-device always provides power for the bus, the ID is called B-device, which is the USB device during connection. The USB Host/USB device role of the device can be switched through HNP.

 

When the OTG device is connected, it cannot cross the USB hub. If the device is connected across the USB hub, the HNP function is lost.

 

Note that a-device/B-device and USB Host/device are not necessarily bound. A-device must be a host, when a-device is connected, the host can be switched through HNP. After switching a-device to a USB device, the power is still provided for the bus.

 

2. device type embedded HOST: provides standard a socket, common USB host with TPL (list of supported devices)
OTG device: using a micro AB outlet, you can switch between host and device at runtime.
Only peripherals B-device: B-device that can be used as peripherals (divided into plug-in integration and plug-in cable separation ).

 

Note: After the OTG device plug is inserted, vbus is enabled first. If no device is connected, vbus is disabled and ADP Detection is enabled, and vbus is not disabled again for Embedded host.

 

3. Protocol SRP (Session Request Protocol ):
B-device. Request a-device to open vbus and start a session through a pulse on the data line. The session is started from vbus to disabled. Supported: A-device allows responses to SRP and B-device (including B-device that can only be used as peripherals), and SRP can be initiated. A B-device that supports HNP should be able to initiate SRP. When plug a is inserted, the host that disables vbus must support responding to SRP. The host that vbus always opens does not have to respond to SRP.

 

ADP (attach Detection protocol): provides a device to detect whether a peer device is inserted. Supports any OTG device, embedded host, and B-device supporting SRP allows ADP probing, b-device and B-device that can only serve as peripherals must also support ADP senseing if they support ADP probing.

 

HNP (host negotiation protocol): the OTG device uses HNP to switch the host/device role. The current USB host uses the host request flag in the data returned by the HNP polling (similar to polling hub) command to query whether the request of the Peer device is changed to host. The polling interval is 1-2 seconds. When the current USB Host decides to allow B-device to be converted to host, use setfeature () to enable B _hnp_enable. After this session ends, the host will return to a-device.

 

4. device framework OTG descriptor: During device enumeration, A-Device Requests the OTG descriptor from Device B through getdeor. The OTG descriptor should also be returned as part of getconfiguration. Bmattributes indicates whether the B-device supports the ADP, HNP, and SRP standard device features and is set through setfeature. B _hnp_enable: set this feature to show that B-device is allowed for HNP, and a must suspend the bus within T (host_req_susp) time. A_hnp_support: Compatibility feature of earlier OTG versions. setting this feature indicates that a-device of the B-device peer supports HNP. A-device should set this feature for B-device if a-device supports HNP. A_alt_hnp_support: discard getstatus (). The OTG status bit in the data section is host request flag, indicating that the current USB device role is expected to be a USB Host role.

 

5. generally, during the connection process (host-> device), the OTG device/Embedded host and the B-device (with a plug-in) host that is only used as peripherals detect plug a insertion and stop ADP, open vbus, because the plug of B-device is integrated with the device. At this time, B-device must be connected to the plug. The host detects the peripheral connection and starts enumeration.
 
OTG device/Embedded host and B-device (plug a is connected to a cable) that is used as peripherals only. The host segment detects plug a insertion, stops ADP, and enables vbus, if B-device is connected by a cable and plug a is inserted, the entire connection process is the same as above, because at this time B-device may not have plug inserted, the device connection times out, shut down vbus again, wait for the next change of ADP (after the cable connection is completed), open vbus again, and start normal bus enumeration.

 

When OTG device and OTG Device Host detect plug insertion, vbus is enabled. If no peripherals detect it, vbus is disabled, ADP probing is enabled, and the device detects plug insertion, SRP is enabled. If the cable is not inserted, SRP times out and the device starts ADP probing. When the cable connection is complete, the device detects ADP changes and sends a SRP request to host to open vbus, host responds to SRP and opens vbus to connect the device.

 

6. insert a common USB host between the OTG device (host/device) and a common USB Host/device OTG device (device): spec indicates that the OTG device meets all USB peripherals, and the implementation of the electrical principle is not identified. Insert common USB device into OTG device (host): OTG is compatible, but the principle of the electrical device is not identified. You have doubts about vbus opening and processing of ADP and SRP. Someone asked this question at usb.org. The reply was only about recognition and compatibility, but the implementation principle and monitoring details were unknown. Original post address: https://www.usb.org/phpbb/viewtopic.php? T = 14450 & Highlight = OTG

 

Some of the latest ideas and guesses:
1. ADP is the key to OTG device as the host, which can disable vbus and monitor general USB devices.

 

2. If OTG device is used as the host and does not support ADP but SRP, vbus should always be enabled (or is it interrupted through insertion? Roothub polling). If you want to disable vbus, you can only initiate srp otg devices, general USB devices, and OTG devices that do not support SRP, if the host does not have ADP, you cannot disable vbus and detect that the device (except insertion interruption) is inserted and vbus is enabled through SRP.

 

Note: When OTG device is used as the host, vbus will be opened when plug a is inserted. If the inserted device cable is already connected when plug a is inserted, it will be enumerated normally during this insertion. If the inserted device cable is not connected when plug a is inserted, the OTG device as the host does not support ADP, but supports SRP, the inserted device can initiate SRP to open vbus after the cable is inserted, if the inserted device does not support SRP. Is the device abnormal?

 

3. before monitoring bus activity and device connection, the OTG device detects the plug when the plug is inserted (normal USB does not detect the plug, because the otg id pin will interrupt the Controller ), in this way, the OTG device role is determined, and the ADP waits for the device to connect, and then vbus is enabled for bus activity.

 

How to enable vbus for bus enumeration is the ultimate goal of SRP and ADP as a B-device or a common USB device. SRP is one of the methods by which B-device requests a-device to open device, however, although ADP is used as a device for detecting insertion, some eh/OTG devices will enable vbus after ADP detects the status (or does not support SRP, if no device connection is available, disable vbus and enable ADP for further detection (only for OTG device EH). Even more, after detecting a plug, directly open vbus (ADP came out late, in many early OTG controllers, there was no such thing as ADP or HNP polling at all, and it is estimated that there may not be any such stuff in spec at that time.) This made SRP seem redundant, however, when we use B-device, we should issue the SRP before starting the bus operation, make sure that ADP is not supported. Only SRP is supported. If vbus is not enabled when the plug is inserted, vbus is enabled only when the SRP is received. The device can also perform normal enumeration.

Usb otg Study Notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.