# US 2017/0255585 A1 · Method and system for switching role of usb otg device and otg device thereof

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2017/0255585 A1
- Document ID: US20170255585A1
- Status: Published application
- Kind: A1
- Application number: 15/438,850
- Filed: 2017-02-22
- Published: 2017-09-07
- Earliest claimed: 2016-03-01
- Assignees: MediaTek Singapore Pte. Ltd.
- Applicants: MediaTek Singapore Pte. Ltd.
- Inventors: Jingbo ZHANG; Chengchun NI
- Web page: https://patentgrep.com/patent/US20170255585A1

## CPC

- G06F 13/4022: {using switching circuits, e.g. switching matrix, connection or expansion network (G06F13/4009 takes precedence)}
- G06F 13/385: {for adaptation of a particular data processing system to different peripheral devices}
- G06F 13/4286: {using a handshaking protocol, e.g. RS232C link}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A method and system of switching a role of a Universal Serial Bus (USB) On-The-Go (OTG) device and a USB OTG device are provided. According to the method, when the USB OTG device receives a Host Negotiation Protocol (HNP) request sent from a link-partner, an OTG controller of the USB OTG device is reset. The state of an ID-pin detection end which is used by the OTG controller to detect a type of plug of a USB cable is modified to switch the role of the USB OTG device between a host and a peripheral.

## Claims

### Claim 1

A method of switching a role of a Universal Serial Bus (USB) On-The-Go (OTG) device, comprising:
resetting an OTG controller of the USB OTG device when the USB OTG device receives a Host Negotiation Protocol (HNP) request sent from a link-partner; modifying a state of an ID-pin detection end of the OTG controller, wherein the ID-pin detection end is utilized to detect a type of plug of a USB cable; and
switching the role of the USB OTG device between a host and a peripheral.

### Claim 2 (depends on 1)

The method as claimed in claim 1,
wherein the step of modifying the state of the ID-pin detection end of the OTG controller comprises:
modifying the state of the ID-pin detection end of the OTG controller by switching a detected type of plug of the USB cable between an A-type and a B-type; and
wherein the step of switching the role of the USB OTG device between the host and the peripheral comprises:
switching the role of the USB OTG device between an A-host and a B-peripheral.

### Claim 3 (depends on 2)

The method as claimed in claim 2 further comprising:
when the role of the USB OTG device is the A-host and the USB OTG device receives the HNP request sent from the link-partner, resetting the OTG controller and modifying the state of the ID-pin detection end of the OTG controller by switching the detected type of plug of the USB cable to the B-type from the A-type and switching the role of the USB OTG device to the B-peripheral from the A-host; and
when the role of the USB OTG device is the B-peripheral and receives the HNP request sent from the link-partner, resetting the OTG controller and modifying the state of the ID-pin detection end of the OTG controller by switching the detected type of plug of the USB cable to the A-type from the B-type and switching the role of the USB OTG device to the A-host from the B-peripheral.

### Claim 4 (depends on 1)

The method as claimed in claim 1, wherein the step of modifying the state of the ID-pin detection end of the OTG controller comprises:
modifying the state of the ID-pin detection end of the OTG controller by switching the state of the ID-pin detection end between a ground and a floating.

### Claim 5 (depends on 1)

The method as claimed in claim 1, wherein the step of modifying the state of the ID-pin detection end of the OTG controller comprises:
using an ID-pin control circuit to control a state value input to the ID-pin detection end to switch between a state value of an ID pin of the plug of the USB cable connecting with the USB OTG device and a state value which is inverse to the state value of the ID pin;
wherein the state value of the ID pin comprises a high voltage level and a low voltage level.

### Claim 6 (depends on 5)

The method as claimed in claim 5,
wherein the ID-pin control circuit comprises a multiplexer, comprising a first input terminal coupled to the ID pin of the USB cable, an output terminal coupled to the ID-pin detection end, and a second input terminal for receiving an input state value being inverse to the state value of the ID pin of the plug of the USB cable, and
wherein the step of using an ID-pin control circuit to control a state value input to the ID-pin detection end comprises:
controlling an output of the multiplexer to switch between a signal at the first input terminal and a signal at the second input terminal.

### Claim 7 (depends on 6)

