You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/en/api-reference/peripherals/usb_host/usb_host_notes_dwc_otg.rst
+36-34Lines changed: 36 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,13 @@
1
1
USB Host Maintainers Notes (DWC_OTG Controller)
2
2
===============================================
3
3
4
+
:link_to_translation:`zh_CN:[中文]`
5
+
4
6
The {IDF_TARGET_NAME} uses a DesignWare USB 2.0 On-the-Go Controller (henceforth referred to as DWC_OTG in this document) as its underlying hardware controller, where the DWC_OTG operates in Host Mode with Scatter/Gather DMA enabled.
5
7
6
8
.. note::
7
9
8
-
This section only summarizes the operation of the DWC_OTG operation in Host Mode at a high level. For full details of the DWC_OTG, refer to the DWC_OTG Databook and Programming Guide.
10
+
This section only summarizes the operation of the DWC_OTG in Host Mode at a high level. For full details of the DWC_OTG, please refer to the DWC_OTG Databook and Programming Guide.
9
11
10
12
Host Mode Operating Model
11
13
-------------------------
@@ -19,26 +21,26 @@ A simplified version of the operating model of the DWC_OTG in Host Mode is illus
19
21
20
22
.. note::
21
23
22
-
Refer to Databook section 2.1.4 (Host Architecture) for more details
24
+
Refer to the Databook section 2.1.4 (Host Architecture) for more details.
23
25
24
26
Host Port
25
27
^^^^^^^^^
26
28
27
-
The Host Port represents the single USB port provided by the DWC_OTG (in USB terms, this can be thought a single USB port of the root hub of the bus). The Host Port can only connect to a single device, though more devices can be connected via hub devices.
29
+
The Host Port represents the single USB port provided by the DWC_OTG (in USB terms, this can be thought of as a single USB port of the root hub of the bus). The Host Port can only connect to a single device, though more devices can be connected via hub devices.
28
30
29
31
The Host Port is responsible for:
30
32
31
-
- detecting direct device connections/disconnections
32
-
- detecting the speed of the directly connected device
33
-
- issuing various bus signals (such as suspend, resume, reset)
33
+
- detecting direct device connections/disconnections.
34
+
- detecting the speed of the directly connected device.
35
+
- issuing various bus signals (such as suspend, resume, reset).
34
36
35
37
Host Channels
36
38
^^^^^^^^^^^^^
37
39
38
-
In Host Mode, the DWC_OTG uses channels to communicate with device endpoints, where one channel maps to a particular endpoint (in USB terms, channels are the hardware representation of pipes). For example, a channel will map to EP 1 OUT. Each channel has its own set of CSRs (Control and Status Registers) so that they can independently configured and controlled independently. A channel's CSRs are used to...
40
+
In Host Mode, the DWC_OTG uses channels to communicate with device endpoints, where one channel maps to a particular endpoint (in USB terms, channels are the hardware representation of pipes). For example, a channel will map to EP 1 OUT. Each channel has its own set of CSRs (Control and Status Registers) so that they can be configured and controlled independently. A channel's CSRs are used to:
39
41
40
-
- specify the details of the channel's target endpoint (e.g., device address, EP number, transfer type, direction)
41
-
- start a transfer on the channel (e.g., by setting up DMA descriptors)
42
+
- specify the details of the channel's target endpoint (e.g., device address, EP number, transfer type, direction).
43
+
- start a transfer on the channel (e.g., by setting up DMA descriptors).
42
44
43
45
When using Scatter/Gather DMA, transfers on Host Channels are completely event driven. Users simply fill out the appropriate DMA descriptors, fill in the channel's CSRs, then enable the channel. The channel will then generate an interrupt when the transfer completes.
44
46
@@ -52,9 +54,9 @@ In Host Mode, the DWC_OTG uses multiple FIFOs as a staging area for the data pay
52
54
53
55
The destination FIFO depends on the direction and transfer type of the channel:
54
56
55
-
- All IN channel data goes to the RX FIFO
56
-
- All non-periodic (i.e., Control and Bulk) OUT channel data goes to the Non-periodic TX (NPTX) FIFO
57
-
- All periodic (i.e., Interrupt and Isochronous) OUT channel data goes to the Periodic TX (PTX) FIFO
57
+
- All IN channel data goes to the RX FIFO.
58
+
- All non-periodic (i.e., Control and Bulk) OUT channel data goes to the Non-periodic TX (NPTX) FIFO.
59
+
- All periodic (i.e., Interrupt and Isochronous) OUT channel data goes to the Periodic TX (PTX) FIFO.
58
60
59
61
.. note::
60
62
@@ -75,19 +77,19 @@ The DMA engine is responsible for copying data between the FIFOs and main memory
75
77
- A 32-bit Buffer Status Quadlet specifying details of the transfer, and also reports the status of the transfer on completion. The Buffer Status Quadlet has bits to specify whether the QTD should generate an interrupt and/or halt the channel on completion.
76
78
- A 32-bit pointer to the data buffer containing the data payload for OUT transfers, or an empty buffer used to store the data payload for IN transfers.
77
79
78
-
- The data payload of each QTD can be larger than the MPS (Maximum Packet Size) of its target endpoint. The DWC_OTG hardware automatically handles splitting of the transfer into multiple transactions.
79
-
- Multiple QTDs can be placed into a single QTD List. A channel will then execute each QTD in the list automatically, and optionally loop back around if configured to do so.
80
+
- The data payload of each QTD can be larger than the MPS (Maximum Packet Size) of its target endpoint. The DWC_OTG hardware automatically handles the split of transfer into multiple transactions.
81
+
- Multiple QTDs can be placed into a single QTD List. A channel will then execute each QTD in the list automatically, and optionally loop back around via configuration.
80
82
- Before a channel starts data transfer, it is configured with a QTD list (and QTD list length). Once the channel is enabled, USB transfers are executed automatically by the hardware.
81
83
- A channel can generate interrupts (configurable) on completion of a particular QTD, or an entire QTD list.
82
84
83
85
.. note::
84
86
85
-
Refer to Programming Guide section 6.2.1 (Descriptor Memory Structures) for more details
87
+
Refer to Programming Guide section 6.2.1 (Descriptor Memory Structures) for more details.
86
88
87
89
Hardware Configuration
88
90
----------------------
89
91
90
-
The DWC_OTG IP is configurable. The notable Host related configurations of the {IDF_TARGET_NAME}'s DWC_OTG are listed below:
92
+
The DWC_OTG IP is configurable. The notable host related configurations of the {IDF_TARGET_NAME}'s DWC_OTG are listed below:
@@ -113,10 +115,10 @@ The DWC_OTG IP is configurable. The notable Host related configurations of the {
113
115
Scatter/Gather DMA Transfer
114
116
---------------------------
115
117
116
-
The basic operating procedure for Host channels transfers consists of the following steps:
118
+
The basic operating procedure for Host Channels' transfers consists of the following steps:
117
119
118
-
#. Prepare data buffers, QTDs, and QTD list. In particular, which QTDs should halt the channel (and generate an interrupt) on completion.
119
-
#. Set channel/endpoint characteristics via CSRs (such as EP address, transfer type, EP MPS etc).
120
+
#. Prepare data buffers, QTDs, and a QTD list. In particular, ensure which QTDs should halt the channel and generate an interrupt on completion.
121
+
#. Set channel and endpoint characteristics via CSRs (such as EP address, transfer type, EP MPS etc).
120
122
#. Set channel's QTD list related CSRs (such as QTD list pointer and QTD list length) and channel interrupt CSRs
121
123
#. Enable the channel. Transfers are now handled automatically by hardware using DMA.
122
124
#. The Channel generates an interrupt on a channel event (e.g., QTD completion or channel error).
@@ -128,21 +130,21 @@ However, there are some minor differences in channel operation and QTD list usag
128
130
Bulk
129
131
^^^^
130
132
131
-
Bulk transfers are a simplest. Each QTD represents a bulk transfer of a particular direction, where the DWC_OTG automatically splits a particular QTD into multiple MPS sized transactions. Thus it is possible to fill a QTD list with multiple bulk transfers, and have the entire list executed automatically (i.e., only interrupt on completion of the last QTD).
133
+
Bulk transfers are the simplest transfers. Each QTD represents a bulk transfer of a particular direction, where the DWC_OTG automatically splits a particular QTD into multiple MPS sized transactions. Thus it is possible to fill a QTD list with multiple bulk transfers, and have the entire list executed automatically (i.e., only interrupt on completion of the last QTD).
132
134
133
135
Control
134
136
^^^^^^^
135
137
136
-
Control transfers are more complicated as they are bi-directional (i.e., each control transfer stage can have a different direction). Thus, a separate QTD is required for each stage, and each QTD must halt the channel on completion. Halting the channel after each QTD allows changing the channel's direction to be changed by reconfiguring the channel's CSRs. Thus a typical control transfer consists of 3 QTDs (one for each stage).
138
+
Control transfers are more complicated as they are bi-directional (i.e., each control transfer stage can have a different direction). Thus, a separate QTD is required for each stage, and each QTD must halt the channel on completion. Halting the channel after each QTD allows the channel's direction to be changed by reconfiguring the channel's CSRs. Thus a typical control transfer consists of 3 QTDs (one for each stage).
137
139
138
140
Interrupt
139
141
^^^^^^^^^
140
142
141
-
In accordance with the USB2.0 specification, interrupt transfers executes transactions at the endpoints specified service period (i.e., ``bInterval``). A particular interrupt endpoint may not execute more than one interrupt transaction within a service period. The service period is specified in number of microframes/frames, thus a particular interrupt endpoint will generally execute one transaction every Nth microframe/frame until the transfer is complete. For interrupt channels, the service period of a particular channel (i.e., ``bInterval``) is specified via the Host Frame List (see section 6.5 of programming guide for more details).
143
+
In accordance with the USB 2.0 specification, interrupt transfers executes transactions at the endpoints specified service period (i.e., ``bInterval``). A particular interrupt endpoint may not execute more than one interrupt transaction within a service period. The service period is specified in number of microframes or frames, thus a particular interrupt endpoint will generally execute one transaction every Nth microframe or frame until the transfer is complete. For interrupt channels, the service period of a particular channel (i.e., ``bInterval``) is specified via the Host Frame List (see section 6.5 of Programming Guide for more details).
142
144
143
145
.. note::
144
146
145
-
HS USB allows an interrupt endpoint to have 3 interrupt transactions in a single microframe. See USB2.0 specification section 5.7.3 (Interrupt Transfer Packet Size Constraints) for more details.
147
+
HS USB allows an interrupt endpoint to have three interrupt transactions in a single microframe. See USB 2.0 specification section 5.7.3 (Interrupt Transfer Packet Size Constraints) for more details.
146
148
147
149
Thus, interrupt transfers in Host Mode Scatter/Gather DMA have the following peculiarities:
148
150
@@ -151,42 +153,42 @@ Thus, interrupt transfers in Host Mode Scatter/Gather DMA have the following pec
151
153
152
154
- the channel generates an extra channel interrupt even if the transfer's QTD did not set the IOC (interrupt on complete) bit.
153
155
- however, the channel is not halted even if this extra channel interrupt is generated.
154
-
- software must then use this extra interrupt to manually halt the interrupt channel (thus canceling any remaining QTDs in the QTD list).
156
+
- software must then use this extra interrupt to manually halt the interrupt channel, thus canceling any remaining QTDs in the QTD list.
155
157
156
158
157
159
.. note::
158
160
159
-
Due to the interrupt transfer peculiarities, it may be easier for software allocate a QTD for each transaction instead of an entire transfer.
161
+
Due to the interrupt transfer peculiarities, it may be easier for software to allocate a QTD for each transaction instead of an entire transfer.
160
162
161
163
Isochronous
162
164
^^^^^^^^^^^
163
165
164
-
In accordance with the USB2.0 specification, isochronous transfers executes transactions at the endpoints specified service period (i.e., ``bInterval``) in order to achieve a constant rate of data transfer. A particular isochronous endpoint may not execute more than one isochronous transaction within a service period. The service period is specified in number of microframes/frames, thus a particular isochronous endpoint will generally execute one transaction every Nth microframe/frame until the transfer is complete. For isochronous channels, the service period of a particular channel (i.e., ``bInterval``) is specified via the Host Frame List (see section 6.5 of programming guide for more details).
166
+
In accordance with the USB 2.0 specification, isochronous transfers executes transactions at the endpoints specified service period (i.e., ``bInterval``) in order to achieve a constant rate of data transfer. A particular isochronous endpoint may not execute more than one isochronous transaction within a service period. The service period is specified in number of microframes or frames, thus a particular isochronous endpoint will generally execute one transaction every Nth microframe or frame until the transfer is complete. For isochronous channels, the service period of a particular channel (i.e., ``bInterval``) is specified via the Host Frame List (see section 6.5 of programming guide for more details).
165
167
166
168
However, unlike interrupt transactions, isochronous transactions are not retried on failure (or NAK), due to the need to maintain the constant data rate.
167
169
168
170
.. note::
169
171
170
-
HS USB allows an isochronous endpoint to have 3 interrupt transactions in a single microframe. See USB2.0 specification section 5.6.3 (Isochronous Transfer Packet Size Constraints) for more details.
172
+
HS USB allows an isochronous endpoint to have three isochronous transactions in a single microframe. See USB 2.0 specification section 5.6.3 (Isochronous Transfer Packet Size Constraints) for more details.
171
173
172
174
Thus, isochronous transfers in Host Mode Scatter/Gather DMA have the following peculiarities:
173
175
174
-
- A QTD must be allocated for each microframe/frame. However, non-service service period QTDs should be left blank (i.e., only ever Nth QTD should be filled if the channel's service period is every Nth microframe/frame).
175
-
- **Each filled QTD must represent a single transaction instead of a transfer**.
176
-
- Because isochronous transactions are not retried on failure, the status each completed QTD must be checked.
176
+
- A QTD must be allocated for each microframe or frame. However, non-service period QTDs should be left blank (i.e., only every Nth QTD should be filled if the channel's service period is every Nth microframe or frame).
177
+
- **Each filled QTD must represent a single transaction instead of the entire transfer**.
178
+
- Because isochronous transactions are not retried on failure, the status of each completed QTD must be checked.
177
179
178
180
Supplemental Notes
179
181
------------------
180
182
181
-
Some of the DWC_OTG's behaviors are not mentioned in the Databook or Programming Guide. This section describes some of those behaviors that are relevant to the Host stack's implementation.
183
+
Some of the DWC_OTG's behaviors are not mentioned in the Databook or Programming Guide. This section describes some of those behaviors that are relevant to the Host Stack's implementation.
182
184
183
185
Port Errors Do Not Trigger a Channel Interrupt
184
186
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
185
187
186
-
If a port error occurs (such as a sudden disconnection or port over-current) while there are one or more active channels...
188
+
If a port error occurs (such as a sudden disconnection or port over-current) while there are one or more active channels,
187
189
188
-
- The active channels remains active (i.e., ``HCCHAR.ChEna`` remains set) and no channel interrupts are generated.
189
-
- Channels could in theory be disabled by setting ``HCCHAR.ChDis``, but this does not work for Isochronous channels as the channel disabled interrupt is never generated.
190
+
- the active channels remains active (i.e., ``HCCHAR.ChEna`` remains set) and no channel interrupts are generated.
191
+
- channels could in theory be disabled by setting ``HCCHAR.ChDis``, but this does not work for Isochronous channels as the channel disabled interrupt is never generated.
190
192
191
193
Therefore, on port errors, a controller soft reset should be used to ensure all channels are disabled.
0 commit comments