0
|
1 |
// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// e32\include\drivers\pbus.h
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
/**
|
|
19 |
@file
|
|
20 |
@publishedPartner
|
|
21 |
@released
|
|
22 |
*/
|
|
23 |
|
|
24 |
#ifndef __P32STD_H__
|
|
25 |
#define __P32STD_H__
|
|
26 |
#include <kernel/kpower.h>
|
|
27 |
|
|
28 |
#ifdef _DEBUG
|
|
29 |
#define __ENABLE_SIMULATED_MEDIA_CHANGE // Enables simulation of media change events using ControlIO
|
|
30 |
#endif
|
|
31 |
|
|
32 |
/********************************************
|
|
33 |
* Peripheral Bus Definitions
|
|
34 |
********************************************/
|
|
35 |
|
|
36 |
/**
|
|
37 |
Defines the maximum number of media change objects.
|
|
38 |
|
|
39 |
@see DMediaChangeBase
|
|
40 |
*/
|
|
41 |
const TInt KMaxMediaChanges=4;
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
/**
|
|
46 |
Defines the maximum number of power supply unit (PSU) objects.
|
|
47 |
|
|
48 |
@see DPBusPsuBase
|
|
49 |
*/
|
|
50 |
const TInt KMaxPBusVccs=4;
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
/**
|
|
56 |
Defines the state of the media, i.e. whether the media door is
|
|
57 |
open or closed.
|
|
58 |
|
|
59 |
A value of this type is returned by DMediaChangeBase::MediaState().
|
|
60 |
|
|
61 |
@see DMediaChangeBase::MediaState()
|
|
62 |
*/
|
|
63 |
enum TMediaState {
|
|
64 |
/**
|
|
65 |
Indicates that the media door is open.
|
|
66 |
*/
|
|
67 |
EDoorOpen,
|
|
68 |
|
|
69 |
/**
|
|
70 |
Indicates that the media door is closed.
|
|
71 |
*/
|
|
72 |
EDoorClosed};
|
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
enum TPBusType {EPBusTypeNone,EPBusTypePcCard,EPBusTypeMultiMedia,EPBusTypeUSB};
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
enum TPBusState
|
|
83 |
{
|
|
84 |
EPBusCardAbsent=0,
|
|
85 |
EPBusOff=1,
|
|
86 |
EPBusPoweringUp=2,
|
|
87 |
EPBusOn=3,
|
|
88 |
EPBusPsuFault=4,
|
|
89 |
EPBusPowerUpPending=5,
|
|
90 |
};
|
|
91 |
|
|
92 |
typedef void (*TPBusCallBackFn)(TAny* aPtr, TInt aReason, TAny* a1, TAny* a2);
|
|
93 |
typedef void (*TPBusIsr)(TAny* aPtr, TInt anId);
|
|
94 |
|
|
95 |
class DPBusSocket;
|
|
96 |
class TPBusCallBack : public SDblQueLink
|
|
97 |
{
|
|
98 |
public:
|
|
99 |
enum TCallBackReason
|
|
100 |
{
|
|
101 |
EPBusStateChange=0,
|
|
102 |
EPBusCustomNotification=1, // Make this the last value
|
|
103 |
};
|
|
104 |
public:
|
|
105 |
IMPORT_C TPBusCallBack();
|
|
106 |
IMPORT_C TPBusCallBack(TPBusCallBackFn aFunction, TAny* aPtr);
|
|
107 |
IMPORT_C TPBusCallBack(TPBusIsr anIsr, TAny* aPtr, TUint anIntMask);
|
|
108 |
public:
|
|
109 |
inline void NotifyPBusStateChange(TInt aState, TInt anError);
|
|
110 |
inline void NotifyCustom(TInt aParam, TInt anError);
|
|
111 |
inline void Isr(TInt anId);
|
|
112 |
public:
|
|
113 |
inline TInt PowerUp();
|
|
114 |
inline TInt PBusState();
|
|
115 |
inline TDfcQue* DfcQ();
|
|
116 |
inline void Add();
|
|
117 |
IMPORT_C void SetSocket(TInt aSocket);
|
|
118 |
IMPORT_C void Remove();
|
|
119 |
public:
|
|
120 |
DPBusSocket* iSocket;
|
|
121 |
TPBusCallBackFn iFunction;
|
|
122 |
TUint iIntMask;
|
|
123 |
TPBusIsr iIsr;
|
|
124 |
TAny* iPtr;
|
|
125 |
};
|
|
126 |
|
|
127 |
|
|
128 |
|
|
129 |
class DMediaChangeBase : public DBase
|
|
130 |
/**
|
|
131 |
Abstract Base class to handle the insertion and removal of removable media.
|
|
132 |
|
|
133 |
This class is intended for derivation at the media and variant layers,
|
|
134 |
which handles the media/variant specific functionality such as interrupt detection,
|
|
135 |
and passes notifications of media change to the peripheral bus socket layers.
|
|
136 |
|
|
137 |
@see DMMCMediaChange
|
|
138 |
|
|
139 |
@publishedPartner
|
|
140 |
@released
|
|
141 |
*/
|
|
142 |
{
|
|
143 |
public:
|
|
144 |
IMPORT_C DMediaChangeBase(TInt aMediaChangeNum);
|
|
145 |
IMPORT_C virtual TInt Create();
|
|
146 |
public:
|
|
147 |
IMPORT_C void DoorOpenService();
|
|
148 |
IMPORT_C void DoorClosedService();
|
|
149 |
void MediaChangeEvent(TBool aDoorOpened);
|
|
150 |
void AcknowledgeEvent(TBool aDoorOpened);
|
|
151 |
static void DoorOpenDfcFn(TAny* aPtr);
|
|
152 |
public:
|
|
153 |
/**
|
|
154 |
* Implemented at the media and variant layers.
|
|
155 |
* Forces a media change, performs actions as if a door open has occurred.
|
|
156 |
* Used for powering down and restarting media.
|
|
157 |
*
|
|
158 |
* @see DMediaChangeBase::DoDoorOpen()
|
|
159 |
*/
|
|
160 |
IMPORT_C virtual void ForceMediaChange()=0;
|
|
161 |
|
|
162 |
/**
|
|
163 |
* Called by DMediaChangeBase::AcknowledgeEvent when the door is opened.
|
|
164 |
* Implemented at the media and variant layer, DoDoorOpen is invoked
|
|
165 |
* in response to the variant calling ::DoDoorOpenService upon detection of
|
|
166 |
* a door open event.
|
|
167 |
*
|
|
168 |
* @see DMediaChangeBase::DoorOpenService()
|
|
169 |
* @see DMediaChangeBase::DoDoorClosed()
|
|
170 |
*/
|
|
171 |
IMPORT_C virtual void DoDoorOpen()=0;
|
|
172 |
|
|
173 |
/**
|
|
174 |
* Called by DMediaChangeBase::AcknowledgeEvent when the door is closed.
|
|
175 |
* Implemented at the media and variant layer, DoDoorClosed is invoked
|
|
176 |
* in response to the variant calling ::DoorOpenService upon detection of
|
|
177 |
* a door closed event.
|
|
178 |
*
|
|
179 |
* @see DMediaChangeBase::DoorOpenService()
|
|
180 |
* @see DMediaChangeBase::DoDoorOpen()
|
|
181 |
*/
|
|
182 |
IMPORT_C virtual void DoDoorClosed()=0;
|
|
183 |
|
|
184 |
/**
|
|
185 |
* Returns the current state of the door.
|
|
186 |
* Implemented at the variant layer to provide information as to the state of the door.
|
|
187 |
*
|
|
188 |
* @return TMediaState enumeration describing the state of door (EDoorOpen, EDoorClosed)
|
|
189 |
*/
|
|
190 |
IMPORT_C virtual TMediaState MediaState()=0;
|
|
191 |
public:
|
|
192 |
/** Unique media change ID, identification scheme is defined by derived classes*/
|
|
193 |
TInt iMediaChangeNum;
|
|
194 |
|
|
195 |
/** Count of media events yet to be acknowledged.*/
|
|
196 |
TInt iReplyCount;
|
|
197 |
|
|
198 |
/** Door Open DFC queue.*/
|
|
199 |
TDfc iDoorOpenDfc;
|
|
200 |
};
|
|
201 |
|
|
202 |
|
|
203 |
|
|
204 |
|
|
205 |
/**
|
|
206 |
Defines the required state of the PSU.
|
|
207 |
|
|
208 |
A value of this type is passed to DPBusPsuBase::DoSetState().
|
|
209 |
|
|
210 |
@see DPBusPsuBase::DoSetState()
|
|
211 |
*/
|
|
212 |
enum TPBusPsuState {
|
|
213 |
/**
|
|
214 |
Indicates that the PSU is to be turned off.
|
|
215 |
*/
|
|
216 |
EPsuOff,
|
|
217 |
|
|
218 |
/**
|
|
219 |
Indicates that the PSU is to be turned on in current
|
|
220 |
limit mode.
|
|
221 |
|
|
222 |
Some power supplies can be turned on in a mode that only
|
|
223 |
supplies a limited amount of current to the device.
|
|
224 |
A faulty device drawing excessive current would cause
|
|
225 |
the PSU output voltage to fall, and would be detected
|
|
226 |
by the PSU's voltage checking mechanism. After a brief
|
|
227 |
checking period in current limit mode, the PSU is
|
|
228 |
subsequently turned fully on.
|
|
229 |
|
|
230 |
For PSU's that don't support current limit mode, this is
|
|
231 |
treated in the same way as EPsuOnFull.
|
|
232 |
*/
|
|
233 |
EPsuOnCurLimit,
|
|
234 |
|
|
235 |
/**
|
|
236 |
Indicates that the PSU is to be turned fully on.
|
|
237 |
*/
|
|
238 |
EPsuOnFull
|
|
239 |
};
|
|
240 |
|
|
241 |
|
|
242 |
|
|
243 |
|
|
244 |
enum TPBusPsuStatus {EPsuStatOff,EPsuStatOn,EPsuStatError};
|
|
245 |
|
|
246 |
|
|
247 |
|
|
248 |
|
|
249 |
const TInt KPBusPsuTickInterval=1000000; // Units 1uS
|
|
250 |
|
|
251 |
|
|
252 |
|
|
253 |
|
|
254 |
/**
|
|
255 |
A bit value that is set into the TPBusPsuInfo::iVoltCheckInterval member to
|
|
256 |
indicate that the checking of the PSU voltage level can be performed when
|
|
257 |
the power supply is first turned on.
|
|
258 |
*/
|
|
259 |
const TUint KPsuChkWhileOn=0x00000001;
|
|
260 |
|
|
261 |
|
|
262 |
|
|
263 |
|
|
264 |
/**
|
|
265 |
A bit value that is set into the TPBusPsuInfo::iVoltCheckInterval member to
|
|
266 |
indicate that the checking of the PSU voltage level can be performed
|
|
267 |
periodically when the power supply is on.
|
|
268 |
*/
|
|
269 |
const TUint KPsuChkOnPwrUp=0x00000002;
|
|
270 |
|
|
271 |
|
|
272 |
|
|
273 |
|
|
274 |
/**
|
|
275 |
Defines the methods that can be used by the platform hardware for checking
|
|
276 |
the VCC voltage while on.
|
|
277 |
*/
|
|
278 |
enum TPsuVoltChkMethod {
|
|
279 |
/**
|
|
280 |
Indicates a simple good/bad check method normally using
|
|
281 |
a comparator arrangement.
|
|
282 |
*/
|
|
283 |
EPsuChkComparator,
|
|
284 |
|
|
285 |
/**
|
|
286 |
Not implemented.
|
|
287 |
*/
|
|
288 |
EPsuChkADCType1,
|
|
289 |
|
|
290 |
/**
|
|
291 |
Not implemented.
|
|
292 |
*/
|
|
293 |
EPsuChkADCType2
|
|
294 |
};
|
|
295 |
|
|
296 |
|
|
297 |
|
|
298 |
|
|
299 |
/**
|
|
300 |
Encapsulates power supply information.
|
|
301 |
|
|
302 |
An object of this type is passed to concrete implementations of
|
|
303 |
DPBusPsuBase::PsuInfo(), which are required to fill
|
|
304 |
the data members of the object.
|
|
305 |
*/
|
|
306 |
class TPBusPsuInfo
|
|
307 |
{
|
|
308 |
public:
|
|
309 |
/**
|
|
310 |
Indicates the voltage level, or range of voltages supported .
|
|
311 |
|
|
312 |
The voltage level, or range of voltages is reported as a bit mask
|
|
313 |
in the same format as defined for the OCR register.
|
|
314 |
|
|
315 |
If the PSU supports voltage adjustment, rather than a single fixed value,
|
|
316 |
then bit31 should be set to indicate this fact
|
|
317 |
as well as setting the appropriate bits to indicate the adjustable voltage
|
|
318 |
range supported.
|
|
319 |
*/
|
|
320 |
TUint iVoltageSupported;
|
|
321 |
|
|
322 |
/**
|
|
323 |
The maximum current (in microAmps) that the PSU is able to supply.
|
|
324 |
*/
|
|
325 |
TInt iMaxCurrentInMicroAmps;
|
|
326 |
|
|
327 |
/**
|
|
328 |
Indicates whether the platform hardware has support for checking whether
|
|
329 |
the voltage level of the PSU is within its expected voltage limit while turned on.
|
|
330 |
|
|
331 |
Such a mechanism could detect when a faulty card is drawing excessive current.
|
|
332 |
|
|
333 |
Set one or both of the bits KPsuChkWhileOn and KPsuChkOnPwrUp,
|
|
334 |
if there is support for voltage checking.
|
|
335 |
Set neither bit if there is no support for voltage checking.
|
|
336 |
|
|
337 |
@see KPsuChkWhileOn
|
|
338 |
@see KPsuChkOnPwrUp
|
|
339 |
*/
|
|
340 |
TUint iVoltCheckInterval;
|
|
341 |
|
|
342 |
/**
|
|
343 |
Indicates the method used by the platform hardware for checking
|
|
344 |
the VCC voltage while on.
|
|
345 |
|
|
346 |
The method used is identified using the values of
|
|
347 |
the TPsuVoltChkMethod enum.
|
|
348 |
|
|
349 |
@see TPsuVoltChkMethod
|
|
350 |
@see DPBusPsuBase::DoCheckVoltage()
|
|
351 |
*/
|
|
352 |
TPsuVoltChkMethod iVoltCheckMethod;
|
|
353 |
|
|
354 |
/**
|
|
355 |
Bus not locked timeout period, in seconds, when no clients are registered.
|
|
356 |
|
|
357 |
Set to 0 to disable the not locked timer.
|
|
358 |
*/
|
|
359 |
TInt iNotLockedTimeOut;
|
|
360 |
|
|
361 |
/**
|
|
362 |
Bus inactivity timeout period, in seconds, when clients are registered.
|
|
363 |
|
|
364 |
Set to 0 to disable the inactivity timer.
|
|
365 |
*/
|
|
366 |
TInt iInactivityTimeOut;
|
|
367 |
};
|
|
368 |
|
|
369 |
|
|
370 |
typedef void (*PsuPwrDownCheckFn)(TAny*);
|
|
371 |
/**
|
|
372 |
Perherpial bus base class to control the power supply.
|
|
373 |
|
|
374 |
This class is intended for derivation at both the media driver and variant layer,
|
|
375 |
which respectively handle the media/variant specific functionality of the power supply.
|
|
376 |
|
|
377 |
@see DMMCPsu
|
|
378 |
|
|
379 |
@publishedPartner
|
|
380 |
@released
|
|
381 |
*/
|
|
382 |
class DPBusPsuBase : public DBase
|
|
383 |
{
|
|
384 |
public:
|
|
385 |
/** Currently not in use. */
|
|
386 |
enum TResetMode {
|
|
387 |
/** Currently not in use.*/
|
|
388 |
ENormalAndRestorable,
|
|
389 |
/** Currently not in use.*/
|
|
390 |
EQuickButRestorable,
|
|
391 |
/** Currently not in use.*/
|
|
392 |
EQuickAndNotRestorable
|
|
393 |
};
|
|
394 |
public:
|
|
395 |
DPBusPsuBase(TInt aPsuNum, TInt aMediaChangeNum);
|
|
396 |
IMPORT_C TInt SetState(TPBusPsuState aState);
|
|
397 |
TPBusPsuStatus Status();
|
|
398 |
TInt CheckVoltage(TUint aCheckStatus);
|
|
399 |
void Reset();
|
|
400 |
public:
|
|
401 |
TInt Create();
|
|
402 |
IMPORT_C virtual TInt DoCreate();
|
|
403 |
IMPORT_C virtual void DoTickService();
|
|
404 |
IMPORT_C virtual TBool IsLocked();
|
|
405 |
public:
|
|
406 |
IMPORT_C virtual void DoSetState(TPBusPsuState aState)=0;
|
|
407 |
|
|
408 |
/**
|
|
409 |
Base abstract method.
|
|
410 |
Checks the voltage level of the PSU is as expected.
|
|
411 |
The result is returned by a call to DPBusPsuBase::ReceiveVoltageCheckResult(),
|
|
412 |
passing either KErrNone, KErrGeneral to indicate the pass/fail state or
|
|
413 |
KErrNotReady if the voltage check isn't complete.
|
|
414 |
|
|
415 |
Provided at the variant layer.
|
|
416 |
*/
|
|
417 |
IMPORT_C virtual void DoCheckVoltage()=0;
|
|
418 |
|
|
419 |
/**
|
|
420 |
Fills in the supplied TPBusPsuInfo object with the characteristics of the platform.
|
|
421 |
Provided at the variant layer.
|
|
422 |
|
|
423 |
@param anInfo A reference to a TPBusPsuInfo to be filled in with the PSU characteristics.
|
|
424 |
*/
|
|
425 |
IMPORT_C virtual void PsuInfo(TPBusPsuInfo &anInfo)=0;
|
|
426 |
|
|
427 |
IMPORT_C virtual void ReceiveVoltageCheckResult(TInt anError);
|
|
428 |
public:
|
|
429 |
inline TUint VoltageSupported();
|
|
430 |
inline void SetCurrLimited();
|
|
431 |
inline TBool IsOff();
|
|
432 |
inline TInt MaxCurrentInMicroAmps();
|
|
433 |
inline void ResetInactivityTimer();
|
|
434 |
public:
|
|
435 |
void PwrDownCheck();
|
|
436 |
static void DoPwrDownCheck(TAny* aPtr);
|
|
437 |
public:
|
|
438 |
/** Unique power supply unit identification number.*/
|
|
439 |
TInt iPsuNum;
|
|
440 |
|
|
441 |
/** Currently not in use. */
|
|
442 |
TInt iMediaChangeNum;
|
|
443 |
|
|
444 |
/**
|
|
445 |
Indicates the method used by the platform hardware for checking
|
|
446 |
the VCC voltage while on.
|
|
447 |
|
|
448 |
The method used is identified using the values of
|
|
449 |
the TPsuVoltChkMethod enum.
|
|
450 |
|
|
451 |
@see TPsuVoltChkMethod
|
|
452 |
@see DPBusPsuBase::DoCheckVoltage()
|
|
453 |
*/
|
|
454 |
TPsuVoltChkMethod iVoltCheckMethod;
|
|
455 |
|
|
456 |
/**
|
|
457 |
Current PSU State.
|
|
458 |
@see TPBusPsuState
|
|
459 |
*/
|
|
460 |
TPBusPsuState iState;
|
|
461 |
|
|
462 |
/** PSU current is limited to a safe level. */
|
|
463 |
TBool iCurrLimited;
|
|
464 |
|
|
465 |
/** PSU Tick Timer */
|
|
466 |
TTickLink iTickLink;
|
|
467 |
|
|
468 |
/**
|
|
469 |
Indicates the voltage level, or range of voltages supported .
|
|
470 |
|
|
471 |
The voltage level, or range of voltages is reported as a bit mask
|
|
472 |
in the same format as defined for the OCR register.
|
|
473 |
|
|
474 |
If the PSU supports voltage adjustment, rather than a single fixed value,
|
|
475 |
then bit31 should be set to indicate this fact
|
|
476 |
as well as setting the appropriate bits to indicate the adjustable voltage
|
|
477 |
range supported.
|
|
478 |
*/
|
|
479 |
TUint iVoltageSupported;
|
|
480 |
|
|
481 |
/** The maximum current (in microAmps) that the PSU is able to supply. */
|
|
482 |
TInt iMaxCurrentInMicroAmps;
|
|
483 |
|
|
484 |
/**
|
|
485 |
Indicates whether the platform hardware has support for checking whether
|
|
486 |
the voltage level of the PSU is within its expected voltage limit while turned on.
|
|
487 |
|
|
488 |
Such a mechanism could detect when a faulty card is drawing excessive current.
|
|
489 |
|
|
490 |
Set one or both of the bits KPsuChkWhileOn and KPsuChkOnPwrUp,
|
|
491 |
if there is support for voltage checking.
|
|
492 |
Set neither bit if there is no support for voltage checking.
|
|
493 |
|
|
494 |
@see KPsuChkWhileOn
|
|
495 |
@see KPsuChkOnPwrUp
|
|
496 |
*/
|
|
497 |
TUint iVoltCheckInterval;
|
|
498 |
|
|
499 |
/** Bus inactivity counter. */
|
|
500 |
TInt iInactivityCount;
|
|
501 |
|
|
502 |
/** Bus not locked counter. */
|
|
503 |
TInt iNotLockedCount;
|
|
504 |
|
|
505 |
/** Bus inactivity timeout period, in seconds, when clients are registered. */
|
|
506 |
TInt iInactivityTimeout;
|
|
507 |
|
|
508 |
/** Bus not locked timeout period, in seconds, when no clients are registered. */
|
|
509 |
TInt iNotLockedTimeout;
|
|
510 |
|
|
511 |
/** DPBusSocket which the PSU powers. */
|
|
512 |
DPBusSocket* iSocket; // for the moment assume a PSU only powers one socket
|
|
513 |
|
|
514 |
/**
|
|
515 |
DFC to handle PSU Tick.
|
|
516 |
@see DPBusPsuBase::DoTickService()
|
|
517 |
@see TDfc
|
|
518 |
*/
|
|
519 |
TDfc iPsuDfc;
|
|
520 |
|
|
521 |
/** Power Down Function to be utilised, default is PwrDownCheck */
|
|
522 |
PsuPwrDownCheckFn iPwrDownCheckFn;
|
|
523 |
|
|
524 |
private:
|
|
525 |
TUint32 reserved[4];
|
|
526 |
};
|
|
527 |
|
|
528 |
NONSHARABLE_CLASS(DPBusPowerHandler) : public DPowerHandler
|
|
529 |
{
|
|
530 |
public:
|
|
531 |
DPBusPowerHandler(DPBusSocket* aSocket);
|
|
532 |
public: // from DPowerHandler
|
|
533 |
// signals from manager to client
|
|
534 |
void PowerUp();
|
|
535 |
void PowerDown(TPowerState);
|
|
536 |
public:
|
|
537 |
DPBusSocket* iSocket;
|
|
538 |
};
|
|
539 |
|
|
540 |
/** Abstract base class for a PBUS socket.
|
|
541 |
DPBusSocket derived class object oversees the power supply and media change functionality with the socket.
|
|
542 |
*/
|
|
543 |
NONSHARABLE_CLASS(DPBusSocket) : public DBase
|
|
544 |
{
|
|
545 |
public:
|
|
546 |
/**
|
|
547 |
Panic codes to handle the invalid powerup and powerdown state of the PBUS.
|
|
548 |
@see TPBusState
|
|
549 |
*/
|
|
550 |
enum TPanic
|
|
551 |
{
|
|
552 |
/**
|
|
553 |
Indicates the invalid door close state.
|
|
554 |
*/
|
|
555 |
EDoorCloseInvalidState=0,
|
|
556 |
|
|
557 |
/**
|
|
558 |
Indicates the invalid powerup state of PBUS, considered as invalid if iState is other than TPBusState while powering up.
|
|
559 |
*/
|
|
560 |
EPowerUpInvalidState=1,
|
|
561 |
|
|
562 |
/** Indicates invalid handler state corresponding to powerup event */
|
|
563 |
EPowerUpInvalidHandlerState=2,
|
|
564 |
|
|
565 |
/** Invalid return code corresponding to powerup event */
|
|
566 |
EPowerUpInvalidReturnCode=3,
|
|
567 |
|
|
568 |
/**
|
|
569 |
Indicates the invalid powerdown state of the media device,
|
|
570 |
considered as invalid if iState is other than TPBusState while powering down.
|
|
571 |
*/
|
|
572 |
EEmergencyPowerDownInvalidState=4,
|
|
573 |
|
|
574 |
/**
|
|
575 |
Indicates the invalid powerup state of the media device,
|
|
576 |
considered as invalid if iState is not in (EPBusCardAbsent,EPBusOff and EPBusPowerUpPending) while on transition from standby.
|
|
577 |
*/
|
|
578 |
EMcPowerUpInvalidState=5,
|
|
579 |
};
|
|
580 |
|
|
581 |
/**
|
|
582 |
The purpose of this enumeration is to handle the postponed events corresponding to media change and power down event.
|
|
583 |
*/
|
|
584 |
enum TPostponedEvent
|
|
585 |
{
|
|
586 |
/** Handles the postponed media change event */
|
|
587 |
EMediaChange=1,
|
|
588 |
|
|
589 |
/** Handles the postponed power down event */
|
|
590 |
EPowerDown=2,
|
|
591 |
};
|
|
592 |
|
|
593 |
/**
|
|
594 |
Enumeration for handling debug functionality.
|
|
595 |
*/
|
|
596 |
enum TPBusDebugFunction
|
|
597 |
{
|
|
598 |
/** Media state used for simulation purposes */
|
|
599 |
EControlMediaState
|
|
600 |
};
|
|
601 |
|
|
602 |
/**
|
|
603 |
PBUS simulated media states.
|
|
604 |
*/
|
|
605 |
enum TPBusSimulateMediaState
|
|
606 |
{
|
|
607 |
/** Normal State */
|
|
608 |
EPeriphBusMediaNormal=0,
|
|
609 |
|
|
610 |
/** Simulated door open */
|
|
611 |
EPeriphBusDoorOpen=1,
|
|
612 |
|
|
613 |
/** Simulated door close with media absent */
|
|
614 |
EPeriphBusMediaRemoved=2,
|
|
615 |
|
|
616 |
/** Simulated door close with media present */
|
|
617 |
EPeriphBusMediaPresent=3,
|
|
618 |
|
|
619 |
/** Simulate two consecutive door open interrupts */
|
|
620 |
EPeriphBusMediaDoubleDoorOpen=4
|
|
621 |
};
|
|
622 |
|
|
623 |
public:
|
|
624 |
DPBusSocket(TInt aSocketNumber);
|
|
625 |
IMPORT_C static DPBusSocket* SocketFromId(TInt anId);
|
|
626 |
IMPORT_C static void Panic(DPBusSocket::TPanic aPanic);
|
|
627 |
public:
|
|
628 |
virtual TInt Create(const TDesC* aName);
|
|
629 |
virtual TInt Init();
|
|
630 |
|
|
631 |
/**
|
|
632 |
Initiates a power up sequence on the stack. This method should be implemented by the derived class.
|
|
633 |
The implementation should call PowerUpSequenceComplete() to notify the status on completion of power up sequence.
|
|
634 |
|
|
635 |
@see DMMCSocket::InitiatePowerUpSequence()
|
|
636 |
@see DMMCStack::PowerUpStack()
|
|
637 |
*/
|
|
638 |
virtual void InitiatePowerUpSequence()=0;
|
|
639 |
|
|
640 |
/**
|
|
641 |
Indicates the presence of a card. This method should be implemented by the derived class.
|
|
642 |
The implementation should use variant specific implementation of CardDetect() method to detect the card presence.
|
|
643 |
|
|
644 |
@return ETrue if a card is present, else EFalse
|
|
645 |
@see DMMCStack::CardDetect()
|
|
646 |
*/
|
|
647 |
virtual TBool CardIsPresent()=0;
|
|
648 |
|
|
649 |
/**
|
|
650 |
Resets the socket. This method should be implemented by the derived class.
|
|
651 |
The implementation should cancel powerup timer and DFC queue if any of this request is outstanding,
|
|
652 |
Power down the stack.
|
|
653 |
|
|
654 |
@see DMMCSocket::Reset1()
|
|
655 |
*/
|
|
656 |
virtual void Reset1()=0;
|
|
657 |
|
|
658 |
/**
|
|
659 |
Resets the socket on media change event.This method should be implemented by the derived class.
|
|
660 |
The implementation should remove any allocated memory following a media change event.
|
|
661 |
|
|
662 |
*/
|
|
663 |
virtual void Reset2()=0;
|
|
664 |
public:
|
|
665 |
inline TInt State();
|
|
666 |
inline TDfcQue* DfcQ();
|
|
667 |
inline TMediaState MediaState();
|
|
668 |
public:
|
|
669 |
IMPORT_C void Add(TPBusCallBack* aCallBack);
|
|
670 |
IMPORT_C TInt PowerUp();
|
|
671 |
IMPORT_C void ForceMediaChange();
|
|
672 |
IMPORT_C TInt InCritical();
|
|
673 |
IMPORT_C void EndInCritical();
|
|
674 |
IMPORT_C void DeltaCurrentConsumption(TInt aDelta);
|
|
675 |
IMPORT_C void PowerUpSequenceComplete(TInt anError);
|
|
676 |
void PsuFault(TInt anError);
|
|
677 |
void PsuTimeout();
|
|
678 |
void ResetSocket(TBool aFullReset);
|
|
679 |
void ChangeState(TInt aState, TInt anError);
|
|
680 |
void MediaChangeEvent(TBool aDoorOpened);
|
|
681 |
void DoorOpenEvent();
|
|
682 |
void DoorCloseEvent();
|
|
683 |
void Isr(TInt anId);
|
|
684 |
void DoPowerUp();
|
|
685 |
void DoPowerDown();
|
|
686 |
IMPORT_C void PowerDownComplete();
|
|
687 |
IMPORT_C void RequestAsyncPowerDown();
|
|
688 |
IMPORT_C virtual TInt ControlIO(TInt aFunction, TAny* aParam1, TAny* aParam2);
|
|
689 |
public:
|
|
690 |
/**
|
|
691 |
Current PBus type.
|
|
692 |
@see TPBusType
|
|
693 |
*/
|
|
694 |
TPBusType iType;
|
|
695 |
/**
|
|
696 |
Current socket number.
|
|
697 |
*/
|
|
698 |
TInt iSocketNumber;
|
|
699 |
/**
|
|
700 |
Name of the socket.
|
|
701 |
*/
|
|
702 |
const TDesC* iName;
|
|
703 |
/**
|
|
704 |
Current state of Peripheral bus controller.
|
|
705 |
@see TPBusState
|
|
706 |
*/
|
|
707 |
TInt iState;
|
|
708 |
/**
|
|
709 |
Counter to keep track of postponed events.
|
|
710 |
*/
|
|
711 |
TInt iPostponeCount;
|
|
712 |
/**
|
|
713 |
Current postponed events.
|
|
714 |
@see TPostponedEvent
|
|
715 |
*/
|
|
716 |
TUint16 iPostponedEvents;
|
|
717 |
/**
|
|
718 |
Current simulated state of the Media.
|
|
719 |
@see TPBusSimulateMediaState
|
|
720 |
*/
|
|
721 |
TUint16 iSimulatedMediaState;
|
|
722 |
/**
|
|
723 |
The call back functions queue.
|
|
724 |
@see SDblQue
|
|
725 |
*/
|
|
726 |
SDblQue iCallBackQ;
|
|
727 |
/**
|
|
728 |
Pointer to DPBusPowerController object.
|
|
729 |
@see DPBusPowerHandler
|
|
730 |
*/
|
|
731 |
DPBusPowerHandler* iPowerHandler;
|
|
732 |
|
|
733 |
/**
|
|
734 |
Holds media change number.
|
|
735 |
@see MediaChangeFromSocket
|
|
736 |
*/
|
|
737 |
TInt iMediaChangeNumber;
|
|
738 |
|
|
739 |
/**
|
|
740 |
Pointer to DMediaChangeBase object.
|
|
741 |
@see DMediaChangeBase
|
|
742 |
*/
|
|
743 |
DMediaChangeBase* iMediaChange;
|
|
744 |
|
|
745 |
/**
|
|
746 |
Holds the state of media door.
|
|
747 |
Updated when there is change in media event corresponing to Door open.
|
|
748 |
@see DMediaChangeBase::DoorOpenService()
|
|
749 |
@see TMediaState
|
|
750 |
*/
|
|
751 |
TBool iDoorOpened;
|
|
752 |
|
|
753 |
/**
|
|
754 |
Pointer to DPBusPsuBase object.
|
|
755 |
@see DPBusPsuBase
|
|
756 |
*/
|
|
757 |
DPBusPsuBase* iVcc;
|
|
758 |
|
|
759 |
/**
|
|
760 |
Indicates the device is in standby state (i.e. Sets to ETrue when the device is in standby state).
|
|
761 |
*/
|
|
762 |
TBool iStandby;
|
|
763 |
|
|
764 |
/**
|
|
765 |
DFC to handle media change events like (DoorOpen,DoorClose).
|
|
766 |
@see DMediaChangeBase::AcknowledgeEvent
|
|
767 |
@see TDfc
|
|
768 |
*/
|
|
769 |
TDfc iMediaChangeDfc;
|
|
770 |
|
|
771 |
/**
|
|
772 |
DFC to handle powering up of the device.
|
|
773 |
@see TDfc
|
|
774 |
*/
|
|
775 |
TDfc iPowerUpDfc;
|
|
776 |
|
|
777 |
/**
|
|
778 |
DFC to handle powerdown state of the device.
|
|
779 |
|
|
780 |
@see TDfc
|
|
781 |
*/
|
|
782 |
TDfc iPowerDownDfc;
|
|
783 |
|
|
784 |
/**
|
|
785 |
DFC to handle PSU Tick.
|
|
786 |
@see DPBusPsuBase::DoTickService()
|
|
787 |
@see TDfc
|
|
788 |
*/
|
|
789 |
TDfc iPsuDfc;
|
|
790 |
|
|
791 |
/**
|
|
792 |
The DFC queue used for driver functions.
|
|
793 |
@see TDfcQue
|
|
794 |
*/
|
|
795 |
TDfcQue iDfcQ;
|
|
796 |
|
|
797 |
/**
|
|
798 |
Used when there is request for power down of the device from client.
|
|
799 |
*/
|
|
800 |
TInt iRequestPowerDownCount;
|
|
801 |
};
|
|
802 |
|
|
803 |
GLREF_D DMediaChangeBase* TheMediaChanges[KMaxMediaChanges];
|
|
804 |
GLREF_D DPBusSocket* TheSockets[KMaxPBusSockets];
|
|
805 |
GLREF_D DPBusPsuBase* TheVccs[KMaxPBusVccs];
|
|
806 |
GLREF_D DPBusPsuBase* TheVccCores[KMaxPBusVccs];
|
|
807 |
|
|
808 |
#include <drivers/pbus.inl>
|
|
809 |
#endif
|