USB device access control method, USB controller, chip, electronic device and USB hub

By detecting the supported modes of USB devices when plugging in, and performing link detection and training when supporting USB3.0, the problem of USB3.0 devices incorrectly adopting USB2.0 links due to plug-in speed problems is solved, and transmission performance and reliability are improved.

CN119718989APending Publication Date: 2025-03-28CHENGDU HAIGUANG INTEGRATED CIRCUIT DESIGN CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411793880.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-06
Publication Date
2025-03-28

AI Technical Summary

Technical Problem

Due to USB device insertion speed problems, USB3.0 devices are incorrectly using USB2.0 link, resulting in a degradation in transmission performance.

Method used

When USB 2.0 impedance access is detected, obtain the device description information of the USB device. If USB 3.0 mode is supported, reset the port and conduct USB 3.0 link detection and training to ensure data transmission is used.

Benefits of technology

Timely discover and solve the problem of USB devices using USB 2.0 link incorrectly, improve the performance and reliability of data transmission and reduce the risk of data loss caused by link switching.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119718989A_ABST
    Figure CN119718989A_ABST
Patent Text Reader

Abstract

The invention provides an access control method of USB equipment, a USB controller, a chip, electronic equipment and a USB concentrator, and the method comprises the steps: obtaining the equipment description information of the currently accessed USB equipment under the condition that USB 2.0 impedance access is detected; under the condition that the device description information represents that the USB device supports the USB 3.0 mode, resetting a port connected to the USB device and carrying out USB 3.0 link detection; and under the condition that the USB3.0 link detection is successful, carrying out USB3.0 link training, and carrying out data transmission by using the USB3.0 link after the USB3.0 link training is successful. According to the method and the device, the transmission performance loss caused by mistakenly adopting the USB2.0 link can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of USB technology, and in particular to an access control method for a USB device, a USB controller, a chip, an electronic device and a USB hub. Background Art

[0002] Currently, USB (Universal Serial Bus) 3.0 devices are also equipped with USB 2.0 pins. When a USB 3.0 link cannot be established with a USB Host (a host that supports USB access), the USB 2.0 link is switched to ensure the data transmission capability between the USB 3.0 device and the USB Host as much as possible.

[0003] When inserting a USB 3.0 device into a USB Host, since the pins on the connector that implement USB 2.0 are longer than those that implement USB 3.0, if the user inserts the device slowly, or if the USB interface design of the USB Host causes the USB 3.0 device to be inserted slowly (for example, the USB interface is designed too tight), the USB 2.0 pins in the USB 3.0 device may contact the corresponding pins in the USB Host and thus be powered on successfully, but the USB 3.0 pins may fail to contact the corresponding pins in the USB Host within the set time after power-on, resulting in the USB Host timing out and failing to detect the USB 3.0 link, and instead using the USB 2.0 link to establish a connection with the USB 3.0 device.

[0004] However, there is a significant difference in transmission speed between USB 3.0 and USB 2.0. The above situation may lead to the use of USB 2.0 link instead of USB 3.0 link due to device insertion speed issues, resulting in a decrease in transmission performance. Summary of the invention

[0005] The purpose of the embodiments of the present application is to provide a USB device access control method, a USB controller, a chip, an electronic device and a USB hub, so as to solve the problem of decreased transmission performance caused by incorrect use of a USB 2.0 link.

[0006] The embodiment of the present application provides an access control method for a USB device, comprising: when USB2.0 impedance access is detected, obtaining device description information of a currently connected USB device; when the device description information indicates that the USB device supports USB3.0 mode, resetting the port connected to the USB device and performing USB3.0 link detection; when the USB3.0 link detection is successful, performing USB3.0 link training, and using the USB3.0 link for data transmission after the USB3.0 link training is successful.

[0007] Based on the USB protocol, when performing USB access detection, a preset number of USB3.0 link detections (i.e., detecting Rx Termination at both ends of the USB3.0 link as specified in the USB protocol) will be performed first, and after the detection fails, USB2.0 link detection will be performed, at which time it will be detected whether there is USB2.0 impedance access. Therefore, in the above implementation scheme, when USB2.0 impedance access is detected, it indicates that the USB device is in the access process, and the USB3.0 link has failed to be detected. There may be a situation where the USB2.0 link is mistakenly used due to the device insertion speed problem. To this end, when USB2.0 impedance access is detected, the device description information of the currently connected USB device is first obtained, and then when the device description information indicates that the USB device supports the USB3.0 mode, the port connected to the USB device is reset and the USB3.0 link detection is performed. When the USB3.0 link detection is successful, USB3.0 link training is performed, and after the USB3.0 link training is successful, the USB3.0 link is used for data transmission. In this way, during the access process of the USB device, it is possible to promptly detect the situation where the USB2.0 link is incorrectly used, and the link can be restored to the USB3.0 link in time, reducing the transmission performance loss caused by the incorrect use of the USB2.0 link.