The method as claimed in claim 6,
wherein the ID-pin control circuit further comprises an internal storage coupled to the second input terminal of the multiplexer for providing the input state value, and a state-value controller coupled to the internal storage, an enable terminal of the multiplexer, the ID pin of the plug of the USB cable, and the OTG controller, and
wherein the method further comprises:
when the USB OTG device is coupled to the USB cable, the state-value controller detecting the state value of the ID pin of the plug of the USB cable and writing a state value which is inverse to the detected state value of the ID pin into the internal storage; and
when the USB OTG device receives the HNP request sent from the link-partner, the state-value controller, which is indicated by the OTG controller, controlling the output of the multiplexer to switch between the state value of the ID pin and a state value of the internal storage through the enable control terminal of the multiplexer.

### Claim 8 (depends on 5)

The method as claimed in claim 5,
wherein the ID-pin control circuit comprises a state-value controller coupled to the ID pin of the USB cable, an output of the OTG controller, and the ID-pin detection end,
wherein the method further comprises:
the state-value controller outputting a corresponding state value to the ID-pin detection end according to a current state of a state machine of the OTG controller;
when the current state of the state machine of the OTG controller is a start state, the state-value controller outputting the detected state value of the ID pin to the ID-pin detection end;
when the current state of the state machine of the OTG controller is an A-host state or an A-suspend state, the state-value controller outputting a state value “1” to the ID-pin detection end; and
when the current state of the state machine of the OTG controller is an A-host state or an A-suspend state, the state-value controller outputting a state value “0” to the ID-pin detection end.

### Claim 9

A Universal Serial Bus (USB) On-The-Go (OTG) device, comprising:
a host controller;
a peripheral controller;
an OTG controller, coupled to the host controller and the peripheral controller, comprising an ID-pin detection end for detecting a type of plug of a USB cable coupled to the USB OTG device,
wherein the OTG controller is configured to be reset in response to a Host Negotiation Protocol (HNP) request sent from a link-partner, and to modify the state of the ID-pin detection end to control a currently enabled controller of the USB OTG device to switch between the host controller and the peripheral controller.

### Claim 10 (depends on 9)

The USB OTG device as claimed in claim 9, wherein the OTG controller is further configured to modify the state of the ID-pin detection end by switching a detected type of plug of the USB cable between an A-type and a B-type to control a currently enabled controller of the USB OTG device to switch between the host controller and the peripheral controller.

### Claim 11 (depends on 9)

The USB OTG device as claimed in claim 9 further comprises:
an ID-pin control circuit, coupled between an ID pin of the plug of the USB cable, which is coupled to the USB OTG device, and the ID-pin detection end of the OTG controller,
wherein the ID-pin control circuit is configured to control a state value input to the ID-pin detection end to switch between a state value of the ID pin and a state value which is inverse to the state value of the ID pin, wherein the state value of the ID pin comprises a high voltage level and a low voltage level.

### Claim 12 (depends on 11)

The USB OTG device as claimed in claim 11, wherein the ID-pin control circuit comprises:
a multiplexer, comprising a first input terminal coupled to the ID pin of the USB cable, an output terminal coupled to the ID-pin detection end, and a second input terminal for receiving an input state value being inverse to the state value of the ID pin of the plug of the USB cable, and,
wherein the multiplexer is configured to select a signal at the first input terminal or a signal at the second input terminal to be output to the ID-pin detection end under the control of the OTG controller.

### Claim 13 (depends on 12)

The USB OTG device as claimed in claim 12,
wherein the ID-pin control circuit further comprises an internal storage coupled to the second input terminal of the multiplexer for providing the input state value, and a state-value controller coupled to the internal storage, an enable terminal of the multiplexer, the ID pin of the plug of the USB cable, and the OTG controller, and
wherein when the USB OTG device is coupled to the USB cable, the state-value controller is configured to detect the state value of the ID pin of the plug of the USB cable and write a state value which is inverse to the detected state value of the ID pin into the internal storage, and
wherein when the USB OTG device receives the HNP request sent from the link-partner, the state-value controller is configured to control the output of the multiplexer to switch between the state value of the ID pin and a state value of the internal storage through the enable control terminal of the multiplexer under the indication of the OTG controller.

### Claim 14 (depends on 13)

The USB OTG device as claimed in claim 13, wherein the multiplexer, the internal storage, and the state-value controller are integrated into a chip where the USB OTG controller is located.

### Claim 15 (depends on 13)

The USB OTG device as claimed in claim 13, wherein the internal storage and the state-value controller are integrated into a chip where the USB OTG controller is located, and the multiplexer is disposed and independent from the chip where the USB OTG controller is located.

### Claim 16 (depends on 11)

