First public contribution.
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
18 #include "T_MmcSDPsuDriverData.h"
20 //MMCSD Commands index
25 _LIT(KCmdPsuInfo, "PsuInfo");
26 _LIT(KCmdPbusState, "PbusState");
27 _LIT(KCmdSetPsuState, "SetState");
28 _LIT(KCmdVccState, "VccState");
29 _LIT(KCmdPsuVoltage, "SetVoltage");
30 _LIT(KCmdPsuNumber, "PsuNumber");
31 _LIT(KCmdMediaChangeNumber, "MediaChangeNumber");
32 _LIT(KCmdPsuCurLimit, "PsuCurLimit");
34 _LIT(KVoltage, "expectedvoltage");
35 _LIT(KCurrent, "expectedcurrent");
36 _LIT(KVoltageinterval, "expectedvoltageinterval");
37 _LIT(KVoltagecheck, "expectedvoltagecheck");
38 _LIT(KInactivityTimeOut, "expectedpsuinactivitytimeOut");
39 _LIT(KNotlockedtimeOut, "expectednotlockedtimeOut");
40 _LIT(KPbusState, "expectedpbusstate");
41 _LIT(KVccState, "expectedvccstate");
42 _LIT(KExpectedpsuNumber, "expectedpsuNumber");
43 _LIT(KExpectedmediaChangeNumber, "expectedmediaChangeNumber");
44 _LIT(KExpectedpsuCurLimit, "expectedpsuCurLimit");
46 _LIT(KPsuState, "psustate");
47 _LIT(KPsuVoltage, "psuVoltage");
50 _LIT(KPsuChkComparator, "EDPsuChkComparator");
51 _LIT(KPsuChkADCType, "EDPsuChkADCType");
52 _LIT(KPsuChkADCType2, "EDPsuChkADCType2");
54 _LIT(KBusCardAbsent, "EBusCardAbsent");
55 _LIT(KBusOff, "EBusOff");
56 _LIT(KBusPoweringUp, "EBusPoweringUp");
57 _LIT(KBusOn, "EBusOn");
58 _LIT(KEBusPsuFault, "EBusPsuFault");
59 _LIT(KBusPowerUpPending, "EBusPowerUpPending");
61 _LIT(KPsuOff, "EDPsuOff");
62 _LIT(KPsuOnCurLimit, "EDPsuOnCurLimit");
63 _LIT(KPsuOnFull, "EDPsuOnFull");
65 const CDataWrapperBase::TEnumEntryTable CT_MMCSDPsuDriverData::iEnumTableVoltageCheckMethod[] =
67 // Enum as a descriptor Enum
68 KPsuChkComparator, EDPsuChkComparator,
69 KPsuChkADCType, EDPsuChkADCType,
70 KPsuChkADCType2, EDPsuChkADCType2,
74 const CDataWrapperBase::TEnumEntryTable CT_MMCSDPsuDriverData::iEnumTablePbusState[] =
76 // Enum as a descriptor Enum
77 KBusCardAbsent, EBusCardAbsent,
79 KBusPoweringUp, EBusPoweringUp,
81 KEBusPsuFault, EBusPsuFault,
82 KBusPowerUpPending, EBusPowerUpPending,
86 const CDataWrapperBase::TEnumEntryTable CT_MMCSDPsuDriverData::iEnumTableVccState[] =
88 // Enum as a descriptor Enum
90 KPsuOnCurLimit, EDPsuOnCurLimit,
91 KPsuOnFull, EDPsuOnFull,
95 //////////////////////////////////////////////////////////////////////
96 // Construction/Destruction
97 //////////////////////////////////////////////////////////////////////
99 CT_MMCSDPsuDriverData* CT_MMCSDPsuDriverData::NewL()
101 CT_MMCSDPsuDriverData* ret=new (ELeave) CT_MMCSDPsuDriverData();
102 CleanupStack::PushL(ret);
104 CleanupStack::Pop(ret);
109 CT_MMCSDPsuDriverData::CT_MMCSDPsuDriverData()
110 : CT_MmcSDDriverData()
111 , iAsyncErrorIndex(0)
115 void CT_MMCSDPsuDriverData::ConstructL()
117 * Second phase construction
126 * @leave system wide error
129 CT_MmcSDDriverData::ConstructL();
132 CT_MMCSDPsuDriverData::~CT_MMCSDPsuDriverData()
139 TBool CT_MMCSDPsuDriverData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
141 * Process a command read from the ini file
143 * @param aCommand The command to process
144 * @param aSection The section in the ini containing data for the command
145 * @param aAsyncErrorIndex Command index for async calls to return errors to
147 * @return ETrue if the command is processed
149 * @leave System wide error
154 if ( aCommand==KCmdPsuInfo )
156 DoCmdPsuInfo(aSection);
158 else if ( aCommand==KCmdPsuVoltage )
160 DoCmdSetPsuVoltage(aSection);
162 else if ( aCommand==KCmdPsuNumber )
164 DoCmdPsuNumber(aSection);
166 else if ( aCommand==KCmdMediaChangeNumber )
168 DoCmdMediaChangeID(aSection);
170 else if ( aCommand==KCmdPsuCurLimit )
172 DoCmdPsuCurLimit(aSection);
174 else if ( aCommand==KCmdPbusState)
176 DoCmdPbusState(aSection);
178 else if ( aCommand==KCmdSetPsuState)
180 DoCmdSetPsuState(aSection);
182 else if ( aCommand==KCmdVccState)
184 DoCmdVccState(aSection);
188 ret=CT_MmcSDDriverData::DoCommandL(aCommand, aSection, aAsyncErrorIndex);
196 * @param aSection The section in the ini containing data for the command
200 * @leave System wide error
202 void CT_MMCSDPsuDriverData::DoCmdPsuInfo(const TDesC& aSection)
206 err = iMmcSDController->PsuInfo(psuInfo);
209 ERR_PRINTF2(_L("Getting PsuInfo Error %d"), err);
215 INFO_PRINTF2(_L("PSU: Bus Inactivity timeout Period = %d \n"),psuInfo.iInactivityTimeOut);
216 TInt expectedInactivityTimeOut;
217 if(GetIntFromConfig(aSection, KInactivityTimeOut(), expectedInactivityTimeOut))
219 if(psuInfo.iInactivityTimeOut != expectedInactivityTimeOut)
221 SetBlockResult(EFail);
222 ERR_PRINTF3(_L("psuInfo.iInactivityTimeOut(%d) != expectedInactivityTimeOut(%d)"), psuInfo.iInactivityTimeOut, expectedInactivityTimeOut);
224 if(psuInfo.iInactivityTimeOut<=0 || psuInfo.iInactivityTimeOut>10)
226 ERR_PRINTF1(_L("MMC/SD: Error : Inactivity timeout is not programmed correctly. \n"));
227 ERR_PRINTF1(_L("MMC/SD: Inactivity time out depends on platform. Possible value can be (1/3/5/10) seconds \n"));
228 SetBlockResult(EFail);
233 SetBlockResult(EFail);
234 WARN_PRINTF1(_L("Inactivity timeout Value Missing From INI File"));
237 INFO_PRINTF2(_L("PSU: Bus Not Locked Timeout Period = %d \n"),psuInfo.iNotLockedTimeOut);
238 TInt expectedNotlockedtimeOut;
239 if(GetIntFromConfig(aSection, KNotlockedtimeOut(), expectedNotlockedtimeOut))
241 if(psuInfo.iNotLockedTimeOut != expectedNotlockedtimeOut)
243 SetBlockResult(EFail);
244 ERR_PRINTF3(_L("psuInfo.iNotLockedTimeOut(%d) != expectedNotlockedtimeOut(%d)"), psuInfo.iNotLockedTimeOut, expectedNotlockedtimeOut);
249 SetBlockResult(EFail);
250 WARN_PRINTF1(_L("NotlockedtimeOut Value Missing From INI File"));
252 //MaxCurrentInMicroAmps
253 INFO_PRINTF2(_L("PSU: MaxCurrentInMicroAmps = %d \n"),psuInfo.iMaxCurrentInMicroAmps);
254 TInt expectedMaxCurrentInMicroAmps;
255 if(GetIntFromConfig(aSection, KCurrent(), expectedMaxCurrentInMicroAmps))
257 if(psuInfo.iMaxCurrentInMicroAmps != expectedMaxCurrentInMicroAmps)
259 SetBlockResult(EFail);
260 ERR_PRINTF3(_L("psuInfo.iMaxCurrentInMicroAmps(%d) != expectedMaxCurrentInMicroAmps(%d)"), psuInfo.iMaxCurrentInMicroAmps, expectedMaxCurrentInMicroAmps);
265 SetBlockResult(EFail);
266 WARN_PRINTF1(_L("MaxCurrentInMicroAmps Value Missing From INI File"));
269 INFO_PRINTF2(_L("PSU: Volatge Supported(OCR Register Format) = 0x%08x(OCR Format) \n"),psuInfo.iVoltageSupported);
270 TUint expectedVoltageSupported;
271 if(GetUintFromConfig(aSection, KVoltage(), expectedVoltageSupported))
273 if(psuInfo.iVoltageSupported != expectedVoltageSupported)
275 SetBlockResult(EFail);
276 ERR_PRINTF3(_L("psuInfo.iVoltageSupported(0x%08x) != expectedVoltageSupported(0x%08x)"), psuInfo.iVoltageSupported, expectedVoltageSupported);
278 //Bit MASK (Refer OCR register format)
279 if(psuInfo.iVoltageSupported ==0)
281 ERR_PRINTF1(_L("MMC/SD: iVoltageSupported should not be zero \n"));
282 ERR_PRINTF1(_L("MMC/SD: iVoltageSupported depends on platform. Possible values(3.0/3.3) volts in OCR register format\n"));
283 SetBlockResult(EFail);
288 SetBlockResult(EFail);
289 WARN_PRINTF1(_L("VoltageSupported Value Missing From INI File"));
292 INFO_PRINTF2(_L("PSU: Voltage Interval = %x \n"),psuInfo.iVoltCheckInterval);
293 TUint expectedVoltCheckInterval;
294 if(GetUintFromConfig(aSection, KVoltageinterval(), expectedVoltCheckInterval))
296 if(psuInfo.iVoltCheckInterval != expectedVoltCheckInterval)
298 SetBlockResult(EFail);
299 ERR_PRINTF3(_L("psuInfo.iVoltCheckInterval(%d) != expectedVoltCheckInterval(%d)"), psuInfo.iVoltCheckInterval, expectedVoltCheckInterval);
304 SetBlockResult(EFail);
305 WARN_PRINTF1(_L("VoltCheckInterval Value Missing From INI File"));
308 switch(psuInfo.iVoltCheckMethod)
310 case EDPsuChkComparator:
312 INFO_PRINTF1(_L("PSU VoltCheck Method is Comparator"));
315 case EDPsuChkADCType:
317 INFO_PRINTF1(_L("PSU VoltCheck Method is ADCType"));
320 case EDPsuChkADCType2:
322 INFO_PRINTF1(_L("PSU VoltCheck Method is ADCType2"));
326 ERR_PRINTF2(_L("PSU VoltCheck Method is Not Supported=%d"),psuInfo.iVoltCheckMethod);
328 TInt expectedVoltCheckMethod;
329 if ( GetEnumFromConfig(aSection, KVoltagecheck(), iEnumTableVoltageCheckMethod, expectedVoltCheckMethod) )
331 if(psuInfo.iVoltCheckMethod != (TUint)expectedVoltCheckMethod)
333 SetBlockResult(EFail);
334 ERR_PRINTF3(_L("psuInfo.iVoltCheckMethod(%d) != expectedVoltCheckMethod(%d)"), psuInfo.iVoltCheckMethod, expectedVoltCheckMethod);
339 SetBlockResult(EFail);
340 WARN_PRINTF1(_L("expectedVoltCheckMethod Value Missing From INI File"));
347 * TPBusState Information
349 * @param aSection The section in the ini containing data for the command
353 * @leave System wide error
355 void CT_MMCSDPsuDriverData::DoCmdPbusState(const TDesC& aSection)
359 err= iMmcSDController->PbusState(pbusState);
362 ERR_PRINTF2(_L("MMC/SD : Error in getting PbusState information, error code = %d \n"),err);
371 WARN_PRINTF1(_L("Card is absent in the slot"));
376 INFO_PRINTF1(_L("Bus State is OFF"));
381 INFO_PRINTF1(_L("Bus State is Powerwing Up"));
386 INFO_PRINTF1(_L("Bus State is Power ON"));
391 WARN_PRINTF1(_L("Bus State is BusPsuFault"));
394 case EBusPowerUpPending:
396 INFO_PRINTF1(_L("Bus State is BusPowerUpPending"));
400 ERR_PRINTF2(_L("Bus State Not Supported = %d"),pbusState);
402 TInt expectedPbusState;
403 if ( GetEnumFromConfig(aSection, KPbusState(), iEnumTablePbusState, expectedPbusState) )
405 if(pbusState != expectedPbusState)
407 ERR_PRINTF3(_L("pbusState(%d) != expectedPbusState(%d)"), pbusState, expectedPbusState);
408 SetBlockResult(EFail);
413 SetBlockResult(EFail);
414 WARN_PRINTF1(_L("expectedPbusState Value Missing From INI File"));
421 * Set Power Supply State
423 * @param aSection The section in the ini containing data for the command
427 * @leave System wide error
429 void CT_MMCSDPsuDriverData::DoCmdSetPsuState(const TDesC& aSection)
433 GetIntFromConfig(aSection, KPsuState(), psuState);
434 err=iMmcSDController->SetPsuState(psuState);
437 ERR_PRINTF2(_L("MMCSD : Error in Setting PowerSupply State, error code = %d \n"),err);
443 * PSU VCC State Information
445 * @param aSection The section in the ini containing data for the command
449 * @leave System wide error
451 void CT_MMCSDPsuDriverData::DoCmdVccState(const TDesC& aSection)
455 err= iMmcSDController->VccState(vccState);
458 ERR_PRINTF2(_L("MMC/SD : Error in getting VccState information, error code = %d \n"),err);
459 SetBlockResult(EFail);
467 INFO_PRINTF1(_L("PSU VCC State is PsuOff "));
470 case EDPsuOnCurLimit:
472 INFO_PRINTF1(_L("PSU VCC State is PsuOnCurLimit "));
477 INFO_PRINTF1(_L("PSU VCC State is PsuOnFull "));
481 ERR_PRINTF2(_L("PSU VCC State Not Supported = %d"),vccState);
483 TInt expectedvccState;
484 if ( GetEnumFromConfig(aSection, KVccState(), iEnumTableVccState, expectedvccState) )
486 if(vccState != expectedvccState)
488 ERR_PRINTF3(_L("vccState(%d) != expectedvccState(%d)"), vccState, expectedvccState);
489 SetBlockResult(EFail);
494 SetBlockResult(EFail);
495 WARN_PRINTF1(_L("expectedvccState Value Missing From INI File"));
500 *Set Psu Voltage in OCR Format
502 * @param aSection The section in the ini containing data for the command
506 * @leave System wide error
508 void CT_MMCSDPsuDriverData::DoCmdSetPsuVoltage(const TDesC& aSection)
511 TUint psuVoltage; //OCR Register Format
512 GetUintFromConfig(aSection, KPsuVoltage(), psuVoltage);
513 err=iMmcSDController->SetPsuVoltage(psuVoltage);
516 ERR_PRINTF2(_L("MMCSD : Error in Setting Psu Voltage, error code = %d \n"),err);
522 *Reads the MMCSD power supply unit number
524 * @param aSection The section in the ini containing data for the command
528 * @leave System wide error
530 void CT_MMCSDPsuDriverData::DoCmdPsuNumber(const TDesC& aSection)
534 err=iMmcSDController->PsuNumber(psuNumber);
537 ERR_PRINTF2(_L("MMCSD : Error in reading PSU Number from the platform, error code = %d \n"),err);
542 INFO_PRINTF2(_L("MMCSD Psu Number on platform = %d \n"),psuNumber);
543 TInt expectedpsuNumber;
544 if(GetIntFromConfig(aSection, KExpectedpsuNumber(), expectedpsuNumber))
546 if(psuNumber != expectedpsuNumber)
548 ERR_PRINTF3(_L("psuNumber(%d) != expectedpsuNumber(%d)"), psuNumber, expectedpsuNumber);
549 SetBlockResult(EFail);
554 SetBlockResult(EFail);
555 WARN_PRINTF1(_L("expectedpsuNumber Value Missing From INI File"));
561 *Reads the MMCSD Media Change ID
563 * @param aSection The section in the ini containing data for the command
567 * @leave System wide error
569 void CT_MMCSDPsuDriverData::DoCmdMediaChangeID(const TDesC& aSection)
572 TInt mediaChangeNumber;
573 err=iMmcSDController->MediaChangeID(mediaChangeNumber);
576 ERR_PRINTF2(_L("MMCSD : Error in reading MeadiaChangeID from the platform, error code = %d \n"),err);
581 INFO_PRINTF2(_L("MMCSD MeadiaChangeID on platform = %d \n"),mediaChangeNumber);
582 TInt expectedmediaChangeNumber;
583 if(GetIntFromConfig(aSection, KExpectedmediaChangeNumber(), expectedmediaChangeNumber))
585 if(mediaChangeNumber != expectedmediaChangeNumber)
587 ERR_PRINTF3(_L("mediaChangeNumber(%d) != expectedmediaChangeNumber(%d)"), mediaChangeNumber, expectedmediaChangeNumber);
588 SetBlockResult(EFail);
593 SetBlockResult(EFail);
594 WARN_PRINTF1(_L("expectedmediaChangeNumber Value Missing From INI File"));
601 *Reads PSU current is limited to a safe level or Not
603 * @param aSection The section in the ini containing data for the command
607 * @leave System wide error
609 void CT_MMCSDPsuDriverData::DoCmdPsuCurLimit(const TDesC& aSection)
613 err=iMmcSDController->PsuCurLimit(psuCurLimit);
616 ERR_PRINTF2(_L("MMCSD : Error in reading PsuCurLimit from the platform, error code = %d \n"),err);
621 INFO_PRINTF2(_L("MMCSD PsuCurLimit on platform = %d \n"),psuCurLimit);
622 TInt expectedpsuCurLimit;
623 if(GetIntFromConfig(aSection, KExpectedpsuCurLimit(), expectedpsuCurLimit))
625 if(psuCurLimit != expectedpsuCurLimit)
627 ERR_PRINTF3(_L("psuCurLimit(%d) != expectedpsuCurLimit(%d)"), psuCurLimit, expectedpsuCurLimit);
628 SetBlockResult(EFail);
633 SetBlockResult(EFail);
634 WARN_PRINTF1(_L("expectedpsuCurLimit Value Missing From INI File"));