[0008] Furthermore, resetting the port connected to the USB device and performing USB3.0 link detection includes: detecting the port connected to the USB device; if the detection result indicates that there is a data transmission operation on the port, then: stopping the data transmission operation and storing the data to be transmitted that has not been transmitted in the data transmission operation; resetting the port and performing USB3.0 link detection after the storage of the data to be transmitted is completed; correspondingly, using the USB3.0 link to perform data transmission includes: using the USB3.0 link to transmit the data to be transmitted.

[0009] For USB devices, the reliability of data transmission is one of the important indicators. If the data is lost during the transmission process due to the switching of the USB link, it will seriously affect the user's sense of use. In the above implementation, before resetting the port connected to the USB device and performing the USB3.0 link detection, the port is first detected to determine whether there is a data transmission operation on the port, and if there is a data transmission operation, the data transmission operation is stopped first and the data to be transmitted that has not been completed in the data transmission operation is stored, and after successfully switching to the USB3.0 link, the USB3.0 link is continued to be used to transmit the data to be transmitted. In this way, the risk of data loss due to the switching of the USB link can be reduced, and the reliability of data transmission can be improved.

[0010] Furthermore, resetting the port connected to the USB device and performing USB 3.0 link detection further includes: if the detection result indicates that there is no data transmission operation on the port, resetting the port and performing USB 3.0 link detection.

[0011] In the above implementation, when the detection result indicates that there is no data transmission operation on the port, the port is directly reset and the USB3.0 link detection is performed. At this time, there is no risk of data loss. In addition, since the port reset and USB3.0 link detection operations are directly performed, the switching efficiency of the USB3.0 link is improved.

[0012] Furthermore, the port connected to the USB device is detected, including: detecting whether there is a target endpoint in a running state on the port; if so, it indicates that there is a data transmission operation on the port; if not, it indicates that there is no data transmission operation on the port; stopping the data transmission operation includes: ending the running state of the target endpoint.

[0013] A port often includes multiple endpoints (i.e., Endpoints), and data needs to be transmitted through endpoints. Therefore, in the above implementation, by detecting whether there is a target endpoint in operation on the port, it is possible to quickly detect whether there is data transmission on the port, thereby improving detection efficiency and accuracy.

[0014] Furthermore, after the data to be transmitted is stored, the method further includes: if the USB3.0 link detection fails, or the USB3.0 link training fails, then: performing USB2.0 device enumeration to restore the USB2.0 link, and using the USB2.0 link to transmit the data to be transmitted.

[0015] In the above implementation, after the USB3.0 link detection fails or the USB3.0 link training fails, USB2.0 device enumeration is performed to restore the USB2.0 link, and the USB2.0 link is used to transmit the data to be transmitted. In this way, when it is impossible to switch to USB3.0, the USB2.0 link can be restored to ensure that USB-based data transmission can still be achieved.

[0016] Furthermore, the method also includes: if the USB3.0 link detection fails, or the USB3.0 link training fails, then: performing USB2.0 device enumeration to restore the USB2.0 link, and after a preset interval, resetting the port connected to the USB device and performing USB3.0 link detection again, until the USB3.0 link training succeeds, or the preset end condition is met.

[0017] In the above implementation, each time the USB3.0 link detection fails or the USB3.0 link training fails, the port connected to the USB device is reset and the USB3.0 link detection is performed again after a preset interval, until the USB3.0 link training succeeds or the preset end condition is met. In this way, during each interval, the USB2.0 link can be restored for data transmission. Since the time taken for the port reset, USB3.0 link detection, and USB3.0 link training performed in the device is very short, usually in the millisecond level, the user is basically unaware of it. Therefore, each time the USB3.0 link detection fails or the USB3.0 link training fails, the USB2.0 link is switched back to perform data transmission. The user is basically unaware of it. Therefore, for the user, it is equivalent to being able to achieve seamless switching between the USB2.0 link and the USB3.0 link without affecting data transmission, thereby improving the user experience.