The USB OTG device as claimed in claim 11,
wherein the ID-pin control circuit comprises a state-value controller which is coupled to the ID pin of the USB cable, an output of the OTG controller, and the ID-pin detection end,
wherein the state-value controller is configured to output a corresponding state value to the ID-pin detection end according to a current state of a state machine of the OTG controller,
wherein when the current state of the state machine of the OTG controller is a start state, the state-value controller is configured to output the detected state value of the ID pin to the ID-pin detection end,
wherein when the current state of the state machine of the OTG controller is an A-host state or an A-suspend state, the state-value controller is configured to output a state value “1” to the ID-pin detection end, and
wherein when the current state of the state machine of the OTG controller is an A-host state or an A-suspend state, the state-value controller is configured to output a state value “0′” to the ID-pin detection end.

### Claim 17 (depends on 16)

The USB OTG device as claimed in claim 16, wherein the state-value controller is integrated into a chip where the USB OTG controller is located.

### Claim 18

A method of switching a role of a Universal Serial Bus (USB) On-The-Go (OTG) device for a first USB OTG device and a second USB OTG device which couple to each other through a USB cable, the first USB OTG being initially an A-host, and the second USB OTG device being initially a B-peripheral, the method comprising:
the second USB OTG device sending a first Host Negotiation Protocol (HNP) request to the first USB OTG device, wherein the HNP request is a request to become a host;
the first USB OTG device suspending the USB bus, resetting an OTG controller of the first USB OTG device, and modifying a state of an ID-pin detection end to a B-type from an A-type, and switching a role of the first USB OTG device to the B-peripheral from the A-host; and
after the second USB OTG detects that the first USB OTG device suspends the USB bus, the second USB OTG switching a role of the second USB OTG device to a B-host from the B-peripheral.

### Claim 19 (depends on 18)

The method as claimed in claim 18 further comprising:
the second USB OTG device sending a second HNP request to the first USB OTG device, wherein the second HNP request is a request to return to a peripheral; and
the first USB OTG device resetting the OTG controller and modifying the state of the ID-pin detection end to the A-type from the B-type, and switching the role of the first USB OTG device to the A-host from the B-peripheral; and
the second USB OTG device switching a role of the second USB OTG device to the B-peripheral to the B-host.

### Claim 20 (depends on 18)

The method as claimed in claim 18, wherein the first USB OTG device is a USB OTG device which supports an OTG 1.3 protocol, and the second USB OTG device is a USB OTG device which supports an OTG 2.0 protocol.

### Claim 21

A system of switching a role of a Universal Serial Bus (USB) On-The-Go (OTG) device comprising:
a first USB OTG device; and
a second USB OTG device coupled to the first USB OTG device through a USB cable,
wherein the first USB OTG device comprises a first host controller, a first peripheral controller, and a first OTG controller, the first USB OTG is initially an A-host, the first OTG controller is coupled to the first host controller and the first peripheral controller, the first OTG controller comprises an ID-pin detection end which is used to detect a type of plug of a USB cable coupled to the first USB OTG device,
wherein the first OTG controller is configured to receive a first Host Negotiation Protocol (HNP) request sent from the second USB OTG device, suspend a USB bus, reset modify a state of an ID-pin detection end to a B-type from an A-type, and control a currently enabled controller of the first USB OTG device to switch to the first peripheral controller from the first host controller,
wherein the second USB OTG device comprises a second host controller, a second peripheral controller, and a second OTG controller, the second USB OTG is initially a B-peripheral, and
wherein the second OTG controller is configured to switch a role of the second USB OTG device to a B-host from the B-peripheral and control a currently enabled controller of the second USB OTG device to switch to the second host controller from the second peripheral controller after detecting the first USB OTG device suspend the USB bus.

### Claim 22 (depends on 21)

The system as claimed in claim 21,
wherein the first OTG controller is further configured to receive a second HNP request from the second USB OTG device, reset, modify the state of the ID-pin detection end to the A-type from the B-type, and control the controller, which is currently enabled, to switch to the first host controller from the first peripheral controller, and
wherein the second OTG controller is further configured to switch the role of the second USB OTG device switches to the B-peripheral from the B-host, and control the controller, which is currently enabled, to switch to the second peripheral controller from second host controller after the second OTG controller sends a second HNP request to the first USB OTG device.

### Claim 23 (depends on 21)

The system as claimed in claim 21, wherein the first USB OTG device is a USB OTG device which supports an OTG 1.3 protocol, and the second USB OTG device is a USB OTG device which supports an OTG 2.0 protocol.
