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 |
|
|
18 |
/** @file
|
|
19 |
@brief USB OTG SHAI header
|
48
|
20 |
@version 0.3.0
|
33
|
21 |
|
|
22 |
This header specifies the USB OTG SHAI.
|
|
23 |
|
|
24 |
@publishedDeviceAbstraction
|
|
25 |
*/
|
|
26 |
|
|
27 |
#ifndef USB_OTG_SHAI_H
|
|
28 |
#define USB_OTG_SHAI_H
|
|
29 |
|
|
30 |
// System includes
|
|
31 |
#include <kern_priv.h>
|
|
32 |
#include <usb/usb_common_shai.h> // Common types shared between the USB SHAIs
|
|
33 |
|
|
34 |
/**
|
|
35 |
* This macro specifies the version of the USB OTG SHAI header in
|
|
36 |
* binary coded decimal format. This allows the PSL layer to confirm a
|
|
37 |
* certain definition is available, if needed. This can for example
|
|
38 |
* make it possible for a new PSL to support compilation in an older
|
|
39 |
* environment with old USB SHAI version that is missing some new
|
|
40 |
* definitions.
|
|
41 |
*/
|
48
|
42 |
#define USB_OTG_SHAI_VERSION 0x030
|
33
|
43 |
|
|
44 |
// The namespace is documented in file usb_common_shai.h, so it is not
|
|
45 |
// repeated here
|
|
46 |
namespace UsbShai
|
|
47 |
{
|
|
48 |
// Forward declarations
|
|
49 |
|
|
50 |
class MOtgControllerIf;
|
|
51 |
class MOtgObserverIf;
|
|
52 |
class MPeripheralControllerIf;
|
|
53 |
class TPeripheralControllerProperties;
|
|
54 |
class MHostControllerIf;
|
|
55 |
class THostControllerProperties;
|
|
56 |
|
|
57 |
// Data types
|
|
58 |
|
|
59 |
/**
|
|
60 |
* Enumeration listing the possible states of the ID pin. Due to a
|
|
61 |
* dependency between OTG and USB Battery Charging, this
|
|
62 |
* enumeration lists also the special states introduced as part of
|
|
63 |
* the Battery Charging Specification version 1.1.
|
|
64 |
*
|
|
65 |
* An OTG Controller PSL for a system that does not support
|
|
66 |
* Accessory Charger Adapter (ACA) will always report only
|
|
67 |
* EIdStateRidFloat or EIdStateRidGnd. An OTG Controller PSL that
|
|
68 |
* supports ACA is required to report the ID pin state accurately
|
|
69 |
* in order for the OTG State Machine to understand why VBUS
|
|
70 |
* appears high even though we should default to the host role and
|
|
71 |
* should normally drive VBUS ourselves (in case of RID_A).
|
|
72 |
*
|
|
73 |
* Reporting an ACA state via the ID pin notification mechanism is
|
|
74 |
* not a substitute for reporting port type detection via the USB
|
|
75 |
* Charger Detection SHAI that is documented separately in
|
48
|
76 |
* usb_charger_detection_shai.h. See documentation of
|
|
77 |
* MOtgObserverIf::NotifyIdPinAndVbusState() for more details.
|
33
|
78 |
*
|
|
79 |
* @see usb_charger_detection_shai.h
|
|
80 |
*/
|
|
81 |
enum TIdPinState
|
|
82 |
{
|
|
83 |
/** ID pin is grounded */
|
|
84 |
EIdStateRidGnd = 0,
|
|
85 |
|
|
86 |
/** ID pin is floating */
|
|
87 |
EIdStateRidFloat,
|
|
88 |
|
|
89 |
/**
|
|
90 |
* ID pin is in the RID_A range, as specified in Battery
|
|
91 |
* Charging 1.1 specification
|
|
92 |
*/
|
|
93 |
EIdStateRidA,
|
|
94 |
|
|
95 |
/**
|
|
96 |
* ID pin is in the RID_B range, as specified in Battery
|
|
97 |
* Charging 1.1 specification
|
|
98 |
*/
|
|
99 |
EIdStateRidB,
|
|
100 |
|
|
101 |
/**
|
|
102 |
* ID pin is in the RID_C range, as specified in Battery
|
|
103 |
* Charging 1.1 specification
|
|
104 |
*/
|
|
105 |
EIdStateRidC
|
|
106 |
};
|
|
107 |
|
|
108 |
/**
|
|
109 |
* Enumeration listing the reported states of VBUS on the OTG
|
|
110 |
* port.
|
|
111 |
*
|
|
112 |
* The threshold for Session Valid comparison is VOTG_SESS_VLD as
|
|
113 |
* defined in the "On-The-Go and Embedded Host Supplement to the
|
|
114 |
* USB Revision 2.0 Specification", Table 4-1 Electrical
|
|
115 |
* Characteristics. The voltage level for a compliant
|
|
116 |
* implementation can be anywhere between 0.8 V and 4.0 V.
|
|
117 |
*/
|
|
118 |
enum TVbusState
|
|
119 |
{
|
|
120 |
/** VBUS is below the OTG Session Valid threshold */
|
|
121 |
EVbusStateNoSession = 0,
|
|
122 |
|
|
123 |
/**
|
|
124 |
* VBUS is above the OTG Session Valid threshold, but below
|
|
125 |
* the requirements of AVbusValid.
|
|
126 |
*/
|
|
127 |
EVbusStateSessionValid,
|
|
128 |
|
|
129 |
/**
|
|
130 |
* When operating as the A-device and driving VBUS, indicates
|
|
131 |
* that the VBUS is in regulation, as defined in "On-The-Go
|
|
132 |
* and Embedded Host Supplement to the USB Revision 2.0
|
|
133 |
* Specification" Section 4.2.1, "VBUS Output Voltage and
|
|
134 |
* Current".
|
|
135 |
*
|
|
136 |
* When a VBUS session has been started as the A-device, the
|
|
137 |
* OTG Controller PSL is required to report a VBUS level of
|
|
138 |
* EVbusStateAVbusValid when VBUS has successfully risen to
|
|
139 |
* allow the OTG State Machine to transition out of the
|
|
140 |
* a_wait_vrise state.
|
|
141 |
*
|
|
142 |
* After VBUS has been successfully raised when operating as
|
|
143 |
* the A-device, the PSL reporting a VBUS level less than
|
|
144 |
* EVbusStateAVbusValid is considered as a report of a VBUS
|
|
145 |
* error (over-current) situation and will result in ending
|
|
146 |
* the session immediately.
|
|
147 |
*/
|
|
148 |
EVbusStateAVbusValid
|
|
149 |
};
|
|
150 |
|
|
151 |
/**
|
|
152 |
* Enumeration listing the state of the OTG 2.0 state machine.
|
|
153 |
*
|
|
154 |
* The states match those defined in the "On-The-Go and Embedded
|
|
155 |
* Host Supplement to the USB Revision 2.0 Specification" for the
|
|
156 |
* OTG A-device and B-device states.
|
|
157 |
*/
|
|
158 |
enum TOtgState
|
|
159 |
{
|
|
160 |
/** The OTG state is b_idle */
|
|
161 |
EOtgStateBIdle = 0,
|
|
162 |
|
|
163 |
/** The OTG state is b_peripheral */
|
|
164 |
EOtgStateBPeripheral,
|
|
165 |
|
|
166 |
/** The OTG state is b_wait_acon */
|
|
167 |
EOtgStateBWaitAcon,
|
|
168 |
|
|
169 |
/** The OTG state is b_host */
|
|
170 |
EOtgStateBHost,
|
|
171 |
|
|
172 |
/** The OTG state is a_idle */
|
|
173 |
EOtgStateAIdle,
|
|
174 |
|
|
175 |
/** The OTG state is a_wait_vrise */
|
|
176 |
EOtgStateAWaitVrise,
|
|
177 |
|
|
178 |
/** The OTG state is a_wait_bcon */
|
|
179 |
EOtgStateAWaitBcon,
|
|
180 |
|
|
181 |
/** The OTG state is a_host */
|
|
182 |
EOtgStateAHost,
|
|
183 |
|
|
184 |
/** The OTG state is a_suspend */
|
|
185 |
EOtgStateASuspend,
|
|
186 |
|
|
187 |
/** The OTG state is a_peripheral */
|
|
188 |
EOtgStateAPeripheral,
|
|
189 |
|
|
190 |
/** The OTG state is a_wait_vfall */
|
|
191 |
EOtgStateAWaitVfall,
|
|
192 |
|
|
193 |
/** The OTG state is a_vbus_err */
|
|
194 |
EOtgStateAVbusErr
|
|
195 |
};
|
|
196 |
|
|
197 |
/**
|
|
198 |
* Enumeration listing the roles that our device can be in.
|
|
199 |
*/
|
|
200 |
enum TOtgRole
|
|
201 |
{
|
|
202 |
/**
|
|
203 |
* Our device is idle, i.e. we are not operating in either the
|
|
204 |
* peripheral or the host role. This role indicates that
|
|
205 |
* neither the host controller nor the peripheral controller
|
|
206 |
* needs to be activated and the PSL is free to power down the
|
|
207 |
* controllers.
|
|
208 |
*/
|
|
209 |
EOtgRoleIdle = 0,
|
|
210 |
|
|
211 |
/** Our device is operating in the peripheral role */
|
|
212 |
EOtgRolePeripheral,
|
|
213 |
|
|
214 |
/** Our device is operating in the host role */
|
|
215 |
EOtgRoleHost
|
|
216 |
};
|
|
217 |
|
|
218 |
// Class declaration
|
|
219 |
|
|
220 |
/**
|
|
221 |
* An interface class that needs to be implemented by each OTG
|
|
222 |
* Controller PSL that registers to the USB stack.
|
|
223 |
*
|
|
224 |
* The USB OTG Stack will call the functions of this interface
|
|
225 |
* from a DFC queued on the DFC queue supplied by the OTG
|
|
226 |
* Controller PSL in TOtgControllerProperties::iControllerDfcQueue
|
|
227 |
* when the OTG Controller PSL registered.
|
|
228 |
*/
|
|
229 |
NONSHARABLE_CLASS( MOtgControllerIf )
|
|
230 |
{
|
|
231 |
public:
|
|
232 |
/**
|
|
233 |
* Called by the OTG stack to set the observer callback
|
|
234 |
* interface to be used by the OTG Controller PSL to report
|
|
235 |
* events.
|
|
236 |
*
|
|
237 |
* When the observer pointer is set to non-NULL value, the OTG
|
|
238 |
* Controller PSL is required to immediately report the
|
|
239 |
* current VBUS and ID states to the observer to get the
|
|
240 |
* status of the OTG stack up to date.
|
|
241 |
*
|
48
|
242 |
* If the OTG Controller PSL has detected that we are attached
|
|
243 |
* to a bad device already before the OTG Observer was set by
|
|
244 |
* this function, the PSL needs to immediately report ID
|
|
245 |
* floating and VBUS low, and report the bad device by calling
|
|
246 |
* MOtgObserverIf::NotifyBadDeviceAttached(). See the
|
|
247 |
* documentation of MOtgObserverIf::NotifyBadDeviceAttached()
|
|
248 |
* for more information on the detection of bad devices.
|
|
249 |
*
|
33
|
250 |
* @param aObserver Pointer to the observer interface to use,
|
|
251 |
* or NULL when the OTG stack is being unloaded.
|
|
252 |
*/
|
|
253 |
virtual void SetOtgObserver( MOtgObserverIf* aObserver ) = 0;
|
|
254 |
|
|
255 |
/**
|
|
256 |
* When operating as the B-peripheral, the OTG stack calls
|
|
257 |
* this function to indicate that the upper layers are
|
|
258 |
* requesting our device to become the B-host. This means that
|
|
259 |
* our OTG device will need start the HNP signalling by
|
|
260 |
* disconnecting from the bus and allowing the A-device to
|
|
261 |
* connect as the peripheral. The signalling shall be started
|
|
262 |
* when the host has suspended the bus, which may already be
|
|
263 |
* the case or happen later.
|
|
264 |
*
|
|
265 |
* This function call is only relevant for OTG controllers
|
|
266 |
* that implement the HNP signalling in hardware and require
|
|
267 |
* an explicit request from SW to start the HNP role switch.
|
|
268 |
* If the OTG controller is under SW control by the Host and
|
|
269 |
* Peripheral Controller PSLs, the OTG Controller PSL should
|
|
270 |
* ignore this call. The HNP signalling in the SW-controlled
|
|
271 |
* case will be handled as normal calls to disconnect as
|
|
272 |
* peripheral and then start the host controller.
|
|
273 |
*
|
|
274 |
* For all controller types, the Host Controller PSL and the
|
|
275 |
* Peripheral Controller PSL associated with the OTG port are
|
|
276 |
* required to report events as they normally would when
|
|
277 |
* operating as the default role. For the Host Controller PSL,
|
|
278 |
* this includes notifying device connection, disconnection,
|
|
279 |
* and other relevant events via MRootHubCallbackIf. For the
|
|
280 |
* Peripheral Controller PSL, this includes notifying bus
|
|
281 |
* state events such as reset, suspend, and resume via
|
|
282 |
* MUsbPeripheralPilCallbackIf::DeviceEventNotification.
|
|
283 |
*
|
|
284 |
* The OTG Controller PSL is not required to perform any
|
|
285 |
* monitoring of HNP success or failure, or report that to the
|
|
286 |
* PIL layer. The PSL is only responsible for making the
|
|
287 |
* normal host and peripheral notifications mentioned above,
|
|
288 |
* and the PIL can see the HNP success or failure from those
|
|
289 |
* notifications.
|
|
290 |
*/
|
|
291 |
virtual void SetBHnpRequest() = 0;
|
|
292 |
|
|
293 |
/**
|
|
294 |
* When operating as the B-device, the OTG stack calls this
|
|
295 |
* function to request the PSL to drive SRP signalling on the
|
|
296 |
* bus by pulsing the D+ dataline. The OTG Controller PSL may
|
|
297 |
* synchronously drive the 5..10 millisecond pulse before
|
|
298 |
* returning, but it may also do it asynchronously.
|
|
299 |
*
|
|
300 |
* The OTG PIL layer guarantees that the initial conditions
|
|
301 |
* for driving SRP are satisfied before the PIL calls this
|
|
302 |
* function. That is, the PIL guarantees that sufficient time
|
|
303 |
* has elapsed since the end of the previous VBUS session (if
|
|
304 |
* any) and the bus has been idle long enough.
|
|
305 |
*
|
|
306 |
* No special report from the OTG Controller PSL is required
|
|
307 |
* in either success or fail case. In a success case, the
|
|
308 |
* A-device will raise VBUS and the OTG state machine gets
|
|
309 |
* this as a normal VBUS notifications from the OTG Controller
|
|
310 |
* PSL. In a fail case, a timer in the upper layers will
|
|
311 |
* expire, indicating to upper layers that the SRP was not
|
|
312 |
* successful.
|
|
313 |
*/
|
|
314 |
virtual void SignalBSrp() = 0;
|
|
315 |
|
|
316 |
/**
|
|
317 |
* Called by the OTG state machine to indicate a change in the
|
|
318 |
* required controller role.
|
|
319 |
*
|
|
320 |
* Whether the PSL needs to do any actions depends on the HW.
|
|
321 |
* For controllers that require special configuration in
|
|
322 |
* changing a role (other than just starting the peripheral
|
|
323 |
* controller or the host controller normally), the OTG
|
|
324 |
* Controller should do that special configuration when it
|
|
325 |
* gets this call.
|
|
326 |
*
|
|
327 |
* When changing a role, the OTG state machine will first
|
|
328 |
* disable the stack for the previous role, causing that stack
|
|
329 |
* to issue a stop request to the respective controller
|
|
330 |
* PSL. The OTG state machine will then call this function
|
|
331 |
* SetControllerRole() to set the controller role to the
|
|
332 |
* target role. Following this, the OTG state machine will
|
|
333 |
* enable the stack for the target role, causing that stack to
|
|
334 |
* issue a start request to the respective controller PSL.
|
|
335 |
*
|
|
336 |
* @param aControllerRole The OTG role to set our device to
|
|
337 |
*
|
|
338 |
* @return KErrNone if the OTG Controller successfully set the
|
|
339 |
* role or required no actions. Otherwise a system-wide
|
|
340 |
* error code.
|
|
341 |
*/
|
|
342 |
virtual TInt SetControllerRole( TOtgRole aControllerRole ) = 0;
|
|
343 |
};
|
|
344 |
|
|
345 |
|
|
346 |
/**
|
|
347 |
* An interface class implemented by the USB stack to allow the
|
|
348 |
* OTG controller to report events to the USB stack. This includes
|
|
349 |
* events like VBUS rising and falling, ID pin becoming grounded
|
|
350 |
* or floating, and SRP being detected.
|
|
351 |
*
|
|
352 |
* It is required that the OTG Controller PSL calls these
|
|
353 |
* functions in the context of the DFC queue supplied by the OTG
|
|
354 |
* Controller PSL in TOtgControllerProperties::iControllerDfcQueue
|
|
355 |
* when the OTG Controller PSL registered.
|
|
356 |
*/
|
|
357 |
NONSHARABLE_CLASS( MOtgObserverIf )
|
|
358 |
{
|
|
359 |
public:
|
|
360 |
/**
|
48
|
361 |
* Notify the current ID-pin and VBUS state to the OTG
|
|
362 |
* stack. This needs to be called by the OTG Controller PSL
|
|
363 |
* everytime there is a change in the ID pin or VBUS
|
|
364 |
* level. Redundant notifications that don't change the
|
|
365 |
* previously reported state are silently ignored, so the
|
|
366 |
* function is safe to call without worrying about extra
|
|
367 |
* calls.
|
33
|
368 |
*
|
|
369 |
* When USB Battery Charging is supported on the OTG-capable
|
|
370 |
* port, there is a dependency between normal USB
|
|
371 |
* functionality and USB Battery Charging (see
|
|
372 |
* usb_charger_detection_shai.h and specifically the
|
|
373 |
* description of class MChargerDetectorIf). In this case it
|
|
374 |
* is the responsibility of the OTG Controller PSL to
|
|
375 |
* communicate with the Charger Detector PSL (which it may
|
|
376 |
* implement itself) with respect to VBUS and ID pin events.
|
|
377 |
*
|
48
|
378 |
* Due to Accessory Charger Adapter specified in Battery
|
|
379 |
* Charging 1.1, the ID pin state is relevant for both
|
|
380 |
* charging and OTG. The USB OTG SHAI and the USB Charger
|
|
381 |
* Detection SHAI receive the ID pin notifications from the
|
|
382 |
* PSL independently. For ID and VBUS events that indicate
|
|
383 |
* connection to an Accessory Charger Adapter, it is required
|
|
384 |
* that a BC 1.1 capable PSL reports the state to both the
|
|
385 |
* Charger Detector PSL Observer (via
|
|
386 |
* MChargerDetectorObserverIf::NotifyPortType), and the OTG
|
|
387 |
* Observer (via this function). The reporting order is not
|
|
388 |
* significant and can be freely chosen by the PSL.
|
33
|
389 |
*
|
|
390 |
* When VBUS rises on the OTG-capable port that is currently
|
|
391 |
* the B-device and fully supports Battery Charging
|
|
392 |
* Specification Revision 1.1, the Charger Detector PSL and
|
|
393 |
* the OTG Controller PSL need to together guarantee that Data
|
|
394 |
* Contact Detect is completed and the port type detected
|
48
|
395 |
* before reporting the ID and VBUS state. When the port type
|
|
396 |
* is known, the port type needs to be notified to the Charger
|
|
397 |
* Detector PSL Observer, followed by notifying the ID and
|
|
398 |
* VBUS state to the OTG Observer (via this function).
|
33
|
399 |
*
|
48
|
400 |
* Where Data Contact Detect is not supported, the initial
|
|
401 |
* B-device VBUS rise event needs to be notified to the OTG
|
|
402 |
* Observer (via this function) immediately and charger
|
|
403 |
* detection needs to proceed in parallel with the upper
|
|
404 |
* layers preparing the USB personality. This is necessary in
|
|
405 |
* order to ensure that we can fulfill the requirement to
|
|
406 |
* connect to the bus within a second, while still making as
|
|
407 |
* long as possible charger detection cycle to minimize the
|
|
408 |
* chances of false detections due to datalines not making
|
|
409 |
* contact yet.
|
33
|
410 |
*
|
|
411 |
* The OTG Controller PSL, the Peripheral Controller PSL and
|
|
412 |
* the Charger Detector PSL need to together guarantee that
|
|
413 |
* the peripheral controller does not attempt to connect to
|
|
414 |
* the bus while charger detection is still on-going. When
|
|
415 |
* detection has been completed and upper layers have
|
|
416 |
* indicated readiness to connect to the bus (see
|
|
417 |
* MPeripheralControllerIf::PeripheralConnect(), the
|
|
418 |
* Peripheral Controller PSL must connect to the bus.
|
|
419 |
*
|
48
|
420 |
* @param aIdPinState The current ID-pin state
|
33
|
421 |
* @param aVbusState The current VBUS state
|
|
422 |
*/
|
48
|
423 |
virtual void NotifyIdPinAndVbusState( TIdPinState aIdPinState,
|
|
424 |
TVbusState aVbusState ) = 0;
|
33
|
425 |
|
|
426 |
/**
|
|
427 |
* When operating as the A-device with VBUS low, notify the
|
|
428 |
* OTG stack that SRP signalling has been detected on the
|
|
429 |
* bus. The OTG Controller must detect the SRP signalling from
|
|
430 |
* dataline pulsing, as specified in the "On-The-Go and
|
|
431 |
* Embedded Host Supplement to the USB Revision 2.0
|
|
432 |
* Specification".
|
|
433 |
*/
|
|
434 |
virtual void NotifySrpDetected() = 0;
|
|
435 |
|
|
436 |
/**
|
|
437 |
* This function is called by the OTG Controller PSL to report
|
|
438 |
* that it has detected the attachment of a device (A or B)
|
|
439 |
* that is malfunctioning in a low-level way that prevents
|
|
440 |
* attempting communication with the connected device. Such
|
|
441 |
* cases may include but are not necessarily limited to:
|
|
442 |
*
|
|
443 |
* 1. A B-device that drives its upstream VBUS. To prevent
|
|
444 |
* damage to the VBUS charge pump in our A-device, it may be
|
|
445 |
* necessary to prevent VBUS from being raised by our device.
|
|
446 |
*
|
|
447 |
* 2. A B-device that presents a single-ended one (both
|
|
448 |
* datalines high) on the bus.
|
|
449 |
*
|
|
450 |
* The detection of such malfunctioning devices is left to the
|
|
451 |
* OTG Controller PSL, as this type of malfunctions are
|
|
452 |
* low-level problems not necessarily detectable with the
|
|
453 |
* standard inputs available to the OTG state machine.
|
|
454 |
*
|
|
455 |
* To ensure that the OTG state machine stays in an idle
|
|
456 |
* state, the OTG Controller PSL should report ID floating and
|
|
457 |
* VBUS low prior to reporting the bad device attachment by
|
|
458 |
* calling this function. When the bad device is detached, the
|
|
459 |
* OTG Controller PSL can resume reporting ID and VBUS state
|
|
460 |
* truthfully, and must call NotifyBadDeviceDetached() to
|
|
461 |
* allow the upper layers to see the error condition has been
|
|
462 |
* cleared.
|
|
463 |
*
|
|
464 |
* @see NotifyBadDeviceDetached()
|
|
465 |
*/
|
|
466 |
virtual void NotifyBadDeviceAttached() = 0;
|
|
467 |
|
|
468 |
/**
|
|
469 |
* This function is called by the OTG Controller PSL to report
|
|
470 |
* that a previously detected bad device has been detached.
|
|
471 |
* See NotifyBadDeviceAttached() for description of this
|
|
472 |
* functionality.
|
|
473 |
*
|
|
474 |
* @see NotifyBadDeviceAttached()
|
|
475 |
*/
|
|
476 |
virtual void NotifyBadDeviceDetached() = 0;
|
|
477 |
};
|
|
478 |
|
|
479 |
|
|
480 |
/**
|
|
481 |
* This class specifies the information provided by an OTG
|
|
482 |
* Controller PSL when registering to the USB OTG stack.
|
|
483 |
*
|
|
484 |
* The PSL should prepare for the possibility that members may be
|
|
485 |
* added to the end of this class in later SHAI versions if new
|
|
486 |
* information is needed to support new features. The PSL should
|
|
487 |
* not use this class as a direct member in an object that is not
|
|
488 |
* allowed to grow in size due to binary compatibility reasons.
|
|
489 |
*
|
|
490 |
* @see UsbOtgPil::RegisterOtgController()
|
|
491 |
*/
|
|
492 |
NONSHARABLE_CLASS( TOtgControllerProperties )
|
|
493 |
{
|
|
494 |
public: // Types and constants
|
|
495 |
/**
|
|
496 |
* A bitmask type used to indicate the static capabilities of
|
|
497 |
* the OTG Controller.
|
|
498 |
*/
|
|
499 |
typedef TUint32 TOtgCaps;
|
|
500 |
|
|
501 |
public:
|
|
502 |
/**
|
|
503 |
* Inline constructor for the OTG Controller properties
|
|
504 |
* object. This is inline rather than an exported function to
|
|
505 |
* prevent a binary break in a case where an older PSL binary
|
|
506 |
* might provide the constructor a smaller object due to the
|
|
507 |
* PSL being compiled against an older version of the SHAI
|
|
508 |
* header. When it's inline, the function is always in sync
|
|
509 |
* with the object size.
|
|
510 |
*
|
|
511 |
* We slightly violate the coding conventions which say that
|
|
512 |
* inline functions should be in their own file. We don't want
|
|
513 |
* to double the number of USB SHAI headers just for sake of a
|
|
514 |
* trivial constructor.
|
|
515 |
*/
|
|
516 |
inline TOtgControllerProperties() :
|
|
517 |
iCapabilities(0),
|
|
518 |
iControllerDfcQueue(NULL)
|
|
519 |
{
|
|
520 |
};
|
|
521 |
|
|
522 |
public: // Data
|
|
523 |
/**
|
|
524 |
* A bitmask specifying the static capabilities of this OTG
|
|
525 |
* Controller. No capabilities are specified at the moment and
|
|
526 |
* the PSL shall fill this field with a zero value.
|
|
527 |
*
|
|
528 |
* The field is added for sake of future proofing the binary
|
|
529 |
* compatibility of the OTG SHAI. By having a field reserved
|
|
530 |
* for capability bits, we can later specify bits to indicate
|
|
531 |
* added virtual functions or extension to this controller
|
|
532 |
* properties structure. The PIL layer can then at runtime
|
|
533 |
* confirm the existence of the new functions or fields and
|
|
534 |
* safely support an older binary, if we choose to.
|
|
535 |
*/
|
|
536 |
TOtgCaps iCapabilities;
|
|
537 |
|
|
538 |
/**
|
|
539 |
* Pointer to a DFC queue that will be used for DFCs of this
|
|
540 |
* controller and the associated peripheral and host
|
|
541 |
* controllers.
|
|
542 |
*
|
|
543 |
* The OTG Controller must supply a pointer to a dedicated DFC
|
|
544 |
* queue that has been created for this OTG Controller PSL.
|
|
545 |
* Both the OTG Controller PSL itself and the OTG stack must
|
|
546 |
* queue their DFCs for this controller in this DFC queue to
|
|
547 |
* ensure the code is running in the same context.
|
|
548 |
*
|
|
549 |
* Furthermore, it is the responsibility of the OTG Controller
|
|
550 |
* PSL that registers to ensure that the Peripheral and Host
|
|
551 |
* Controller PSLs that are registered at the same time use
|
|
552 |
* the same DFC Queue in their respective properties object.
|
|
553 |
*/
|
|
554 |
TDfcQue* iControllerDfcQueue;
|
|
555 |
};
|
|
556 |
|
|
557 |
|
|
558 |
/**
|
|
559 |
* A static class implemented by the USB OTG PIL layer to allow
|
|
560 |
* the OTG controller PSL to register to the PIL layer.
|
|
561 |
*/
|
|
562 |
NONSHARABLE_CLASS( UsbOtgPil )
|
|
563 |
{
|
|
564 |
public:
|
|
565 |
/**
|
|
566 |
* Registration function to be used by the OTG Controller PSL
|
|
567 |
* to register itself and the associated peripheral and host
|
|
568 |
* controller PSLs to the PIL layer.
|
|
569 |
*
|
|
570 |
* The intended usage is that OTG Controller PSL (of which
|
|
571 |
* only one can exists in a given system) is a kernel
|
|
572 |
* extension that registers itself and the associated
|
|
573 |
* peripheral and host controller PSLs to the USB PIL layer by
|
|
574 |
* making this call from its kernel extension entry point
|
|
575 |
* function (or an equivalent code that runs during bootup).
|
|
576 |
*
|
|
577 |
* @param aOtgControllerIf Reference to the OTG Controller
|
48
|
578 |
* interface implemented by the registering PSL. The PIL
|
|
579 |
* layer requires that the supplied reference remains valid
|
|
580 |
* indefinitely, as the OTG Controller cannot unregister.
|
33
|
581 |
*
|
|
582 |
* @param aOtgProperties Reference to an object describing the
|
48
|
583 |
* static properties of the OTG Controller. The PIL takes a
|
|
584 |
* copy and the PSL is free to release the properties object
|
|
585 |
* upon return.
|
33
|
586 |
*
|
|
587 |
* @param aPeripheralControllerIf Reference to the Peripheral
|
|
588 |
* Controller interface implemented by the PSL controlling the
|
|
589 |
* Peripheral Controller associated with the registering OTG
|
48
|
590 |
* port. The PIL layer requires that the supplied reference
|
|
591 |
* remains valid indefinitely, as the OTG Controller cannot
|
|
592 |
* unregister.
|
33
|
593 |
*
|
|
594 |
* @param aPeripheralProperties Reference to an object
|
|
595 |
* describing the static properties of the Peripheral
|
48
|
596 |
* Controller. The PIL takes a copy and the PSL is free to
|
|
597 |
* release the properties object upon return.
|
33
|
598 |
*
|
|
599 |
* @param aHostControllerIf Reference to the Host Controller
|
|
600 |
* interface implemented by the PSL controlling the Host
|
48
|
601 |
* Controller associated with the registering OTG port. The
|
|
602 |
* PIL layer requires that the supplied reference remains
|
|
603 |
* valid indefinitely, as the OTG Controller cannot
|
|
604 |
* unregister.
|
33
|
605 |
*
|
|
606 |
* @param aHostProperties Reference to an object describing the
|
48
|
607 |
* static properties of the Host Controller. The PIL takes a
|
|
608 |
* copy and the PSL is free to release the properties object
|
|
609 |
* upon return.
|
33
|
610 |
*
|
|
611 |
* @lib usbotghostpil.lib
|
|
612 |
*/
|
|
613 |
IMPORT_C static void RegisterOtgController(
|
|
614 |
MOtgControllerIf& aOtgControllerIf,
|
|
615 |
const TOtgControllerProperties& aOtgProperties,
|
|
616 |
MPeripheralControllerIf& aPeripheralControllerIf,
|
|
617 |
const TPeripheralControllerProperties& aPeripheralProperties,
|
|
618 |
MHostControllerIf& aHostControllerIf,
|
|
619 |
const THostControllerProperties& aHostProperties );
|
|
620 |
};
|
|
621 |
};
|
|
622 |
|
|
623 |
#endif // USB_OTG_SHAI_H
|
|
624 |
|
|
625 |
/* End of File */
|