[0018] Further, the preset termination condition includes at least one of the following: the total number of failures reaches a preset first number threshold; wherein the total number of failures is equal to the sum of the number of USB3.0 link detection failures and the number of USB3.0 link training failures; a first time period from the time when the port is reset for the first time to the time when the USB3.0 link detection fails or the USB3.0 link training fails is greater than or equal to a preset first time period threshold; a second time period from the time when the USB3.0 link detection is performed for the first time to the time when the USB3.0 link detection fails or the USB3.0 link training fails is greater than or equal to a preset second time period threshold; a third time period from the time when USB2.0 impedance access is detected to the time when the USB3.0 link detection fails or the USB3.0 link training fails is greater than or equal to a preset third time period threshold.

[0019] In the above implementation, by reasonably setting the preset first count threshold, or the first duration threshold, or the second duration threshold, or the third duration threshold, it is possible to switch back to the USB2.0 link if the USB device has been stably inserted and the USB3.0 link still cannot be used normally, thereby avoiding the continuous detection of the USB3.0 link and causing unnecessary power consumption.

[0020] Furthermore, the method further comprises: if the USB 3.0 link detection fails, re-performing the USB 3.0 link detection, and if the USB 3.0 link training fails, re-performing the USB 3.0 link detection until the USB 3.0 link training succeeds or a preset end condition is met.

[0021] In the above implementation, when the SB device supports USB 3.0 mode but fails to correctly connect to the USB 3.0 link, the USB 3.0 link detection is continued until the USB 3.0 link training is successful or the preset end condition is met. In this way, through continuous attempts, the USB 3.0 link can be switched to the USB 3.0 link as soon as the USB 3.0 pin in the USB device contacts the corresponding pin on the host during the continuous insertion of the USB device, thereby improving the timeliness of the USB 3.0 link switching.

[0022] Further, the preset termination condition includes at least one of the following: the total number of failures reaches a preset second number threshold; wherein the total number of failures is equal to the sum of the number of USB3.0 link detection failures and the number of USB3.0 link training failures; a first time period from the time when the port is reset for the first time to the time when the USB3.0 link detection fails or the USB3.0 link training fails is greater than or equal to a preset first time period threshold; a second time period from the time when the USB3.0 link detection is first performed to the time when the USB3.0 link detection fails or the USB3.0 link training fails is greater than or equal to a preset second time period threshold; a third time period from the time when USB2.0 impedance access is detected to the time when the USB3.0 link detection fails or the USB3.0 link training fails is greater than or equal to a preset third time period threshold.

[0023] In the above implementation, by reasonably setting the preset second number threshold, or the first duration threshold, or the second duration threshold, or the third duration threshold, it is possible to switch back to the USB2.0 link if the USB device has been stably inserted and the USB3.0 link still cannot be used normally, thereby avoiding the continuous detection of the USB3.0 link and causing unnecessary power consumption.

[0024] An embodiment of the present application also provides a USB controller, including: a control circuit and a USB connector; the USB connector is used to connect to a USB device; the control circuit is used to implement any of the above-mentioned USB device access control methods.

[0025] An embodiment of the present application also provides a chip, including the above-mentioned USB controller.

[0026] An embodiment of the present application also provides an electronic device, including the above-mentioned USB controller, or including the above-mentioned chip.

[0027] An embodiment of the present application also provides a USB hub, including the above-mentioned USB controller. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0029] Figure 1 A cross-sectional view of a Type A connector provided in an embodiment of the present application;

[0030] Figure 2 A flowchart of a method for controlling access to a USB device provided in an embodiment of the present application;

[0031] Figure 3 A schematic diagram of the structure of a USB controller provided in an embodiment of the present application;

[0032] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;

[0033] Figure 5 A flowchart of a specific USB device access control process provided in an embodiment of the present application. DETAILED DESCRIPTION

[0034] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.

[0035] Currently, USB3.0 devices are equipped with both USB2.0 and USB3.0 pins. However, the pins on the connector that implement USB2.0 are longer than those that implement USB3.0. Figure 1The cross-sectional view of the Type A connector is shown, in which the four longer pins are USB 2.0 pins and the five shorter pins are USB 3.0 pins.

[0036] According to the USB3.0 protocol specification, when a USB3.0 device is inserted into the system, it is initially in the power state, in which the port periodically (for example, every 12ms) performs USB3.0 link detection. If the USB3.0 link is not detected for eight consecutive times, it will switch to the USB2.0 impedance access detection, and after detecting the USB2.0 impedance, it will create and use the USB2.0 link.

[0037] Then, since the pins on the connector that implement USB2.0 are longer than those that implement USB3.0, and since the detection of the USB3.0 link is performed first and has a limit on the number of times, when the user inserts the device slowly, or the USB host's USB interface design problems (for example, the USB interface is designed too tight) result in slow insertion of the USB3.0 device, the USB3.0 link may be detected eight times before the USB3.0 pin successfully contacts the corresponding pin in the USB host, thereby erroneously using the USB2.0 link.

