0
|
1 |
/*
|
|
2 |
* Copyright (c) 2003 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 the License "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 |
|
|
19 |
#include <kernel/kernel.h>
|
|
20 |
|
|
21 |
#include <drivers/sdio/callback.h>
|
|
22 |
#include <drivers/sdio/sdio.h>
|
|
23 |
#include "utraceepbussdio.h"
|
|
24 |
|
|
25 |
EXPORT_C void TSDIOFunctionCallback::Register(DMMCSocket* aSocketP)
|
|
26 |
/**
|
|
27 |
@publishedPartner
|
|
28 |
@released
|
|
29 |
|
|
30 |
Provides support for passing notification events to clients of the SDIO controller.
|
|
31 |
|
|
32 |
@param aSocketP A pointer to the socket from which to recieve notification events
|
|
33 |
*/
|
|
34 |
{
|
|
35 |
TRACE2(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIOFunctionCallbackRegistered, reinterpret_cast<TUint32>(this), reinterpret_cast<TUint32>(aSocketP)); // @SymTraceDataPublishedTvk
|
|
36 |
|
|
37 |
iBusState = (TPBusState)(aSocketP->State());
|
|
38 |
|
|
39 |
iCallBack.iFunction = TSDIOFunctionCallback::NotificationCallBack;
|
|
40 |
iCallBack.iPtr=this;
|
|
41 |
iCallBack.SetSocket(aSocketP->iSocketNumber);
|
|
42 |
iCallBack.Add();
|
|
43 |
|
|
44 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIOFunctionCallbackRegisteredReturning, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk
|
|
45 |
}
|
|
46 |
|
|
47 |
void TSDIOFunctionCallback::NotificationCallBack(TAny* aPtr, TInt aReason, TAny* a1, TAny* a2)
|
|
48 |
/**
|
|
49 |
Provides support for passing notification events to clients of the cards functions.
|
|
50 |
*/
|
|
51 |
{
|
|
52 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "TSDIOFunctionCallback::NotificationCallBack(%d, 0x%08x, 0x%08x)", aReason, a1, a2)); // @SymTraceDataInternalTechnology
|
|
53 |
|
|
54 |
TSDIOFunctionCallback& self = *static_cast<TSDIOFunctionCallback*>(aPtr);
|
|
55 |
|
|
56 |
switch (aReason)
|
|
57 |
{
|
|
58 |
case TPBusCallBack::EPBusStateChange:
|
|
59 |
{
|
|
60 |
// a1 == TPBusState
|
|
61 |
// a2 == error code
|
|
62 |
self.DoStateChange((TPBusState)(TInt)a1, (TInt)a2);
|
|
63 |
break;
|
|
64 |
}
|
|
65 |
|
|
66 |
case TPBusCallBack::EPBusCustomNotification:
|
|
67 |
{
|
|
68 |
TInt customReason = (TInt)a1;
|
|
69 |
switch(customReason)
|
|
70 |
{
|
|
71 |
case ESdioNotifyPowerSleep:
|
|
72 |
{
|
|
73 |
self.CallBack(ESdioNotifyPowerSleep);
|
|
74 |
break;
|
|
75 |
}
|
|
76 |
|
|
77 |
case ESdioNotifyPowerDownPending:
|
|
78 |
{
|
|
79 |
self.CallBack(ESdioNotifyPowerDownPending);
|
|
80 |
break;
|
|
81 |
}
|
|
82 |
|
|
83 |
default:
|
|
84 |
{
|
|
85 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EWarning), "Unknown Custom Callback Reason (%d)", customReason)); // @SymTraceDataInternalTechnology
|
|
86 |
break;
|
|
87 |
}
|
|
88 |
}
|
|
89 |
break;
|
|
90 |
}
|
|
91 |
|
|
92 |
default:
|
|
93 |
{
|
|
94 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EWarning), "Unknown Callback Reason (%d, 0x%08x, 0x%08x)", aReason, a1, a2)); // @SymTraceDataInternalTechnology
|
|
95 |
break;
|
|
96 |
}
|
|
97 |
}
|
|
98 |
}
|
|
99 |
|
|
100 |
|
|
101 |
/**
|
|
102 |
Provides support for passing notification events to clients of the cards functions.
|
|
103 |
*/
|
|
104 |
void TSDIOFunctionCallback::DoStateChange(TPBusState aNewState, TInt aReasonCode)
|
|
105 |
{
|
|
106 |
if (iBusState != aNewState)
|
|
107 |
{
|
|
108 |
iBusState = aNewState;
|
|
109 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "Calling Back to client. iBusState = %d", iBusState)); // @SymTraceDataInternalTechnology
|
|
110 |
switch(iBusState)
|
|
111 |
{
|
|
112 |
case EPBusCardAbsent:
|
|
113 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EState), "EPBusCardAbsent (%d)", aReasonCode)); // @SymTraceDataInternalTechnology
|
|
114 |
CallBack(ESdioNotifyCardRemoved);
|
|
115 |
break;
|
|
116 |
|
|
117 |
case EPBusOff:
|
|
118 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EState), "EPBusOff (%d)", aReasonCode)); // @SymTraceDataInternalTechnology
|
|
119 |
|
|
120 |
switch (aReasonCode)
|
|
121 |
{
|
|
122 |
case KErrNone:
|
|
123 |
case KErrTimedOut:
|
|
124 |
CallBack(ESdioNotifyPowerDown);
|
|
125 |
break;
|
|
126 |
case KErrNotReady:
|
|
127 |
// card detected following door close
|
|
128 |
CallBack(ESdioNotifyCardInserted);
|
|
129 |
break;
|
|
130 |
case KErrAbort:
|
|
131 |
CallBack(ESdioNotifyEmergencyPowerDown);
|
|
132 |
break;
|
|
133 |
default:
|
|
134 |
CallBack(ESdioNotifyPowerUp);
|
|
135 |
break;
|
|
136 |
}
|
|
137 |
break;
|
|
138 |
|
|
139 |
case EPBusPoweringUp:
|
|
140 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EState), "EPBusPoweringUp (%d)", aReasonCode)); // @SymTraceDataInternalTechnology
|
|
141 |
break;
|
|
142 |
|
|
143 |
case EPBusOn:
|
|
144 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EState), "EPBusOn (%d)", aReasonCode)); // @SymTraceDataInternalTechnology
|
|
145 |
CallBack(ESdioNotifyPowerUp);
|
|
146 |
break;
|
|
147 |
|
|
148 |
case EPBusPsuFault:
|
|
149 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EState), "EPBusPsuFault (%d)", aReasonCode)); // @SymTraceDataInternalTechnology
|
|
150 |
CallBack(ESdioNotifyPsuFault);
|
|
151 |
break;
|
|
152 |
|
|
153 |
case EPBusPowerUpPending:
|
|
154 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EState), "EPBusPowerUpPending (%d)", aReasonCode)); // @SymTraceDataInternalTechnology
|
|
155 |
break;
|
|
156 |
|
|
157 |
default:
|
|
158 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EWarning), "Unknown State Change (%d)", aReasonCode)); // @SymTraceDataInternalTechnology
|
|
159 |
break;
|
|
160 |
}
|
|
161 |
}
|
|
162 |
}
|