54 class MRootHubIf; |
54 class MRootHubIf; |
55 |
55 |
56 // Data types |
56 // Data types |
57 |
57 |
58 /** |
58 /** |
59 * An enumeration listing the host role electrical test modes |
59 * An enumeration listing the host role electrical test modes that |
60 * supported. These correspond to the test modes specified in |
60 * require special support from the host controller. These |
61 * Section "6.4.1.1 Test Modes" of the "On-The-Go and Embedded |
61 * correspond to the test modes specified in Section "6.4.1.1 Test |
62 * Host Supplement to the USB Revision 2.0 Specification" Revision |
62 * Modes" of the "On-The-Go and Embedded Host Supplement to the |
63 * 2.0 (a.k.a. USB OTG 2.0). |
63 * USB Revision 2.0 Specification" Revision 2.0 (a.k.a. USB OTG |
|
64 * 2.0). |
|
65 * |
|
66 * The single-step control transfer tests are performed as |
|
67 * transfers on the control pipe, but a special transfer flag |
|
68 * THostTransfer::KSingleStepControlDelayedDataPhase requests the |
|
69 * Host Controller PSL to delay the DATA phase when needed. |
|
70 * |
|
71 * Suspend and resume tests are performed using the normal suspend |
|
72 * and resume functionality in the USB Host SHAI, so they are not |
|
73 * a special case for the Host Controller PSL. |
64 * |
74 * |
65 * @see MHostControllerIf::EnterHostTestMode() |
75 * @see MHostControllerIf::EnterHostTestMode() |
66 */ |
76 */ |
67 enum THostTestMode |
77 enum THostTestMode |
68 { |
78 { |
69 /** |
79 /** |
70 * Drive SE0 until host controller is reset. The call returns |
80 * Drive SE0 until the host controller is reset. |
71 * immediately after enabling the test mode. |
|
72 */ |
81 */ |
73 ETestModeTestSE0NAK = 0, |
82 ETestModeTestSE0NAK = 0, |
74 |
83 |
75 /** |
84 /** |
76 * Drive high-speed J until host controller is reset. The call |
85 * Drive high-speed J until the host controller is reset. |
77 * returns immediately after enabling the test mode. |
|
78 */ |
86 */ |
79 ETestModeTestJ, |
87 ETestModeTestJ, |
80 |
88 |
81 /** |
89 /** |
82 * Drive high-speed K until host controller is reset. The call |
90 * Drive high-speed K until the host controller is reset. |
83 * returns immediately after enabling the test mode. |
|
84 */ |
91 */ |
85 ETestModeTestK, |
92 ETestModeTestK, |
86 |
93 |
87 /** |
94 /** |
88 * Send test packets until host controller is reset. The |
95 * Send test packets until the host controller is reset. The |
89 * format of the required test packet is specified in Section |
96 * format of the required test packet is specified in Section |
90 * "7.1.20 Test Mode Support" of the USB 2.0 specification. |
97 * "7.1.20 Test Mode Support" of the USB 2.0 specification. |
91 * |
98 */ |
92 * The call returns immediately after enabling the test |
99 ETestModeTestPacket |
93 * mode. |
|
94 */ |
|
95 ETestModeTestPacket, |
|
96 |
|
97 /** |
|
98 * Suspend and resume the port with 15 second delays to allow |
|
99 * the operator to adjust test tool settings. The Host |
|
100 * Controller PSL must perform the following test steps: |
|
101 * |
|
102 * 1. Allow SOFs to continue for 15 seconds. |
|
103 * |
|
104 * 2. Suspend the port under test. |
|
105 * |
|
106 * 3. Wait for 15 seconds. |
|
107 * |
|
108 * 4. Resume the port under test. |
|
109 * |
|
110 * This test mode is synchronous, i.e. the call returns after |
|
111 * the test has been completed. |
|
112 */ |
|
113 ETestModeHsHostPortSuspendResume, |
|
114 |
|
115 /** |
|
116 * Perform a single-step GetDescriptor(Device) transfer. This |
|
117 * is called after the USB Host Stack has enumerated a device |
|
118 * with VID=0x1A0A and PID=0x0107. The Host Controller PSL |
|
119 * must perform the following test steps: |
|
120 * |
|
121 * 1. Allow SOFs to continue for 15 seconds. |
|
122 * |
|
123 * 2. Send a complete GetDescriptor(Device) transfer |
|
124 * |
|
125 * This test mode is synchronous, i.e. the call returns after |
|
126 * the test has been completed. |
|
127 */ |
|
128 ETestModeSingleStepGetDeviceDescriptor, |
|
129 |
|
130 /** |
|
131 * Perform a single-step GetDescriptor(Device) transfer with a |
|
132 * delayed data phase. This is called after the USB Host Stack |
|
133 * has enumerated a device with VID=0x1A0A and PID=0x0108. The |
|
134 * Host Controller PSL must perform the following test steps: |
|
135 * |
|
136 * 1. Send the SETUP packet for GetDescriptor(Device). The |
|
137 * device ACKs the packet as usual. |
|
138 * |
|
139 * 2. Allow SOFs to continue for 15 seconds. |
|
140 * |
|
141 * 3. Send the IN token for the data phase of |
|
142 * GetDescriptor(Device). The device responds with |
|
143 * the data. |
|
144 * |
|
145 * 4. Send the acknowledgement (zero-length OUT data) in |
|
146 * response to the data. |
|
147 * |
|
148 * This test mode is synchronous, i.e. the call returns after |
|
149 * the test has been completed. |
|
150 */ |
|
151 ETestModeSingleStepGetDeviceDescriptorData |
|
152 }; |
100 }; |
153 |
101 |
154 |
102 |
155 // Class declaration |
103 // Class declaration |
156 |
104 |
223 * specify the hub address and the port to which the targeted |
177 * specify the hub address and the port to which the targeted |
224 * device is connected, and the iEndpointFlags flag |
178 * device is connected, and the iEndpointFlags flag |
225 * KHubHasMultipleTTs specifies whether the hub has been |
179 * KHubHasMultipleTTs specifies whether the hub has been |
226 * configured to use multiple transaction translators. |
180 * configured to use multiple transaction translators. |
227 */ |
181 */ |
228 static const TUint32 KHubTranslates = 0x00000001; |
182 static const TEndpointFlags KHubTranslates = 0x00000001; |
229 |
183 |
230 /** |
184 /** |
231 * When the iEndpointFlags flag KHubTranslates is set, this |
185 * When the iEndpointFlags flag KHubTranslates is set, this |
232 * flag is set if the hub has multiple transaction |
186 * flag is set if the hub has multiple transaction |
233 * translators. |
187 * translators. |
234 */ |
188 */ |
235 static const TUint32 KHubHasMultipleTTs = 0x00000002; |
189 static const TEndpointFlags KHubHasMultipleTTs = 0x00000002; |
236 |
190 |
237 public: // Data |
191 public: // Data |
238 /** |
192 /** |
239 * The type of the endpoint (control, bulk, interrupt, |
193 * The type of the endpoint (control, bulk, interrupt, |
240 * isochronous) |
194 * isochronous) |
302 * reference to an object of this class when setting up a new transfer |
256 * reference to an object of this class when setting up a new transfer |
303 * with MHostPipeIf::StartTransfer(). |
257 * with MHostPipeIf::StartTransfer(). |
304 */ |
258 */ |
305 NONSHARABLE_CLASS( THostTransfer ) |
259 NONSHARABLE_CLASS( THostTransfer ) |
306 { |
260 { |
307 public: |
261 public: // Types and constants |
|
262 /** |
|
263 * A bitmask type used to indicate some boolean properties of |
|
264 * a transfer. |
|
265 */ |
|
266 typedef TUint32 TTransferFlags; |
|
267 |
308 // These are public constants that specify the values that can |
268 // These are public constants that specify the values that can |
309 // be bitwise OR'ed to the request flags field iRequestFlags |
269 // be bitwise OR'ed to the request flags field iRequestFlags |
310 // to indicate some boolean parameters of the transfer |
270 // to indicate some boolean parameters of the transfer |
311 |
271 |
312 /** |
272 /** |
313 * When set, specifies that the transfer direction is IN, |
273 * This flag is set or cleared by the PIL layer and is only |
314 * i.e. the host is reading from the connected device. This is |
274 * relevant for bi-directional pipes, i.e. control pipes |
315 * needed for endpoint zero, which is bi-directional and |
275 * performing control transfers. The bit is not set for other |
316 * cannot implicitly know the direction of the transfer. |
276 * endpoint types. |
|
277 * |
|
278 * For a control transfer, this bit is set to specify that the |
|
279 * transfer direction is IN, i.e. the host is reading from the |
|
280 * connected device. For a control transfer with the bit |
|
281 * cleared, the transfer direction is OUT, i.e. the host is |
|
282 * writing to the connected device. |
317 * |
283 * |
318 * This bit is set or cleared by the USB Host stack before |
284 * This bit is set or cleared by the USB Host stack before |
319 * issuing a new transfer. |
285 * issuing a new transfer. |
320 */ |
286 */ |
321 static const TUint32 KTransferDirIsIN = 0x00000001; |
287 static const TTransferFlags KTransferDirIsIN = 0x00000001; |
322 |
288 |
323 /** |
289 /** |
324 * For OUT endpoint transfers, indicates whether the Host |
290 * This flag is set or cleared by the PIL layer and is only |
325 * Controller PSL is required to force a short packet at the |
291 * relevant for bi-directional pipes, i.e. control pipes |
326 * end of the transfer. |
292 * performing control transfers. The bit is not set for other |
|
293 * endpoint types. |
|
294 * |
|
295 * For a control transfer, this bit is set to specify that the |
|
296 * transfer is a special single-step transfer with a delayed |
|
297 * data phase. This type of transfer is only used during the |
|
298 * high-speed host electrical tests. |
|
299 * |
|
300 * When this flag is set, the Host Controller PSL should |
|
301 * perform the transfer like it normally would, except that it |
|
302 * must have a 15 second delay between the completion of the |
|
303 * SETUP phase and the sending of the first IN token for the |
|
304 * DATA phase. |
|
305 * |
|
306 * For description and background of the usage of this special |
|
307 * transfer option, see the OTG 2.0 Supplement Section 6.4.1.1 |
|
308 * Test Modes, and specifically the test |
|
309 * SINGLE_STEP_GET_DEVICE_DESCRIPTOR_DATA. |
|
310 * |
|
311 * This bit is set or cleared by the USB Host stack before |
|
312 * issuing a new transfer. |
|
313 */ |
|
314 static const TTransferFlags KSingleStepControlDelayedDataPhase = 0x00000002; |
|
315 |
|
316 /** |
|
317 * This flag is set or cleared by the PIL layer before issuing |
|
318 * a new transfer and is relevant for OUT transfers on bulk, |
|
319 * interrupt, and control pipes. It is never set for transfers |
|
320 * on isochronous pipes. |
|
321 * |
|
322 * For bulk, interrupt, or control OUT endpoint transfers, |
|
323 * indicates whether the Host Controller PSL is required to |
|
324 * force a short packet at the end of the transfer. |
327 * |
325 * |
328 * When the bit is set, the Host Controller PSL must send a |
326 * When the bit is set, the Host Controller PSL must send a |
329 * ZLP (Zero-Length Packet) after the last packet of the |
327 * ZLP (Zero-Length Packet) after the last packet of the |
330 * transfer, if and only if the last packet was a full packet, |
328 * transfer, if and only if the last packet was a full packet, |
331 * i.e. had the same size as the maximum packet size for the |
329 * i.e. had the same size as the maximum packet size for the |
332 * endpoint. |
330 * endpoint. |
333 * |
331 */ |
334 * This bit is set or cleared by the USB Host stack before |
332 static const TTransferFlags KOutForceShortPacket = 0x00000002; |
335 * issuing a new transfer. |
333 |
336 */ |
334 /** |
337 static const TUint32 KOutForceShortPacket = 0x00000002; |
335 * This flag is set or cleared by the Host Controller PSL |
338 |
336 * before completing the transfer and is only relevant for IN |
339 /** |
337 * pipes. |
340 * For IN endpoint transfers, indicates whether the transfer |
338 * |
341 * was terminated with a ZLP (Zero-Length Packet). |
339 * For IN endpoint transfers, this flag indicates whether the |
342 * |
340 * transfer was terminated with a ZLP (Zero-Length Packet). |
343 * This bit is set by the Host Controller PSL before |
341 */ |
344 * completing the transfer if the transfer ended due to a |
342 static const TTransferFlags KInZlpReceived = 0x00000004; |
345 * ZLP. Otherwise the bit is cleared by the Host Controller |
|
346 * PSL. |
|
347 */ |
|
348 static const TUint32 KInZlpReceived = 0x00000004; |
|
349 |
343 |
350 /** |
344 /** |
351 * Enumeration specifying the packet status values to be used |
345 * Enumeration specifying the packet status values to be used |
352 * for isochronous transfers. |
346 * for isochronous transfers. |
353 */ |
347 */ |
576 * with the actual length and status of the transfer and then |
570 * with the actual length and status of the transfer and then |
577 * complete it to the callback interface by calling |
571 * complete it to the callback interface by calling |
578 * MHostTransferCallbackIf::CompleteTransfer(). The pointer to |
572 * MHostTransferCallbackIf::CompleteTransfer(). The pointer to |
579 * the callback interface is provided in the member |
573 * the callback interface is provided in the member |
580 * THostTransfer::iTransferCbIf of the supplied aTransferInfo. |
574 * THostTransfer::iTransferCbIf of the supplied aTransferInfo. |
|
575 * |
|
576 * To maximize throughput, the PIL layer may call |
|
577 * StartTransfer() directly from a previous completion call |
|
578 * (see description in |
|
579 * MHostTransferCallbackIf::CompleteTransfer()). To prevent |
|
580 * recursion, the PSL should not call |
|
581 * MHostTransferCallbackIf::CompleteTransfer() directly from |
|
582 * within the MHostPipeIf::StartTransfer() call, but should |
|
583 * instead queue a DFC to complete the transfer, if |
|
584 * immediately completed. |
581 * |
585 * |
582 * The following rules shall be used by the Host Controller |
586 * The following rules shall be used by the Host Controller |
583 * PSL to assess the completeness of a transfer: |
587 * PSL to assess the completeness of a transfer: |
584 * |
588 * |
585 * 1. A read or write transfer on a control pipe is completed |
589 * 1. A read or write transfer on a control pipe is completed |
708 * |
712 * |
709 * When all ports of the root hub have been suspended, the USB |
713 * When all ports of the root hub have been suspended, the USB |
710 * Host Stack will suspend the entire host controller by |
714 * Host Stack will suspend the entire host controller by |
711 * calling MHostControllerIf::SuspendController(). |
715 * calling MHostControllerIf::SuspendController(). |
712 * |
716 * |
713 * When the root hub only has one port and SOFs cannot be |
|
714 * gated on the port without suspending the whole controller, |
|
715 * the Host Controller PSL should ignore the port-specific |
|
716 * suspend and resume calls and instead suspend/resume the |
|
717 * controller based on the controller-specific suspend and |
|
718 * resume calls in MHostControllerIf. |
|
719 * |
|
720 * @param aPort The number of the root hub port to operate |
717 * @param aPort The number of the root hub port to operate |
721 * on. For a root hub with N ports, the port numbers are in |
718 * on. For a root hub with N ports, the port numbers are in |
722 * range [1..N]. |
719 * range [1..N]. |
723 */ |
720 */ |
724 virtual void SuspendPort( TUint aPort ) = 0; |
721 virtual void SuspendPort( TUint aPort ) = 0; |
735 * Before resuming the first port of a completely suspended |
732 * Before resuming the first port of a completely suspended |
736 * controller, the USB Host Stack will first resume the entire |
733 * controller, the USB Host Stack will first resume the entire |
737 * host controller by calling |
734 * host controller by calling |
738 * MHostControllerIf::ResumeController(). |
735 * MHostControllerIf::ResumeController(). |
739 * |
736 * |
740 * When the root hub only has one port and SOFs cannot be |
737 * This function is synchronous and should return when the |
741 * gated on the port without suspending the whole controller, |
738 * resume signalling on the port has completed. |
742 * the Host Controller PSL should ignore the port-specific |
739 * |
743 * suspend and resume calls and instead suspend/resume the |
740 * This function is also called when the Host Controller PSL |
744 * controller based on the controller-specific suspend and |
741 * has reported detection of a remote wakeup on a port of the |
745 * resume calls in MHostControllerIf. |
742 * root hub. This is to make sure the host port takes over |
|
743 * driving the resume on the bus. The Host Controller PSL or |
|
744 * the HW may have already started driving resume upon |
|
745 * detecting the remote wakeup, in which case the PSL only |
|
746 * needs to wait in this function until the resume signalling |
|
747 * has been completed. |
746 * |
748 * |
747 * @param aPort The number of the root hub port to operate |
749 * @param aPort The number of the root hub port to operate |
748 * on. For a root hub with N ports, the port numbers are in |
750 * on. For a root hub with N ports, the port numbers are in |
749 * range [1..N]. |
751 * range [1..N]. |
750 */ |
752 */ |
885 */ |
887 */ |
886 virtual TInt StopHostController() = 0; |
888 virtual TInt StopHostController() = 0; |
887 |
889 |
888 /** |
890 /** |
889 * Place the host controller to the USB suspend state where it |
891 * Place the host controller to the USB suspend state where it |
890 * does not send SOF packets. |
892 * does not send SOF packets. The Host Controller PSL may also |
|
893 * go into a power-saving mode where it for example shuts down |
|
894 * some clocks needed by the host controller when active. The |
|
895 * Host Controller PSL must still ensure that the host |
|
896 * controller or the root hub will be capable of detecting |
|
897 * device disconnection and remote wakeup when suspended. |
891 */ |
898 */ |
892 virtual void SuspendController() = 0; |
899 virtual void SuspendController() = 0; |
893 |
900 |
894 /** |
901 /** |
895 * Resume the host controller from the USB suspend state by |
902 * Resume the host controller from the suspend state. If the |
896 * driving the resume signalling towards the root hub. The |
903 * Host Controller PSL put the host controller into a |
897 * signalling must last at least 20 milliseconds and follow |
904 * power-saving state by shutting down some clocks, the PSL |
898 * the requirements specified in USB 2.0 Specification Section |
905 * can re-enable them in this call. This call shall not result |
899 * 7.1.7.7 Resume Signaling. After the resume signalling has |
906 * in resume signalling to be driven on the bus, as that |
900 * completed, the controller must allow SOFs to be sent to the |
907 * should be done from MRootHubIf::ResumePort(). |
901 * connected device again. |
|
902 */ |
908 */ |
903 virtual void ResumeController() = 0; |
909 virtual void ResumeController() = 0; |
904 |
910 |
905 /** |
911 /** |
906 * Force the controller into a specific high-speed host test |
912 * Force the controller into a specific high-speed host test |
908 * Controller PSLs for high-speed capable controllers. The |
914 * Controller PSLs for high-speed capable controllers. The |
909 * function will only be called when the controller is |
915 * function will only be called when the controller is |
910 * operating in high-speed mode and a special test device has |
916 * operating in high-speed mode and a special test device has |
911 * been enumerated. |
917 * been enumerated. |
912 * |
918 * |
913 * When called, the Host Controller PSL shall synchronously |
919 * The function shall return immediately when the controller |
914 * run the selected test as specified for each tests in the |
920 * has been set to the requested test mode. The host |
915 * documentation of THostTestMode. |
921 * controller is expected to remain in the test mode until it |
|
922 * is shutdown by a call to StopHostController(). |
916 * |
923 * |
917 * @param aTestMode Specifies the test mode to enter |
924 * @param aTestMode Specifies the test mode to enter |
918 * |
|
919 * @param aDefaultPipe Information of the default pipe (the |
|
920 * control pipe to endpoint zero) of the connected test |
|
921 * device. |
|
922 * |
925 * |
923 * @return KErrNone if the specified test mode was entered |
926 * @return KErrNone if the specified test mode was entered |
924 * successfully, otherwise a system-wide error |
927 * successfully, otherwise a system-wide error |
925 */ |
928 */ |
926 virtual TInt EnterHostTestMode( THostTestMode aTestMode, |
929 virtual TInt EnterHostTestMode( THostTestMode aTestMode ) = 0; |
927 const THostPipe& aDefaultPipe ) = 0; |
|
928 |
930 |
929 /** |
931 /** |
930 * Get the size and alignment requirements for the Host |
932 * Get the size and alignment requirements for the Host |
931 * Controller. The reference parameters are both input and |
933 * Controller. The reference parameters are both input and |
932 * output. Upon input, they describe the values requested by |
934 * output. Upon input, they describe the values requested by |
1268 * Host PIL layer by making this call from their own kernel |
1278 * Host PIL layer by making this call from their own kernel |
1269 * extension entry point function (or an equivalent code that |
1279 * extension entry point function (or an equivalent code that |
1270 * runs during bootup). |
1280 * runs during bootup). |
1271 * |
1281 * |
1272 * @param aHostControllerIf Reference to the Host Controller |
1282 * @param aHostControllerIf Reference to the Host Controller |
1273 * interface implemented by the registering PSL. |
1283 * interface implemented by the registering PSL. The PIL layer |
|
1284 * requires that the supplied reference remains valid |
|
1285 * indefinitely, as the Host Controller cannot unregister. |
1274 * |
1286 * |
1275 * @param aProperties Reference to an object describing the |
1287 * @param aProperties Reference to an object describing the |
1276 * static properties of the Host Controller. The PIL layer |
1288 * static properties of the Host Controller. The PIL takes a |
1277 * requires that the supplied reference remains valid |
1289 * copy and the PSL is free to release the properties object |
1278 * indefinitely, as a Host Controller cannot unregister. |
1290 * upon return. |
1279 * |
1291 * |
1280 * @lib usbotghostpil.lib |
1292 * @lib usbotghostpil.lib |
1281 */ |
1293 */ |
1282 IMPORT_C static void RegisterHostController( |
1294 IMPORT_C static void RegisterHostController( |
1283 MHostControllerIf& aHostControllerIf, |
1295 MHostControllerIf& aHostControllerIf, |