[0038] There is a significant difference in the transmission rate between USB 3.0 and USB 2.0. The transmission rate of USB 2.0 is only 480Mbps, while the transmission rate of USB 3.0 can reach 5Gbps or even 10Gbps. Therefore, once the above situation occurs, the transmission performance will be significantly reduced.

[0039] In order to solve the above problems, an access control method for a USB device is provided in an embodiment of the present application. Figure 2 As shown, Figure 2 A flowchart of a method for controlling access to a USB device provided in an embodiment of the present application includes:

[0040] S201: When USB 2.0 impedance access is detected, device description information of the currently connected USB device is obtained.

[0041] In the embodiment of the present application, the execution subject of the method provided in the embodiment of the present application may be a USB controller, and the USB controller is set in an electronic device that can be connected to a USB device. Exemplarily, the USB controller is set in an electronic device such as a chip, a hub, a computer host, etc. that can be connected to a USB device.

[0042] In the embodiment of the present application, the USB controller follows the USB protocol. When the USB device is connected, the USB3.0 link detection is first performed for the number of times specified in the protocol. After the USB3.0 link detection for the number of times specified in the protocol fails, the USB2.0 impedance access detection is performed. Therefore, when the USB2.0 impedance access is detected, it indicates that the USB device is in the access process and the USB3.0 link has failed to be detected. There may be a situation where the USB2.0 link is mistakenly used due to the device insertion speed problem.

[0043] At this time, the USB controller can obtain the device description information of the currently connected USB device, and then determine whether the USB device supports the USB 3.0 mode.

[0044] Optionally, the acquired device description information may be but is not limited to a device descriptor of a previously connected USB device, and the USB controller may determine whether the USB device supports USB 3.0 mode according to a bcdUSB code in the device descriptor.

[0045] In the embodiment of the present application, the USB 3.0 link detection method may be: switching the port to the Rx.Detect.Active state to detect whether there is USB 3.0 impedance access, which is called USB 3.0 RxTermination detection in the protocol.

[0046] S202: When the device description information indicates that the USB device supports the USB 3.0 mode, the port connected to the USB device is reset and a USB 3.0 link detection is performed.

[0047] In an embodiment of the present application, when the device description information indicates that the USB device does not support USB3.0 mode, it indicates that the connected USB device is a USB2.0 device, which means that the USB device only has USB2.0 pins, so there is no situation of erroneously using the USB2.0 link. Therefore, the process can be terminated at this time, and the USB2.0 link can be directly used to interact with the USB device.

[0048] In an embodiment of the present application, when the device description information indicates that the USB device supports the USB 3.0 mode, it indicates that the connected USB device is a device that supports USB 3.0. Therefore, a situation where a USB 2.0 link is incorrectly adopted may occur. Therefore, when the device description information indicates that the USB device supports the USB 3.0 mode, the port connected to the USB device can be reset and a USB 3.0 link detection can be performed to try to establish a USB 3.0 link.

[0049] In an embodiment of the present application, when the device description information indicates that the USB device supports the USB 3.0 mode, the port connected to the USB device can also be detected. If the detection result indicates that there is a data transmission operation on the port, the data transmission operation can be stopped and the data to be transmitted that has not been transmitted in the data transmission operation can be stored, and after the storage of the data to be transmitted is completed, the port is reset and the USB 3.0 link detection is performed. Thereafter, after successfully switching to the USB 3.0 link (i.e., after the USB 3.0 link detection is successful and the USB 3.0 link training is successful), the USB 3.0 link is used to continue to transmit the data to be transmitted. In this way, the risk of data loss due to the switching of the USB link can be reduced, and the reliability of data transmission can be improved.

[0050] Correspondingly, if the detection result indicates that there is no data transmission operation on the port, the port can be directly reset and the USB 3.0 link detection can be performed.

[0051] Since a port often includes multiple endpoints (i.e., Endpoints), data needs to be transmitted through endpoints. Therefore, in an optional implementation of the embodiment of the present application, it is possible to detect whether there is a target endpoint in a running state on the port; if it exists, it indicates that there is a data transmission operation on the port; if it does not exist, it indicates that there is no data transmission operation on the port. Accordingly, when the data transmission operation is stopped at this time, the running state of the target endpoint can be ended by executing the Stop Endpoint command. In this way, by detecting whether there is a target endpoint in a running state on the port, it is possible to quickly detect whether there is data transmission on the port, thereby improving the detection efficiency and accuracy.

