0
|
1 |
/*
|
|
2 |
* Copyright (c) 2003-2007 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 |
#include <drivers/sdio/sdio.h>
|
|
19 |
#include <drivers/sdio/function.h>
|
|
20 |
#include <drivers/sdio/regifc.h>
|
|
21 |
#include "utraceepbussdio.h"
|
|
22 |
|
|
23 |
_LIT(KThreadName, "SdioSocketThread-");
|
|
24 |
|
|
25 |
|
|
26 |
EXPORT_C DSDIOSocket::DSDIOSocket(TInt aSocketNumber, TMMCPasswordStore* aPasswordStore)
|
|
27 |
/**
|
|
28 |
Construct the DSDIOSocket object.
|
|
29 |
|
|
30 |
@param aSocketNumber The socket
|
|
31 |
@param aPasswordStore A pointer to a password store
|
|
32 |
*/
|
|
33 |
: DMMCSocket(aSocketNumber, aPasswordStore),
|
|
34 |
iSleepDfc(DSDIOSocket::SleepDFC, this, 1)
|
|
35 |
{
|
|
36 |
TRACE2(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOSocketConstructor, reinterpret_cast<TUint32>(this), aSocketNumber); // @SymTraceDataPublishedTvk
|
|
37 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOSocketConstructorReturning, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk
|
|
38 |
}
|
|
39 |
|
|
40 |
TInt DSDIOSocket::Init()
|
|
41 |
/**
|
|
42 |
Initialize the socket
|
|
43 |
*/
|
|
44 |
{
|
|
45 |
// The SDIO Socket creates it's own DFC Que for sleep mode control
|
|
46 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "DSDIOSocket::Init");) // @SymTraceDataInternalTechnology
|
|
47 |
|
|
48 |
const TInt KSdioSocketThreadPriority=26;
|
|
49 |
|
|
50 |
TKName name(KThreadName);
|
|
51 |
name.AppendNumFixedWidth((TUint)this,EHex,8);
|
|
52 |
|
|
53 |
TInt r=Kern::DfcQInit(&iSleepDfcQ, KSdioSocketThreadPriority, &name);
|
|
54 |
if (r!=KErrNone)
|
|
55 |
{
|
|
56 |
return(r);
|
|
57 |
}
|
|
58 |
|
|
59 |
iSleepDfc.SetDfcQ(&iSleepDfcQ);
|
|
60 |
|
|
61 |
return(DMMCSocket::Init());
|
|
62 |
}
|
|
63 |
|
|
64 |
void DSDIOSocket::InitiatePowerUpSequence()
|
|
65 |
/**
|
|
66 |
Start the power up sequence for the socket
|
|
67 |
*/
|
|
68 |
{
|
|
69 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "DSDIOSocket::InitiatePowerUpSequence")); // @SymTraceDataInternalTechnology
|
|
70 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOSocketPoweringUpCard, reinterpret_cast<TUint32>(this));
|
|
71 |
|
|
72 |
iSleeping = EFalse;
|
|
73 |
DMMCSocket::InitiatePowerUpSequence();
|
|
74 |
}
|
|
75 |
|
|
76 |
TBool DSDIOSocket::CardIsPresent()
|
|
77 |
/**
|
|
78 |
Test whether the SDIO card is present
|
|
79 |
|
|
80 |
@return Returns ETrue if the card is present, EFalse if the card is not present
|
|
81 |
*/
|
|
82 |
{
|
|
83 |
return DMMCSocket::CardIsPresent();
|
|
84 |
}
|
|
85 |
|
|
86 |
void DSDIOSocket::Reset1()
|
|
87 |
/**
|
|
88 |
Reset the state of the SDIO card, declaring the card as gone
|
|
89 |
*/
|
|
90 |
{
|
|
91 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "DSDIOSocket::Reset1");) // @SymTraceDataInternalTechnology
|
|
92 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOSocketPoweringDownCard, reinterpret_cast<TUint32>(this));
|
|
93 |
|
|
94 |
if (iState != EPBusCardAbsent)
|
|
95 |
{
|
|
96 |
// Card is still present but to be powered down
|
|
97 |
TSDIOCardArray& cardArray = static_cast<DSDIOStack*>(iStack)->CardArray();
|
|
98 |
|
|
99 |
for (TUint i=0;i<iStack->iMaxCardsInStack;i++)
|
|
100 |
{
|
|
101 |
if (cardArray.Card(i).IsIOCard() || cardArray.Card(i).IsComboCard())
|
|
102 |
{
|
|
103 |
// IO capable cards must be declared as gone inorder to reset the
|
|
104 |
// interrupt controller and tidy up function lists
|
|
105 |
cardArray.DeclareCardAsGone(i);
|
|
106 |
}
|
|
107 |
}
|
|
108 |
}
|
|
109 |
|
|
110 |
DMMCSocket::Reset1();
|
|
111 |
}
|
|
112 |
|
|
113 |
void DSDIOSocket::Reset2()
|
|
114 |
/**
|
|
115 |
Reset the state of the SDIO card
|
|
116 |
*/
|
|
117 |
{
|
|
118 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "DSDIOSocket::Reset2");) // @SymTraceDataInternalTechnology
|
|
119 |
DMMCSocket::Reset2();
|
|
120 |
}
|
|
121 |
|
|
122 |
|
|
123 |
void DSDIOSocket::ResetAndPowerDown()
|
|
124 |
/**
|
|
125 |
Reset the card and power it down
|
|
126 |
*/
|
|
127 |
{
|
|
128 |
// To provide support for asynchronous power down, the SDIO socket
|
|
129 |
// shall issue a PowerDownPending notification to all clients.
|
|
130 |
// Should any client request that the power down be deferred, then
|
|
131 |
// the power supply shall not enter the PowerOff state immediately
|
|
132 |
|
|
133 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "DSDIOSocket::ResetAndPowerDown (iRequestPowerDownCount: %d)",iRequestPowerDownCount);) // @SymTraceDataInternalTechnology
|
|
134 |
|
|
135 |
iSleeping = EFalse;
|
|
136 |
SDblQueLink* pC=iCallBackQ.iA.iNext;
|
|
137 |
while (pC && pC!=&iCallBackQ.iA)
|
|
138 |
{
|
|
139 |
((TPBusCallBack*)pC)->NotifyCustom(ESdioNotifyPowerDownPending, KErrNone);
|
|
140 |
pC=pC->iNext;
|
|
141 |
}
|
|
142 |
|
|
143 |
if(iRequestPowerDownCount == 0)
|
|
144 |
{
|
|
145 |
PsuTimeout();
|
|
146 |
}
|
|
147 |
}
|
|
148 |
|
|
149 |
void DSDIOSocket::SignalSleepMode()
|
|
150 |
/**
|
|
151 |
Signals entry to sleep mode to the clients of the socket
|
|
152 |
*/
|
|
153 |
{
|
|
154 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "DSDIOSocket::SignalSleepMode");) // @SymTraceDataInternalTechnology
|
|
155 |
|
|
156 |
if(iSleeping == EFalse)
|
|
157 |
{
|
|
158 |
// notify all clients of state change
|
|
159 |
SDblQueLink* pC=iCallBackQ.iA.iNext;
|
|
160 |
while (pC && pC!=&iCallBackQ.iA)
|
|
161 |
{
|
|
162 |
((TPBusCallBack*)pC)->NotifyCustom(ESdioNotifyPowerSleep, KErrNone);
|
|
163 |
pC=pC->iNext;
|
|
164 |
}
|
|
165 |
|
|
166 |
// If no clients have requested time to enter sleep mode, then we
|
|
167 |
// can switch into low-power mode immediately. Otherwise, we wait
|
|
168 |
// for all clients to perform their function-specific power down sequence
|
|
169 |
if(iRequestSleepCount == 0)
|
|
170 |
{
|
|
171 |
if(iSleepDfc.Queued() == EFalse)
|
|
172 |
{
|
|
173 |
if (NKern::CurrentContext()==NKern::EInterrupt)
|
|
174 |
iSleepDfc.Add();
|
|
175 |
else
|
|
176 |
iSleepDfc.Enque();
|
|
177 |
}
|
|
178 |
}
|
|
179 |
}
|
|
180 |
}
|
|
181 |
|
|
182 |
EXPORT_C void DSDIOSocket::RequestAsyncSleep()
|
|
183 |
/**
|
|
184 |
@publishedPartner
|
|
185 |
@released
|
|
186 |
|
|
187 |
Request that a sleep request is deferred.
|
|
188 |
|
|
189 |
@see DPBusSocket::SleepComplete
|
|
190 |
|
|
191 |
@TODO This must be rationalised with InCritical
|
|
192 |
*/
|
|
193 |
{
|
|
194 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOSocketRequestAsyncSleep, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk
|
|
195 |
|
|
196 |
__e32_atomic_add_ord32(&iRequestSleepCount, 1);
|
|
197 |
|
|
198 |
TRACE2(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOSocketRequestAsyncSleepReturning, reinterpret_cast<TUint32>(this), iRequestSleepCount); // @SymTraceDataPublishedTvk
|
|
199 |
}
|
|
200 |
|
|
201 |
EXPORT_C void DSDIOSocket::SleepComplete()
|
|
202 |
/**
|
|
203 |
@publishedPartner
|
|
204 |
@released
|
|
205 |
|
|
206 |
The sleep deferral is complete, can now proceed to sleep.
|
|
207 |
|
|
208 |
@see DPBusSocket::RequestAsyncSleep
|
|
209 |
|
|
210 |
@TODO This must be rationalised with InCritical
|
|
211 |
*/
|
|
212 |
{
|
|
213 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOSocketSleepComplete, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk
|
|
214 |
|
|
215 |
if(__e32_atomic_tas_ord32(&iRequestSleepCount, 1, -1, 0) == 1)
|
|
216 |
{
|
|
217 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "...entering Sleep Mode (deferred)");) // @SymTraceDataInternalTechnology
|
|
218 |
|
|
219 |
if(iSleepDfc.Queued() == EFalse)
|
|
220 |
{
|
|
221 |
iSleepDfc.Add();
|
|
222 |
}
|
|
223 |
}
|
|
224 |
|
|
225 |
TRACE2(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOSocketSleepComplete, reinterpret_cast<TUint32>(this), iRequestSleepCount); // @SymTraceDataPublishedTvk
|
|
226 |
}
|
|
227 |
|
|
228 |
void DSDIOSocket::SleepDFC(TAny* aSelfP)
|
|
229 |
/**
|
|
230 |
DFC to enter sleep mode
|
|
231 |
*/
|
|
232 |
{
|
|
233 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "DSDIOSocket::SleepDFC")); // @SymTraceDataInternalTechnology
|
|
234 |
|
|
235 |
DSDIOSocket& self=*(DSDIOSocket*)aSelfP;
|
|
236 |
|
|
237 |
TSDIOCard& ioCard = static_cast<DSDIOStack*>(self.iStack)->CardArray().Card(0);
|
|
238 |
ioCard.CommonRegisterInterface()->SetBusWidth(1);
|
|
239 |
self.SetSleep(ETrue);
|
|
240 |
}
|
|
241 |
|
|
242 |
|
|
243 |
void DSDIOSocket::SetSleep(TBool aIsSleeping)
|
|
244 |
/**
|
|
245 |
Sets the sleep state
|
|
246 |
*/
|
|
247 |
{
|
|
248 |
iSleeping = aIsSleeping;
|
|
249 |
}
|