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