[0052] In the embodiment of the present application, other methods may also be used to determine whether there is a data transmission operation on the port.

[0053] S203: When the USB 3.0 link detection is successful, USB 3.0 link training is performed, and after the USB 3.0 link training is successful, the USB 3.0 link is used for data transmission.

[0054] In the embodiment of the present application, if the USB3.0 link detection fails, for example, the USB3.0 impedance access is not detected, or the USB3.0 link training fails, the USB2.0 device enumeration can be performed to restore the USB2.0 link, so that the USB device can continue to exchange data with the electronic device connected to the USB device. The device enumeration refers to the operation process of establishing a link with the USB device, including the operation of obtaining device information, configuring, and loading drivers for the USB device.

[0055] In an embodiment of the present application, if the USB3.0 link detection fails, or the USB3.0 link training fails, and there is data stored to be transmitted, then after the USB2.0 link is restored, the USB2.0 link can continue to be used to transmit the data to be transmitted, so as to reduce the risk of data loss caused by USB3.0 link detection and USB3.0 link training.

[0056] In an embodiment of the present application, the previously stopped target endpoint can be restored based on the register related to the USB2.0 link in the USB controller, so as to continue to transmit the data to be transmitted on the target endpoint. For example, if the USB controller adopts the XHCI (eXtensible Host Controller Interface) system, the target endpoint can be restored based on the doorbell register in the XHCI system.

[0057] In the implementation of the embodiment of the present application, when the USB3.0 link detection fails or the USB3.0 link training fails, the USB3.0 link detection can be performed again to form a loop to increase the probability of successful USB3.0 detection. At the same time, the end condition can be preset, and when the end condition is met, the USB3.0 link detection and USB3.0 link training are no longer performed, but the USB2.0 device enumeration is performed to restore the USB2.0 link, so as to avoid continuous USB3.0 link detection and USB3.0 link training, thereby affecting the normal use of the USB device.

[0058] In an optional implementation, if the USB3.0 link detection fails, or the USB3.0 link training fails, the USB2.0 device enumeration can be performed to restore the USB2.0 link, and after a preset interval, the port connected to the USB device is reset and the USB3.0 link detection is performed again, until the USB3.0 link training is successful, or the preset end condition is met. In this way, during each interval, the USB2.0 link can be restored for data transmission. Since the time taken for port reset, USB3.0 link detection, and USB3.0 link training in the device is very short, usually in the millisecond level, it is basically imperceptible to the user. Therefore, each time the USB3.0 link detection fails, or the USB3.0 link training fails, it switches back to the USB2.0 link for data transmission, which is basically imperceptible to the user. Therefore, for the user, it is equivalent to being able to achieve seamless switching between the USB2.0 link and the USB3.0 link without almost affecting data transmission, thereby improving the user experience.

[0059] In the above optional implementation manner, the preset interval duration can be set by an engineer according to actual needs, for example, it can be set to 1 second.

[0060] In the above optional implementation manner, the preset end condition includes at least one of the following:

[0061] The total number of failures reaches a preset first number threshold; wherein the total number of failures is equal to the sum of the number of USB3.0 link detection failures and the number of USB3.0 link training failures;

[0062] The first time duration from the time when the port is reset for the first time to the time when the USB 3.0 link detection fails or the USB 3.0 link training fails is greater than or equal to the preset first time duration threshold;

[0063] The second time period from the time when the USB 3.0 link detection is first performed to the time when the USB 3.0 link detection fails or the USB 3.0 link training fails is greater than or equal to the preset second time period threshold;

[0064] A third time period from when the USB2.0 impedance access is detected to when the current USB3.0 link detection fails or the USB3.0 link training fails is greater than or equal to a preset third time period threshold.

[0065] The first time threshold, the second time threshold and the third time threshold can be set according to the time taken when the USB is inserted slowly, for example, set to a time greater than or equal to the time taken when the USB is inserted slowly. The time taken when the USB is inserted slowly can be determined through offline collection, interviews, and experiments. In theory, the second time threshold < the first time threshold < the third time threshold.

[0066] In the embodiment of the present application, the first count threshold can be determined based on the time taken when the USB is inserted slowly (recorded as T) and the time taken to perform a single USB3.0 link detection (recorded as t1) plus a preset interval time (recorded as t2), or the sum of the time taken to perform a single USB3.0 link detection plus the time taken to perform USB3.0 link training (recorded as t3) plus the preset interval time. For example, the first count threshold can be determined as T / (t1+t2) rounded up or rounded down, or the first count threshold can be determined as T / (t1+t2+t3) rounded up or rounded down.

