1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 /** @file |
|
19 |
|
20 @brief USB Peripheral SHAI header |
|
21 |
|
22 @version 0.3.0 |
|
23 |
|
24 Abstract interface for USB Peripheral Controller. |
|
25 |
|
26 @publishedDeviceAbstraction |
|
27 |
|
28 */ |
|
29 |
|
30 #ifndef USB_PERIPHERAL_SHAI_H |
|
31 #define USB_PERIPHERAL_SHAI_H |
|
32 |
|
33 // System includes |
|
34 #include <kern_priv.h> |
|
35 #include <usb/usb_common_shai.h> // Common types shared between the USB SHAIs |
|
36 #include <usb/usb_peripheral_shai_shared.h> // Common types shared with upper layers |
|
37 |
|
38 /** |
|
39 * This macro specifies the version of the USB Peripheral SHAI header |
|
40 * in binary coded decimal format. This allows the PSL layer to |
|
41 * confirm a certain definition is available, if needed. This can for |
|
42 * example make it possible for a new PSL to support compilation in an |
|
43 * older environment with old USB SHAI version that is missing some |
|
44 * new definitions. |
|
45 */ |
|
46 #define USB_PERIPHERAL_SHAI_VERSION 0x030 |
|
47 |
|
48 // The namespace is documented in file usb_common_shai.h, so it is not |
|
49 // repeated here |
|
50 namespace UsbShai |
|
51 { |
|
52 /** |
|
53 * Masks defined for TUsbPeripheralEndpointCaps.iSizes. |
|
54 * |
|
55 * Zero means this endpoint is not available (= no size). |
|
56 */ |
|
57 const TUint KUsbEpNotAvailable = 0x00000000; |
|
58 |
|
59 /** |
|
60 * Max packet size is continuously variable up to some size specified. |
|
61 * (Interrupt and Isochronous endpoints only.) |
|
62 */ |
|
63 const TUint KUsbEpSizeCont = 0x00000001; |
|
64 |
|
65 /** Max packet size 8 bytes is supported */ |
|
66 const TUint KUsbEpSize8 = 0x00000008; |
|
67 |
|
68 /** Max packet size 16 bytes is supported */ |
|
69 const TUint KUsbEpSize16 = 0x00000010; |
|
70 |
|
71 /** Max packet size 32 bytes is supported */ |
|
72 const TUint KUsbEpSize32 = 0x00000020; |
|
73 |
|
74 /** Max packet size 64 bytes is supported */ |
|
75 const TUint KUsbEpSize64 = 0x00000040; |
|
76 |
|
77 /** Max packet size 128 bytes is supported */ |
|
78 const TUint KUsbEpSize128 = 0x00000080; |
|
79 |
|
80 /** Max packet size 256 bytes is supported */ |
|
81 const TUint KUsbEpSize256 = 0x00000100; |
|
82 |
|
83 /** Max packet size 512 bytes is supported */ |
|
84 const TUint KUsbEpSize512 = 0x00000200; |
|
85 |
|
86 /** Max packet size 1023 bytes is supported */ |
|
87 const TUint KUsbEpSize1023 = 0x00000400; |
|
88 |
|
89 /** Max packet size 1024 bytes is supported */ |
|
90 const TUint KUsbEpSize1024 = 0x00000800; |
|
91 |
|
92 /** |
|
93 * Test Mode Selectors (Set/ClearFeature) |
|
94 * Refer to usb specification 2.0, Chapter 9.4.9, table 9-7 |
|
95 */ |
|
96 enum TUsbTestModeSelector |
|
97 { |
|
98 EUsbTestSelector_Test_J = 0x01, |
|
99 EUsbTestSelector_Test_K, |
|
100 EUsbTestSelector_Test_SE0_NAK, |
|
101 EUsbTestSelector_Test_Packet, |
|
102 EUsbTestSelector_Test_Force_Enable |
|
103 }; |
|
104 |
|
105 /** |
|
106 * Transfer direction of a USB transfer request. |
|
107 * @see TUsbPeripheralRequest |
|
108 */ |
|
109 enum TTransferDirection |
|
110 { |
|
111 EControllerNone, |
|
112 EControllerRead, |
|
113 EControllerWrite |
|
114 }; |
|
115 |
|
116 /** |
|
117 * Enumeration listing the event codes that are passed from PSL to |
|
118 * PIL to indicate peripheral events |
|
119 */ |
|
120 enum TUsbPeripheralEvent |
|
121 { |
|
122 /** The USB Suspend bus state has been detected. |
|
123 * |
|
124 * When the Peripheral Controller PSL is part of an |
|
125 * OTG-capable port, the PSL shall report this event also when |
|
126 * operating as the A-peripheral, in which case this final |
|
127 * suspend event starts the HNP role switch back to A-host. |
|
128 */ |
|
129 EUsbEventSuspend, |
|
130 |
|
131 /** USB Resume signaling has been detected. */ |
|
132 EUsbEventResume, |
|
133 |
|
134 /** A USB Reset condition has been detected. */ |
|
135 EUsbEventReset, |
|
136 |
|
137 /** |
|
138 * VBUS level has risen above the B-session valid threshold. This |
|
139 * is only relevant for a stand-alone peripheral controllers |
|
140 * (those not associated with an OTG port). For an OTG port, the |
|
141 * VBUS state is reported to PIL layer by the OTG Controller PSL. |
|
142 */ |
|
143 EUsbEventVbusRisen, |
|
144 |
|
145 /** |
|
146 * VBUS level has fallen below the B-session valid threshold. This |
|
147 * is only relevant for a stand-alone peripheral controllers |
|
148 * (those not associated with an OTG port). For an OTG port, the |
|
149 * VBUS state is reported to PIL layer by the OTG Controller PSL. |
|
150 */ |
|
151 EUsbEventVbusFallen |
|
152 }; |
|
153 |
|
154 typedef TUint32 TUsbPeripheralPacketArray; |
|
155 |
|
156 /** |
|
157 * @brief A USB transfer request. |
|
158 * |
|
159 * This class will be constructed in PIL or upper layer, and be |
|
160 * passed down to PSL. After the request was done, PSL layer will |
|
161 * modify corresponding members (like data length, packet info |
|
162 * etc.) and re-pass it back to PIL via interface |
|
163 * MUsbPeripheralPilCallbackIf::EndpointRequestComplete(). |
|
164 * |
|
165 */ |
|
166 NONSHARABLE_CLASS(TUsbPeripheralRequest) |
|
167 { |
|
168 public: |
|
169 /** |
|
170 * This class doesn't need a destructor because it has nothing to be |
|
171 * freed, closed, destroyed. It 'owns' nothing. |
|
172 */ |
|
173 IMPORT_C TUsbPeripheralRequest(TInt aRealEpNum); |
|
174 |
|
175 public: |
|
176 /** The 'real' endpoint number this request to be bind to. */ |
|
177 TInt iRealEpNum; |
|
178 |
|
179 /** |
|
180 * Start address of this buffer. Filled-in by PIL. |
|
181 * |
|
182 * PSL needs to put received data in this buffer if it's a read request. |
|
183 * PSL needs to get data from this buffer if it is a write request. |
|
184 */ |
|
185 TUint8* iBufferStart; |
|
186 |
|
187 /** Physical address of buffer start (used for DMA). */ |
|
188 TUintPtr iBufferAddr; |
|
189 |
|
190 /** Length in bytes to be read/write. Filled-in by PIL. */ |
|
191 TInt iLength; |
|
192 |
|
193 /** |
|
194 * Number of bytes transmitted (if it is a write); |
|
195 * This value need to be updated by PSL. |
|
196 */ |
|
197 TUint iTxBytes; |
|
198 |
|
199 /** |
|
200 * Number of packets received (if it is a read); |
|
201 * This value need to be updated by PSL. |
|
202 */ |
|
203 TUint iRxPackets; |
|
204 |
|
205 /** |
|
206 * This is a re-interpretation of what's inside in buffer iBufferStart. |
|
207 * It is designed to be that the first packet always contains all the |
|
208 * bytes received. So only the following scenario are possible: |
|
209 * |
|
210 * 1. Nothing, iRxPackets is zero, no packet received. |
|
211 * |
|
212 * 2. 1 data Packet, iRxPackets is one. |
|
213 * iPacketIndex[0] is the offset against iBufferStart of where the |
|
214 * first byte of received data begins. |
|
215 * iPacketSize[0] is the size (in bytes) of the received data. |
|
216 * |
|
217 * 3. 1 data packet, and one ZLP packet, iRxPackets is two. |
|
218 * iPacketIndex[0] is the offset against iBufferStart of where the |
|
219 * first byte of received data begins. |
|
220 * iPacketSize[0] is the size (in bytes) of the data packet. |
|
221 * |
|
222 * iPacketIndex[1] is the offset of the ZLP packet. |
|
223 * iPacketSize[1] is always set to zero since ZLP contains no data. |
|
224 * |
|
225 */ |
|
226 TUsbPeripheralPacketArray* iPacketIndex; |
|
227 |
|
228 /** Array of packet sizes. Details see iPacketIndex */ |
|
229 TUsbPeripheralPacketArray* iPacketSize; |
|
230 |
|
231 /** |
|
232 * Indicates the transfer direction of this request. |
|
233 * Note, SetupEndpointRead/Write likewise functions already point out |
|
234 * the transfer direction, PSL may select to use it or not. |
|
235 */ |
|
236 TTransferDirection iTransferDir; |
|
237 |
|
238 /** |
|
239 * For EControllerWrite (IN) transfers, it is used to Indicates that if |
|
240 * a Zero Length Packet is required at the end of this transfer. |
|
241 * It will be set to ETrue if ZLP is needed, EFalse otherwise. |
|
242 */ |
|
243 TBool iZlpReqd; |
|
244 |
|
245 /** |
|
246 * The error code upon completion of the request; |
|
247 * PSL need to set it to KErrNone if no errors, Set it to other |
|
248 * system error codes otherwise. |
|
249 */ |
|
250 TInt iError; |
|
251 }; |
|
252 |
|
253 /** |
|
254 * Peripheral controller capabilities. |
|
255 * |
|
256 * PSL should use those values to fill in data member iControllerCaps in |
|
257 * structure TPeripheralControllerProperties. |
|
258 * |
|
259 * @see TPeripheralControllerProperties. |
|
260 */ |
|
261 typedef TUint32 TDeviceCaps; |
|
262 |
|
263 /** |
|
264 * Indicates whether peripheral controller hardware supports USB High-speed. |
|
265 * This capability affects driver functionality and behavior throughout the |
|
266 * implementation. |
|
267 * |
|
268 * Set this bit if this peripheral controller supports USB High-speed; |
|
269 * Clear it otherwise. |
|
270 */ |
|
271 const TDeviceCaps KDevCapHighSpeed = 0x00000001; |
|
272 |
|
273 /** |
|
274 * Indicates whether the peripheral controller supports hardware acceleration |
|
275 * for setting the device address, i.e. automatically setting device address |
|
276 * on conclusion of status phase of SET_ADDRESS. |
|
277 * |
|
278 * If this capability is supported PIL will call SetDeviceAddress() before |
|
279 * sending a zero byte status packet. |
|
280 * |
|
281 * Set this bit if hardware acceleration is supported. |
|
282 * Clear it otherwise. |
|
283 */ |
|
284 const TDeviceCaps KDevCapSetAddressAcceleration = 0x00000002; |
|
285 |
|
286 /** |
|
287 * Indicates whether controller support Session Request Protocol. |
|
288 * |
|
289 * Set this bit if SRP is supported. |
|
290 * Clear it otherwise. |
|
291 */ |
|
292 const TDeviceCaps KDevCapSrpSupport = 0x00000004; |
|
293 |
|
294 /** |
|
295 * Indicates whether controller support Host Negotiation Protocol. |
|
296 * |
|
297 * Set this bit if HNP is supported. |
|
298 * Clear it otherwise. |
|
299 */ |
|
300 const TDeviceCaps KDevCapHnpSupport = 0x00000008; |
|
301 |
|
302 /** |
|
303 * Indicates whether controller support Remote wakeup |
|
304 * |
|
305 * Set this bit if remote wakeup is supported. |
|
306 * Clear it otherwise. |
|
307 */ |
|
308 const TDeviceCaps KDevCapRemoteWakeupSupport = 0x00000010; |
|
309 |
|
310 /** |
|
311 * Configuration data from PSL to PIL when register a controller through |
|
312 * interface UsbPeripheralPil::RegisterPeripheralController(). |
|
313 */ |
|
314 NONSHARABLE_CLASS(TPeripheralControllerProperties) |
|
315 { |
|
316 public: |
|
317 TPeripheralControllerProperties(); |
|
318 |
|
319 public: // Data |
|
320 /** |
|
321 * A bitmap used to Indicates the capabilities of this controller. |
|
322 * PSL should set the corresponding bit to '1' if one capability is |
|
323 * supported by this controller. |
|
324 */ |
|
325 TDeviceCaps iControllerCaps; |
|
326 |
|
327 /** |
|
328 * Pointer to a DFC queue that will be used for DFCs of this controller. |
|
329 * |
|
330 * A stand-alone (one not associated with an OTG-port) peripheral PSL |
|
331 * implementation must supply a pointer to a dedicated DFC queue that |
|
332 * has been created for this controller. Both the PSL itself and the PIL |
|
333 * layer must queue their DFCs for this controller in this DFC queue to |
|
334 * ensure the code is running in the same context. |
|
335 * |
|
336 * A peripheral PSL that is part of an OTG port will be registered by |
|
337 * the OTG PSL. In this case, the DFC queue supplied here must be the |
|
338 * same DFC queue as the one supplied in the properties of the OTG |
|
339 * Controller. |
|
340 */ |
|
341 TDfcQue* iDfcQueue; |
|
342 |
|
343 /** |
|
344 * Describe the capabilities of all endpoint owned by this controller. |
|
345 * |
|
346 * Note that there might be gaps in the array, because the endpoints |
|
347 * must be numbered by using the 'real endpoint' numbering scheme. |
|
348 * |
|
349 * An example of end point capability array: |
|
350 * |
|
351 * @code |
|
352 * static const TUsbPeripheralEndpointCaps DevEndpointCaps[KTotalEps] = |
|
353 * { |
|
354 * // MaxSize mask , Types&Dir , High ,Reserved |
|
355 * speed? |
|
356 * {KEp0MaxPktSzMask,(KUsbEpTypeControl | KUsbEpDirOut), ETrue ,0 , 0}, |
|
357 * {KEp0MaxPktSzMask,(KUsbEpTypeControl | KUsbEpDirIn ), ETrue ,0 , 0}, |
|
358 * |
|
359 * {KUsbEpNotAvailable,KUsbEpNotAvailable , ETrue ,0 , 0}, |
|
360 * |
|
361 * {KBlkMaxPktSzMask,(KUsbEpTypeBulk | KUsbEpDirIn ) , ETrue ,0 , 0}, |
|
362 * {KBlkMaxPktSzMask,(KUsbEpTypeBulk | KUsbEpDirOut) , ETrue ,0 , 0} |
|
363 * }; |
|
364 * @endcode |
|
365 * |
|
366 * For endpoint maxinum packet size on USB2.0 High-speed, PSL should |
|
367 * provide the overlaid values for both full speed and high speed, as |
|
368 * PIL can deduce the appropriate values for either speed. |
|
369 * |
|
370 */ |
|
371 const TUsbPeripheralEndpointCaps* iDeviceEndpointCaps; |
|
372 |
|
373 /** |
|
374 * Set by the PSL to indicate the number of entries in |
|
375 * iDeviceEndpointCaps array. |
|
376 * Be noted that this value include the ones that are marked as |
|
377 * KUsbEpNotAvailable in table iDeviceEndpointCaps. |
|
378 */ |
|
379 TInt iDeviceTotalEndpoints; |
|
380 |
|
381 /** |
|
382 * Maximum size of ep0 packet. |
|
383 * @see USB spec 2.0, chapter 9, table 9-8. |
|
384 */ |
|
385 TUint8 iMaxEp0Size; |
|
386 |
|
387 /** |
|
388 * Device Release number in binary-coded decimal. |
|
389 * @see USB spec 2.0, chapter 9, table 9-8. |
|
390 */ |
|
391 TUint16 iDeviceRelease; |
|
392 }; |
|
393 |
|
394 /** |
|
395 * Enumeration of stages within a control transfer |
|
396 * |
|
397 * Possible stages defined in USB spec include: |
|
398 * 1. setup -> status in |
|
399 * 2. setup -> data in -> status out |
|
400 * 3. setup -> data out -> status in |
|
401 */ |
|
402 enum TControlStage |
|
403 { |
|
404 /** |
|
405 * Control transfer always start with a setup stage in which a setup |
|
406 * packet is expected. |
|
407 */ |
|
408 EControlTransferStageSetup, |
|
409 |
|
410 /** The stage that a data packet is expected from be received */ |
|
411 EControlTransferStageDataOut, |
|
412 |
|
413 /** |
|
414 * Status in stage can either following a Setup stage (if no data stage) |
|
415 * or following a data out stage. |
|
416 */ |
|
417 EControlTransferStageStatusIn, |
|
418 |
|
419 /** |
|
420 * Depends on the request type of a setup packet, a data in stage maybe |
|
421 * followed after a setup packet. |
|
422 * |
|
423 * Within this stage we expect upper/ourself to send some data to host. |
|
424 */ |
|
425 EControlTransferStageDataIn, |
|
426 |
|
427 /** |
|
428 * This is an optional stage, some controller will silently swallow |
|
429 * Status out packet and not able to report it. |
|
430 * PIL has consider this situation when control transfer state machine |
|
431 * is introduced. |
|
432 */ |
|
433 EControlTransferStageStatusOut, |
|
434 |
|
435 EControlTransferStageMax |
|
436 }; |
|
437 |
|
438 /** |
|
439 * Packet types in control transfers. |
|
440 * |
|
441 * PSL need to tell PIL about the types of each packet it received. |
|
442 * @see MUsbPeripheralPilCallbackIf::Ep0RequestComplete(). |
|
443 */ |
|
444 enum TControlPacketType |
|
445 { |
|
446 /** Indicates a setup packet */ |
|
447 EControlPacketTypeSetup, |
|
448 |
|
449 /** Indicates a data out packet */ |
|
450 EControlPacketTypeDataOut, |
|
451 |
|
452 /** |
|
453 * Indicates a status in packet. |
|
454 * optional, PSL can select not to complete this packet. |
|
455 */ |
|
456 EControlPacketTypeStatusIn, |
|
457 |
|
458 /** Indicates a data in packet */ |
|
459 EControlPacketTypeDataIn, |
|
460 |
|
461 /** |
|
462 * Indicates that a status out packet. |
|
463 * optional, PSL can select not to complete this packet. |
|
464 */ |
|
465 EControlPacketTypeStatusOut, |
|
466 |
|
467 }; |
|
468 |
|
469 /** |
|
470 * @brief Interface for PSL to do callback to PIL |
|
471 * |
|
472 * This is the interface that a PSL need talk with PIL in order to: |
|
473 * 1. Pass device event (reset/suspend/resume/vbus high/vbus low etc) to PIL. |
|
474 * 2. Complete a read/write request to PIL. |
|
475 * 3. Query control transfer stage from PIL. |
|
476 * 3. Other functions like SetAdress/Handle HNP/Get remote wake up etc. |
|
477 * |
|
478 * This interface already been implemented and exported via library |
|
479 * usbperipheralpil.lib. PSL need to add this library as a dependency in |
|
480 * you PSL .mmp file. |
|
481 * |
|
482 * @lib usbperipheralpil.lib |
|
483 */ |
|
484 NONSHARABLE_CLASS(MUsbPeripheralPilCallbackIf) |
|
485 { |
|
486 public: |
|
487 /** |
|
488 * Used to synchronize the Ep0 Stage machine between PSL and PIL. |
|
489 * Accepts a SETUP packet and returns the next Ep0 Stage. |
|
490 * |
|
491 * This function will NOT lead anything to be changed at PIL, it is |
|
492 * functioning by parsing the supplied buffer only. |
|
493 * |
|
494 * @param aSetupBuf The SETUP packet received by PSL. |
|
495 * @return The next Ep0 Stage at PIL if PIL receive this setup packet. |
|
496 * |
|
497 */ |
|
498 virtual TControlStage EnquireEp0NextStage(const TUint8* aSetupBuf) const = 0; |
|
499 |
|
500 /** |
|
501 * This function gets called by PSL upon completion of a pending |
|
502 * endpoint zero data transfer request. |
|
503 * |
|
504 * @param aRealEndpoint Either 0 for Ep0 OUT (= Read) |
|
505 * or 1 for Ep0 IN (= Write). |
|
506 * @param aCount The number of bytes received or transmitted. |
|
507 * @param aError The error code of the completed transfer request. |
|
508 * KErrNone if no error. |
|
509 * KErrCancel if transfer was cancelled. |
|
510 * KErrPrematureEnd if a premature end was encountered. |
|
511 * @param aPktType The type of the packet that being completed. |
|
512 * |
|
513 * @return KErrNone if no error during transfer completion processing; |
|
514 * KErrGeneral if request was a read & a Setup packet was received & |
|
515 * the recipient for that packet couldn't be found (invalid packet: Ep0 |
|
516 * has been stalled); KErrNotFound if the request was a read & the |
|
517 * recipient for that packet (Setup or data) _was_ * found - however no |
|
518 * read had been set up by that recipient (this case should be used by |
|
519 * PSL to disable Ep0 interrupt at that point and give the upper layer |
|
520 * software time to set up a new Ep0 read; once the 'missing' read was |
|
521 * set up either Ep0DataReceiveProceed or Ep0ReadSetupPktProceed of |
|
522 * MPeripheralControllerIf class will be called by PIL). |
|
523 */ |
|
524 virtual TInt Ep0RequestComplete(TInt aRealEndpoint, |
|
525 TInt aCount, |
|
526 TInt aError, |
|
527 TControlPacketType aPktType) = 0; |
|
528 |
|
529 /** |
|
530 * PSL call this function upon completion of a pending data transfer |
|
531 * request. This function isn't to be used for endpoint zero completions |
|
532 * (use Ep0RequestComplete instead). |
|
533 * |
|
534 * @param aCallback A pointer to a data transfer request callback |
|
535 * structure which was previously passed to PSL in a |
|
536 * SetupEndpointWrite() or SetupEndpointRead() call. |
|
537 * |
|
538 */ |
|
539 virtual void EndpointRequestComplete(TUsbPeripheralRequest* aCallback) = 0; |
|
540 |
|
541 /** |
|
542 * This function gets called by PSL upon detection of either of the |
|
543 * following events: |
|
544 * - USB Reset, |
|
545 * - USB Suspend event, |
|
546 * - USB Resume signaling, |
|
547 * |
|
548 * When the Peripheral Controller PSL is part of an |
|
549 * OTG-capable port, the PSL shall report the above events |
|
550 * also when operating as the A-peripheral, including |
|
551 * reporting the final suspend event that starts the HNP role |
|
552 * switch back to A-host. |
|
553 * |
|
554 * In addition to the events above, a stand-alone peripheral |
|
555 * controller PSL (one not associated with an OTG port) is |
|
556 * required to report the following events: |
|
557 * - VBUS rising above the session valid threshold |
|
558 * - VBUS falling below the session valid threshold |
|
559 * |
|
560 * When the peripheral controller is part of an OTG port, the |
|
561 * PIL layer receives VBUS notifications via the OTG stack, |
|
562 * and the peripheral PSL is not expected to report them via |
|
563 * this interface. |
|
564 * |
|
565 * When USB Battery Charging is supported on the |
|
566 * peripheral-only port, there is a dependency between normal |
|
567 * USB functionality and USB Battery Charging (see |
|
568 * usb_charger_detection_shai.h and specifically the |
|
569 * description of class MChargerDetectorIf). In this case it |
|
570 * is the responsibility of the Peripheral Controller PSL to |
|
571 * communicate with the Charger Detector PSL (which it may |
|
572 * implement itself) with respect to VBUS events. |
|
573 * |
|
574 * When VBUS rises on the peripheral-only port that fully |
|
575 * supports Battery Charging Specification Revision 1.1, the |
|
576 * Charger Detector PSL and the Peripheral Controller PSL need |
|
577 * to together guarantee that Data Contact Detect is completed |
|
578 * and the port type detected before notifying VBUS rising. |
|
579 * When the port type is known, the port type needs to be |
|
580 * notified to the Charger Detector PSL Observer, followed by |
|
581 * notifying a VBUS rising event to the Peripheral Controller |
|
582 * PIL callback interface (via this function). |
|
583 * |
|
584 * Where Data Contact Detect is not supported, the VBUS rise |
|
585 * event needs to be notified to the Peripheral Controller PIL |
|
586 * callback interface (via this function) immediately and |
|
587 * charger detection needs to proceed in parallel with the |
|
588 * upper layers preparing the USB personality. This is |
|
589 * necessary in order to ensure that we can fulfill the |
|
590 * requirement to connect to the bus within a second, while |
|
591 * still making as long as possible charger detection cycle to |
|
592 * minimize the changes of false detections due to datalines |
|
593 * not making contact yet. |
|
594 * |
|
595 * The Peripheral Controller PSL and the Charger Detector PSL |
|
596 * need to together guarantee that the peripheral controller |
|
597 * does not attempt to connect to the bus while charger |
|
598 * detection is still on-going. When detection has been |
|
599 * completed and upper layers have indicated readiness to |
|
600 * connect to the bus (see MPeripheralControllerIf::PeripheralConnect(), |
|
601 * the Peripheral Controller PSL must connect to the bus. |
|
602 * |
|
603 * @param aEvent An enum denoting the event that has occurred. |
|
604 * |
|
605 * @return KErrArgument if the event is not recognized, KErrNone |
|
606 * otherwise |
|
607 */ |
|
608 virtual TInt DeviceEventNotification(TUsbPeripheralEvent aEvent) = 0; |
|
609 |
|
610 /** |
|
611 * This function should be called by PSL once the peripheral |
|
612 * controller (and thus the USB device) is in the Address state. |
|
613 */ |
|
614 virtual void MoveToAddressState() = 0; |
|
615 |
|
616 /** |
|
617 * This function should be called by PSL after reception of an Ep0 |
|
618 * SET_FEATURE request with a feature selector of either {b_hnp_enable, |
|
619 * a_hnp_support, a_alt_hnp_support}, but ONLY when that Setup packet is |
|
620 * not handed up to PIL (for instance because it is auto-decoded and |
|
621 * 'swallowed' by the peripheral controller hardware). |
|
622 * |
|
623 * @param aHnpState A bitmask indicating the present state of the three |
|
624 * OTG feature selectors as follows: |
|
625 * |
|
626 * bit.0 == a_alt_hnp_support |
|
627 * bit.1 == a_hnp_support |
|
628 * bit.2 == b_hnp_enable |
|
629 * |
|
630 * @see TUsbHnpCaps |
|
631 * |
|
632 */ |
|
633 virtual void HandleHnpRequest(TInt aHnpState) = 0; |
|
634 |
|
635 /** |
|
636 * Returns the current USB device state. |
|
637 * |
|
638 * 'USB device state' here refers to the device states as defined |
|
639 * in chapter 9 of the USB specification. |
|
640 * |
|
641 * @return The current USB device state, or EUsbPeripheralStateUndefined |
|
642 * if peripheral stack is disabled. |
|
643 * |
|
644 */ |
|
645 virtual TUsbPeripheralState DeviceStatus() const = 0; |
|
646 |
|
647 }; |
|
648 |
|
649 /** |
|
650 * MPeripheralControllerIf |
|
651 * @brief Abstract class for USB peripheral Chipset API. |
|
652 * @version 0.2. |
|
653 * |
|
654 * PSL driver need to implement all those virtual functions in this class. |
|
655 * |
|
656 * Four Steps to create a vendor specific usb peripheral PDD. |
|
657 * |
|
658 * Step 1: Derive a new class from MUsbPeripheralControllerIf and |
|
659 * implement all interfaces defined. |
|
660 * |
|
661 * Step 2: Create a new instance (we call it inst_of_psl) of the new class. |
|
662 * Prepare the configuration data defined by structure |
|
663 * TUsbPeripheralControllerProps (let's call it cfg_data ) |
|
664 * |
|
665 * Step 3: Call UsbPeripheralPil::RegisterPeripheralController(inst_of_psl,cfg_data). |
|
666 * |
|
667 * Step 4: Member function SetPilCallbackInterface() will be called. |
|
668 * An instance of MUsbPeripheralPilCallbackIf will be passed to |
|
669 * PSL via this call. Record it since PSL need to reuse it later |
|
670 * for any PIL functionality callback. |
|
671 * |
|
672 * That's all. |
|
673 * |
|
674 * dynamic view of PDD creation. |
|
675 * PIL will be compiled and linked alone. |
|
676 * PSL will be compiled alone and linked against a new lib named |
|
677 * usbperipheralpil.lib. |
|
678 * |
|
679 * For PSL vendors, the following stuff are provided: |
|
680 * usb_peripheral_shai.h & usb_peripheral_shai_shared.h which is |
|
681 * used for PSL to implement against. |
|
682 * usbperipheralpil.lib which is used for PSL to link against. |
|
683 * |
|
684 */ |
|
685 NONSHARABLE_CLASS(MPeripheralControllerIf) |
|
686 { |
|
687 public: |
|
688 /** |
|
689 * This function will be called once and only once by PIL when a PSL |
|
690 * registered itself to PIL by calling |
|
691 * UsbPeripheralPil::RegisterPeripheralController(). |
|
692 * |
|
693 * PSL is expected to store the callback interface pointer so that make |
|
694 * it possible to reporting events back to PIL layer. |
|
695 * |
|
696 * For stand-alone peripheral controllers (controllers not associated |
|
697 * with an OTG port),the Peripheral Controller PSL is required to report |
|
698 * a EUsbEventVbusRisen event by calling MUsbPeripheralPilCallbackIf:: |
|
699 * DeviceEventNotification() if VBUS is already high at the point this |
|
700 * function is called. |
|
701 * |
|
702 * @param aPilCallbackIf A reference to PIL callback interface which |
|
703 a PSL must use to report events. |
|
704 */ |
|
705 virtual void SetPilCallbackInterface(MUsbPeripheralPilCallbackIf& aPilCallbackIf) = 0; |
|
706 |
|
707 /** |
|
708 * Sets endpoint zero's RX buffer. |
|
709 * This buffer is maintains at PIL and always exists. |
|
710 * |
|
711 * @param aBuffer the buffer address |
|
712 * @param aBufferLen the length of the buffer. |
|
713 * |
|
714 */ |
|
715 virtual void SetEp0RxBuffer(TUint8* aBuffer, TInt aBufferLen) = 0; |
|
716 |
|
717 /** |
|
718 * Determines the speed mode that this controller is operating at. |
|
719 * |
|
720 * @return one of the speed mode defined by TSpeed. |
|
721 * @see TSpeed. |
|
722 */ |
|
723 virtual TSpeed DeviceOperatingSpeed() = 0; |
|
724 |
|
725 /** |
|
726 * Forces the peripheral controller into a non-idle state to perform a |
|
727 * USB remote wakeup operation. |
|
728 * |
|
729 * PIL layer will make sure the following preconditions are meet before |
|
730 * calling this function: |
|
731 * 1. we're already in suspended state for at least 5ms (Twtrsm). |
|
732 * 2. remote wakeup had been enabled by host. |
|
733 * |
|
734 * @return KErrNone if successful, otherwise one of the system-wide |
|
735 * error codes. |
|
736 */ |
|
737 virtual TInt SignalRemoteWakeup() = 0; |
|
738 |
|
739 /** |
|
740 * This function will be called by PIL upon decoding a SET_ADDRESS |
|
741 * request. PIL will make sure that a status packet will be sent before |
|
742 * calling this function as USB spec required if capability of |
|
743 * KDevCapSetAddressAcceleration is not support by hardware; Otherwise |
|
744 * SetAddress call will go ahead of status packet. |
|
745 * @see KDevCapSetAddressAcceleration |
|
746 * |
|
747 * @param aAddress A valid USB device address that was received with the |
|
748 * SET_ADDRESS request. |
|
749 * |
|
750 * @return KErrNone if address was set successfully or if controller's |
|
751 * address cannot be set manually. otherwise one of the system- |
|
752 * wide error codes. |
|
753 */ |
|
754 virtual TInt SetDeviceAddress(TInt aAddress) = 0; |
|
755 |
|
756 /** |
|
757 * Configures (enables) an endpoint (incl. Ep0) for data transmission or |
|
758 * reception. |
|
759 * |
|
760 * @param aRealEndpoint The number of the endpoint to be configured. |
|
761 * @param aEndpointInfo A properly filled-in endpoint info structure. |
|
762 * |
|
763 * @return KErrNone if endpoint successfully configured; KErrArgument if |
|
764 * endpoint number or endpoint info invalid; otherwise one of |
|
765 * the system-wide error codes. |
|
766 */ |
|
767 virtual TInt ConfigureEndpoint(TInt aRealEndpoint, |
|
768 const TUsbPeripheralEndpointInfo& aEndpointInfo) = 0; |
|
769 |
|
770 /** |
|
771 * De-configures (disables) an endpoint (incl. Ep0). |
|
772 * |
|
773 * @param aRealEndpoint The number of the endpoint to be disabled. |
|
774 * |
|
775 * @return KErrNone if endpoint successfully de-configured; KErrArgument |
|
776 * if endpoint number invalid; otherwise one of the system-wide |
|
777 * error codes. |
|
778 */ |
|
779 virtual TInt DeConfigureEndpoint(TInt aRealEndpoint) = 0; |
|
780 |
|
781 /** |
|
782 * Queries the use of and endpoint resource. |
|
783 * |
|
784 * @param aRealEndpoint The number of the endpoint. |
|
785 * @param aResource The endpoint resource to be queried. |
|
786 * they are one of the following currently: |
|
787 * KUsbEndpointInfoFeatureWord1_DMA. |
|
788 * KUsbEndpointInfoFeatureWord1_DoubleBuffering. |
|
789 * |
|
790 * @return ETrue if the specified resource is in use at the endpoint, |
|
791 * EFalse if not. |
|
792 */ |
|
793 virtual TBool QueryEndpointResource(TInt aRealEndpoint, TUint32 aResource) const = 0; |
|
794 |
|
795 /** |
|
796 * Sets up a read request on an endpoint (excl. Ep0) for data reception. |
|
797 * |
|
798 * PIL will construct a read request as aCallback, and use this function |
|
799 * to setup and indicate the readiness for reading data from end point. |
|
800 * |
|
801 * PSL need to update related data member of aCallback and complete this |
|
802 * request by calling EndpointRequestComplete() when request is done. |
|
803 * |
|
804 * @see TUsbPeripheralRequest |
|
805 * |
|
806 * @param aRealEndpoint The number of the endpoint to be used. |
|
807 * @param aCallback A properly filled-in (by PIL) request callback. |
|
808 * |
|
809 * @return KErrNone if read successfully set up; KErrArgument if endpoint |
|
810 * number is invalid. otherwise one of the system-wide error |
|
811 * codes. |
|
812 */ |
|
813 virtual TInt SetupEndpointRead(TInt aRealEndpoint, TUsbPeripheralRequest& aCallback) = 0; |
|
814 |
|
815 /** |
|
816 * Sets up a write request on an endpoint (excl. Ep0) for transmission. |
|
817 * |
|
818 * PIL will contruct a write request as aCallback, and use this function |
|
819 * to pass down it to PSL. |
|
820 * |
|
821 * PSL need to update related data member of aCallback and complete this |
|
822 * request by calling EndpointRequestComplete() when data is transmitted |
|
823 * or any error found. |
|
824 * @see TUsbPeripheralRequest |
|
825 * |
|
826 * @param aRealEndpoint The number of the endpoint to be used. |
|
827 * @param aCallback A properly filled-in request callback. |
|
828 * |
|
829 * @return KErrNone if write successfully set up; KErrArgument if |
|
830 * endpoint number is invalid; otherwise one of the system-wide |
|
831 * error codes. |
|
832 */ |
|
833 virtual TInt SetupEndpointWrite(TInt aRealEndpoint, TUsbPeripheralRequest& aCallback) = 0; |
|
834 |
|
835 /** |
|
836 * Cancels a read request on an endpoint (excl. Ep0). |
|
837 * |
|
838 * Note that endpoint 0 read requests are never cancelled by PIL, so |
|
839 * there is also no CancelEndpointZeroRead() function. |
|
840 * |
|
841 * @param aRealEndpoint The number of the endpoint to be used. |
|
842 * |
|
843 * @return KErrNone if read successfully cancelled; KErrArgument if |
|
844 * endpoint number is invalid; otherwise one of the system-wide |
|
845 * error codes. |
|
846 */ |
|
847 virtual TInt CancelEndpointRead(TInt aRealEndpoint) = 0; |
|
848 |
|
849 /** |
|
850 * Cancels a write request on an endpoint (incl. Ep0). |
|
851 * |
|
852 * PIL calls this function also to cancel endpoint zero write requests. |
|
853 * |
|
854 * @param aRealEndpoint The number of the endpoint to be used. |
|
855 * |
|
856 * @return KErrNone if write successfully cancelled; KErrArgument if |
|
857 * endpoint number is invalid; otherwise one of the system-wide |
|
858 * error codes. |
|
859 */ |
|
860 virtual TInt CancelEndpointWrite(TInt aRealEndpoint) = 0; |
|
861 |
|
862 /** |
|
863 * Same as SetupEndpointRead(), but for endpoint zero only. |
|
864 * |
|
865 * No callback structure is used here as reading to ep0 (host may at any |
|
866 * time send a SETUP packet) must be ready even before upper application |
|
867 * is ready. So, a buffer will be passed down to PSL by |
|
868 * MPeripheralControllerIf::SetEp0RxBuffer() during PIL construction, |
|
869 * this will benefits the PSL to have a buffer always available for this |
|
870 * purpose. |
|
871 * |
|
872 * PSL must complete this request by EndpointRequestComplete() |
|
873 * |
|
874 * @return KErrNone if read successfully set up; otherwise one of the |
|
875 * system-wide error codes. |
|
876 */ |
|
877 virtual TInt SetupEndpointZeroRead() = 0; |
|
878 |
|
879 /** |
|
880 * Same as SetupEndpointWrite(), but for endpoint zero only. |
|
881 * |
|
882 * No callback is used here as this function is only used by |
|
883 * PIL layer only and no user side request exists for it. |
|
884 * |
|
885 * @param aBuffer This points to the beginning of the data to be sent. |
|
886 * @param aLength The number of bytes to be sent. |
|
887 * @param aZlpReqd ETrue if a ZLP is must be sent after the data. |
|
888 * |
|
889 * PSL must complete this request by EndpointRequestComplete() |
|
890 * |
|
891 * @return KErrNone if write successfully set up; otherwise one of the |
|
892 * system-wide error codes. |
|
893 */ |
|
894 virtual TInt SetupEndpointZeroWrite(const TUint8* aBuffer, |
|
895 TInt aLength, |
|
896 TBool aZlpReqd = EFalse) = 0; |
|
897 |
|
898 /** |
|
899 * Sets up on Ep0 for the transmission of a single zero-length packet. |
|
900 * |
|
901 * @return KErrNone if ZLP successfully set up; otherwise one of the |
|
902 * system-wide error codes. |
|
903 */ |
|
904 virtual TInt SendEp0ZeroByteStatusPacket() = 0; |
|
905 |
|
906 /** |
|
907 * Stalls an endpoint (incl. Ep0). |
|
908 * |
|
909 * Not applicable to Isochronous endpoints. |
|
910 * |
|
911 * @param aRealEndpoint The number of the endpoint to be stalled. |
|
912 * |
|
913 * @return KErrNone if endpoint successfully stalled; KErrArgument if |
|
914 * endpoint number is invalid; otherwise one of the system-wide |
|
915 * error codes. |
|
916 */ |
|
917 virtual TInt StallEndpoint(TInt aRealEndpoint) = 0; |
|
918 |
|
919 /** |
|
920 * Clears the stall condition on an endpoint (incl. Ep0). |
|
921 * |
|
922 * Not applicable to Isochronous endpoints. |
|
923 * |
|
924 * @param aRealEndpoint The number of the endpoint to be stalled. |
|
925 * |
|
926 * @return KErrNone if endpoint successfully de-stalled; KErrArgument if |
|
927 * endpoint number invalid; otherwise one of the system-wide |
|
928 * error codes. |
|
929 */ |
|
930 virtual TInt ClearStallEndpoint(TInt aRealEndpoint) = 0; |
|
931 |
|
932 /** |
|
933 * Resets the data toggle bit for an endpoint (incl. Ep0). |
|
934 * |
|
935 * Isochronous endpoints don't use data toggles. |
|
936 * |
|
937 * @param aRealEndpoint The number of the endpoint to be used. |
|
938 * |
|
939 * @return KErrNone if data toggle successfully reset; KErrArgument if |
|
940 * endpoint number invalid; otherwise one of the system-wide |
|
941 * error codes. |
|
942 */ |
|
943 virtual TInt ResetDataToggle(TInt aRealEndpoint) = 0; |
|
944 |
|
945 /** |
|
946 * Returns the frame number of the last received SOF packet. |
|
947 * |
|
948 * @return The (11-bit) frame number of the last received SOF packet. |
|
949 * |
|
950 */ |
|
951 virtual TInt SynchFrameNumber() const = 0; |
|
952 |
|
953 /** |
|
954 * Stores the (11-bit) frame number that should be sent in response to |
|
955 * the next SYNCH_FRAME request(s). |
|
956 * |
|
957 * @param aFrameNumber The (11-bit) frame number to be set |
|
958 */ |
|
959 virtual void SetSynchFrameNumber(TInt aFrameNumber) = 0; |
|
960 |
|
961 /** |
|
962 * Starts peripheral controller. |
|
963 * |
|
964 * This initializes the device controller hardware before any other |
|
965 * operation can be performed. |
|
966 * Tasks to be carried out here might include: |
|
967 * - resetting the whole peripheral controller design |
|
968 * - enabling the peripheral controller's clock |
|
969 * - binding & enabling the peripheral controller (primary) interrupt |
|
970 * - write meaningful values to some general controller registers |
|
971 * - enabling the USB Reset interrupt |
|
972 * - enabling the peripheral controller proper (for instance by |
|
973 * setting an Enable bit). |
|
974 * |
|
975 * This function is also used in an OTG environment when the |
|
976 * peripheral stack becomes enabled and the controller needs |
|
977 * to be started and enabled for peripheral use. If the HW |
|
978 * platform shares resources such as clocks and power between |
|
979 * the host and peripheral HW, it is probably easiest for the |
|
980 * PSL to handle the role switch based on the |
|
981 * MOtgControllerIf::SetControllerRole() call to the OTG |
|
982 * Controller interface. |
|
983 * |
|
984 * @return KErrNone if the controller was successfully started; |
|
985 * otherwise one of the system-wide error codes. |
|
986 * |
|
987 * @see usb_otg_shai.h, MOtgControllerIf::SetControllerRole() |
|
988 */ |
|
989 virtual TInt StartPeripheralController() = 0; |
|
990 |
|
991 /** |
|
992 * Stops the peripheral controller. |
|
993 * |
|
994 * This basically makes undone what happened in StartPeripheralController(). |
|
995 * Tasks to be carried out here might include: |
|
996 * - disabling peripheral controller proper. |
|
997 * - disabling the USB Reset interrupt. |
|
998 * - disabling & unbinding the peripheral controller (primary) interrupt. |
|
999 * - disabling the peripheral controller's clock. |
|
1000 * |
|
1001 * This function is also used in an OTG environment when the peripheral |
|
1002 * stack becomes disabled and the peripheral hardware resources can be |
|
1003 * released. If the hardware platform shares resources such as clocks |
|
1004 * and power between the host and peripheral hardware, it is probably |
|
1005 * easiest for the PSL to handle the role switch based on the |
|
1006 * MOtgControllerIf::SetControllerRole() call to the OTG Controller |
|
1007 * interface. |
|
1008 * |
|
1009 * @return KErrNone if peripheral controller successfully stopped; |
|
1010 * otherwise one of the system-wide error codes. |
|
1011 * |
|
1012 * @see usb_otg_shai.h, MOtgControllerIf::SetControllerRole() |
|
1013 */ |
|
1014 virtual TInt StopPeripheralController() = 0; |
|
1015 |
|
1016 /** |
|
1017 * This function is used to indicate that upper layers are ready to |
|
1018 * start operating as peripheral and want to connect to the USB bus |
|
1019 * if possible. |
|
1020 * |
|
1021 * Since this functionality is not part of the USB specification it |
|
1022 * has to be explicitly supported, either by the peripheral controller |
|
1023 * itself or by the hardware platform. |
|
1024 * |
|
1025 * This call merely reports the upper layer readiness to connect, and |
|
1026 * it is the responsiblity of the PSL to assess when all prerequisites |
|
1027 * for connection are satisfied and physically connect when they are. |
|
1028 * These prerequisites include: |
|
1029 * |
|
1030 * 1. Upper layer readiness has been indicated by calling |
|
1031 * PeripheralConnect(). |
|
1032 * |
|
1033 * 2. The peripheral controller has been started and enabled |
|
1034 * by StartPeripheralController(). |
|
1035 * |
|
1036 * The connection readiness assessment responsibility is delegated to the |
|
1037 * PSL because the physical connection may sometimes be handled by a HW |
|
1038 * state machine, thus making the correct SW-controlled connection time |
|
1039 * HW-specific. |
|
1040 * |
|
1041 * @return KErrNone if peripheral controller successfully connected; |
|
1042 * otherwise one of the system-wide error codes. |
|
1043 */ |
|
1044 virtual TInt PeripheralConnect() = 0; |
|
1045 |
|
1046 /** |
|
1047 * Called to indicate that upper layers no longer want to operate as the |
|
1048 * peripheral and we must disconnect from the USB bus. |
|
1049 * |
|
1050 * Since this functionality is not part of the USB specification it |
|
1051 * has to be explicitly supported, either by the peripheral controller |
|
1052 * itself or by the hardware platform. |
|
1053 * |
|
1054 * @return KErrNone if controller is successfully disconnected; |
|
1055 * otherwise one of the system-wide error codes. |
|
1056 */ |
|
1057 virtual TInt PeripheralDisconnect() = 0; |
|
1058 |
|
1059 /** |
|
1060 * Implements anything peripheral controller might required by following |
|
1061 * bus resume signal. |
|
1062 * |
|
1063 * This function gets called by PIL after it has been notified (by |
|
1064 * PSL) about the Suspend condition. |
|
1065 */ |
|
1066 virtual void Suspend() = 0; |
|
1067 |
|
1068 /** |
|
1069 * Implements anything peripheral controller might required by following |
|
1070 * bus resume signal. |
|
1071 * |
|
1072 * This function gets called by PIL after it has been notified (by |
|
1073 * PSL) about the Resume event. |
|
1074 */ |
|
1075 virtual void Resume() = 0; |
|
1076 |
|
1077 /** |
|
1078 * Implements anything peripheral controller might required by following |
|
1079 * bus resume signal. |
|
1080 * |
|
1081 * This function gets called by PIL after it has been notified (by |
|
1082 * PSL) about the Reset event. |
|
1083 */ |
|
1084 virtual void Reset() = 0; |
|
1085 |
|
1086 /** |
|
1087 * PIL call this function to signal PSL that it has finished processing |
|
1088 * a received Setup packet (on Ep0) and that PSL can now prepare |
|
1089 * itself for the next Ep0 reception. |
|
1090 * |
|
1091 * The reason for having this function is that the situation where no |
|
1092 * Ep0 read has been set up by user and thus a received Setup packet |
|
1093 * cannot immediately be delivered to user. Once user however |
|
1094 * sets up an Ep0 read, PIL then completes the request and eventually |
|
1095 * calls this function. We can implement some sort of flow-control by |
|
1096 * this way. |
|
1097 */ |
|
1098 virtual void Ep0ReadSetupPktProceed() = 0; |
|
1099 |
|
1100 /** |
|
1101 * PIL call this function to signal PSL that it has finished processing |
|
1102 * a received Ep0 data packet and that PSL can now prepare itself for |
|
1103 * the next Ep0 reception. |
|
1104 * |
|
1105 * The reason for having this function is that the situation where no |
|
1106 * Ep0 read has been set up by user and thus a received Setup packet |
|
1107 * cannot immediately be delivered to user. Once user however |
|
1108 * sets up an Ep0 read, PIL then completes the request and eventually |
|
1109 * calls this function. We can implement some sort of flow-control by |
|
1110 * this way. |
|
1111 */ |
|
1112 virtual void Ep0ReadDataPktProceed() = 0; |
|
1113 |
|
1114 /** |
|
1115 * Puts controller into a specific test mode (during HS operation only). |
|
1116 * |
|
1117 * 9.4.9 Set Feature: "The transition to test mode must be complete no |
|
1118 * later than 3 ms after the completion of the status stage of the |
|
1119 * request." (The status stage will have been completed immediately |
|
1120 * before this function gets called.) |
|
1121 * |
|
1122 * @param aTestSelector The specific test mode selector. |
|
1123 * |
|
1124 * @return KErrNone if the specified test mode was entered successfully; |
|
1125 * otherwise one of the system-wide error codes. |
|
1126 */ |
|
1127 virtual TInt EnterTestMode(TUsbTestModeSelector aTestSelector) = 0; |
|
1128 }; |
|
1129 |
|
1130 |
|
1131 /** |
|
1132 * This static class provides the interface which PSL implementation shall |
|
1133 * use to register itself to PIL layer. |
|
1134 */ |
|
1135 NONSHARABLE_CLASS(UsbPeripheralPil) |
|
1136 { |
|
1137 public: |
|
1138 /** |
|
1139 * Registration function to be used by a stand-alone (non-OTG |
|
1140 * port) Peripheral Controller PSL to register itself to the |
|
1141 * PIL layer. Peripheral Controllers that are part of an |
|
1142 * OTG-port are registered by the OTG Controller PSL (see |
|
1143 * usb_otg_shai.h, function UsbOtgPil::RegisterOtgController). |
|
1144 * |
|
1145 * The intended usage is that each stand-alone Peripheral |
|
1146 * Controller PSL is a kernel extension that registers itself |
|
1147 * to the USB Peripheral PIL layer by making this call from |
|
1148 * their own kernel extension entry point function (or an |
|
1149 * equivalent code that runs during bootup). |
|
1150 * |
|
1151 * When the PSL makes this call, PIL layer will call |
|
1152 * SetPilCallbackInterface() function of the supplied Peripheral |
|
1153 * Controller interface to supply the PSL a reference to PIL |
|
1154 * callback interface to be used for reporting peripheral events. |
|
1155 * |
|
1156 * @param aPeripheralControllerIf Reference to the Peripheral |
|
1157 * Controller interface implemented by the registering PSL. |
|
1158 * |
|
1159 * @param aProperties Reference to an object describing the |
|
1160 * static properties of the Peripheral Controller. PIL |
|
1161 * layer requires that the supplied reference remains valid |
|
1162 * indefinitely, as a Peripheral Controller cannot unregister. |
|
1163 * |
|
1164 * @lib usbperipheralpil.lib |
|
1165 */ |
|
1166 IMPORT_C static void RegisterPeripheralController(MPeripheralControllerIf& aPeripheralControllerIf, |
|
1167 const TPeripheralControllerProperties& aProperties ); |
|
1168 |
|
1169 private: |
|
1170 /** |
|
1171 * No instance of this class need to be created |
|
1172 */ |
|
1173 UsbPeripheralPil(); |
|
1174 }; |
|
1175 }; |
|
1176 |
|
1177 #include <usb/usb_peripheral_shai.inl> |
|
1178 |
|
1179 #endif // USB_PERIPHERAL_SHAI_H |
|
1180 |
|
1181 // End of File |
|