author | hgs |
Thu, 12 Aug 2010 11:55:14 +0100 | |
changeset 244 | a77889bee936 |
parent 90 | 947f0dc9f7a8 |
child 257 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 2003-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 |
// |
|
15 |
||
16 |
#include <drivers/sdio/sdio.h> |
|
17 |
#include <drivers/sdio/cisreader.h> |
|
18 |
#include <drivers/sdio/function.h> |
|
19 |
#include <drivers/sdio/regifc.h> |
|
20 |
#include "utraceepbussdio.h" |
|
21 |
||
22 |
#ifdef __SMP__ |
|
23 |
TSpinLock SDIOLock(TSpinLock::EOrderGenericIrqHigh0); |
|
24 |
#endif |
|
25 |
||
26 |
#if !defined(__WINS__) |
|
27 |
#define DISABLEPREEMPTION TUint irq = __SPIN_LOCK_IRQSAVE(SDIOLock); |
|
28 |
#define RESTOREPREEMPTION __SPIN_UNLOCK_IRQRESTORE(SDIOLock,irq); |
|
29 |
#else |
|
30 |
#define DISABLEPREEMPTION |
|
31 |
#define RESTOREPREEMPTION |
|
32 |
#endif |
|
33 |
||
34 |
// Some SDIO cards don't respond to an I/O reset command, but sending ECmdGoIdleState |
|
35 |
// after the timeout has the effect of putting the card into SPI mode. |
|
36 |
// Undefine this macro for these cards. |
|
37 |
#define __SEND_CMD0_AFTER_RESETIO_TIMEOUT__ |
|
38 |
||
39 |
// The ReadWriteExtendSM can handle fragmented RAM, this functionity may not be required |
|
40 |
// with the introduction of defragment RAM/3rd party driver support features |
|
41 |
#define __FRAGMENTED_RAM_SUPPORT |
|
42 |
||
43 |
// Temporarily override the MMC version of SMF_BEGIN to add Tracing to the state machine |
|
44 |
#undef SMF_BEGIN |
|
45 |
#define SMF_BEGIN TMMCStateMachine& m=Machine();const TMMCErr err=m.SetExitCode(0);\ |
|
46 |
for(;;){SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EState), "SDIOStack state change, m.State = %d", m.State()));/*//@SymTraceDataInternalTechnology*/\ |
|
47 |
switch(m.State()){case EStBegin:{if(err) (void)0; |
|
48 |
||
49 |
// ======== DSDIOStack ======== |
|
50 |
||
51 |
EXPORT_C TInt DSDIOStack::Init() |
|
52 |
/** |
|
53 |
@publishedPartner |
|
54 |
@released |
|
55 |
||
56 |
Initialize the stack |
|
57 |
*/ |
|
58 |
{ |
|
59 |
return DStackBase::Init(); |
|
60 |
} |
|
61 |
||
62 |
||
63 |
TMMCErr DSDIOStack::ConfigureIoCardSMST(TAny* aStackP) |
|
64 |
{ return static_cast<DSDIOStack*>(aStackP)->ConfigureIoCardSM(); } |
|
65 |
||
66 |
TMMCErr DSDIOStack::CIMGetIoCommonConfigSMST(TAny* aStackP) |
|
67 |
{ return static_cast<DSDIOStack*>(aStackP)->GetIoCommonConfigSM(); } |
|
68 |
||
69 |
TMMCErr DSDIOStack::CIMReadFunctionBasicRegistersSMST(TAny* aStackP) |
|
70 |
{ return static_cast<DSDIOStack*>(aStackP)->ReadFunctionBasicRegistersSM(); } |
|
71 |
||
72 |
TMMCErr DSDIOStack::CIMIoIssueCommandCheckResponseSMST(TAny* aStackP) |
|
73 |
{ return( static_cast<DSDIOStack *>(aStackP)->CIMIoIssueCommandCheckResponseSM() ); } |
|
74 |
||
75 |
TMMCErr DSDIOStack::CIMIoReadWriteDirectSMST(TAny* aStackP) |
|
76 |
{ return static_cast<DSDIOStack*>(aStackP)->CIMIoReadWriteDirectSM(); } |
|
77 |
||
78 |
TMMCErr DSDIOStack::CIMIoReadWriteExtendedSMST(TAny* aStackP) |
|
79 |
{return static_cast<DSDIOStack*>(aStackP)->CIMIoReadWriteExtendedSM(); } |
|
80 |
||
81 |
TMMCErr DSDIOStack::CIMIoModifySMST(TAny* aStackP) |
|
82 |
{ return static_cast<DSDIOStack*>(aStackP)->CIMIoModifySM(); } |
|
83 |
||
84 |
TMMCErr DSDIOStack::CIMIoInterruptHandlerSMST(TAny* aStackP) |
|
85 |
{ return static_cast<DSDIOStack*>(aStackP)->CIMIoInterruptHandlerSM(); } |
|
86 |
||
87 |
TMMCErr DSDIOStack::CIMIoFindTupleSMST(TAny* aStackP) |
|
88 |
{ return static_cast<DSDIOStack*>(aStackP)->CIMIoFindTupleSM(); } |
|
89 |
||
90 |
TMMCErr DSDIOStack::CIMIoSetBusWidthSMST(TAny* aStackP) |
|
91 |
{ return static_cast<DSDIOStack*>(aStackP)->CIMIoSetBusWidthSM(); } |
|
92 |
||
93 |
TMMCErr DSDIOStack::CIMReadWriteMemoryBlocksSMST(TAny* aStackP) |
|
94 |
{ return( static_cast<DSDIOStack *>(aStackP)->DSDStack::CIMReadWriteBlocksSM() ); } |
|
95 |
||
96 |
||
97 |
const TInt KMaxRCASendLoops=3; |
|
98 |
||
99 |
const TUint32 KDefaultFn0BlockSize = 0x40; |
|
100 |
const TUint8 KSDIONoTranSpeed = 0x00; |
|
101 |
const TUint8 KSDIODefaultLowTranSpeed = 0x48; |
|
102 |
const TUint8 KSDIODefaultHighTranSpeed = 0x32; |
|
103 |
||
104 |
||
105 |
EXPORT_C TMMCErr DSDIOStack::AcquireStackSM() |
|
106 |
/** |
|
107 |
This macro acquires new cards in an SDIO Card stack. |
|
108 |
||
109 |
This is an extension of the DSDStack::AcquireStackSM state machine |
|
110 |
function, and handles the SDIO initialisation procedure as described |
|
111 |
in Version 1.10f of the the SDIO Card Specification. |
|
112 |
||
113 |
@return TMMCErr Error Code |
|
114 |
*/ |
|
115 |
{ |
|
116 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOStackAcquireStack, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk |
|
117 |
||
118 |
enum states |
|
119 |
{ |
|
120 |
EStBegin=0, |
|
121 |
EStInitIOReset, |
|
122 |
EStIOReset, |
|
123 |
EStCheckIOResetResponse, |
|
124 |
EStInitIOSendOpCond, |
|
125 |
EStInitIOCheckResponse, |
|
126 |
EStInitIOSetWorkingOCR, |
|
127 |
EStInitIOCheckOcrResponse, |
|
128 |
EStInitMemoryCard, |
|
129 |
EStHandleRcaForCardType, |
|
130 |
EStIssueSendRCA, |
|
131 |
EStIssueSetRCA, |
|
132 |
EStSendRCACheck, |
|
133 |
EStRCADone, |
|
134 |
EStConfigureMemoryCardDone, |
|
135 |
EStGoInactive, |
|
136 |
EStCheckNextCard, |
|
137 |
EStEnd |
|
138 |
}; |
|
139 |
||
140 |
DSDIOSession& s=SDIOSession(); |
|
141 |
DMMCPsu* psu=(DMMCPsu*)MMCSocket()->iVcc; |
|
142 |
||
143 |
SMF_BEGIN |
|
144 |
||
145 |
iRCAPool.ReleaseUnlocked(); |
|
146 |
||
147 |
iCxCardCount=0; // Reset current card number |
|
148 |
||
149 |
CardArray().Card(iCxCardCount).RCA() = 0x0000; |
|
150 |
||
151 |
SMF_STATE(EStInitIOReset) |
|
152 |
||
153 |
// EStInitIOReset : Reset the IO Card. |
|
154 |
// |
|
155 |
// We expect the card to be reset before enumeration in order for the |
|
156 |
// card to be in the default state (ie- functions disabled, 1-bit mode) |
|
157 |
// |
|
158 |
// Resets the IO card by setting RES bit in IO_ABORT reg of the CCCR |
|
159 |
// |
|
160 |
||
161 |
iFunctionCount = 0; |
|
162 |
iMemoryPresent = EFalse; |
|
163 |
||
164 |
if (!CardDetect(iCxCardCount)) |
|
165 |
{ |
|
166 |
SMF_GOTOS(EStCheckNextCard) |
|
167 |
} |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
168 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
169 |
iCxCardType = CardType(MMCSocket()->iSocketNumber, iCxCardCount); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
170 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
171 |
if (iCxCardType!=ESDCardTypeUnknown) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
172 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
173 |
// Skip the SDIO Protocol Seq. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
174 |
SMF_GOTOS(EStInitMemoryCard); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
175 |
} |
0 | 176 |
|
177 |
TRACE2(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOStackPSLCalledAddressCard, reinterpret_cast<TUint32>(this), iCxCardCount); // @SymTraceDataPublishedTvk |
|
178 |
AddressCard(iCxCardCount); |
|
179 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOStackPSLAddressCardReturned, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk |
|
180 |
||
181 |
SMF_STATE(EStIOReset) |
|
182 |
||
183 |
// EStResetIo |
|
184 |
m.SetTraps(KMMCErrAll); |
|
185 |
s.iCardP = static_cast<TSDIOCard*>(CardArray().CardP(iCxCardCount)); |
|
186 |
s.FillDirectCommandDesc(Command(), ECIMIoWriteDirect, 0x00, KCCCRRegIoAbort, KSDIOCardIoAbortReset, NULL); |
|
187 |
SMF_INVOKES(IssueCommandCheckResponseSMST, EStCheckIOResetResponse) |
|
188 |
||
189 |
SMF_STATE(EStCheckIOResetResponse) |
|
190 |
||
191 |
// EStCheckIOResetResponse |
|
192 |
||
193 |
DoSetBusWidth(KSDBusWidth1); |
|
194 |
||
195 |
#ifdef __SEND_CMD0_AFTER_RESETIO_TIMEOUT__ |
|
196 |
||
197 |
if(err) |
|
198 |
{ |
|
199 |
m.SetTraps(KMMCErrAll); |
|
200 |
SMF_INVOKES(GoIdleSMST, EStInitIOSendOpCond) |
|
201 |
} |
|
202 |
#endif |
|
203 |
||
204 |
// Drop through to EStInitIOSendOpCond if reset OK |
|
205 |
||
206 |
SMF_STATE(EStInitIOSendOpCond) |
|
207 |
||
208 |
// EStInitIOSendOpCond : Determine the capabilities of the card. |
|
209 |
// |
|
210 |
// Determine the basic capabilities of the card by sending the card |
|
211 |
// IO_SEND_OP_COND (CMD5) with ARG=0x0000, which should respond with |
|
212 |
// the number of supported IO functions and the supported OCR. |
|
213 |
||
214 |
if(err) |
|
215 |
{ |
|
216 |
SMF_GOTOS(EStInitMemoryCard) |
|
217 |
} |
|
218 |
||
219 |
iCxPollRetryCount=0; |
|
220 |
||
221 |
iConfig.RemoveMode( KMMCModeEnableTimeOutRetry ); |
|
222 |
m.SetTraps(KMMCErrResponseTimeOut); |
|
223 |
||
224 |
DSDIOSession::FillAppCommandDesc(Command(), ESDIOCmdOpCond, 0x0000); |
|
225 |
SMF_INVOKES(ExecCommandSMST, EStInitIOCheckResponse) |
|
226 |
||
227 |
SMF_STATE(EStInitIOCheckResponse) |
|
228 |
||
229 |
// EStInitIOCheckResponse : Check the response to IO_SEND_OP_COND (CMD5) |
|
230 |
// |
|
231 |
// The R4 response shall contain the following information: |
|
232 |
// |
|
233 |
// 1. Number of IO Functions : 0 = no IO present, 1 = Single Function, >1 = Multi-Function Card |
|
234 |
// 2. Memory Present : 1 = Memory is present (if nIO>0, then this is a Combo Card) |
|
235 |
// 3. IO OCR : The OCR for the IO portion of the card (Use ACMD41 for Memory OCR) |
|
236 |
||
237 |
// |
|
238 |
// If the CMD5 response has timed out, then this can't be an SDIO card. |
|
239 |
// We should now continue and try to detect the presence of a memory card. |
|
240 |
||
241 |
if (err & KMMCErrResponseTimeOut) |
|
242 |
{ |
|
243 |
SMF_GOTOS(EStInitMemoryCard) |
|
244 |
} |
|
245 |
||
246 |
// |
|
247 |
// Check the R4 response for the number of IO functions and presence of Memory |
|
248 |
// |
|
249 |
iFunctionCount = 0; |
|
250 |
iMemoryPresent = EFalse; |
|
251 |
||
252 |
TUint32 ioOCR = 0x00000000; |
|
253 |
||
254 |
// |
|
255 |
// No need to test IO_READY yet, as we have not yet set the OCR |
|
256 |
// |
|
257 |
(void)ExtractSendOpCondResponse(TMMC::BigEndian32(s.ResponseP()), iFunctionCount, iMemoryPresent, ioOCR); |
|
258 |
||
259 |
if(iFunctionCount == 0) |
|
260 |
{ |
|
261 |
// F=0, MP=1 => Initialise Memory Controller |
|
262 |
// F=0, MP=0 => Go Inactive |
|
263 |
SMF_GOTOS(iMemoryPresent ? EStInitMemoryCard : EStGoInactive) |
|
264 |
} |
|
265 |
else |
|
266 |
{ |
|
267 |
// |
|
268 |
// IO is ready and there is at least one function present, so now determine a |
|
269 |
// suitable setting for the IO OCR based on the capabilities of our hardware. |
|
270 |
// |
|
271 |
iCurrentOpRange &= ioOCR; |
|
272 |
if (iCurrentOpRange==0) |
|
273 |
{ |
|
274 |
// The card is incompatible with our h/w |
|
275 |
SMF_GOTOS(iMemoryPresent ? EStInitMemoryCard : EStGoInactive) |
|
276 |
} |
|
277 |
} |
|
278 |
||
279 |
// Reset retry count. Timeout to 1S |
|
280 |
iCxPollRetryCount=0; |
|
281 |
||
282 |
//...drop through to next state (EStInitIOSetWorkingOCR) |
|
283 |
||
284 |
SMF_STATE(EStInitIOSetWorkingOCR) |
|
285 |
||
286 |
// EStInitIOSetWorkingOCR : |
|
287 |
// |
|
288 |
// The OCR range is supported by our hardware, so re-issue |
|
289 |
// IO_SEND_OP_COND (CMD5) with our chosen voltage range |
|
290 |
// |
|
291 |
||
292 |
m.SetTraps(KMMCErrResponseTimeOut); |
|
293 |
DSDIOSession::FillAppCommandDesc(Command(), ESDIOCmdOpCond, TMMCArgument(iCurrentOpRange)); |
|
294 |
SMF_INVOKES(ExecCommandSMST, EStInitIOCheckOcrResponse) |
|
295 |
||
296 |
SMF_STATE(EStInitIOCheckOcrResponse) |
|
297 |
||
298 |
// EStInitIOCheckOcrResponse : Verify the response to IO_SEND_OP_COND (CMD5) with ARG=IO_OCR |
|
299 |
// |
|
300 |
// Verifies that the OCR has been successfully accepted by the SDIO Card (within 1 Second) |
|
301 |
||
302 |
if(err == KMMCErrResponseTimeOut) |
|
303 |
{ |
|
304 |
// Previous CMD5 (Arg=0000) worked, but this one failed |
|
305 |
// with no response, so give up and go inactive. |
|
306 |
SMF_GOTOS(EStGoInactive) |
|
307 |
} |
|
308 |
// |
|
309 |
// Check the R4 response for the number of IO functions and presence of Memory |
|
310 |
// |
|
311 |
TUint32 ioOCR = 0x00000000; |
|
312 |
if(ExtractSendOpCondResponse(TMMC::BigEndian32(s.ResponseP()), iFunctionCount, iMemoryPresent, ioOCR) != KErrNotReady) |
|
313 |
{ |
|
314 |
// |
|
315 |
// The OCR has been communicated successfully to the card, |
|
316 |
// so now adjust the hardware's PSU accordingly |
|
317 |
// |
|
318 |
psu->SetVoltage(iCurrentOpRange); |
|
319 |
if (psu->SetState(EPsuOnFull) != KErrNone) |
|
320 |
{ |
|
321 |
return(KMMCErrHardware); |
|
322 |
} |
|
323 |
||
324 |
// We can be sure that this is at least an IO Card |
|
325 |
CardArray().CardP(iCxCardCount)->iFlags |= KSDIOCardIsIOCard; |
|
326 |
||
327 |
// |
|
328 |
// Restore the original error conditions and timeout settings |
|
329 |
// |
|
330 |
iConfig.SetMode( EffectiveModes(s.iConfig) & KMMCModeEnableTimeOutRetry ); |
|
331 |
iConfig.SetPollAttempts(KMMCMaxPollAttempts); |
|
332 |
||
333 |
// |
|
334 |
// Initialise memory if present, otherwise configure the IO Card |
|
335 |
// |
|
336 |
iCxPollRetryCount = 0; // Re-Initialise for RCA poll check |
|
337 |
SMF_GOTOS(iMemoryPresent ? EStInitMemoryCard : EStIssueSendRCA) |
|
338 |
} |
|
339 |
else |
|
340 |
{ |
|
341 |
// |
|
342 |
// IO Not Ready (IORDY=0) - Still powering up |
|
343 |
// |
|
344 |
m.ResetTraps(); |
|
345 |
||
346 |
if ( ++iCxPollRetryCount > iConfig.OpCondBusyTimeout() ) |
|
347 |
{ |
|
348 |
// IO Timeout - Try to initialise memory |
|
349 |
SMF_GOTOS(iMemoryPresent ? EStInitMemoryCard : EStGoInactive) |
|
350 |
} |
|
351 |
||
352 |
SMF_INVOKES(RetryGapTimerSMST, EStInitIOSetWorkingOCR) |
|
353 |
} |
|
354 |
||
355 |
SMF_STATE(EStInitMemoryCard) |
|
356 |
||
357 |
// EStInitMemoryCard |
|
358 |
// |
|
359 |
// Initialise the Memory Card or the Memory portion of a Combo Card |
|
360 |
// |
|
361 |
// If the IO portion of a Combo Card has just been initialised, |
|
362 |
// then the card shall already be stored in the Card Array and the |
|
363 |
// supported voltage settings present in iCurrentOpRange, which |
|
364 |
// shall be used in the SDCARD Initialisation state machine |
|
365 |
||
366 |
m.SetTraps(KMMCErrResponseTimeOut); |
|
367 |
SMF_INVOKES(InitialiseMemoryCardSMST, EStHandleRcaForCardType) |
|
368 |
||
369 |
SMF_STATE(EStHandleRcaForCardType) |
|
370 |
||
371 |
// EStHandleRcaForCardType |
|
372 |
// |
|
373 |
// At this stage, the SDIO controller should have determined if |
|
374 |
// the card contains IO functionality, and the SD controller should |
|
375 |
// have determined the type of memory present. We now combine these |
|
376 |
// two factors to work out the actual card type. |
|
377 |
||
378 |
m.ResetTraps(); |
|
379 |
||
380 |
if(err) |
|
381 |
{ |
|
382 |
// Memory timeout - check next card |
|
383 |
SMF_GOTOS(EStConfigureMemoryCardDone); |
|
384 |
} |
|
385 |
||
386 |
TSDIOCard& ioCard = CardArray().Card(iCxCardCount); |
|
387 |
||
388 |
if(!(ioCard.IsSDCard() || ioCard.IsIOCard())) |
|
389 |
{ |
|
390 |
SMF_GOTOS(EStIssueSetRCA) |
|
391 |
} |
|
392 |
||
393 |
ioCard.iCID=s.ResponseP(); |
|
394 |
iCxPollRetryCount = 0; // Re-Initialise for RCA poll check |
|
395 |
||
396 |
// Drop through to EStIssueSendRCA if the card is an SD or IO card |
|
397 |
||
398 |
SMF_STATE(EStIssueSendRCA) |
|
399 |
||
400 |
// EStIssueSendRCA |
|
401 |
// |
|
402 |
// Sends SEND_RCA (CMD3) in SD Mode |
|
403 |
||
404 |
s.FillCommandDesc(ECmdSetRelativeAddr,0); |
|
405 |
// override default MMC settings |
|
406 |
Command().iSpec.iCommandType=ECmdTypeBCR; |
|
407 |
Command().iSpec.iResponseType=ERespTypeR6; |
|
408 |
m.ResetTraps(); |
|
409 |
||
410 |
SMF_INVOKES(ExecCommandSMST,EStSendRCACheck) |
|
411 |
||
412 |
SMF_STATE(EStIssueSetRCA) |
|
413 |
||
414 |
// EStIssueSetRCA |
|
415 |
// |
|
416 |
// Sends SET_RCA (CMD3) for MMC Cards |
|
417 |
// |
|
418 |
// The card array allocates an RCA, either the old RCA |
|
419 |
// if we have seen this card before, or a new one. |
|
420 |
||
421 |
TRCA rca; |
|
422 |
CardArray().AddCardSDMode(iCxCardCount, s.ResponseP(), &rca); |
|
423 |
||
424 |
// Now assign the new RCA to the card |
|
425 |
s.FillCommandDesc(ECmdSetRelativeAddr,TMMCArgument(rca)); |
|
426 |
SMF_INVOKES(ExecCommandSMST,EStRCADone) |
|
427 |
||
428 |
SMF_STATE(EStSendRCACheck) |
|
429 |
||
430 |
// EStIssueSendRCA |
|
431 |
// |
|
432 |
// Checks response to SEND_RCA (CMD3) and selects the card |
|
433 |
// |
|
434 |
// We need to check that the RCA recieved from the card doesn't clash |
|
435 |
// with any others in this stack. RCA is first 2 bytes of response buffer (in big endian) |
|
436 |
||
437 |
TInt err = KErrNone; |
|
438 |
TSDIOCard& ioCard = CardArray().Card(iCxCardCount); |
|
439 |
||
440 |
TRCA rca=(TUint16)((s.ResponseP()[0]<<8) | s.ResponseP()[1]); |
|
441 |
||
442 |
if(ioCard.IsIOCard()) |
|
443 |
{ |
|
444 |
err = CardArray().AddSDIOCard(iCxCardCount, rca, iFunctionCount); |
|
445 |
} |
|
446 |
else |
|
447 |
{ |
|
448 |
err = CardArray().AddSDCard(iCxCardCount, rca); |
|
449 |
} |
|
450 |
||
451 |
if(err != KErrNone) |
|
452 |
{ |
|
453 |
if(++iCxPollRetryCount<KMaxRCASendLoops) |
|
454 |
{ |
|
455 |
SMF_GOTOS(EStIssueSendRCA) |
|
456 |
} |
|
457 |
else |
|
458 |
{ |
|
459 |
// Memory only cards cannot accept CMD15 until CMD3 has been succesfully |
|
460 |
// recieved and we have entered STBY state. IO Cards can accept RCA=0000 |
|
461 |
SMF_GOTOS(ioCard.IsIOCard() ? EStGoInactive : EStCheckNextCard) |
|
462 |
} |
|
463 |
} |
|
464 |
||
465 |
// ...drop through to next state (EStRCADone) |
|
466 |
||
467 |
SMF_STATE(EStRCADone) |
|
468 |
||
469 |
// Cards is initialised so get its CSD |
|
470 |
m.ResetTraps(); // We are no longer processing any errors |
|
471 |
||
472 |
TSDIOCard& ioCard = CardArray().Card(iCxCardCount); |
|
473 |
||
474 |
if(ioCard.IsIOCard() && !ioCard.IsSDCard()) |
|
475 |
{ |
|
476 |
// IO Only Card - Jump straight to the IO Configuration SM |
|
477 |
SMF_INVOKES(ConfigureIoCardSMST, EStCheckNextCard) |
|
478 |
} |
|
479 |
else |
|
480 |
{ |
|
481 |
// Initialise cards containing memory first, then configure IO. |
|
482 |
// This ensures that the memory portion will have set the |
|
483 |
// bus with via ACMD6 prior to setting the width of the IO controller. |
|
484 |
// The SDIO specification states that the bus width of a combo card |
|
485 |
// shall not change until BOTH controllers have been notified. |
|
486 |
// (ie - ACMD6 + IO_BUS_WIDTH) |
|
487 |
SMF_INVOKES(ConfigureMemoryCardSMST, EStConfigureMemoryCardDone) |
|
488 |
} |
|
489 |
||
490 |
SMF_STATE(EStConfigureMemoryCardDone) |
|
491 |
||
492 |
if(CardArray().Card(iCxCardCount).IsComboCard()) |
|
493 |
{ |
|
494 |
// Combo Card - Need to initialise IO after Memory |
|
495 |
SMF_INVOKES(ConfigureIoCardSMST, EStCheckNextCard) |
|
496 |
} |
|
497 |
||
498 |
SMF_GOTOS(EStCheckNextCard) |
|
499 |
||
500 |
SMF_STATE(EStGoInactive) |
|
501 |
||
502 |
// EStGoInactive |
|
503 |
// |
|
504 |
// Issues CMD15 to enter Inactive state in case of initialisation errors |
|
505 |
// IO Cards accept CMD15 with RCA=0, so it's OK if we enter here before |
|
506 |
// issuing CMD3 - However, this is not true for Memory Only Cards |
|
507 |
||
508 |
TSDIOCard& ioCard = CardArray().Card(iCxCardCount); |
|
509 |
s.FillCommandDesc(ECmdGoInactiveState, TMMCArgument(ioCard.iRCA)); |
|
510 |
SMF_INVOKES(ExecCommandSMST, EStCheckNextCard) |
|
511 |
||
512 |
SMF_STATE(EStCheckNextCard) |
|
513 |
||
514 |
// EStCheckNextCard |
|
515 |
// |
|
516 |
// Checks the next card in the stack (or exits) |
|
517 |
||
518 |
if (++iCxCardCount < (TInt)iMaxCardsInStack) |
|
519 |
{ |
|
520 |
// Check the next card |
|
521 |
SMF_GOTOS(EStInitIOReset) |
|
522 |
} |
|
523 |
else |
|
524 |
{ |
|
525 |
// Set back to broadcast mode and exit |
|
526 |
TRACE2(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOStackPSLCalledAddressCard, reinterpret_cast<TUint32>(this), KBroadcastToAllCards); // @SymTraceDataPublishedTvk |
|
527 |
AddressCard(KBroadcastToAllCards); |
|
528 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOStackPSLAddressCardReturned, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk |
|
529 |
} |
|
530 |
||
531 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOStackAcquireStackReturning, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk |
|
532 |
||
533 |
SMF_END |
|
534 |
} |
|
535 |
||
536 |
||
537 |
TMMCErr DSDIOStack::ConfigureIoCardSM() |
|
538 |
/** |
|
539 |
*/ |
|
540 |
{ |
|
541 |
enum states |
|
542 |
{ |
|
543 |
EStBegin=0, |
|
544 |
EStSetDefaultBusWidth, |
|
545 |
EStGetCommonConfig, |
|
546 |
EStReadFunctionBasicRegisters, |
|
547 |
EStDeselectCard, |
|
548 |
EStDone, |
|
549 |
EStEnd |
|
550 |
}; |
|
551 |
||
552 |
DSDIOSession& s=SDIOSession(); |
|
553 |
||
554 |
SMF_BEGIN |
|
555 |
||
556 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), ">DSDIOStack::ConfigureIoCardSM()")); // @SymTraceDataInternalTechnology |
|
557 |
||
558 |
// Cards is initialised so get its CSD |
|
559 |
m.ResetTraps(); // We are no longer processing any errors |
|
560 |
||
561 |
TSDIOCard* ioCardP = static_cast<TSDIOCard*>(s.iCardP); |
|
562 |
TRACE2(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOStackPSLCalledAddressCard, reinterpret_cast<TUint32>(this), ioCardP->iIndex-1); // @SymTraceDataPublishedTvk |
|
563 |
AddressCard(ioCardP->iIndex-1); |
|
564 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOStackPSLAddressCardReturned, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk |
|
565 |
||
566 |
// Successfully added the card, so now select so we can interrogate further |
|
567 |
TUint32 arg = TUint32(CardArray().Card(iCxCardCount).RCA()) << 16; |
|
568 |
s.FillCommandDesc(ECmdSelectCard, arg); |
|
569 |
SMF_INVOKES(ExecCommandSMST, EStSetDefaultBusWidth) |
|
570 |
||
571 |
SMF_STATE(EStSetDefaultBusWidth) |
|
572 |
||
573 |
// EStSetDefaultBusWidth |
|
574 |
// |
|
575 |
// All commands so far have relied on transfer over CMD line. |
|
576 |
// This state ensures that the card transfers data in 1-bit mode |
|
577 |
// (in-case the card was not powered down for some reason) |
|
578 |
// (This also verifies that the previous steps have succeeded) |
|
579 |
||
580 |
s.iCardP = static_cast<TSDIOCard*>(CardArray().CardP(iCxCardCount)); |
|
581 |
s.FillIoModifyCommandDesc(Command(), 0, KCCCRRegBusInterfaceControl, 0x00, KSDIOCardBicMaskBusWidth, NULL); |
|
582 |
SMF_INVOKES(CIMIoModifySMST, EStGetCommonConfig) |
|
583 |
||
584 |
SMF_STATE(EStGetCommonConfig) |
|
585 |
||
586 |
// EStGetCommonConfig |
|
587 |
// |
|
588 |
// Interrogate the IO capabilities (uses GetIoCommonConfigSM) |
|
589 |
||
590 |
DoSetBusWidth(KSDBusWidth1); |
|
591 |
||
592 |
SMF_INVOKES(CIMGetIoCommonConfigSMST, EStReadFunctionBasicRegisters); |
|
593 |
||
594 |
SMF_STATE(EStReadFunctionBasicRegisters) |
|
595 |
||
596 |
// EStReadFunctionBasicRegisters |
|
597 |
// |
|
598 |
// Interrogate the FBR of each function (uses GetFunctionBasicRegistersSM) |
|
599 |
||
600 |
SMF_INVOKES(CIMReadFunctionBasicRegistersSMST, EStDeselectCard); |
|
601 |
||
602 |
SMF_STATE(EStDeselectCard) |
|
603 |
||
604 |
// EStDeselectCard |
|
605 |
||
606 |
s.FillCommandDesc(ECmdSelectCard, 0); |
|
607 |
SMF_INVOKES(ExecCommandSMST, EStDone) |
|
608 |
||
609 |
SMF_STATE(EStDone) |
|
610 |
||
611 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "<DSDIOStack::ConfigureIoCardSM()")); // @SymTraceDataInternalTechnology |
|
612 |
// All Done |
|
613 |
||
614 |
SMF_END |
|
615 |
} |
|
616 |
||
617 |
||
618 |
TMMCErr DSDIOStack::GetIoCommonConfigSM() |
|
619 |
/** |
|
620 |
This macro interrogates the card and performs some IO initialisation. |
|
621 |
||
622 |
In particular, we use the following during initialisation: |
|
623 |
||
624 |
1. Finds the mandatory CIS Tuples |
|
625 |
2. CCCR Revision, SDIO Revision |
|
626 |
3. LSC - Low Speed Device (used to determine FMax) |
|
627 |
4. 4BLS - If LSC, then this determines if 4-Bit mode is supported |
|
628 |
5. BW[1:0] - Bus Width (Selects between 1 and 4-bit bus) |
|
629 |
6. SHS - Supports High Speed Mode |
|
630 |
||
631 |
The remaining information retained in the card class for further use |
|
632 |
(ie - Supports Multi-Block, CIS Pointer etc..) |
|
633 |
||
634 |
This state machine first searches for the Common Function Extension Tuple |
|
635 |
int the CIS (Which is MANDATORY for SDIO cards) in order to determine |
|
636 |
the FN0 Maximum Block/Byte Count. |
|
637 |
||
638 |
This state machine also makes use of IO_RW_EXTENDED (CMD53) to read the |
|
639 |
entire CCCR, rather than issuing single IO_RW_DIRECT (CMD52) commands. |
|
640 |
This is more efficient than transferring 4x48-Bit commands and the response |
|
641 |
(4 registers is the minimum number of registers that we need to read), and |
|
642 |
also reduces the complexity of the state machine. |
|
643 |
||
644 |
@return TMMCErr Error Code |
|
645 |
*/ |
|
646 |
{ |
|
647 |
enum states |
|
648 |
{ |
|
649 |
EStBegin=0, |
|
650 |
EStGotCommonCisPointer, |
|
651 |
EStFindCommonTuple, |
|
652 |
EStFoundCommonTuple, |
|
653 |
EStGotTupleExtensionType, |
|
654 |
EStGotFn0BlockSize, |
|
655 |
EStGotMaxTranSpeed, |
|
656 |
EStIOReadCCCR, |
|
657 |
EStIOParseCCCR, |
|
658 |
EStSetE4MI, |
|
659 |
EStTestSHS, |
|
660 |
EStSetEHS, |
|
661 |
EStDone, |
|
662 |
EStEnd |
|
663 |
}; |
|
664 |
||
665 |
DSDIOSession& s=SDIOSession(); |
|
666 |
TSDIOCard* ioCardP = static_cast<TSDIOCard*>(CardArray().CardP(iCxCardCount)); |
|
667 |
||
668 |
SMF_BEGIN |
|
669 |
||
670 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), ">DSDIOStack::GetIoCommonConfigSM()")); // @SymTraceDataInternalTechnology |
|
671 |
||
672 |
// EStBegin |
|
673 |
// |
|
674 |
// Start off by reading the common CIS pointer from the CCCR |
|
675 |
||
676 |
ioCardP->iCommonConfig.iCommonCisP = 0; |
|
677 |
s.FillDirectCommandDesc(Command(), ECIMIoReadDirect, 0, KCCCRRegCisPtrLo, 0x00, (TUint8*)&ioCardP->iCommonConfig.iCommonCisP, 3); |
|
678 |
s.iSessionID = (TMMCSessionTypeEnum)ECIMIoReadDirect; |
|
679 |
SMF_INVOKES(CIMIoReadWriteDirectSMST, EStGotCommonCisPointer) |
|
680 |
||
681 |
SMF_STATE(EStGotCommonCisPointer) |
|
682 |
||
683 |
// EStGotCommonCisPointer |
|
684 |
// |
|
685 |
// Verify the CIS pointer and set up for the tuple walk |
|
686 |
||
687 |
if(ioCardP->iCommonConfig.iCommonCisP == 0) |
|
688 |
{ |
|
689 |
// Common CIS Pointer is Mandatory for IO Cards |
|
690 |
SMF_RETURN(KMMCErrNotSupported) |
|
691 |
} |
|
692 |
||
693 |
TSDIOTupleInfo* tupleInfoP = (TSDIOTupleInfo*)iBufCCCR; |
|
694 |
||
695 |
tupleInfoP->iTupleId = KSdioCisTplFunce; |
|
696 |
tupleInfoP->iLength = 0; |
|
697 |
tupleInfoP->iAddress = ioCardP->iCommonConfig.iCommonCisP; |
|
698 |
||
699 |
SMF_STATE(EStFindCommonTuple) |
|
700 |
||
701 |
// EStFindCommonTuple |
|
702 |
// |
|
703 |
// Find the Function 0 Extension Tuple |
|
704 |
||
705 |
// Set up some sensible defaults |
|
706 |
// Low-Speed Card - Maximum speed = 400KHz (SDIO Card Compliance #1-4) |
|
707 |
// High-Speed Card - Maximum speed = 25MHz (SDIO Card Compliance #1-2) |
|
708 |
ioCardP->iCommonConfig.iFn0MaxBlockSize = KDefaultFn0BlockSize; |
|
709 |
ioCardP->iCommonConfig.iMaxTranSpeed = KSDIONoTranSpeed; |
|
710 |
ioCardP->iCommonConfig.iCardCaps |= KSDIOCardCapsBitLSC; |
|
711 |
||
712 |
m.SetTraps(KMMCErrNotFound); |
|
713 |
||
714 |
TSDIOTupleInfo* tupleInfoP = (TSDIOTupleInfo*)iBufCCCR; |
|
715 |
s.FillCommandArgs(0, 0, (TUint8*)tupleInfoP, 0); |
|
716 |
||
717 |
s.iSessionID = (TMMCSessionTypeEnum) ECIMIoFindTuple; |
|
718 |
SMF_INVOKES(CIMIoFindTupleSMST, EStFoundCommonTuple) |
|
719 |
||
720 |
SMF_STATE(EStFoundCommonTuple) |
|
721 |
||
722 |
// EStFoundCommonTuple |
|
723 |
||
724 |
if(err == KMMCErrNotFound) |
|
725 |
{ |
|
726 |
m.ResetTraps(); |
|
727 |
s.PushCommandStack(); |
|
728 |
SMF_GOTOS(EStIOReadCCCR); |
|
729 |
} |
|
730 |
||
731 |
TSDIOTupleInfo* tupleInfoP = (TSDIOTupleInfo*)iBufCCCR; |
|
732 |
||
733 |
if(tupleInfoP->iLength < KSdioCisTplExtCmnLen) |
|
734 |
{ |
|
735 |
// Invalid length for this type of tuple, so try again |
|
736 |
tupleInfoP->iAddress += (KSdioTupleOffsetLink + tupleInfoP->iLength); |
|
737 |
SMF_GOTOS(EStFindCommonTuple) |
|
738 |
} |
|
739 |
||
740 |
m.ResetTraps(); |
|
741 |
||
742 |
// Now read the TPLFE_TYPE value to ensure that this is the Common Tuple |
|
743 |
||
744 |
s.PushCommandStack(); |
|
745 |
s.FillDirectCommandDesc(Command(), ECIMIoReadDirect, 0, tupleInfoP->iAddress + KSdioExtOffIdent, 0x00, NULL); |
|
746 |
s.iSessionID = (TMMCSessionTypeEnum)ECIMIoReadDirect; |
|
747 |
SMF_INVOKES(CIMIoReadWriteDirectSMST, EStGotTupleExtensionType) |
|
748 |
||
749 |
SMF_STATE(EStGotTupleExtensionType) |
|
750 |
||
751 |
// EStGotTupleExtensionType |
|
752 |
// |
|
753 |
// Verify the contents of the extension tuple type code |
|
754 |
||
755 |
const TSDIOResponseR5 response(s.ResponseP()); |
|
756 |
TUint8 readVal = response.Data(); |
|
757 |
||
758 |
s.PopCommandStack(); |
|
759 |
||
760 |
TSDIOTupleInfo* tupleInfoP = (TSDIOTupleInfo*)iBufCCCR; |
|
761 |
||
762 |
if(readVal != KSdioExtCmnIdent) |
|
763 |
{ |
|
764 |
tupleInfoP->iAddress += (KSdioTupleOffsetLink + tupleInfoP->iLength); |
|
765 |
SMF_GOTOS(EStFindCommonTuple) |
|
766 |
} |
|
767 |
||
768 |
// Found the common extension tuple. Now read the FN0 block size. |
|
769 |
||
770 |
s.PushCommandStack(); |
|
771 |
||
772 |
s.FillDirectCommandDesc(Command(), ECIMIoReadDirect, 0, tupleInfoP->iAddress + KSdioExtCmnOffFn0MBSLo, 0x00, (TUint8*)&ioCardP->iCommonConfig.iFn0MaxBlockSize, 2); |
|
773 |
s.iSessionID = (TMMCSessionTypeEnum)ECIMIoReadDirect; |
|
774 |
SMF_INVOKES(CIMIoReadWriteDirectSMST, EStGotFn0BlockSize) |
|
775 |
||
776 |
SMF_STATE(EStGotFn0BlockSize) |
|
777 |
||
778 |
// EStGotFn0BlockSize |
|
779 |
// |
|
780 |
// Validates the FN0 Block Size, and reads the MAX_TRAN_SPEED tuple entry |
|
781 |
||
782 |
if(ioCardP->iCommonConfig.iFn0MaxBlockSize == 0) |
|
783 |
{ |
|
784 |
// This is an invalid block/byte size for Function Zero |
|
785 |
// (This maintains compatability with some early SDIO devices) |
|
786 |
ioCardP->iCommonConfig.iFn0MaxBlockSize = KDefaultFn0BlockSize; |
|
787 |
} |
|
788 |
||
789 |
TSDIOTupleInfo* tupleInfoP = (TSDIOTupleInfo*)iBufCCCR; |
|
790 |
s.FillDirectCommandDesc(Command(), ECIMIoReadDirect, 0, tupleInfoP->iAddress + KSdioExtCmnOffMaxTranSpeed, 0x00, (TUint8*)&ioCardP->iCommonConfig.iMaxTranSpeed, 1); |
|
791 |
s.iSessionID = (TMMCSessionTypeEnum)ECIMIoReadDirect; |
|
792 |
SMF_INVOKES(CIMIoReadWriteDirectSMST, EStGotMaxTranSpeed) |
|
793 |
||
794 |
SMF_STATE(EStGotMaxTranSpeed) |
|
795 |
||
796 |
// EStGotMaxTranSpeed |
|
797 |
// |
|
798 |
// Validates the MAX_TRAN_SPEED tuple entry |
|
799 |
||
800 |
if((ioCardP->iCommonConfig.iMaxTranSpeed & 0x80) != 0) |
|
801 |
{ |
|
802 |
ioCardP->iCommonConfig.iMaxTranSpeed = KSDIONoTranSpeed; |
|
803 |
} |
|
804 |
||
805 |
// ...drop through to next state |
|
806 |
||
807 |
SMF_STATE(EStIOReadCCCR) |
|
808 |
||
809 |
// EStIOReadCCCR |
|
810 |
// |
|
811 |
// Reads the CCCR using IO_RW_EXTENDED (CMD53) command |
|
812 |
// (This will use byte mode as we have not yet read the SMB bit) |
|
813 |
||
814 |
s.PopCommandStack(); |
|
815 |
||
816 |
memclr(iBufCCCR, KSDIOCccrLength); |
|
817 |
||
818 |
s.iCardP = ioCardP; |
|
819 |
s.PushCommandStack(); |
|
820 |
||
821 |
#ifdef SYMBIAN_FUNCTION0_CMD53_NOTSUPPORTED |
|
822 |
s.FillDirectCommandDesc(Command(), ECIMIoReadDirect, 0, 0, 0x00, iBufCCCR, KSDIOCccrLength); |
|
823 |
s.iSessionID = (TMMCSessionTypeEnum)ECIMIoReadDirect; |
|
824 |
SMF_INVOKES(CIMIoReadWriteDirectSMST, EStIOParseCCCR) |
|
825 |
#else |
|
826 |
s.FillExtendedCommandDesc(Command(), ECIMIoReadMultiple, 0, 0, KSDIOCccrLength, iBufCCCR, ETrue); |
|
827 |
SMF_INVOKES(CIMIoReadWriteExtendedSMST,EStIOParseCCCR) |
|
828 |
#endif |
|
829 |
SMF_STATE(EStIOParseCCCR) |
|
830 |
||
831 |
// EStIOParseCCCR |
|
832 |
// |
|
833 |
// Parse the contents of the CCCR and extract the usefil info. |
|
834 |
||
835 |
s.PopCommandStack(); |
|
836 |
||
837 |
TRACE_CCCR_INFO() |
|
838 |
||
839 |
// |
|
840 |
// Store the important information obtained from the CCCR |
|
841 |
// |
|
842 |
ioCardP->iCommonConfig.iRevision = iBufCCCR[KCCCRRegSdioRevision]; |
|
843 |
ioCardP->iCommonConfig.iSDFormatVer = iBufCCCR[KCCCRRegSdSpec]; |
|
844 |
ioCardP->iCommonConfig.iCardCaps = iBufCCCR[KCCCRRegCardCapability]; |
|
845 |
ioCardP->iCommonConfig.iCommonCisP = iBufCCCR[KCCCRRegCisPtrHi] << 16 | iBufCCCR[KCCCRRegCisPtrMid] << 8 | iBufCCCR[KCCCRRegCisPtrLo]; |
|
846 |
||
847 |
// If we have not yet deduced the Maximum Tran. Speed, base it on the device capabilities |
|
848 |
if(ioCardP->iCommonConfig.iMaxTranSpeed == KSDIONoTranSpeed) |
|
849 |
{ |
|
850 |
ioCardP->iCommonConfig.iMaxTranSpeed = (ioCardP->iCommonConfig.iCardCaps & KSDIOCardCapsBitLSC) ? KSDIODefaultLowTranSpeed : KSDIODefaultHighTranSpeed; |
|
851 |
} |
|
852 |
||
853 |
// |
|
854 |
// We can now set the bus width, depending on the values reported in the CCCR |
|
855 |
// (4-Bit Support is Mandatory for High Speed Cards, and optional for Low Speed Cards) |
|
856 |
// |
|
857 |
// This assumes that the memory portion of a Combo Card has been initialised first. |
|
858 |
// |
|
859 |
// ...also disable the CD Pullup using CD_DISABLE bit |
|
860 |
// |
|
861 |
TUint8 busInterfaceControl = (TUint8)((iBufCCCR[KCCCRRegBusInterfaceControl] & ~KSDIOCardBicMaskBusWidth) | KSDIOCardBicBitCdDisable); |
|
862 |
||
863 |
const TUint8 lowSpeed4BitMask = KSDIOCardCapsBitLSC | KSDIOCardCapsBit4BLS; |
|
864 |
if((ioCardP->IsComboCard() && (ioCardP->BusWidth() == 4)) || ioCardP->IsIOCard()) |
|
865 |
{ |
|
866 |
if(((ioCardP->iCommonConfig.iCardCaps & lowSpeed4BitMask) == lowSpeed4BitMask) || |
|
867 |
(!(ioCardP->iCommonConfig.iCardCaps & KSDIOCardCapsBitLSC))) |
|
868 |
{ |
|
869 |
busInterfaceControl |= KSDIOCardBicBitBusWidth4; |
|
870 |
} |
|
871 |
} |
|
872 |
||
873 |
// Gets the High Speed register |
|
874 |
ioCardP->iCommonConfig.iHighSpeed = iBufCCCR[KCCCRRegHighSpeed]; |
|
875 |
||
876 |
// Notify the PSL of the required bus width |
|
877 |
DoSetBusWidth((busInterfaceControl & KSDIOCardBicBitBusWidth4) ? KSDBusWidth4 : KSDBusWidth1); |
|
878 |
||
879 |
// Write to the Bus Interface Control[Offset 7] in the CCCR |
|
880 |
s.PushCommandStack(); |
|
881 |
s.FillDirectCommandDesc(Command(), ECIMIoWriteDirect, 0x00, KCCCRRegBusInterfaceControl, busInterfaceControl, NULL); |
|
882 |
SMF_INVOKES(CIMIoReadWriteDirectSMST, (iBufCCCR[KCCCRRegCardCapability] & KSDIOCardCapsBitS4MI) ? EStSetE4MI : EStTestSHS) |
|
883 |
||
884 |
SMF_STATE(EStSetE4MI) |
|
885 |
||
886 |
// EStSetE4MI |
|
887 |
// |
|
888 |
// Sets the E4MI bit in the CCCR (if the S4MI bit is set) |
|
889 |
||
890 |
const TUint8 cardCapability = (TUint8)(iBufCCCR[KCCCRRegCardCapability] | KSDIOCardCapsBitE4MI); |
|
891 |
s.FillDirectCommandDesc(Command(), ECIMIoWriteDirect, 0x00, KCCCRRegCardCapability, cardCapability, NULL); |
|
892 |
SMF_INVOKES(CIMIoReadWriteDirectSMST, EStTestSHS) |
|
893 |
||
894 |
SMF_STATE(EStTestSHS) |
|
895 |
||
896 |
// EStTestSHS |
|
897 |
// |
|
898 |
// Check the SHS bit in the CCCR |
|
899 |
||
900 |
if (iBufCCCR[KCCCRRegHighSpeed] & KSDIOCardHighSpeedSHS) |
|
901 |
SMF_GOTOS(EStSetEHS) |
|
902 |
else |
|
903 |
SMF_GOTOS(EStDone) |
|
904 |
||
905 |
SMF_STATE(EStSetEHS) |
|
906 |
||
907 |
#if defined(_DISABLE_HIGH_SPEED_MODE_) |
|
908 |
SMF_GOTOS(EStDone) |
|
909 |
#else |
|
910 |
// EStSetEHS |
|
911 |
// |
|
912 |
// Sets the EHS bit in the CCCR (if the SHS bit is set) |
|
913 |
||
914 |
const TUint8 highSpeedMode = (TUint8)(iBufCCCR[KCCCRRegHighSpeed] | KSDIOCardHighSpeedEHS); |
|
915 |
s.FillDirectCommandDesc(Command(), ECIMIoWriteDirect, 0x00, KCCCRRegHighSpeed, highSpeedMode, NULL); |
|
916 |
SMF_INVOKES(CIMIoReadWriteDirectSMST, EStDone) |
|
917 |
#endif |
|
918 |
||
919 |
SMF_STATE(EStDone) |
|
920 |
||
921 |
s.PopCommandStack(); |
|
922 |
||
923 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "<DSDIOStack::GetIoCommonConfigSM()")); // @SymTraceDataInternalTechnology |
|
924 |
||
925 |
SMF_END |
|
926 |
} |
|
927 |
||
928 |
||
929 |
TMMCErr DSDIOStack::ReadFunctionBasicRegistersSM() |
|
930 |
/** |
|
931 |
This macro interrogates the FBR of each function. |
|
932 |
||
933 |
@return TMMCErr Error Code |
|
934 |
*/ |
|
935 |
{ |
|
936 |
enum states |
|
937 |
{ |
|
938 |
EStBegin=0, |
|
939 |
EStReadFBR, |
|
940 |
EStValidateCIS, |
|
941 |
EStValidateFBR, |
|
942 |
EStCheckNextFunction, |
|
943 |
EStDone, |
|
944 |
EStEnd |
|
945 |
}; |
|
946 |
||
947 |
||
948 |
||
949 |
DSDIOSession& s=SDIOSession(); |
|
950 |
TSDIOCard* ioCardP = static_cast<TSDIOCard*>(CardArray().CardP(iCxCardCount)); |
|
951 |
||
952 |
SMF_BEGIN |
|
953 |
||
954 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), ">DSDIOStack::ReadFunctionBasicRegistersSM()")); // @SymTraceDataInternalTechnology |
|
955 |
||
956 |
iFunctionScan = 1; |
|
957 |
||
958 |
if(iFunctionCount == 0) |
|
959 |
{ |
|
960 |
// There are no functions to interrogate, so exit |
|
961 |
SMF_EXIT |
|
962 |
} |
|
963 |
||
964 |
// From here on, iFunctionCount shall be modified so we must use ioCardP->FunctionCount() |
|
965 |
||
966 |
SMF_STATE(EStReadFBR) |
|
967 |
||
968 |
// EStReadFBR |
|
969 |
// |
|
970 |
// Read the Function Basic Register for the current function. |
|
971 |
||
972 |
s.iCardP = ioCardP; |
|
973 |
||
974 |
// Only read FBR upto the CSA Data Pointer and do not read the CSA Data Window. |
|
975 |
// Some non-compliant cards report OUT_OF_RANGE if the CSA Data window is read when CSA is not supported. |
|
976 |
#ifdef SYMBIAN_FUNCTION0_CMD53_NOTSUPPORTED |
|
977 |
s.FillDirectCommandDesc(Command(), ECIMIoReadDirect, 0, KFBRFunctionOffset * iFunctionScan, 0x00, iPSLBuf, KSDIOFbrLength); |
|
978 |
s.iSessionID = (TMMCSessionTypeEnum)ECIMIoReadDirect; |
|
979 |
SMF_INVOKES(CIMIoReadWriteDirectSMST, EStValidateCIS) |
|
980 |
#else |
|
981 |
s.FillExtendedCommandDesc(Command(), ECIMIoReadMultiple, 0, KFBRFunctionOffset * iFunctionScan, KSDIOFbrLength, iPSLBuf, ETrue); |
|
982 |
SMF_INVOKES(CIMIoReadWriteExtendedSMST, EStValidateCIS) |
|
983 |
#endif |
|
984 |
||
985 |
SMF_STATE(EStValidateCIS) |
|
986 |
||
987 |
// EStValidateCIS |
|
988 |
// |
|
989 |
// To cope with early cards that don't report functions in sequence, |
|
990 |
// this checks for a non-zero CIS pointer and a valid tuple chain. |
|
991 |
||
992 |
const TUint32 cisPtr = iPSLBuf[KFBRRegCisPtrHi] << 16 | iPSLBuf[KFBRRegCisPtrMid] << 8 | iPSLBuf[KFBRRegCisPtrLo]; |
|
993 |
||
994 |
if(cisPtr >= KSdioCisAreaMin && cisPtr <= KSdioCisAreaMax) |
|
995 |
{ |
|
996 |
s.FillDirectCommandDesc(Command(), ECIMIoReadDirect, 0, cisPtr, 0x00, NULL); |
|
997 |
s.iSessionID = (TMMCSessionTypeEnum)ECIMIoReadDirect; |
|
998 |
SMF_INVOKES(CIMIoReadWriteDirectSMST, EStValidateFBR) |
|
999 |
} |
|
1000 |
||
1001 |
SMF_GOTOS(EStCheckNextFunction) |
|
1002 |
||
1003 |
SMF_STATE(EStValidateFBR) |
|
1004 |
||
1005 |
// EStValidateFBR |
|
1006 |
// |
|
1007 |
// Validate the first CIS tuple, extracts info from the FBR, and move on to the next function. |
|
1008 |
||
1009 |
const TSDIOResponseR5 response(s.ResponseP()); |
|
1010 |
TUint8 tupleId = response.Data(); |
|
1011 |
||
1012 |
if(tupleId != KSdioCisTplEnd) |
|
1013 |
{ |
|
1014 |
iFunctionCount--; |
|
1015 |
||
1016 |
if (NULL == ioCardP->IoFunction(iFunctionScan)) |
|
1017 |
{ |
|
1018 |
if(ioCardP->CreateFunction(iFunctionScan) != KErrNone) |
|
1019 |
{ |
|
1020 |
SMF_RETURN(KMMCErrGeneral) |
|
1021 |
} |
|
1022 |
} |
|
1023 |
||
1024 |
TSDIOFunction* pFunction = ioCardP->IoFunction(iFunctionScan); |
|
1025 |
||
1026 |
if(pFunction) |
|
1027 |
{ |
|
1028 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "SDIO:Validate Function(%d)",iFunctionScan)); // @SymTraceDataInternalTechnology |
|
1029 |
||
1030 |
pFunction->iCapabilities.iNumber = iFunctionScan; |
|
1031 |
pFunction->iCapabilities.iDevCodeEx = iPSLBuf[KFBRRegExtendedCode]; |
|
1032 |
pFunction->iCapabilities.iType = (TSdioFunctionType)(iPSLBuf[KFBRRegInterfaceCode] & KFBRRegInterfaceCodeMask); |
|
1033 |
pFunction->iCapabilities.iHasCSA = (iPSLBuf[KFBRRegInterfaceCode] & KFBRRegSupportsCSA) ? ETrue : EFalse; |
|
1034 |
pFunction->iCapabilities.iPowerFlags = (TUint8)(iPSLBuf[KFBRRegPowerFlags] & KFBRRegPowerSupportMask); |
|
1035 |
||
1036 |
pFunction->iCisPtr = iPSLBuf[KFBRRegCisPtrHi] << 16 | iPSLBuf[KFBRRegCisPtrMid] << 8 | iPSLBuf[KFBRRegCisPtrLo]; |
|
1037 |
pFunction->iCsaPtr = iPSLBuf[KFBRRegCsaPtrHi] << 16 | iPSLBuf[KFBRRegCsaPtrMid] << 8 | iPSLBuf[KFBRRegCsaPtrLo]; |
|
1038 |
||
1039 |
pFunction->iCurrentBlockSize = 0; |
|
1040 |
||
1041 |
TRACE_FUNCTION_INFO(pFunction) |
|
1042 |
} |
|
1043 |
else |
|
1044 |
{ |
|
1045 |
SMF_RETURN(KMMCErrNotFound) |
|
1046 |
} |
|
1047 |
} |
|
1048 |
||
1049 |
SMF_STATE(EStCheckNextFunction) |
|
1050 |
||
1051 |
// EStCheckNextFunction |
|
1052 |
// |
|
1053 |
// Prepare to read the next function's FBR (unless we have exceeded the maximum possible number) |
|
1054 |
||
1055 |
iFunctionScan++; |
|
1056 |
||
1057 |
if (iFunctionCount && iFunctionScan <= KMaxSDIOFunctions) |
|
1058 |
{ |
|
1059 |
SMF_GOTOS(EStReadFBR) |
|
1060 |
} |
|
1061 |
||
1062 |
SMF_STATE(EStDone) |
|
1063 |
||
1064 |
// EStDone |
|
1065 |
// |
|
1066 |
// Check that we have found all functions and update the card if required. |
|
1067 |
||
1068 |
if(iFunctionCount) |
|
1069 |
{ |
|
1070 |
ioCardP->iFunctionCount = (TUint8)(ioCardP->iFunctionCount - iFunctionCount); |
|
1071 |
} |
|
1072 |
||
1073 |
iFunctionCount = ioCardP->FunctionCount(); |
|
1074 |
||
1075 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "<DSDIOStack::ReadFunctionBasicRegistersSM() FunctionCount: %d",iFunctionCount)); // @SymTraceDataInternalTechnology |
|
1076 |
||
1077 |
SMF_END |
|
1078 |
} |
|
1079 |
||
1080 |
||
1081 |
||
1082 |
inline TInt DSDIOStack::ExtractSendOpCondResponse(TUint32 aResponseR4, TUint8& aFunctionCount, TBool& aMemPresent, TUint32& aIoOCR) |
|
1083 |
/** |
|
1084 |
Checks the contents of the R4 response for the |
|
1085 |
number of IO functions, presence of Memory and OCR bits |
|
1086 |
||
1087 |
@param aResponseR4 The R4 response to be parsed. |
|
1088 |
@param aFunctionCount Number of IO functions. |
|
1089 |
@param aMemPresent ETrue is memory is present, EFalse otherwise |
|
1090 |
@param aIoOCR 24-Bit IO OCR |
|
1091 |
||
1092 |
@return KErrNone if IO is ready, KErrNotReady otherwise |
|
1093 |
*/ |
|
1094 |
{ |
|
1095 |
aFunctionCount = (TUint8)((aResponseR4 & KSDIOFunctionCountMask) >> KSDIOFunctionCountShift); |
|
1096 |
aIoOCR = aResponseR4 & KSDIOOCRMask; |
|
1097 |
aMemPresent = (aResponseR4 & KSDIOMemoryPresent) ? ETrue : EFalse; |
|
1098 |
||
1099 |
if(aResponseR4 & KSDIOReady) |
|
1100 |
{ |
|
1101 |
return(KErrNone); |
|
1102 |
} |
|
1103 |
||
1104 |
// IO Not Ready |
|
1105 |
return(KErrNotReady); |
|
1106 |
} |
|
1107 |
||
1108 |
||
1109 |
EXPORT_C TMMCErr DSDIOStack::CIMIoReadWriteDirectSM() |
|
1110 |
/** |
|
1111 |
Implements the state machine for the IO_RW_DIRECT command (CMD52) |
|
1112 |
@return Standard TMMCErr error code |
|
1113 |
*/ |
|
1114 |
{ |
|
1115 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOStackIoReadWriteDirect, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk |
|
1116 |
||
1117 |
enum states |
|
1118 |
{ |
|
1119 |
EStBegin=0, |
|
1120 |
EStSendCommand, |
|
1121 |
EStCommandSent, |
|
1122 |
EStDone, |
|
1123 |
EStEnd |
|
1124 |
}; |
|
1125 |
||
1126 |
DSDIOSession& s=SDIOSession(); |
|
1127 |
TMMCCommandDesc& cmd = s.Command(); |
|
1128 |
||
1129 |
SMF_BEGIN |
|
1130 |
||
1131 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), ">SDIO:CIMIoReadWriteDirectSM %x",TUint(s.iLastStatus))); // @SymTraceDataInternalTechnology |
|
1132 |
||
1133 |
s.iState |= KMMCSessStateInProgress; |
|
1134 |
||
1135 |
SMF_STATE(EStSendCommand) |
|
1136 |
||
1137 |
SMF_INVOKES(CIMIoIssueCommandCheckResponseSMST, EStCommandSent) |
|
1138 |
||
1139 |
SMF_STATE(EStCommandSent) |
|
1140 |
||
1141 |
if(cmd.iDataMemoryP) |
|
1142 |
{ |
|
1143 |
// Enter here if we are performing RAW operation, or Multi-Byte Read |
|
1144 |
const TSDIOResponseR5 response(s.ResponseP()); |
|
1145 |
*(cmd.iDataMemoryP) = response.Data(); |
|
1146 |
||
1147 |
if(cmd.iTotalLength > 1) |
|
1148 |
{ |
|
1149 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "SDIO:Multi-Byte Read")); // @SymTraceDataInternalTechnology |
|
1150 |
// modify the address parameter to increment the address |
|
1151 |
||
1152 |
cmd.iArgument = (cmd.iArgument & ~KSdioCmdAddressMaskShifted) | |
|
1153 |
((cmd.iArgument + KSdioCmdAddressAIncVal) & KSdioCmdAddressMaskShifted); |
|
1154 |
||
1155 |
cmd.iDataMemoryP++; |
|
1156 |
cmd.iTotalLength--; |
|
1157 |
||
1158 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "SDIO:iDataMemoryP: %d",cmd.iDataMemoryP)); // @SymTraceDataInternalTechnology |
|
1159 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "SDIO:iTotalLength %d",cmd.iTotalLength)); // @SymTraceDataInternalTechnology |
|
1160 |
||
1161 |
SMF_GOTOS(EStSendCommand); |
|
1162 |
} |
|
1163 |
} |
|
1164 |
||
1165 |
// No buffer for data, so only perform one byte transfer and return the data in the response |
|
1166 |
||
1167 |
SMF_STATE(EStDone) |
|
1168 |
||
1169 |
s.iState &= ~KMMCSessStateInProgress; |
|
1170 |
||
1171 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOStackIoReadWriteDirectReturning, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk |
|
1172 |
||
1173 |
SMF_END |
|
1174 |
} |
|
1175 |
||
1176 |
EXPORT_C TMMCErr DSDIOStack::CIMIoReadWriteExtendedSM() |
|
1177 |
/** |
|
1178 |
Implements the state machine for the IO_RW_EXTENDED command (CMD53) |
|
1179 |
@return Standard TMMCErr error code |
|
1180 |
*/ |
|
1181 |
{ |
|
1182 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOStackIoReadWriteExtended, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk |
|
1183 |
||
1184 |
enum states |
|
1185 |
{ |
|
1186 |
EStBegin=0, |
|
1187 |
EStFullPower, |
|
1188 |
EStSetupBlockCommandLo, |
|
1189 |
EStSetupBlockCommandHi, |
|
1190 |
EStIssueFirstBlockCommand, |
|
1191 |
EstProcessChunk, |
|
1192 |
EstSetupNextMemFragment, |
|
1193 |
EStIssueBlockCommand, |
|
1194 |
EStIssueByteCommand, |
|
1195 |
EStCommandSent, |
|
1196 |
EStDone, |
|
1197 |
EStEnd |
|
1198 |
}; |
|
1199 |
||
1200 |
DSDIOSession& s=SDIOSession(); |
|
1201 |
TSDIOCard* cardP = static_cast<TSDIOCard*>(s.iCardP); |
|
1202 |
||
1203 |
SMF_BEGIN |
|
1204 |
||
1205 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), ">DSDIOStack:CIMIoReadWriteExtendedSM %x",TUint(s.iLastStatus))); // @SymTraceDataInternalTechnology |
|
1206 |
||
1207 |
s.iState |= KMMCSessStateInProgress; |
|
1208 |
||
1209 |
// The same command is used for both Read and Write, so determine the dt |
|
1210 |
// direction from the argument supplied (rather than the command table) |
|
1211 |
TMMCCommandDesc& cmd = s.Command(); |
|
1212 |
||
1213 |
if(cmd.iTotalLength == 0) |
|
1214 |
{ |
|
1215 |
SMF_RETURN(KMMCErrArgument) |
|
1216 |
} |
|
1217 |
||
1218 |
cmd.iSpec.iDirection = (cmd.iArgument & KSdioCmdWrite) ? EDirWrite : EDirRead; |
|
1219 |
||
1220 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "DSDIOStack:Direction - %s",((cmd.iArgument & KSdioCmdWrite) ? "Write" : "Read"))); // @SymTraceDataInternalTechnology |
|
1221 |
||
1222 |
const TUint8 functionNumber = s.FunctionNumber(); |
|
1223 |
||
1224 |
if(functionNumber == 0) |
|
1225 |
{ |
|
1226 |
// Function 0 is not stored in the function list as it a |
|
1227 |
// special fixed function with limited capabilities. |
|
1228 |
s.iMaxBlockSize = cardP->iCommonConfig.iFn0MaxBlockSize; |
|
1229 |
} |
|
1230 |
else |
|
1231 |
{ |
|
1232 |
// If we are performing CMD53 on Functions 1:7, then we should have already |
|
1233 |
// parsed the CIS and set up a Maximum Block Size. |
|
1234 |
const TSDIOFunction* functionP = cardP->IoFunction(functionNumber); |
|
1235 |
||
1236 |
if(functionP == NULL) |
|
1237 |
{ |
|
1238 |
SMF_RETURN(KMMCErrNotSupported) |
|
1239 |
} |
|
1240 |
||
1241 |
s.iMaxBlockSize = functionP->Capabilities().iMaxBlockSize; |
|
1242 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "DSDIOStack:BlockSize:%d)", s.iMaxBlockSize)); // @SymTraceDataInternalTechnology |
|
1243 |
} |
|
1244 |
||
1245 |
// maxBlockSize is the maximum block size (block mode), or byte count (byte mode) |
|
1246 |
// so a value of zero is invalid (this is obtained from the CIS). |
|
1247 |
if(s.iMaxBlockSize == 0) |
|
1248 |
{ |
|
1249 |
SMF_RETURN(KMMCErrNotSupported) |
|
1250 |
} |
|
1251 |
||
1252 |
// Ensure that the block size used is supported by the hardware |
|
1253 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOStackPSLCalledMaxBlockSize, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk |
|
1254 |
const TUint32 pslMaxBlockSize = MaxBlockSize(); |
|
1255 |
TRACE2(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOStackPSLMaxBlockSizeReturned, reinterpret_cast<TUint32>(this), pslMaxBlockSize); // @SymTraceDataPublishedTvk |
|
1256 |
if(s.iMaxBlockSize > pslMaxBlockSize) |
|
1257 |
{ |
|
1258 |
s.iMaxBlockSize = pslMaxBlockSize; |
|
1259 |
} |
|
1260 |
||
1261 |
s.iNumBlocks = (cmd.iTotalLength / s.iMaxBlockSize); |
|
1262 |
s.iNumBytes = cmd.iTotalLength - (s.iNumBlocks * s.iMaxBlockSize); |
|
1263 |
||
1264 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "DSDIOStack:Blocks:%d, Bytes:%d)", s.iNumBlocks, s.iNumBytes)); // @SymTraceDataInternalTechnology |
|
1265 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "DSDIOStack:Total Bytes:%d)", cmd.iTotalLength)); // @SymTraceDataInternalTechnology |
|
1266 |
||
1267 |
// Disable Preemption until we have set the bus width |
|
1268 |
s.iConfig.RemoveMode(KMMCModeEnablePreemption); |
|
1269 |
s.PushCommandStack(); |
|
1270 |
||
1271 |
// Request BusWidth of 4 Bits |
|
1272 |
s.FillCommandArgs(4, 0, NULL, 0); |
|
1273 |
m.SetTraps(KMMCErrNotSupported); |
|
1274 |
||
1275 |
SMF_INVOKES(CIMIoSetBusWidthSMST, EStFullPower) |
|
1276 |
||
1277 |
SMF_STATE(EStFullPower) |
|
1278 |
||
1279 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "DSDIOStack:EstFullPower")); // @SymTraceDataInternalTechnology |
|
1280 |
||
1281 |
m.ResetTraps(); |
|
1282 |
s.PopCommandStack(); |
|
1283 |
||
1284 |
if(err == KMMCErrNone || err == KMMCErrNotSupported) |
|
1285 |
{ |
|
1286 |
SMF_GOTOS(((cardP->iCommonConfig.iCardCaps & KSDIOCardCapsBitSMB) && (s.iNumBlocks > 1)) ? EStSetupBlockCommandLo : EstProcessChunk) |
|
1287 |
} |
|
1288 |
||
1289 |
SMF_RETURN(err) |
|
1290 |
||
1291 |
SMF_STATE(EStSetupBlockCommandLo) |
|
1292 |
||
1293 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "DSDIOStack:EstSetupBlockCommandLo")); // @SymTraceDataInternalTechnology |
|
1294 |
||
1295 |
// EStSetupBlockCommand |
|
1296 |
// |
|
1297 |
// Sets up the block length (low byte) for CMD53 if not already set |
|
1298 |
||
1299 |
// There is no need to set the block size if already set |
|
1300 |
const TUint8 functionNumber = s.FunctionNumber(); |
|
1301 |
const TSDIOFunction* functionP = cardP->IoFunction(s.FunctionNumber()); |
|
1302 |
||
1303 |
const TUint16* currentBlockSizeP = (functionNumber == 0) ? &cardP->iCommonConfig.iCurrentBlockSize : &functionP->iCurrentBlockSize; |
|
1304 |
||
1305 |
const TUint16 bsMatch = (TUint16)(*currentBlockSizeP ^ s.iMaxBlockSize); |
|
1306 |
||
1307 |
if(bsMatch == 0x0000) |
|
1308 |
{ |
|
1309 |
s.PushCommandStack(); |
|
1310 |
SMF_GOTOS(EStIssueFirstBlockCommand) |
|
1311 |
} |
|
1312 |
||
1313 |
if(bsMatch & 0x00FF) |
|
1314 |
{ |
|
1315 |
const TUint8 blockSizeLo = (TUint8)(s.iMaxBlockSize & 0xFF); |
|
1316 |
const TUint32 bslAddr = (KFBRFunctionOffset * functionNumber) + KCCCRRegFN0BlockSizeLo; // OK for Function0 and 1:7 |
|
1317 |
||
1318 |
s.PushCommandStack(); |
|
1319 |
s.FillDirectCommandDesc(Command(), ECIMIoWriteDirect, 0x00, bslAddr, blockSizeLo, (TUint8*)currentBlockSizeP); |
|
1320 |
SMF_INVOKES(CIMIoReadWriteDirectSMST, EStSetupBlockCommandHi) |
|
1321 |
} |
|
1322 |
||
1323 |
s.PushCommandStack(); // ...to match up with the Pop in EStSetupBlockCommandHi |
|
1324 |
||
1325 |
// .. drop through to set Block Length (High) |
|
1326 |
||
1327 |
SMF_STATE(EStSetupBlockCommandHi) |
|
1328 |
||
1329 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "DSDIOStack:EstSetupBlockCommandHi")); // @SymTraceDataInternalTechnology |
|
1330 |
||
1331 |
// EStSetupBlockCommand |
|
1332 |
// |
|
1333 |
// Sets up the block length (high byte) for CMD53 if not already set |
|
1334 |
||
1335 |
s.PopCommandStack(); |
|
1336 |
||
1337 |
const TUint8 functionNumber = s.FunctionNumber(); |
|
1338 |
const TSDIOFunction* functionP = cardP->IoFunction(functionNumber); |
|
1339 |
||
1340 |
const TUint16* currentBlockSizeP = (functionNumber == 0) ? &cardP->iCommonConfig.iCurrentBlockSize : &functionP->iCurrentBlockSize; |
|
1341 |
||
1342 |
if((*currentBlockSizeP ^ s.iMaxBlockSize) & 0xFF00) |
|
1343 |
{ |
|
1344 |
const TUint8 blockSizeHi = (TUint8)((s.iMaxBlockSize >> 8) & 0xFF); |
|
1345 |
const TUint32 bshAddr = (KFBRFunctionOffset * functionNumber) + KCCCRRegFN0BlockSizeHi; // OK for Function0 and 1:7 |
|
1346 |
||
1347 |
s.PushCommandStack(); |
|
1348 |
s.FillDirectCommandDesc(Command(), ECIMIoWriteDirect, 0x00, bshAddr, blockSizeHi, ((TUint8*)currentBlockSizeP)+1); |
|
1349 |
SMF_INVOKES(CIMIoReadWriteDirectSMST, EStIssueFirstBlockCommand) |
|
1350 |
} |
|
1351 |
||
1352 |
s.PushCommandStack(); // ...to match up with the Pop in EStIssueFirstBlockCommand |
|
1353 |
||
1354 |
// .. drop through if high byte OK |
|
1355 |
||
1356 |
SMF_STATE(EStIssueFirstBlockCommand) |
|
1357 |
||
1358 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "DSDIOStack:EstIssueFirstBlockCommand")); // @SymTraceDataInternalTechnology |
|
1359 |
||
1360 |
s.PopCommandStack(); |
|
1361 |
||
1362 |
const TUint8 functionNumber = s.FunctionNumber(); |
|
1363 |
const TSDIOFunction* functionP = cardP->IoFunction(functionNumber); |
|
1364 |
||
1365 |
const TUint16 currentBlockSize = (functionNumber == 0) ? cardP->iCommonConfig.iCurrentBlockSize : functionP->iCurrentBlockSize; |
|
1366 |
if(currentBlockSize != s.iMaxBlockSize) |
|
1367 |
{ |
|
1368 |
// If the block size could not be set, then disable future Block Mode transfers |
|
1369 |
// to avoid performing these tests again (this is a compatability check issue) |
|
1370 |
cardP->iCommonConfig.iCardCaps &= ~KSDIOCardCapsBitSMB; |
|
1371 |
} |
|
1372 |
// .. drop through |
|
1373 |
||
1374 |
SMF_STATE(EstProcessChunk) |
|
1375 |
||
1376 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "DSDIOStack:EstProcessChunk")); // @SymTraceDataInternalTechnology |
|
1377 |
s.iConfig.SetMode(KMMCModeEnablePreemption); |
|
1378 |
||
1379 |
TMMCCommandDesc& cmd = s.Command(); |
|
1380 |
s.iCrrFrgRmn = cmd.iTotalLength; |
|
1381 |
||
1382 |
if((cmd.iFlags & KMMCCmdFlagDMARamValid) && (s.iChunk != NULL)) |
|
1383 |
{ |
|
1384 |
//Chunk Params available for this command |
|
1385 |
||
1386 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "DSDIOStack:SharedChunk Opened")); // @SymTraceDataInternalTechnology |
|
1387 |
||
1388 |
TUint32 pageSize = Kern::RoundToPageSize(1); |
|
1389 |
||
1390 |
// calculate number of possible physical pages |
|
1391 |
// +1 for rounding & +1 for physical page spanning |
|
1392 |
TUint32 totalPages = (cmd.iTotalLength/pageSize)+2; |
|
1393 |
||
1394 |
// Allocate array for list of physical pages |
|
1395 |
TUint32* physicalPages = new TPhysAddr[totalPages]; |
|
1396 |
if(!physicalPages) |
|
1397 |
{ |
|
1398 |
SMF_RETURN(KMMCErrGeneral) |
|
1399 |
} |
|
1400 |
||
1401 |
TInt r = KErrNone; |
|
1402 |
TUint32 offset = (TUint32)cmd.iDataMemoryP; //for chunk based transfer DataMemory pointer contains the chunk offset |
|
1403 |
TLinAddr kernAddr; |
|
1404 |
TUint32 mapAttr; |
|
1405 |
TUint32 physAddr; |
|
1406 |
||
1407 |
// Query Physical Structure of chunk |
|
1408 |
r = Kern::ChunkPhysicalAddress(s.iChunk, offset, cmd.iTotalLength, kernAddr, mapAttr, physAddr, physicalPages); |
|
1409 |
||
1410 |
if(r==KErrNone) |
|
1411 |
{ |
|
1412 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "DSDIOStack:Contiguous RAM Pages")); // @SymTraceDataInternalTechnology |
|
1413 |
cmd.iDataMemoryP = (TUint8*)kernAddr; |
|
1414 |
||
1415 |
//No need to retain knowledge of underlying memory structure |
|
1416 |
delete [] physicalPages; |
|
1417 |
} |
|
1418 |
||
1419 |
#ifndef __FRAGMENTED_RAM_SUPPORT |
|
1420 |
else |
|
1421 |
{ |
|
1422 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "DSDIOStack:Fragmented RAM Pages - Not supported")); // @SymTraceDataInternalTechnology |
|
1423 |
||
1424 |
delete [] physicalPages; |
|
1425 |
||
1426 |
SMF_RETURN(KMMCErrNotSupported) |
|
1427 |
} |
|
1428 |
#else |
|
1429 |
else if(r==1) |
|
1430 |
{ |
|
1431 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "DSDIOStack:Fragmented RAM Pages (%d pages)", totalPages)); // @SymTraceDataInternalTechnology |
|
1432 |
||
1433 |
// Need to determine the fragments and their sizes |
|
1434 |
// RAM pages may all be seperate so alloc a big enough array |
|
1435 |
delete [] s.iFrgPgs; |
|
1436 |
s.iFrgPgs = new TSDIOFragInfo[totalPages]; |
|
1437 |
if(!s.iFrgPgs) |
|
1438 |
{ |
|
1439 |
delete [] physicalPages; |
|
1440 |
SMF_RETURN(KMMCErrGeneral) |
|
1441 |
} |
|
1442 |
||
1443 |
TUint currFrg = 0; |
|
1444 |
||
1445 |
//Addresses must be converted back to virtual for the PSL |
|
1446 |
s.iFrgPgs[currFrg].iAddr = (TUint8*)kernAddr; |
|
1447 |
//Calculate the odd size for the first fragment |
|
1448 |
s.iFrgPgs[currFrg].iSize = pageSize-(offset%pageSize); |
|
1449 |
||
1450 |
for(TUint i=1; i < totalPages; i++) |
|
1451 |
{ |
|
1452 |
//Check if RAM pages are physically adjacent |
|
1453 |
if ((physicalPages[i-1] + pageSize) == physicalPages[i]) |
|
1454 |
{ |
|
1455 |
// Pages are contiguous, |
|
1456 |
s.iFrgPgs[currFrg].iSize += pageSize; |
|
1457 |
} |
|
1458 |
else |
|
1459 |
{ |
|
1460 |
// Pages not contiguous |
|
1461 |
++currFrg; |
|
1462 |
//Calculate virtual memory address of next fragment |
|
1463 |
s.iFrgPgs[currFrg].iAddr = s.iFrgPgs[currFrg-1].iAddr+s.iFrgPgs[currFrg-1].iSize; |
|
1464 |
s.iFrgPgs[currFrg].iSize = pageSize; |
|
1465 |
} |
|
1466 |
} |
|
1467 |
||
1468 |
s.iCrrFrg = 0; |
|
1469 |
cmd.iDataMemoryP = s.iFrgPgs[0].iAddr; |
|
1470 |
s.iCrrFrgRmn = cmd.iTotalLength = s.iFrgPgs[0].iSize; |
|
1471 |
||
1472 |
delete [] physicalPages; |
|
1473 |
} |
|
1474 |
else |
|
1475 |
{ |
|
1476 |
delete [] physicalPages; |
|
1477 |
SMF_RETURN(KMMCErrGeneral) |
|
1478 |
} |
|
1479 |
#endif //__FRAGMENTED_RAM_SUPPORT |
|
1480 |
} |
|
1481 |
else |
|
1482 |
{ |
|
1483 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "DSDIOStack:Not a Chunk")); // @SymTraceDataInternalTechnology |
|
1484 |
s.iChunk = NULL; |
|
1485 |
//Ensure DMAable flag not set |
|
1486 |
cmd.iFlags &= ~KMMCCmdFlagDMARamValid; |
|
1487 |
} //END if (KMMCCmdFlagDMARamValid) |
|
1488 |
||
1489 |
// ..drop through |
|
1490 |
||
1491 |
SMF_STATE(EstSetupNextMemFragment) |
|
1492 |
||
1493 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "DSDIOStack:EstSetupNextMemFragment")); // @SymTraceDataInternalTechnology |
|
1494 |
||
1495 |
#ifdef __FRAGMENTED_RAM_SUPPORT |
|
1496 |
//Determine if fragment full and next fragment need to be allocated |
|
1497 |
if ((s.iFrgPgs!=NULL) && (s.iCrrFrgRmn == 0)) |
|
1498 |
{ |
|
1499 |
// Fragment full - Need to setup next page |
|
1500 |
TMMCCommandDesc& cmd = s.Command(); |
|
1501 |
s.iCrrFrg++; |
|
1502 |
cmd.iDataMemoryP = s.iFrgPgs[s.iCrrFrg].iAddr; |
|
1503 |
s.iCrrFrgRmn = s.iFrgPgs[s.iCrrFrg].iSize; |
|
1504 |
} |
|
1505 |
#endif //__FRAGMENTED_RAM_SUPPORT |
|
1506 |
||
1507 |
//Determine what the next transfer type is |
|
1508 |
if ((cardP->iCommonConfig.iCardCaps & KSDIOCardCapsBitSMB) && (s.iNumBlocks > 1)) |
|
1509 |
{ |
|
1510 |
||
1511 |
#ifdef __FRAGMENTED_RAM_SUPPORT |
|
1512 |
//Determine if fragment has sufficient space for block transfers |
|
1513 |
if (s.iFrgPgs!=NULL) |
|
1514 |
{ |
|
1515 |
if (s.iCrrFrgRmn < s.iMaxBlockSize ) |
|
1516 |
{ |
|
1517 |
//Insufficent space left... |
|
1518 |
SMF_GOTOS(EStIssueByteCommand) |
|
1519 |
} |
|
1520 |
} |
|
1521 |
#endif //__FRAGMENTED_RAM_SUPPORT |
|
1522 |
||
1523 |
SMF_GOTOS(EStIssueBlockCommand) |
|
1524 |
} |
|
1525 |
||
1526 |
SMF_GOTOS(EStIssueByteCommand) |
|
1527 |
||
1528 |
||
1529 |
SMF_STATE(EStIssueBlockCommand) |
|
1530 |
||
1531 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "DSDIOStack:EstIssueBlockCommand")); // @SymTraceDataInternalTechnology |
|
1532 |
||
1533 |
// Performs data transfer using CMD53 in Block Mode. This shall be invoked |
|
1534 |
// several times if the data cannot be transferred using a single command. |
|
1535 |
||
1536 |
TUint32 blocksThisTransfer = 0; |
|
1537 |
||
1538 |
// Still have blocks worth of data to transfer. |
|
1539 |
blocksThisTransfer = Min( (s.iNumBlocks & KSdioCmdCountMask),(s.iCrrFrgRmn/s.iMaxBlockSize)); |
|
1540 |
s.iNumBlocks -= blocksThisTransfer; |
|
1541 |
s.iCrrFrgRmn -= (blocksThisTransfer * s.iMaxBlockSize); |
|
1542 |
||
1543 |
TMMCCommandDesc& cmd = s.Command(); |
|
1544 |
||
1545 |
TUint32 arg = cmd.iArgument; |
|
1546 |
arg &= ~KSdioCmdCountMask; |
|
1547 |
arg |= (blocksThisTransfer & KSdioCmdCountMask); // Set the new block count |
|
1548 |
arg |= KSdioCmdBlockMode; // Ensure Block Mode |
|
1549 |
cmd.iArgument = arg; |
|
1550 |
||
1551 |
// This is a Multi-Block command, so ensure that iBlockLength and iTotalLength |
|
1552 |
// are calculated correctly for the underlying controller. |
|
1553 |
cmd.iBlockLength = s.iMaxBlockSize; |
|
1554 |
cmd.iTotalLength = blocksThisTransfer * s.iMaxBlockSize; |
|
1555 |
||
1556 |
// ...send the command |
|
1557 |
SMF_INVOKES(CIMIoIssueCommandCheckResponseSMST, EStCommandSent) |
|
1558 |
||
1559 |
||
1560 |
SMF_STATE(EStIssueByteCommand) |
|
1561 |
||
1562 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "DSDIOStack:EstIssueByteCommand")); // @SymTraceDataInternalTechnology |
|
1563 |
||
1564 |
// EStIssueByteCommand |
|
1565 |
// |
|
1566 |
// Performs data transfer using CMD53 in Byte Mode. This is used for transfering |
|
1567 |
// 'blocks' of data (if block mode is not supported) and for transferring the last |
|
1568 |
// non-block-aligned bytes after block mode transfer. |
|
1569 |
||
1570 |
TUint32 bytesThisTransfer = 0; |
|
1571 |
if(s.iNumBlocks && (s.iCrrFrgRmn >= s.iMaxBlockSize)) |
|
1572 |
{ |
|
1573 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "Still have blocks worth of data to transfer...")); // @SymTraceDataInternalTechnology |
|
1574 |
// Still have blocks worth of data to transfer... |
|
1575 |
bytesThisTransfer = s.iMaxBlockSize; |
|
1576 |
--s.iNumBlocks; |
|
1577 |
} |
|
1578 |
else if(s.iNumBlocks && (s.iCrrFrgRmn < s.iMaxBlockSize)) |
|
1579 |
{ |
|
1580 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "Still have blocks worth of data to transfer...but not enough room in the fragment")); // @SymTraceDataInternalTechnology |
|
1581 |
// Still have blocks worth of data to transfer...but not enough room in the fragment |
|
1582 |
// Use whats left in the fragment |
|
1583 |
bytesThisTransfer = s.iCrrFrgRmn; |
|
1584 |
if (s.iCrrFrgRmn > s.iNumBytes) |
|
1585 |
{ |
|
1586 |
--s.iNumBlocks; |
|
1587 |
s.iNumBytes += (s.iMaxBlockSize-s.iCrrFrgRmn); |
|
1588 |
} |
|
1589 |
else |
|
1590 |
{ |
|
1591 |
s.iNumBytes -= s.iCrrFrgRmn; |
|
1592 |
} |
|
1593 |
} |
|
1594 |
else |
|
1595 |
{ |
|
1596 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "Still have partial blocks worth of data to transfer..")); // @SymTraceDataInternalTechnology |
|
1597 |
// Still have partial blocks worth of data to transfer.. |
|
1598 |
bytesThisTransfer = Min(s.iNumBytes,s.iCrrFrgRmn); |
|
1599 |
s.iNumBytes -= bytesThisTransfer; |
|
1600 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "s.iNumBytes %d",s.iNumBytes)); // @SymTraceDataInternalTechnology |
|
1601 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "bytesThisTransfer %d",bytesThisTransfer)); // @SymTraceDataInternalTechnology |
|
1602 |
} |
|
1603 |
||
1604 |
s.iCrrFrgRmn -= bytesThisTransfer; |
|
1605 |
||
1606 |
TMMCCommandDesc& cmd = s.Command(); |
|
1607 |
||
1608 |
TUint32 arg = cmd.iArgument; |
|
1609 |
arg &= ~KSdioCmdCountMask; |
|
1610 |
arg |= (bytesThisTransfer & KSdioCmdCountMask); // Set the new transfer length |
|
1611 |
arg &= ~KSdioCmdBlockMode; // Ensure Byte Mode |
|
1612 |
cmd.iArgument = arg; |
|
1613 |
||
1614 |
// This is not a Multi-Block command (rather, it is a multiple issue of CMD53) |
|
1615 |
// so ensure that iBlockLength == iTotalLength for consistency. |
|
1616 |
cmd.iBlockLength = bytesThisTransfer; |
|
1617 |
cmd.iTotalLength = bytesThisTransfer; |
|
1618 |
||
1619 |
// ...send the command |
|
1620 |
SMF_INVOKES(CIMIoIssueCommandCheckResponseSMST, EStCommandSent) |
|
1621 |
||
1622 |
SMF_STATE(EStCommandSent) |
|
1623 |
||
1624 |
if ((s.iNumBlocks <= 0) && (s.iNumBytes <= 0)) |
|
1625 |
{ |
|
1626 |
// No Data left |
|
1627 |
SMF_GOTOS(EStDone); |
|
1628 |
} |
|
1629 |
||
1630 |
// Increment the data pointer (iTotalLength is the number of bytes transferred if the last command |
|
1631 |
// was a byte mode transfer, or nBlocks*blockSize if it was a Block Mode transfer) |
|
1632 |
TMMCCommandDesc& cmd = s.Command(); |
|
1633 |
||
1634 |
cmd.iDataMemoryP += cmd.iTotalLength; |
|
1635 |
||
1636 |
if((cmd.iArgument & KSdioCmdAutoInc) == KSdioCmdAutoInc) |
|
1637 |
{ |
|
1638 |
// ...and also increment the start address for the next byte/block transfer |
|
1639 |
||
1640 |
const TUint32 KBlockAddressIncrementShifted = (cmd.iTotalLength << KSdioCmdAddressShift); |
|
1641 |
||
1642 |
cmd.iArgument = (cmd.iArgument & ~KSdioCmdAddressMaskShifted) | |
|
1643 |
((cmd.iArgument + KBlockAddressIncrementShifted) & KSdioCmdAddressMaskShifted); |
|
1644 |
} |
|
1645 |
||
1646 |
// Data still to be transmitted |
|
1647 |
SMF_GOTOS(EstSetupNextMemFragment); |
|
1648 |
||
1649 |
SMF_STATE(EStDone) |
|
1650 |
||
1651 |
//Clean up memory allocated for physical pages if necessary |
|
1652 |
delete [] s.iFrgPgs; |
|
1653 |
s.iFrgPgs = NULL; |
|
1654 |
||
1655 |
s.iState &= ~KMMCSessStateInProgress; |
|
1656 |
||
1657 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOStackIoReadWriteExtended, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk |
|
1658 |
||
1659 |
SMF_END |
|
1660 |
||
1661 |
} |
|
1662 |
||
1663 |
||
1664 |
TMMCErr DSDIOStack::CIMIoIssueCommandCheckResponseSM() |
|
1665 |
/** |
|
1666 |
Implements the state machine for the SDIO command sending (CMD52, CMD53) |
|
1667 |
@return Standard TMMCErr error code : KMMCErrResponseTimeOut |
|
1668 |
KMMCErrDataTimeOut |
|
1669 |
KMMCErrBusInconsistent |
|
1670 |
KMMCErrArgument |
|
1671 |
KMMCErrDataCRC |
|
1672 |
KMMCErrGeneral |
|
1673 |
*/ |
|
1674 |
{ |
|
1675 |
enum states |
|
1676 |
{ |
|
1677 |
EStBegin=0, |
|
1678 |
EStRetry, |
|
1679 |
EStCommandSent, |
|
1680 |
EStRecover, |
|
1681 |
EStDone, |
|
1682 |
EStEnd |
|
1683 |
}; |
|
1684 |
||
1685 |
DSDIOSession& s=SDIOSession(); |
|
1686 |
TMMCCommandDesc& cmd = s.Command(); |
|
1687 |
||
1688 |
SMF_BEGIN |
|
1689 |
||
1690 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), ">SDIO:CIMIoIssueCommandCheckResponseSM %x",TUint(s.iLastStatus))); // @SymTraceDataInternalTechnology |
|
1691 |
||
1692 |
__ASSERT_ALWAYS(cmd.iCommand == ECmd52 || cmd.iCommand == ECmd53, DSDIOStack::Panic(DSDIOStack::ESDIOStackBadCommand)); |
|
1693 |
||
1694 |
s.iState |= KMMCSessStateInProgress; |
|
1695 |
||
1696 |
SMF_STATE(EStRetry) |
|
1697 |
||
1698 |
// EStRetry |
|
1699 |
// |
|
1700 |
// Retries the current command in the case of an R5 response error. |
|
1701 |
// |
|
1702 |
// Note that errors such as CRC and Timeout errors are handled by the |
|
1703 |
// underlying controller (via ExecCommandSMST). This only handles |
|
1704 |
// the errors specifically reported in the R5 response. |
|
1705 |
// |
|
1706 |
// Expects the command paramaters to have been set up previously |
|
1707 |
// (ie - by using FillDirectCommandDesc or similar method) |
|
1708 |
||
1709 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "SDIO:Issue SDIO Command (cmd:%d arg:0x%x)", cmd.iCommand, TUint32(cmd.iArgument))); // @SymTraceDataInternalTechnology |
|
1710 |
||
1711 |
// Prevent the MMC stack from retrying - not recommended for IO based devices |
|
1712 |
||
1713 |
iConfig.RemoveMode(KMMCModeEnableRetries); |
|
1714 |
||
1715 |
m.SetTraps(KMMCErrStatus | KMMCErrDataTimeOut | KMMCErrResponseTimeOut | KMMCErrDataCRC | KMMCErrAbort); |
|
1716 |
||
1717 |
SMF_INVOKES(ExecCommandSMST, EStCommandSent) |
|
1718 |
||
1719 |
SMF_STATE(EStCommandSent) |
|
1720 |
||
1721 |
// EStCommandSent |
|
1722 |
// |
|
1723 |
// Checks the R5 response and performs the necessary error handling |
|
1724 |
||
1725 |
s.iConfig.SetMode(KMMCModeEnablePreemption); |
|
1726 |
||
1727 |
m.ResetTraps(); |
|
1728 |
||
1729 |
// The PSL should return with one of the following errors: |
|
1730 |
// |
|
1731 |
// KMMCErrResponseTimeOut : Response has timed out |
|
1732 |
// KMMCErrDataTimeOut : Data transmission has timed out |
|
1733 |
// KMMCErrStatus : General status error (to be decoded) |
|
1734 |
||
1735 |
if (err & KMMCErrResponseTimeOut) |
|
1736 |
{ |
|
1737 |
// This could occur for any command, and it is unsafe to automatically retry |
|
1738 |
// as we don't know how the specific function will behave. However, we can be |
|
1739 |
// sure about specific areas of Function 0 (apart from the CSA access windows) |
|
1740 |
||
1741 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "SDIO:KMMCErrResponseTimeout")); // @SymTraceDataInternalTechnology |
|
1742 |
||
1743 |
SMF_RETURN(KMMCErrResponseTimeOut) |
|
1744 |
} |
|
1745 |
||
1746 |
const TMMCErr KMMCErrAbortCondition = KMMCErrDataTimeOut | KMMCErrDataCRC; |
|
1747 |
||
1748 |
if ((err & KMMCErrAbortCondition) && (cmd.iCommand == ECmd53)) |
|
1749 |
{ |
|
1750 |
// This occurs only for CMD53. In this case, issue an IO_ABORT using CMD52 |
|
1751 |
// and use the response to determine the possible timeout reason. |
|
1752 |
// |
|
1753 |
// The PSL may set KMMCErrAbort to indicate that the transfer has already |
|
1754 |
// been aborted at the generic layer, or the card has stoped data transfer already |
|
1755 |
||
1756 |
if(err & KMMCErrAbort) |
|
1757 |
{ |
|
1758 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "SDIO:IO_ABORT Issued at PSL")); // @SymTraceDataInternalTechnology |
|
1759 |
SMF_RETURN(err & ~KMMCErrAbort) |
|
1760 |
} |
|
1761 |
else |
|
1762 |
{ |
|
1763 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "SDIO:Issue IO_ABORT")); // @SymTraceDataInternalTechnology |
|
1764 |
||
1765 |
// Store the last error in iExecNotHandle (we need this later if the abort succeeds) |
|
1766 |
Command().iExecNotHandle = err; |
|
1767 |
||
1768 |
// Ensure that only this command gets through to the controller |
|
1769 |
s.iConfig.RemoveMode(KMMCModeEnablePreemption); |
|
1770 |
||
1771 |
s.PushCommandStack(); |
|
1772 |
s.FillDirectCommandDesc(Command(), ECIMIoWriteDirect, 0x00, KCCCRRegIoAbort, s.FunctionNumber(), NULL); |
|
1773 |
m.SetTraps(KMMCErrAll); |
|
1774 |
SMF_INVOKES(CIMIoReadWriteDirectSMST, EStRecover) |
|
1775 |
} |
|
1776 |
} |
|
1777 |
||
1778 |
if (err & KMMCErrStatus) |
|
1779 |
{ |
|
1780 |
// Handles the following response errors in this order: |
|
1781 |
// |
|
1782 |
// KSDIOErrIllegalCommand : Command not legal for the current bus state |
|
1783 |
// KSDIOErrFunctionNumber : Invalid function number specified |
|
1784 |
// KSDIOErrOutOfRange : Command Argument is out of range |
|
1785 |
// KSDIOErrCrc : CRC of the previous command failed |
|
1786 |
// KSDIOErrGeneral : General or Unknown error |
|
1787 |
||
1788 |
const TSDIOResponseR5 response(s.ResponseP()); |
|
1789 |
const TUint32 error = response.Error(); |
|
1790 |
||
1791 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "SDIO:KMMCErrStatus: %08x", error)); // @SymTraceDataInternalTechnology |
|
1792 |
||
1793 |
if(!error) |
|
1794 |
{ |
|
1795 |
// The PSL reported an error, but not in the response! |
|
1796 |
SMF_GOTOS(EStDone); |
|
1797 |
} |
|
1798 |
||
1799 |
if(error & KSDIOErrIllegalCommand) |
|
1800 |
{ |
|
1801 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "SDIO:Illegal Command")); // @SymTraceDataInternalTechnology |
|
1802 |
||
1803 |
TBool validState = EFalse; |
|
1804 |
||
1805 |
switch(cmd.iCommand) |
|
1806 |
{ |
|
1807 |
// Verify the bus state is valid for the command: |
|
1808 |
// |
|
1809 |
// ESDIOCardStateCmd : Data lines are free : CMD52 or CMD53 valid |
|
1810 |
// ESDIOCardStateTrn : Data transfer using DAT[3:0] : CMD52 valid |
|
1811 |
||
1812 |
case ECmd52: |
|
1813 |
validState = ((response.State() == ESDIOCardStateCmd) || |
|
1814 |
(response.State() == ESDIOCardStateTrn)) ? ETrue : EFalse; |
|
1815 |
break; |
|
1816 |
case ECmd53: |
|
1817 |
validState = (response.State() == ESDIOCardStateCmd) ? ETrue : EFalse; |
|
1818 |
break; |
|
1819 |
default: |
|
1820 |
DSDIOStack::Panic(DSDIOStack::ESDIOStackBadCommand); |
|
1821 |
break; |
|
1822 |
} |
|
1823 |
||
1824 |
#if defined _DEBUG |
|
1825 |
if(!validState && (response.State() == ESDIOCardStateDis)) |
|
1826 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "State = DIS")); // @SymTraceDataInternalTechnology |
|
1827 |
if(!validState && (response.State() == ESDIOCardStateCmd)) |
|
1828 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "State = CMD")); // @SymTraceDataInternalTechnology |
|
1829 |
if(!validState && (response.State() == ESDIOCardStateTrn)) |
|
1830 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "State = TRN")); // @SymTraceDataInternalTechnology |
|
1831 |
#endif |
|
1832 |
||
1833 |
if(validState == EFalse) |
|
1834 |
{ |
|
1835 |
SMF_RETURN(KMMCErrBusInconsistent) |
|
1836 |
} |
|
1837 |
} |
|
1838 |
||
1839 |
if(error & (KSDIOErrOutOfRange | KSDIOErrFunctionNumber)) |
|
1840 |
{ |
|
1841 |
// There's nothing we can do if an invalid function number is provided |
|
1842 |
// or the address is out of range (which is a card-specific error) |
|
1843 |
// except return control to the originator of the comand. |
|
1844 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "SDIO:Invalid Argument")); // @SymTraceDataInternalTechnology |
|
1845 |
||
1846 |
SMF_RETURN(KMMCErrArgument) |
|
1847 |
} |
|
1848 |
||
1849 |
if(error & KSDIOErrCrc) |
|
1850 |
{ |
|
1851 |
// The CRC check of the previous command failed. |
|
1852 |
// |
|
1853 |
// It is the responsibility of the PSL to handle the extended Memory Response |
|
1854 |
// codes and forward these to the SDIO controller through the IO response. |
|
1855 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "SDIO:CRC Error")); // @SymTraceDataInternalTechnology |
|
1856 |
||
1857 |
SMF_RETURN(KMMCErrDataCRC) |
|
1858 |
} |
|
1859 |
||
1860 |
if(error & KSDIOErrGeneral) |
|
1861 |
{ |
|
1862 |
// A CRC or general error occurred (for the previous command), so retry |
|
1863 |
// in case of a random error due to noise on the bus and give up if not successful. |
|
1864 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "SDIO:Unknown Error")); // @SymTraceDataInternalTechnology |
|
1865 |
||
1866 |
SMF_RETURN(KMMCErrGeneral) |
|
1867 |
} |
|
1868 |
} |
|
1869 |
||
1870 |
SMF_GOTOS(EStDone) |
|
1871 |
||
1872 |
SMF_STATE(EStRecover) |
|
1873 |
||
1874 |
// EStRecover |
|
1875 |
// |
|
1876 |
// Attempt any error recovery and returns the extended response code |
|
1877 |
||
1878 |
TMMCErr finalErr = KMMCErrNone; |
|
1879 |
if(err & (KMMCErrBusInconsistent | KMMCErrResponseTimeOut | KMMCErrGeneral)) |
|
1880 |
{ |
|
1881 |
// Clients should de-register themselves if this condition is detected, |
|
1882 |
// and force a media change to reset the card as we are unable to recover. |
|
1883 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "SDIO:Abort Failed (err: %08x)", err)); // @SymTraceDataInternalTechnology |
|
1884 |
finalErr = KMMCErrAbort; |
|
1885 |
} |
|
1886 |
||
1887 |
s.PopCommandStack(); |
|
1888 |
m.ResetTraps(); |
|
1889 |
||
1890 |
SMF_RETURN(finalErr | Command().iExecNotHandle); |
|
1891 |
||
1892 |
SMF_STATE(EStDone) |
|
1893 |
||
1894 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "<SDIO:CIMIoIssueCommandCheckResponseSM()")); // @SymTraceDataInternalTechnology |
|
1895 |
||
1896 |
s.iState &= ~KMMCSessStateInProgress; |
|
1897 |
||
1898 |
SMF_END |
|
1899 |
} |
|
1900 |
||
1901 |
||
1902 |
EXPORT_C TMMCErr DSDIOStack::CIMIoModifySM() |
|
1903 |
/** |
|
1904 |
@return Standard TMMCErr error code |
|
1905 |
*/ |
|
1906 |
{ |
|
1907 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOStackIoModify, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk |
|
1908 |
||
1909 |
enum states |
|
1910 |
{ |
|
1911 |
EStBegin=0, |
|
1912 |
EStReadRegister, |
|
1913 |
EStModifyWriteRegister, |
|
1914 |
EStDone, |
|
1915 |
EStEnd |
|
1916 |
}; |
|
1917 |
||
1918 |
DSDIOSession& s=SDIOSession(); |
|
1919 |
TMMCCommandDesc& cmd = s.Command(); |
|
1920 |
||
1921 |
SMF_BEGIN |
|
1922 |
||
1923 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), ">SDIO:CIMIoModifySM %x",TUint(s.iLastStatus))); // @SymTraceDataInternalTechnology |
|
1924 |
||
1925 |
s.iState |= KMMCSessStateInProgress; |
|
1926 |
||
1927 |
SMF_STATE(EStReadRegister) |
|
1928 |
||
1929 |
// EStReadRegister |
|
1930 |
// |
|
1931 |
// Disables pre-emption of this session and reads from the register |
|
1932 |
||
1933 |
s.iConfig.RemoveMode(KMMCModeEnablePreemption); |
|
1934 |
||
1935 |
TUint32 param = (cmd.iArgument &~ KSdioCmdDirMask) | KSdioCmdRead; |
|
1936 |
DSDIOSession::FillAppCommandDesc(Command(), ESDIOCmdIoRwDirect, param); |
|
1937 |
||
1938 |
s.iSessionID = (TMMCSessionTypeEnum)ECIMIoReadDirect; |
|
1939 |
SMF_INVOKES(CIMIoReadWriteDirectSMST,EStModifyWriteRegister) |
|
1940 |
||
1941 |
SMF_STATE(EStModifyWriteRegister) |
|
1942 |
||
1943 |
// EStModifyWriteRegister |
|
1944 |
// |
|
1945 |
// Writes the modified data to the register (still non-preemptable) |
|
1946 |
||
1947 |
const TSDIOResponseR5 response(s.ResponseP()); |
|
1948 |
TUint8 readVal = response.Data(); |
|
1949 |
||
1950 |
s.ModifyBits(readVal); |
|
1951 |
||
1952 |
TUint32 param = (cmd.iArgument &~ (KSdioCmdDirMask | KSdioCmdDataMask)); |
|
1953 |
param |= KSdioCmdWrite; |
|
1954 |
param |= readVal; |
|
1955 |
||
1956 |
if(cmd.iDataMemoryP) |
|
1957 |
{ |
|
1958 |
param |= KSdioCmdRAW; |
|
1959 |
} |
|
1960 |
||
1961 |
DSDIOSession::FillAppCommandDesc(Command(), ESDIOCmdIoRwDirect, param); |
|
1962 |
||
1963 |
s.iSessionID = (TMMCSessionTypeEnum)ECIMIoWriteDirect; |
|
1964 |
SMF_INVOKES(CIMIoReadWriteDirectSMST,EStDone) |
|
1965 |
||
1966 |
SMF_STATE(EStDone) |
|
1967 |
||
1968 |
// EStDone |
|
1969 |
// |
|
1970 |
// CIMIoReadWriteDirectSM should have aready written the RAW data to the buffer. |
|
1971 |
s.iState &= ~KMMCSessStateInProgress; |
|
1972 |
||
1973 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOStackIoModifyReturning, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk |
|
1974 |
||
1975 |
SMF_END |
|
1976 |
||
1977 |
} |
|
1978 |
||
1979 |
||
1980 |
TMMCErr DSDIOStack::CIMIoFindTupleSM() |
|
1981 |
/** |
|
1982 |
This state machine walks a tuple chain (within a single CIS) searching |
|
1983 |
for the desired tuple code. The command argument will have been set up to |
|
1984 |
contain the CMD52 parameters for the start of the search, and the data shall |
|
1985 |
point to the Tuple ID structure. |
|
1986 |
@return Standard TMMCErr error code |
|
1987 |
*/ |
|
1988 |
{ |
|
1989 |
enum states |
|
1990 |
{ |
|
1991 |
EStBegin=0, |
|
1992 |
EStReadTupleId, |
|
1993 |
EStGotTupleId, |
|
1994 |
EStFoundTuple, |
|
1995 |
EStReadNextTuple, |
|
1996 |
EStDone, |
|
1997 |
EStEnd |
|
1998 |
}; |
|
1999 |
||
2000 |
DSDIOSession& s=SDIOSession(); |
|
2001 |
||
2002 |
SMF_BEGIN |
|
2003 |
||
2004 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), ">SDIO:CIMIoFindTupleSM %x",TUint(s.iLastStatus))); // @SymTraceDataInternalTechnology |
|
2005 |
||
2006 |
s.iState |= KMMCSessStateInProgress; |
|
2007 |
||
2008 |
if(s.Command().iDataMemoryP == NULL) |
|
2009 |
{ |
|
2010 |
SMF_RETURN(KMMCErrArgument) |
|
2011 |
} |
|
2012 |
||
2013 |
SMF_STATE(EStReadTupleId) |
|
2014 |
||
2015 |
// Set up to read the tuple ID |
|
2016 |
TMMCCommandDesc& cmd = s.Command(); |
|
2017 |
TSDIOTupleInfo* tupleInfoP = (TSDIOTupleInfo*)cmd.iDataMemoryP; |
|
2018 |
||
2019 |
if(tupleInfoP->iAddress < KSdioCisAreaMin || tupleInfoP->iAddress > KSdioCisAreaMax) |
|
2020 |
{ |
|
2021 |
SMF_RETURN(KMMCErrNotFound) |
|
2022 |
} |
|
2023 |
||
2024 |
s.PushCommandStack(); |
|
2025 |
s.FillDirectCommandDesc(Command(), ECIMIoReadDirect, 0, tupleInfoP->iAddress, 0x00, NULL); |
|
2026 |
s.iSessionID = (TMMCSessionTypeEnum)ECIMIoReadDirect; |
|
2027 |
SMF_INVOKES(CIMIoReadWriteDirectSMST, EStGotTupleId) |
|
2028 |
||
2029 |
SMF_STATE(EStGotTupleId) |
|
2030 |
||
2031 |
const TSDIOResponseR5 response(s.ResponseP()); |
|
2032 |
TUint8 tupleId = response.Data(); |
|
2033 |
||
2034 |
s.PopCommandStack(); |
|
2035 |
TMMCCommandDesc& cmd = s.Command(); |
|
2036 |
TSDIOTupleInfo* tupleInfoP = (TSDIOTupleInfo*)cmd.iDataMemoryP; |
|
2037 |
||
2038 |
if(tupleId == tupleInfoP->iTupleId) |
|
2039 |
{ |
|
2040 |
SMF_NEXTS(EStFoundTuple) |
|
2041 |
} |
|
2042 |
else if(tupleId != KSdioCisTplEnd) |
|
2043 |
{ |
|
2044 |
SMF_NEXTS(EStReadNextTuple) |
|
2045 |
} |
|
2046 |
else |
|
2047 |
{ |
|
2048 |
SMF_RETURN(KMMCErrNotFound); |
|
2049 |
} |
|
2050 |
||
2051 |
// Setup the command to read the length, and invoke the relevant state |
|
2052 |
s.PushCommandStack(); |
|
2053 |
s.FillDirectCommandDesc(Command(), ECIMIoReadDirect, 0, tupleInfoP->iAddress + 1, 0x00, NULL); |
|
2054 |
s.iSessionID = (TMMCSessionTypeEnum)ECIMIoReadDirect; |
|
2055 |
SMF_CALL(CIMIoReadWriteDirectSMST) |
|
2056 |
||
2057 |
SMF_STATE(EStReadNextTuple) |
|
2058 |
||
2059 |
const TSDIOResponseR5 response(s.ResponseP()); |
|
2060 |
TUint8 tupleLink = response.Data(); |
|
2061 |
||
2062 |
s.PopCommandStack(); |
|
2063 |
||
2064 |
if(tupleLink == 0xFF) |
|
2065 |
{ |
|
2066 |
SMF_RETURN(KMMCErrNotFound); |
|
2067 |
} |
|
2068 |
||
2069 |
TMMCCommandDesc& cmd = s.Command(); |
|
2070 |
TSDIOTupleInfo* tupleInfoP = (TSDIOTupleInfo*)cmd.iDataMemoryP; |
|
2071 |
||
2072 |
tupleInfoP->iAddress += (2 + tupleLink); |
|
2073 |
||
2074 |
SMF_GOTOS(EStReadTupleId) |
|
2075 |
||
2076 |
||
2077 |
SMF_STATE(EStFoundTuple) |
|
2078 |
||
2079 |
const TSDIOResponseR5 response(s.ResponseP()); |
|
2080 |
TUint8 tupleLink = response.Data(); |
|
2081 |
||
2082 |
s.PopCommandStack(); |
|
2083 |
TMMCCommandDesc& cmd = s.Command(); |
|
2084 |
TSDIOTupleInfo* tupleInfoP = (TSDIOTupleInfo*)cmd.iDataMemoryP; |
|
2085 |
||
2086 |
tupleInfoP->iLength = tupleLink; |
|
2087 |
||
2088 |
SMF_STATE(EStDone) |
|
2089 |
||
2090 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "<SDIO:CIMIoFindTupleSM()")); // @SymTraceDataInternalTechnology |
|
2091 |
||
2092 |
s.iState &= ~KMMCSessStateInProgress; |
|
2093 |
||
2094 |
SMF_END |
|
2095 |
} |
|
2096 |
||
2097 |
||
2098 |
TMMCErr DSDIOStack::CIMIoInterruptHandlerSM() |
|
2099 |
/** |
|
2100 |
@return Standard TMMCErr error code |
|
2101 |
*/ |
|
2102 |
{ |
|
2103 |
enum states |
|
2104 |
{ |
|
2105 |
EStBegin=0, |
|
2106 |
EStEnableMasterInterrupt, |
|
2107 |
EStEnableInterruptsAtPSL, |
|
2108 |
EStReadPendingInterrupts, |
|
2109 |
EStDisablePendingInterrupts, |
|
2110 |
EStNotifyClients, |
|
2111 |
EStDone, |
|
2112 |
EStEnd |
|
2113 |
}; |
|
2114 |
||
2115 |
DSDIOSession& s=SDIOSession(); |
|
2116 |
||
2117 |
SMF_BEGIN |
|
2118 |
||
2119 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), ">SDIO:CIMIoInterruptHandlerSM %x",TUint(s.iLastStatus))); // @SymTraceDataInternalTechnology |
|
2120 |
||
2121 |
// The only way to stop this session is to abort it. |
|
2122 |
m.SetTraps(KMMCErrAbort); |
|
2123 |
||
2124 |
s.iState |= KMMCSessStateInProgress; |
|
2125 |
s.PushCommandStack(); // Save context for after interrupt occurs |
|
2126 |
||
2127 |
s.iConfig.RemoveMode(KMMCModeEnablePreemption); |
|
2128 |
||
2129 |
SMF_STATE(EStEnableMasterInterrupt) |
|
2130 |
||
2131 |
// EStEnableMasterInterrupt |
|
2132 |
// |
|
2133 |
// Enable MIEN bit using safe Read/Modify/Write state machine. |
|
2134 |
||
2135 |
if(err & KMMCErrAbort) |
|
2136 |
SMF_EXIT |
|
2137 |
||
2138 |
s.FillIoModifyCommandDesc(Command(), 0, KCCCRRegIntEnable, KSDIOCardIntEnMaster, 0x00, NULL); |
|
2139 |
||
2140 |
SMF_INVOKES(CIMIoModifySMST,EStEnableInterruptsAtPSL) |
|
2141 |
||
2142 |
SMF_STATE(EStEnableInterruptsAtPSL) |
|
2143 |
||
2144 |
// EStEnableInterruptsAtPSL |
|
2145 |
// |
|
2146 |
// If MIEN bit set successfully, inform the PSL to enable interrupts |
|
2147 |
// (Sets the session to wait on the KMMCBlockOnInterrupt) |
|
2148 |
||
2149 |
if(err & KMMCErrAbort) |
|
2150 |
SMF_EXIT |
|
2151 |
||
2152 |
s.iConfig.SetMode(KMMCModeEnablePreemption); |
|
2153 |
||
2154 |
BlockCurrentSession(KMMCBlockOnInterrupt); |
|
2155 |
||
2156 |
TRACE2(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOStackPSLCalledEnableSDIOInterrupts, reinterpret_cast<TUint32>(this), 1); // @SymTraceDataPublishedTvk |
|
2157 |
EnableSDIOInterrupt(ETrue); |
|
2158 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOStackPSLEnableSDIOInterruptsReturned, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk |
|
2159 |
||
2160 |
SMF_WAITS(EStReadPendingInterrupts) |
|
2161 |
||
2162 |
SMF_STATE(EStReadPendingInterrupts) |
|
2163 |
||
2164 |
// EStReadPendingInterrupts |
|
2165 |
// |
|
2166 |
// Reads the pending interrupts that require service. |
|
2167 |
||
2168 |
TRACE2(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOStackPSLCalledEnableSDIOInterrupts, reinterpret_cast<TUint32>(this), 0); // @SymTraceDataPublishedTvk |
|
2169 |
EnableSDIOInterrupt(EFalse); |
|
2170 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOStackPSLEnableSDIOInterruptsReturned, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk |
|
2171 |
||
2172 |
if(err & KMMCErrAbort) |
|
2173 |
SMF_EXIT |
|
2174 |
||
2175 |
s.iConfig.RemoveMode(KMMCModeEnablePreemption); |
|
2176 |
||
2177 |
s.FillDirectCommandDesc(Command(), ECIMIoReadDirect, 0, KCCCRRegIntPending, 0x00, NULL); |
|
2178 |
||
2179 |
s.iSessionID = (TMMCSessionTypeEnum)ECIMIoReadDirect; |
|
2180 |
SMF_INVOKES(CIMIoReadWriteDirectSMST,EStDisablePendingInterrupts) |
|
2181 |
||
2182 |
SMF_STATE(EStDisablePendingInterrupts) |
|
2183 |
||
2184 |
// EStDisablePendingInterrupts |
|
2185 |
// |
|
2186 |
// Disables the the pending interrupts that require service. |
|
2187 |
// (it is the responsibility of the client to re-enable after service) |
|
2188 |
||
2189 |
if(err & KMMCErrAbort) |
|
2190 |
SMF_EXIT |
|
2191 |
||
2192 |
const TSDIOResponseR5 response(s.ResponseP()); |
|
2193 |
const TUint8 pending = (TUint8)(response.Data() & KSDIOCardIntPendMask); |
|
2194 |
||
2195 |
// if this is a stray interrrupt then there are no interrupts to disable |
|
2196 |
// and no point in calling any client interrupt handlers |
|
2197 |
if (pending == 0) |
|
2198 |
{ |
|
2199 |
SMF_GOTOS(EStEnableInterruptsAtPSL); |
|
2200 |
} |
|
2201 |
||
2202 |
s.PopCommandStack(); |
|
2203 |
Command().iDataMemoryP[0] = pending; |
|
2204 |
s.PushCommandStack(); |
|
2205 |
||
2206 |
s.FillIoModifyCommandDesc(Command(), 0, KCCCRRegIntEnable, 0x00, pending, NULL); |
|
2207 |
SMF_INVOKES(CIMIoModifySMST,EStNotifyClients) |
|
2208 |
||
2209 |
SMF_STATE(EStNotifyClients) |
|
2210 |
||
2211 |
// EStNotifyClients |
|
2212 |
// |
|
2213 |
// Notifies the clients of the pending interrupts and re-start session |
|
2214 |
||
2215 |
if(err & KMMCErrAbort) |
|
2216 |
SMF_EXIT |
|
2217 |
||
2218 |
TSDIOCard* cardP = static_cast<TSDIOCard*>(s.iCardP); |
|
2219 |
||
2220 |
cardP->InterruptController().Service(); |
|
2221 |
||
2222 |
SMF_GOTOS(EStEnableInterruptsAtPSL); |
|
2223 |
||
2224 |
SMF_STATE(EStDone) |
|
2225 |
||
2226 |
// EStDone |
|
2227 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "<SDIO:CIMIoInterruptHandlerSM()")); // @SymTraceDataInternalTechnology |
|
2228 |
||
2229 |
s.iState &= ~KMMCSessStateInProgress; |
|
2230 |
||
2231 |
SMF_END |
|
2232 |
} |
|
2233 |
||
2234 |
||
2235 |
TMMCErr DSDIOStack::CIMIoSetBusWidthSM() |
|
2236 |
/** |
|
2237 |
@return Standard TMMCErr error code |
|
2238 |
*/ |
|
2239 |
{ |
|
2240 |
enum states |
|
2241 |
{ |
|
2242 |
EStBegin=0, |
|
2243 |
EStCleanCardSelect, |
|
2244 |
EStCardSelected, |
|
2245 |
EStCheckMasterInterrupt, |
|
2246 |
EStDisableMasterInterrupt, |
|
2247 |
EStSetBusWidthIO, |
|
2248 |
EStSetBusWidthSDApp, |
|
2249 |
EStSetBusWidthSDCommand, |
|
2250 |
EStEnableMasterInterrupt, |
|
2251 |
EStFinishUp, |
|
2252 |
EStDone, |
|
2253 |
EStEnd |
|
2254 |
}; |
|
2255 |
||
2256 |
DSDIOSession& s=SDIOSession(); |
|
2257 |
TSDIOCard* ioCardP = static_cast<TSDIOCard*>(s.iCardP); |
|
2258 |
||
2259 |
const TUint32 KEnableInterruptFlag = 0x80; |
|
2260 |
||
2261 |
SMF_BEGIN |
|
2262 |
||
2263 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), ">SDIO:CIMIoSetBusWidthSM %x",TUint(s.iLastStatus))); // @SymTraceDataInternalTechnology |
|
2264 |
||
2265 |
s.SetCard(ioCardP); |
|
2266 |
TRCA targetRCA = ioCardP->RCA(); |
|
2267 |
TRACE2(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOStackPSLCalledAddressCard, reinterpret_cast<TUint32>(this), ioCardP->iIndex-1); // @SymTraceDataPublishedTvk |
|
2268 |
AddressCard(ioCardP->iIndex-1); |
|
2269 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOStackPSLAddressCardReturned, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk |
|
2270 |
if (targetRCA == SelectedCard()) |
|
2271 |
{ |
|
2272 |
SMF_GOTOS(EStCardSelected) |
|
2273 |
} |
|
2274 |
||
2275 |
s.PushCommandStack(); |
|
2276 |
s.FillCommandDesc(ECmdSelectCard, targetRCA); |
|
2277 |
||
2278 |
SMF_INVOKES(ExecCommandSMST,EStCleanCardSelect) |
|
2279 |
||
2280 |
SMF_STATE(EStCleanCardSelect) |
|
2281 |
||
2282 |
s.PopCommandStack(); |
|
2283 |
//drop through... |
|
2284 |
||
2285 |
SMF_STATE(EStCardSelected) |
|
2286 |
||
2287 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "DSDIOStack::EstCardSelected")); // @SymTraceDataInternalTechnology |
|
2288 |
||
2289 |
s.iState |= KMMCSessStateInProgress; |
|
2290 |
||
2291 |
// This state machine must not be interrupted |
|
2292 |
s.iConfig.RemoveMode(KMMCModeEnablePreemption); |
|
2293 |
||
2294 |
// Validate some parameters |
|
2295 |
TMMCCommandDesc& cmd = s.Command(); |
|
2296 |
const TInt requestWidth = cmd.iArgument; |
|
2297 |
||
2298 |
if(requestWidth == ioCardP->BusWidth()) |
|
2299 |
{ |
|
2300 |
// Width already set, so exit |
|
2301 |
SMF_GOTOS(EStDone); |
|
2302 |
} |
|
2303 |
||
2304 |
if(!(ioCardP->IsIOCard() || ioCardP->IsSDCard())) |
|
2305 |
{ |
|
2306 |
// Non-IO/SD Cards don't support change of bus width |
|
2307 |
s.iConfig.SetMode(KMMCModeEnablePreemption); |
|
2308 |
s.iState &= ~KMMCSessStateInProgress; |
|
2309 |
SMF_RETURN(KMMCErrNotSupported) |
|
2310 |
} |
|
2311 |
||
2312 |
if(ioCardP->IsSDCard() && ioCardP->IsLocked()) |
|
2313 |
{ |
|
2314 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "DSDIOStack:SD Card is Locked")); // @SymTraceDataInternalTechnology |
|
2315 |
// Don't perform the change |
|
2316 |
s.iConfig.SetMode(KMMCModeEnablePreemption); |
|
2317 |
s.iState &= ~KMMCSessStateInProgress; |
|
2318 |
SMF_RETURN(KMMCErrNotSupported) |
|
2319 |
} |
|
2320 |
||
2321 |
if(ioCardP->IsIOCard()) |
|
2322 |
{ |
|
2323 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "DSDIOStack:IsSDIOCard requestedWidth: %d",requestWidth)); // @SymTraceDataInternalTechnology |
|
2324 |
||
2325 |
switch(requestWidth) |
|
2326 |
{ |
|
2327 |
case 1: |
|
2328 |
// Requesting entry to 1-bit mode. This is always supported. |
|
2329 |
// Drops through to EStCheckMasterInterrupt |
|
2330 |
break; |
|
2331 |
||
2332 |
case 4: |
|
2333 |
// |
|
2334 |
// Requesting entry to 4-bit mode. Dependant on the values reported in the CCCR |
|
2335 |
// (4-Bit Support is Mandatory for High Speed Cards, and optional for Low Speed Cards) |
|
2336 |
// |
|
2337 |
// This assumes that the memory portion of a Combo Card has been initialised first. |
|
2338 |
// |
|
2339 |
{ |
|
2340 |
const TUint8 lowSpeed4BitMask = KSDIOCardCapsBitLSC | KSDIOCardCapsBit4BLS; |
|
2341 |
if(((ioCardP->iCommonConfig.iCardCaps & lowSpeed4BitMask) == lowSpeed4BitMask) || |
|
2342 |
(!(ioCardP->iCommonConfig.iCardCaps & KSDIOCardCapsBitLSC))) |
|
2343 |
{ |
|
2344 |
// OK. Drops through to EStCheckMasterInterrupt |
|
2345 |
} |
|
2346 |
else |
|
2347 |
{ |
|
2348 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "DSDIOStack:4-Bit Mode Not Supported")); // @SymTraceDataInternalTechnology |
|
2349 |
s.iConfig.SetMode(KMMCModeEnablePreemption); |
|
2350 |
s.iState &= ~KMMCSessStateInProgress; |
|
2351 |
SMF_RETURN(KMMCErrNotSupported) |
|
2352 |
} |
|
2353 |
} |
|
2354 |
break; |
|
2355 |
||
2356 |
default: |
|
2357 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "DSDIOStack:Invalid Argument")); // @SymTraceDataInternalTechnology |
|
2358 |
s.iConfig.SetMode(KMMCModeEnablePreemption); |
|
2359 |
s.iState &= ~KMMCSessStateInProgress; |
|
2360 |
SMF_RETURN(KMMCErrArgument) |
|
2361 |
//break; |
|
2362 |
} |
|
2363 |
} |
|
2364 |
else |
|
2365 |
{ |
|
2366 |
// If this is not an IO card, go directly to SD configuration |
|
2367 |
s.PushCommandStack(); |
|
2368 |
SMF_GOTOS(EStSetBusWidthSDApp) |
|
2369 |
} |
|
2370 |
||
2371 |
SMF_STATE(EStCheckMasterInterrupt) |
|
2372 |
||
2373 |
// EStCheckMasterInterrupt |
|
2374 |
// |
|
2375 |
// Checks if MIEN requires disable before changing the bus width |
|
2376 |
||
2377 |
s.PushCommandStack(); |
|
2378 |
||
2379 |
s.FillDirectCommandDesc(Command(), ECIMIoReadDirect, 0, KCCCRRegIntEnable, 0x00, NULL); |
|
2380 |
s.iSessionID = (TMMCSessionTypeEnum)ECIMIoReadDirect; |
|
2381 |
SMF_INVOKES(CIMIoReadWriteDirectSMST, EStDisableMasterInterrupt) |
|
2382 |
||
2383 |
SMF_STATE(EStDisableMasterInterrupt) |
|
2384 |
||
2385 |
// EStDisableMasterInterrupt |
|
2386 |
// |
|
2387 |
// Disable MIEN before changing the bus width |
|
2388 |
||
2389 |
const TSDIOResponseR5 response(s.ResponseP()); |
|
2390 |
if(response.Data() & KSDIOCardIntEnMaster) |
|
2391 |
{ |
|
2392 |
s.PopCommandStack(); |
|
2393 |
TMMCCommandDesc& cmd = s.Command(); |
|
2394 |
const TUint32 arg = cmd.iArgument | KEnableInterruptFlag; |
|
2395 |
cmd.iArgument = arg; |
|
2396 |
s.PushCommandStack(); |
|
2397 |
||
2398 |
s.FillIoModifyCommandDesc(Command(), 0, KCCCRRegIntEnable, 0x00, KSDIOCardIntEnMaster, NULL); |
|
2399 |
SMF_INVOKES(CIMIoModifySMST, EStSetBusWidthIO) |
|
2400 |
} |
|
2401 |
||
2402 |
// MIEN not enabled, so drop through and change the bus width |
|
2403 |
||
2404 |
SMF_STATE(EStSetBusWidthIO) |
|
2405 |
||
2406 |
// EStSetDefaultBusWidthIO |
|
2407 |
// |
|
2408 |
// Modify the Bus Width in the CCCR to 1-Bit mode |
|
2409 |
||
2410 |
s.PopCommandStack(); |
|
2411 |
TMMCCommandDesc& cmd = s.Command(); |
|
2412 |
s.PushCommandStack(); |
|
2413 |
||
2414 |
if((cmd.iArgument & ~KEnableInterruptFlag) == 1) |
|
2415 |
{ |
|
2416 |
s.FillIoModifyCommandDesc(Command(), 0, KCCCRRegBusInterfaceControl, 0x00, KSDIOCardBicMaskBusWidth, NULL); |
|
2417 |
} |
|
2418 |
else |
|
2419 |
{ |
|
2420 |
s.FillIoModifyCommandDesc(Command(), 0, KCCCRRegBusInterfaceControl, KSDIOCardBicBitBusWidth4, KSDIOCardBicMaskBusWidth & ~KSDIOCardBicBitBusWidth4, NULL); |
|
2421 |
} |
|
2422 |
||
2423 |
if(ioCardP->IsComboCard() || ioCardP->IsSDCard()) |
|
2424 |
{ |
|
2425 |
SMF_INVOKES(CIMIoModifySMST, EStSetBusWidthSDApp) |
|
2426 |
} |
|
2427 |
else |
|
2428 |
{ |
|
2429 |
const TBool enableMIEN = (cmd.iArgument & KEnableInterruptFlag) ? ETrue : EFalse; |
|
2430 |
SMF_INVOKES(CIMIoModifySMST, enableMIEN ? EStEnableMasterInterrupt : EStFinishUp) |
|
2431 |
} |
|
2432 |
||
2433 |
SMF_STATE(EStSetBusWidthSDApp) |
|
2434 |
||
2435 |
// EStSetDefaultBusWidthSDApp |
|
2436 |
// |
|
2437 |
// Modify the Bus Width of the SD portion of the card (App Command Stage) |
|
2438 |
||
2439 |
TUint32 arg = TUint32(CardArray().Card(0).RCA()) << 16; |
|
2440 |
s.FillCommandDesc(ECmdAppCmd, arg); |
|
2441 |
SMF_INVOKES(IssueCommandCheckResponseSMST, EStSetBusWidthSDCommand) |
|
2442 |
||
2443 |
SMF_STATE(EStSetBusWidthSDCommand) |
|
2444 |
||
2445 |
// EStSetBusWidthSDCommand |
|
2446 |
// |
|
2447 |
// Modify the Bus Width of the SD portion of the card (Command Stage) |
|
2448 |
||
2449 |
s.PopCommandStack(); |
|
2450 |
TMMCCommandDesc& cmd = s.Command(); |
|
2451 |
const TBool enableMIEN = (cmd.iArgument & KEnableInterruptFlag) ? ETrue : EFalse; |
|
2452 |
s.PushCommandStack(); |
|
2453 |
||
2454 |
DSDSession::FillAppCommandDesc(Command(), ESDACmdSetBusWidth, cmd.iArgument == 1 ? KSDBusWidth1 : KSDBusWidth4); |
|
2455 |
SMF_INVOKES(IssueCommandCheckResponseSMST, (ioCardP->IsIOCard() && enableMIEN) ? EStEnableMasterInterrupt : EStFinishUp) |
|
2456 |
||
2457 |
SMF_STATE(EStEnableMasterInterrupt) |
|
2458 |
||
2459 |
// EStEnableMasterInterrupt |
|
2460 |
// |
|
2461 |
// Re-Enable Master Interrupts |
|
2462 |
||
2463 |
s.FillIoModifyCommandDesc(Command(), 0, KCCCRRegIntEnable, KSDIOCardIntEnMaster, 0x00, NULL); |
|
2464 |
SMF_INVOKES(CIMIoModifySMST, EStFinishUp) |
|
2465 |
||
2466 |
SMF_STATE(EStFinishUp) |
|
2467 |
||
2468 |
// EStFinishUp |
|
2469 |
// |
|
2470 |
// Informs the PSL of the final bus width |
|
2471 |
||
2472 |
s.PopCommandStack(); |
|
2473 |
||
2474 |
TMMCCommandDesc& cmd = s.Command(); |
|
2475 |
cmd.iArgument = TUint32(cmd.iArgument &~ KEnableInterruptFlag); |
|
2476 |
ioCardP->SetBusWidth(cmd.iArgument); |
|
2477 |
DoSetBusWidth(cmd.iArgument == 1 ? KSDBusWidth1 : KSDBusWidth4); |
|
2478 |
||
2479 |
if(cmd.iArgument == 4) |
|
2480 |
{ |
|
2481 |
// Bring the socket out of sleep mode if we have just set 4-bit |
|
2482 |
static_cast<DSDIOSocket*>(MMCSocket())->SetSleep(EFalse); |
|
2483 |
} |
|
2484 |
||
2485 |
SMF_STATE(EStDone) |
|
2486 |
||
2487 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "<DSDIOStack:CIMIoSetBusWidthSM()")); // @SymTraceDataInternalTechnology |
|
2488 |
||
2489 |
s.iConfig.SetMode(KMMCModeEnablePreemption); |
|
2490 |
s.iState &= ~KMMCSessStateInProgress; |
|
2491 |
||
2492 |
SMF_END |
|
2493 |
} |
|
2494 |
||
2495 |
||
2496 |
EXPORT_C TMMCErr DSDIOStack::CIMReadWriteBlocksSM() |
|
2497 |
// |
|
2498 |
// This macro provides the virtual Memory R/W state machine. |
|
2499 |
// Since SDIO supports sleep mode, the bus width may be set to 1-bit |
|
2500 |
// before memory access. This machine ensures that the bus width |
|
2501 |
// is set to 4-bit mode prior to performing the SD R/W state machine. |
|
2502 |
// |
|
2503 |
{ |
|
2504 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOStackIoReadWriteBlock, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk |
|
2505 |
||
2506 |
enum states |
|
2507 |
{ |
|
2508 |
EStBegin=0, |
|
2509 |
EStFullPower, |
|
2510 |
EStDone, |
|
2511 |
EStEnd |
|
2512 |
}; |
|
2513 |
||
2514 |
DMMCSession& s=Session(); |
|
2515 |
||
2516 |
SMF_BEGIN |
|
2517 |
||
2518 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), ">DSDIOStack:RWBlocksSM %x",TUint(s.iLastStatus))); // @SymTraceDataInternalTechnology |
|
2519 |
||
2520 |
s.iState |= KMMCSessStateInProgress; |
|
2521 |
||
2522 |
// Disable Preemption until we have set the bus width |
|
2523 |
s.iConfig.RemoveMode(KMMCModeEnablePreemption); |
|
2524 |
||
2525 |
s.PushCommandStack(); |
|
2526 |
s.FillCommandArgs(4, 0, NULL, 0); |
|
2527 |
m.SetTraps(KMMCErrNotSupported); |
|
2528 |
SMF_INVOKES(CIMIoSetBusWidthSMST, EStFullPower) |
|
2529 |
||
2530 |
SMF_STATE(EStFullPower) |
|
2531 |
||
2532 |
m.ResetTraps(); |
|
2533 |
s.PopCommandStack(); |
|
2534 |
s.iConfig.SetMode(KMMCModeEnablePreemption); |
|
2535 |
||
2536 |
if(err == KMMCErrNone || err == KMMCErrNotSupported) |
|
2537 |
{ |
|
2538 |
SMF_INVOKES(CIMReadWriteMemoryBlocksSMST, EStDone); |
|
2539 |
} |
|
2540 |
||
2541 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "DSDIOStack:RWBlocksSM() - Err: %d",err)); // @SymTraceDataInternalTechnology |
|
2542 |
||
2543 |
SMF_RETURN(err) |
|
2544 |
||
2545 |
SMF_STATE(EStDone) |
|
2546 |
||
2547 |
s.iState &= ~KMMCSessStateInProgress; |
|
2548 |
||
2549 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOStackIoReadWriteBlockReturning, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk |
|
2550 |
||
2551 |
SMF_END |
|
2552 |
||
2553 |
} |
|
2554 |
||
2555 |
||
2556 |
EXPORT_C TMMCErr DSDIOStack::ModifyCardCapabilitySM() |
|
2557 |
/** |
|
2558 |
@publishedPartner |
|
2559 |
@released |
|
2560 |
||
2561 |
This function provides a chance to modify the capability of paticular cards. |
|
2562 |
Licensee may overide this function to modify certain card's capability as needed. |
|
2563 |
A state machine is needed in derived function and function of base class should be |
|
2564 |
called in order to act more generic behaviour. |
|
2565 |
*/ |
|
2566 |
{ |
|
2567 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOStackModifyCardCapability, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk |
|
2568 |
||
2569 |
enum states |
|
2570 |
{ |
|
2571 |
EStBegin=0, |
|
2572 |
EStDone, |
|
2573 |
EStEnd |
|
2574 |
}; |
|
2575 |
||
2576 |
SMF_BEGIN |
|
2577 |
||
2578 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), ">DSDIOStack:ModifyCardCapabilitySM()")); // @SymTraceDataInternalTechnology |
|
2579 |
||
2580 |
SMF_INVOKES( DStackBase::BaseModifyCardCapabilitySMST, EStDone ) |
|
2581 |
||
2582 |
SMF_STATE(EStDone) |
|
2583 |
||
2584 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOStackModifyCardCapabilityReturning, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk |
|
2585 |
||
2586 |
SMF_END |
|
2587 |
||
2588 |
} |
|
2589 |
||
2590 |
||
2591 |
EXPORT_C void DSDIOStack::HandleSDIOInterrupt(TUint aCardIndex) |
|
2592 |
/** |
|
2593 |
@publishedPartner |
|
2594 |
@released |
|
2595 |
||
2596 |
Called from the variant layer to indicate that an SDIO interrupt has occurred. |
|
2597 |
SDIO cards do not share the data bus, so it is the responsibility of the PSL |
|
2598 |
to determine the card that generated the interrupt. |
|
2599 |
||
2600 |
@param aCardIndex The index of the card that generated the interrupt. |
|
2601 |
||
2602 |
@see DSDIOStack::EnableSDIOInterrupt |
|
2603 |
*/ |
|
2604 |
{ |
|
2605 |
// |
|
2606 |
// Pass the interrupt onto the interrupt controller |
|
2607 |
// |
|
2608 |
TSDIOCard& ioCard = CardArray().Card(aCardIndex); |
|
2609 |
ioCard.iInterruptController.Schedule(); |
|
2610 |
} |
|
2611 |
||
2612 |
||
2613 |
EXPORT_C void DSDIOStack::BlockIOSession(TSDIOBlockingCondition aBlockCond) |
|
2614 |
/** |
|
2615 |
Blocks the current IO session. |
|
2616 |
||
2617 |
This is used to support the sending of Direct Commands during Data Transfer, |
|
2618 |
and is part of the implementation of the Read/Wait protocol. |
|
2619 |
||
2620 |
@param aBlockCond The requested blocking condition |
|
2621 |
*/ |
|
2622 |
{ |
|
2623 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOStackBlockIoSession, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk |
|
2624 |
||
2625 |
DSDIOSession* bSessP = NULL; |
|
2626 |
TBool allowPremption = EFalse; |
|
2627 |
||
2628 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), ">SDIO:BlockIOSession()")); // @SymTraceDataInternalTechnology |
|
2629 |
||
2630 |
switch(aBlockCond) |
|
2631 |
{ |
|
2632 |
case ESDIOBlockOnCommand: |
|
2633 |
{ |
|
2634 |
// Requesting to block in command mode: |
|
2635 |
// The stack must be fully blocked under this condition |
|
2636 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "SDIO:ESDIOBlockOnCommand")); // @SymTraceDataInternalTechnology |
|
2637 |
||
2638 |
__ASSERT_ALWAYS((iBlockedSessions & KCommandSessionBlocked) == 0, Panic(ESDIOStackOverlappedSession)); |
|
2639 |
||
2640 |
bSessP = &SDIOSession(); |
|
2641 |
iCmdSessionP = bSessP; |
|
2642 |
iBlockedSessions |= KCommandSessionBlocked; |
|
2643 |
||
2644 |
break; |
|
2645 |
} |
|
2646 |
||
2647 |
case ESDIOBlockOnData: |
|
2648 |
{ |
|
2649 |
// Requesting to block in data transfer: |
|
2650 |
// Check the card capabilities to determine the blocking conditions. |
|
2651 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "SDIO:ESDIOBlockOnData")); // @SymTraceDataInternalTechnology |
|
2652 |
||
2653 |
__ASSERT_ALWAYS((iBlockedSessions & KDataSessionBlocked) == 0, Panic(ESDIOStackOverlappedSession)); |
|
2654 |
||
2655 |
bSessP = &SDIOSession(); |
|
2656 |
||
2657 |
const TSDIOCard* ioCardP = static_cast<TSDIOCard*>(bSessP->iCardP); |
|
2658 |
const TBool supportsDC = (ioCardP->iCommonConfig.iCardCaps & KSDIOCardCapsBitSDC) ? ETrue : EFalse; |
|
2659 |
||
2660 |
if(supportsDC) |
|
2661 |
{ |
|
2662 |
allowPremption = ETrue; |
|
2663 |
} |
|
2664 |
||
2665 |
iDataSessionP = bSessP; |
|
2666 |
iBlockedSessions |= KDataSessionBlocked; |
|
2667 |
||
2668 |
break; |
|
2669 |
} |
|
2670 |
||
2671 |
default: |
|
2672 |
break; |
|
2673 |
} |
|
2674 |
||
2675 |
if(bSessP) |
|
2676 |
{ |
|
2677 |
DISABLEPREEMPTION |
|
2678 |
||
2679 |
if(allowPremption) |
|
2680 |
{ |
|
2681 |
bSessP->iState |= KMMCSessStateAllowDirectCommands; |
|
2682 |
} |
|
2683 |
else |
|
2684 |
{ |
|
2685 |
bSessP->iState &= ~KMMCSessStateAllowDirectCommands; |
|
2686 |
} |
|
2687 |
||
2688 |
Block(bSessP, KMMCBlockOnDataTransfer); |
|
2689 |
||
2690 |
RESTOREPREEMPTION |
|
2691 |
} |
|
2692 |
||
2693 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOStackBlockIoSessionReturning, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk |
|
2694 |
} |
|
2695 |
||
2696 |
||
2697 |
EXPORT_C DSDIOSession* DSDIOStack::UnblockIOSession(TSDIOBlockingCondition aBlockCond, TMMCErr aError) |
|
2698 |
/** |
|
2699 |
Unblocks the current IO session. |
|
2700 |
||
2701 |
This is used to support the sending of Direct Commands during Data Transfer, |
|
2702 |
and is part of the implementation of the Read/Wait protocol. |
|
2703 |
||
2704 |
@param aBlockCond The requested unblocking condition |
|
2705 |
@param aError Standard MMC error code |
|
2706 |
@return The previously blocked session |
|
2707 |
*/ |
|
2708 |
{ |
|
2709 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOStackUnblockIoSession, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk |
|
2710 |
||
2711 |
DSDIOSession* ubSessP = NULL; |
|
2712 |
||
2713 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), ">SDIO:UnblockIOSession()")); // @SymTraceDataInternalTechnology |
|
2714 |
||
2715 |
DISABLEPREEMPTION |
|
2716 |
||
2717 |
switch(aBlockCond) |
|
2718 |
{ |
|
2719 |
case ESDIOBlockOnCommand: |
|
2720 |
{ |
|
2721 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "SDIO:ESDIOBlockOnCommand")); // @SymTraceDataInternalTechnology |
|
2722 |
ubSessP = iCmdSessionP; |
|
2723 |
iBlockedSessions &= ~KCommandSessionBlocked; |
|
2724 |
iCmdSessionP = NULL; |
|
2725 |
break; |
|
2726 |
} |
|
2727 |
||
2728 |
case ESDIOBlockOnData: |
|
2729 |
{ |
|
2730 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "SDIO:ESDIOBlockOnData")); // @SymTraceDataInternalTechnology |
|
2731 |
ubSessP = iDataSessionP; |
|
2732 |
iBlockedSessions &= ~KDataSessionBlocked; |
|
2733 |
iDataSessionP = NULL; |
|
2734 |
break; |
|
2735 |
} |
|
2736 |
||
2737 |
default: |
|
2738 |
break; |
|
2739 |
} |
|
2740 |
||
2741 |
if (ubSessP) |
|
2742 |
{ |
|
2743 |
ubSessP->iState &= ~KMMCSessStateAllowDirectCommands; |
|
2744 |
RESTOREPREEMPTION |
|
2745 |
UnBlock(ubSessP, KMMCBlockOnDataTransfer, aError); |
|
2746 |
} |
|
2747 |
else |
|
2748 |
{ |
|
2749 |
RESTOREPREEMPTION |
|
2750 |
} |
|
2751 |
||
2752 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOStackUnblockIoSessionReturning, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk |
|
2753 |
return ubSessP; |
|
2754 |
} |
|
2755 |
||
2756 |
||
2757 |
EXPORT_C DMMCSession* DSDIOStack::AllocSession(const TMMCCallBack& aCallBack) const |
|
2758 |
/** |
|
2759 |
Used by clients of the SDIO controller to allocate the appropriate DMMCSession derived session |
|
2760 |
object (in this case, a DSDIOSession object). |
|
2761 |
||
2762 |
Rather than clients directly using this function, it is recommended that the session |
|
2763 |
be accessed indirectly using the functionality provided by the DSDIORegisterInterface class. |
|
2764 |
||
2765 |
@param aCallBack Callback function to notify the client that a session has completed |
|
2766 |
||
2767 |
@return A pointer to the new session |
|
2768 |
||
2769 |
@see DSDIORegisterInterface |
|
2770 |
*/ |
|
2771 |
{ |
|
2772 |
TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOStackAllocateNewSession, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk |
|
2773 |
DMMCSession* session = new DSDIOSession(aCallBack); |
|
2774 |
TRACE2(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOStackAllocateNewSessionReturning, reinterpret_cast<TUint32>(this), reinterpret_cast<TUint32>(session)); // @SymTraceDataPublishedTvk |
|
2775 |
return session; |
|
2776 |
} |
|
2777 |
||
2778 |
||
2779 |
void DSDIOStack::Panic(DSDIOStack::TPanic aPanic) |
|
2780 |
/** |
|
2781 |
Session Panic |
|
2782 |
*/ |
|
2783 |
{ |
|
2784 |
Kern::Fault("SDIO_SESS", aPanic); |
|
2785 |
} |
|
2786 |
||
2787 |
||
2788 |
#ifdef _DEBUG |
|
2789 |
void DSDIOStack::TraceCCCRInfo() |
|
2790 |
/** |
|
2791 |
Debug function to output the contents of the FBR |
|
2792 |
*/ |
|
2793 |
{ |
|
2794 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "\nCCCR/SDIO Revision : %02xH (CCCR Rev: %d, SDIO Rev: %d) ", iBufCCCR[0x00], iBufCCCR[0x00] & 0x0F, (iBufCCCR[0x00] & 0xF0) >> 4)); // @SymTraceDataInternalTechnology |
|
2795 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "SD Spec Revision : %02xH", iBufCCCR[0x01])); // @SymTraceDataInternalTechnology |
|
2796 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "I/O Enable : %02xH", iBufCCCR[0x02])); // @SymTraceDataInternalTechnology |
|
2797 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "I/O Ready : %02xH", iBufCCCR[0x03])); // @SymTraceDataInternalTechnology |
|
2798 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "Int Enable : %02xH", iBufCCCR[0x04])); // @SymTraceDataInternalTechnology |
|
2799 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "Int Pending : %02xH", iBufCCCR[0x05])); // @SymTraceDataInternalTechnology |
|
2800 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "I/O Abort : %02xH", iBufCCCR[0x06])); // @SymTraceDataInternalTechnology |
|
2801 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "Bus Interface Control : %02xH - CD Disable : %db (Disconnect CD Pullup))", iBufCCCR[0x07], (iBufCCCR[0x07] & 0x80) ? ETrue : EFalse)); // @SymTraceDataInternalTechnology |
|
2802 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), " - SCSI : %db (Supports Cont. SPI Interrupts)", (iBufCCCR[0x07] & 0x40) ? ETrue : EFalse)); // @SymTraceDataInternalTechnology |
|
2803 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), " - ECSI : %db (Cont. SPI Interrupts Enable)", (iBufCCCR[0x07] & 0x20) ? ETrue : EFalse)); // @SymTraceDataInternalTechnology |
|
2804 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), " - Bus Width : %d-bit", (iBufCCCR[0x07] & 0x03) ? 4 : 1)); // @SymTraceDataInternalTechnology |
|
2805 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "Card Capability : %02xH - 4BLS : %db (LSC supports 4-bit)", iBufCCCR[0x08], iBufCCCR[0x08] & 0x80 ? ETrue : EFalse)); // @SymTraceDataInternalTechnology |
|
2806 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), " - LSC : %db (Low Speed Card)", iBufCCCR[0x08] & 0x40 ? ETrue : EFalse)); // @SymTraceDataInternalTechnology |
|
2807 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), " - E4MI : %db (Enable Int. in 4-bit blocks)", iBufCCCR[0x08] & 0x20 ? ETrue : EFalse)); // @SymTraceDataInternalTechnology |
|
2808 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), " - S4MI : %db (Supports Int. in 4-bit blocks)", iBufCCCR[0x08] & 0x10 ? ETrue : EFalse)); // @SymTraceDataInternalTechnology |
|
2809 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), " - SBS : %db (Supports Suspend/Resume)", iBufCCCR[0x08] & 0x08 ? ETrue : EFalse)); // @SymTraceDataInternalTechnology |
|
2810 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), " - SRW : %db (Supports Read/Wait)", iBufCCCR[0x08] & 0x04 ? ETrue : EFalse)); // @SymTraceDataInternalTechnology |
|
2811 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), " - SMB : %db (Supports Multi-Block)", iBufCCCR[0x08] & 0x02 ? ETrue : EFalse)); // @SymTraceDataInternalTechnology |
|
2812 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), " - SDC : %db (Supports CMD52 in mult-ibyte)", iBufCCCR[0x08] & 0x01 ? ETrue : EFalse)); // @SymTraceDataInternalTechnology |
|
2813 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "Bus Suspend : %02xH", iBufCCCR[0x0c])); // @SymTraceDataInternalTechnology |
|
2814 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "Function Select : %02xH", iBufCCCR[0x0d])); // @SymTraceDataInternalTechnology |
|
2815 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "Exec Flags : %02xH", iBufCCCR[0x0e])); // @SymTraceDataInternalTechnology |
|
2816 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "Ready Flags : %02xH\n", iBufCCCR[0x0f])); // @SymTraceDataInternalTechnology |
|
2817 |
SYMBIAN_TRACE_SDIO_VERBOSE_ONLY(Printf(TTraceContext(EInternals), "High Speed Flags : %02xH\n", iBufCCCR[0x13])); // @SymTraceDataInternalTechnology |
|
2818 |
} |
|
2819 |
||
2820 |
#endif |
|
2821 |
||
2822 |
EXPORT_C void DSDIOStack::Dummy1() {} |
|
2823 |
EXPORT_C void DSDIOStack::Dummy2() {} |
|
2824 |
EXPORT_C void DSDIOStack::Dummy3() {} |
|
2825 |
EXPORT_C void DSDIOStack::Dummy4() {} |
|
244 | 2826 |
#if defined(__WINS__) || defined (__X86__) |
2827 |
EXPORT_C void Dummy1() {} |
|
2828 |
#endif |