[0067] In another optional implementation, if the USB 3.0 link detection fails or the USB 3.0 link training fails, the USB 3.0 link detection may be directly re-performed until the USB 3.0 link training succeeds or a preset end condition is met.

[0068] At this time, since there is no need to restore the USB2.0 link, there is no need to reset the port or set the interval time when the USB3.0 link detection fails or the USB3.0 link training fails. By continuously trying, the USB3.0 link can be switched to as soon as the USB3.0 pin in the USB device contacts the corresponding pin on the host during the insertion of the USB device, thereby improving the switching timeliness of the USB3.0 link.

[0069] In the above optional implementation, when data to be transmitted is stored, the data to be transmitted can be transmitted using the USB3.0 link or the restored USB2.0 link after the USB3.0 link training is successful or the preset end condition is met.

[0070] In the embodiment of the present application, in order to facilitate the determination of whether to store data to be transmitted, a variable value k can be set, and k defaults to 0. When storing data to be transmitted, the k value is modified to 1. Thereafter, by judging whether the k value is 1, it can be determined whether to store data to be transmitted.

[0071] In the above optional implementation manner, the preset end condition includes at least one of the following:

[0072] The total number of failures reaches a preset second number threshold; wherein the total number of failures is equal to the sum of the number of USB3.0 link detection failures and the number of USB3.0 link training failures.

[0073] The first time duration from the time when the port is reset for the first time to the time when the USB 3.0 link detection fails or the USB 3.0 link training fails is greater than or equal to the preset first time duration threshold;

[0074] The second time period from the time when the USB 3.0 link detection is first performed to the time when the USB 3.0 link detection fails or the USB 3.0 link training fails is greater than or equal to the preset second time period threshold;

[0075] A third time period from when the USB2.0 impedance access is detected to when the current USB3.0 link detection fails or the USB3.0 link training fails is greater than or equal to a preset third time period threshold.

[0076] The determination method of the first duration threshold, the second duration threshold and the third duration threshold in the above-mentioned preset end condition is consistent with that described above and will not be repeated here.

[0077] The second count threshold can be determined based on the time taken when the USB is inserted slowly (represented as T), or the sum of the time taken to perform a single USB 3.0 link detection and the time taken to perform a USB 3.0 link training (represented as t3). For example, the first count threshold can be determined as T / t1 with rounding up or rounding down, or the first count threshold can be determined as T / (t1+t3) with rounding up or rounding down.

[0078] In the embodiment of the present application, in order to facilitate determining whether the total number of failures reaches the preset first number threshold or the preset second number threshold, a variable value m can be set, and each time the USB3.0 link detection fails or the USB3.0 link is trained, the value of m is increased by 1. When m reaches the preset first number threshold or the preset second number threshold, it is determined that the preset end condition is met.

[0079] Based on the access control method of the USB device provided by the embodiment of the present application, when the USB2.0 impedance access is detected, it indicates that the USB device is in the access process, and the USB3.0 link has failed to be detected. There may be a situation where the USB2.0 link is mistakenly used due to the device insertion speed problem. To this end, when the USB2.0 impedance access is detected, the device description information of the currently connected USB device is first obtained, and then when the device description information indicates that the USB device supports the USB3.0 mode, the port connected to the USB device is reset and the USB3.0 link detection is performed. When the USB3.0 link detection is successful, the USB3.0 link training is performed, and the USB3.0 link is used for data transmission after the USB3.0 link training is successful. In this way, during the access process of the USB device, it is possible to timely discover the situation where the USB2.0 link is mistakenly used, and the link is restored to the USB3.0 link in time, reducing the transmission performance loss caused by the mistaken use of the USB2.0 link.

[0080] The present application also provides a USB controller, see Figure 3 As shown, it includes a control circuit and a USB connector. The USB connector is used to connect to a USB device. The control circuit is used to implement the aforementioned USB device access control method.

[0081] In the embodiment of the present application, the control circuit can be implemented using the control structure of an existing USB controller, which is not limited to the embodiment of the present application.

[0082] Exemplarily, the USB controller may be implemented using an xHCI system or an EHCI system.

[0083] In the embodiment of the present application, the USB connector may be, but is not limited to, a Standard-A (Type-A) connector, a Mini-A connector, a Micro-A connector, a Standard-B (Type-B) connector, a Type-C connector, and the like.

[0084] In the embodiment of the present application, the USB connector may have pins with the same functions as those on the USB device, for example, it may include a power pin Vcc, a ground pin Gnd, differential signal pins D+ and D- for USB2.0 data transmission, and differential signal pins Tx+, Tx-, Rx+, and Rx- for USB3.0 data transmission.

[0085] A chip is also provided in an embodiment of the present application, which may include the aforementioned USB controller.

[0086] Optionally, the chip may include but is not limited to a CPU chip, a GPU chip, and the like.

[0087] An electronic device is also provided in an embodiment of the present application, which includes the aforementioned chip or includes the aforementioned USB controller.

[0088] Optionally, the electronic device may be, but is not limited to, a computer host, a tablet, a laptop computer and other intelligent terminals, and a server provided with a USB port.

[0089] Optionally, an onboard hub may be provided in the electronic device to expand the number of USB ports, for example Figure 4 shown.

[0090] Optionally, a signal booster (e.g. Figure 4 Retimer or ReDriver module shown in ) to enhance the signal, for example Figure 4 shown.

[0091] Figure 4 The structure shown is only an example of the structure of an electronic device, and the electronic device may have more or fewer structures. For example, the electronic device may also have an independent CPU and memory.

[0092] In an embodiment of the present application, a USB hub is also provided, in which the USB controller described above may be disposed.

[0093] To facilitate understanding of the solution of the embodiment of the present application, Figure 5 The specific implementation method shown is taken as an example to illustrate the solution of the embodiment of the present application. The entire USB device access control process includes:

[0094] 1. Detect USB2.0 impedance access and start the device enumeration process in USB2.0 mode.

[0095] 2. Obtain the bcdUSB code of the USB device through the device descriptor to determine whether the USB device supports USB 3.0 mode.

[0096] 3. If the answer to step 2 is no, the process ends directly.

[0097] 4. If the answer in step 2 is yes, set k=0, m=0.

[0098] 5. Determine whether m is less than 10.

[0099] 6. If the answer to step 5 is no, then the process ends directly.

[0100] 7. If the answer in step 5 is yes, continue to determine whether there is an Endpoint in running state on the port (i.e., the port connected to the USB device).

[0101] 8. If the answer to step 7 is no, directly perform the port reset operation of the USB2.0 link.

[0102] 9. If the step 7 is yes, set k=1, execute the Stop Endpoint command, cache the unfinished data, and then execute the Port reset operation of the USB2.0 link.

[0103] 10. Exit the USB2.0 state machine, and the Host (host equipped with a USB controller) and the USB device re-enable the Rx Termination detection of the USB3.0 link (i.e., USB3.0 link detection).

[0104] 11. Determine whether the Rx Termination test of the USB3.0 link is successful.

[0105] 12. If the answer to step 11 is no, the system returns to USB 2.0 mode and completes the device enumeration in USB 2.0 mode.

[0106] 13. If the answer in step 11 is yes, start USB 3.0 link training.

[0107] 14. Continue from step 12 and determine whether k is equal to 1.

[0108] 15. If the answer of step 14 is no, set m=m+1 and delay for 1 second.

[0109] 16. If the answer in step 14 is yes, set k=0, and restore the corresponding Endpoint through the doorbell register in xHCI, then set m=m+1, and delay for 1 second.

[0110] 17. Return to step 5.

[0111] 18. Continue with step 13 to determine whether the USB3.0 link training is successful.

[0112] 19. If step 18 is no, switch to USB 2.0 link and return to step 14.

[0113] 20. If the answer in step 18 is yes, then establish a USB 3.0 link.

[0114] 21. Determine whether k is equal to 1.

[0115] 22. If the answer of step 21 is no, then end directly.

[0116] 23. If the answer to step 21 is yes, set k=0 and continue to transmit the data cached in step 8 on the Endpoint of the new USB3.0 link.

[0117] 24. The end.

[0118] Based on the above implementation process, for hosts and USB devices that support USB3.0, when encountering a situation where the USB2.0 link is incorrectly used due to slow insertion of the USB device, the USB device speed drop can be promptly discovered and the USB3.0 link can be automatically created quickly within a short period of time after the USB device is inserted. The link can be restored to USB3.0 mode almost seamlessly without affecting USB2.0 data transmission, allowing both parties of the link to work in the highest speed mode, thereby improving transmission performance.

[0119] In the embodiments provided in the present application, it should be understood that the disclosed methods can be implemented in other ways. The embodiments described above are merely illustrative. The mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some communication interface, device or unit, which can be electrical, mechanical or other forms.

[0120] In this document, relational terms such as first and second, etc. are used merely to distinguish one entity or operation from another entity or operation, but do not necessarily require or imply any such actual relationship or order between these entities or operations.

[0121] As used herein, a plurality refers to two or more than two.

[0122] The above description is only an embodiment of the present application and is not intended to limit the protection scope of the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A method for controlling access to a USB device, characterized in that: include: When USB2.0 impedance access is detected, the device description information of the currently connected USB device is obtained; When the device description information indicates that the USB device supports the USB 3.0 mode, resetting the port connected to the USB device and performing a USB 3.0 link detection; When the USB 3.0 link detection is successful, USB 3.0 link training is performed, and after the USB 3.0 link training is successful, the USB 3.0 link is used for data transmission.

2. The USB device access control method according to claim 1, characterized in that: The step of resetting the port connected to the USB device and performing USB 3.0 link detection includes: Detecting the port connected to the USB device; If the detection result indicates that there is a data transmission operation on the port, then: stop the data transmission operation and store the untransmitted data to be transmitted in the data transmission operation; after the storage of the data to be transmitted is completed, reset the port and perform USB3.0 link detection; Correspondingly, using the USB 3.0 link to perform data transmission includes: The data to be transmitted is transmitted using the USB 3.0 link.

3. The USB device access control method according to claim 2, characterized in that: The step of resetting the port connected to the USB device and performing USB 3.0 link detection also includes: If the detection result indicates that there is no data transmission operation on the port, then: the port is reset and a USB 3.0 link detection is performed.

4. The USB device access control method according to claim 2, characterized in that: Detecting the port connected to the USB device includes: Detecting whether there is a target endpoint in a running state on the port; if so, it indicates that there is a data transmission operation on the port; if not, it indicates that there is no data transmission operation on the port; Stopping the data transmission operation includes: End the operation state of the target endpoint.

5. The USB device access control method according to claim 2, characterized in that: After the data to be transmitted is stored, the method further includes: If the USB 3.0 link detection fails, or the USB 3.0 link training fails, then: USB 2.0 device enumeration is performed to restore the USB 2.0 link, and the USB 2.0 link is used to transmit the data to be transmitted.

6. The USB device access control method according to any one of claims 1 to 5, characterized in that: The method further comprises: If the USB 3.0 link detection fails, or the USB 3.0 link training fails, then: USB 2.0 device enumeration is performed to restore the USB 2.0 link, and after a preset interval, the port connected to the USB device is reset and USB 3.0 link detection is performed again, until the USB 3.0 link training succeeds, or the preset end condition is met.

7. The USB device access control method according to claim 6, characterized in that: The preset end condition includes at least one of the following: The total number of failures reaches a preset first number threshold; wherein the total number of failures is equal to the sum of the number of USB3.0 link detection failures and the number of USB3.0 link training failures; A first time period from when the port is reset for the first time to when the USB 3.0 link detection fails or the USB 3.0 link training fails is greater than or equal to a preset first time period threshold; The second time period from the time when the USB 3.0 link detection is first performed to the time when the USB 3.0 link detection fails or the USB 3.0 link training fails is greater than or equal to the preset second time period threshold; A third time period from when the USB2.0 impedance access is detected to when the current USB3.0 link detection fails or the USB3.0 link training fails is greater than or equal to a preset third time period threshold.

8. The USB device access control method according to any one of claims 1 to 4, characterized in that: The method further comprises: If the USB 3.0 link detection fails, the USB 3.0 link detection is performed again, and if the USB 3.0 link training fails, the USB 3.0 link detection is performed again until the USB 3.0 link training succeeds or the preset end condition is met.

9. The USB device access control method according to claim 8, characterized in that: The preset end condition includes at least one of the following: The total number of failures reaches a preset second number threshold; wherein the total number of failures is equal to the sum of the number of USB3.0 link detection failures and the number of USB3.0 link training failures; A first time period from when the port is reset for the first time to when the USB 3.0 link detection fails or the USB 3.0 link training fails is greater than or equal to a preset first time period threshold; The second time period from the time when the USB 3.0 link detection is first performed to the time when the USB 3.0 link detection fails or the USB 3.0 link training fails is greater than or equal to the preset second time period threshold; A third time period from when the USB2.0 impedance access is detected to when the current USB3.0 link detection fails or the USB3.0 link training fails is greater than or equal to a preset third time period threshold.

10. A USB controller, characterized in that: include: A control circuit and a USB connector; the USB connector is used to connect to a USB device; The control circuit is used to implement the USB device access control method as described in any one of claims 1-9.

11. A chip, characterized in that: Comprising the USB controller as claimed in claim 10.

12. An electronic device, characterized in that: Includes the USB controller as claimed in claim 10, or includes the chip as claimed in claim 11.

13. A USB hub, characterized in that: Comprising the USB controller as claimed in claim 10.