sl@0: // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // SD-specific extensions of generic MMC classes adhering to SD Physical layer simplified spec v2.0 sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent sl@0: */ sl@0: sl@0: #ifndef __SDCARD_H__ sl@0: #define __SDCARD_H__ sl@0: sl@0: #include sl@0: sl@0: class DSDStack; sl@0: sl@0: enum TSDSessionTypeEnum sl@0: { sl@0: // empty. sl@0: }; sl@0: sl@0: const TUint KSDMinCustomSession = KMMCMinCustomSession + 1024; sl@0: sl@0: const TUint32 KSDBusWidth1 = 0x00; sl@0: const TUint32 KSDBusWidth4 = 0x02; sl@0: const TUint32 KSDStatusBlockLength = 0x40; sl@0: sl@0: const TUint32 KSDSCRLength = 0x08; sl@0: const TUint32 KSDSwitchFuncLength = 0x40; sl@0: const TUint32 KSDCheckFunctionHighSpeed = 0x00FFFF01; sl@0: const TUint32 KSDSwitchFunctionHighSpeed = 0x80FFFF01; sl@0: sl@0: const TUint32 KSDCardIsSDCard = KBit16; // KMMCardFirstCustomFlag sl@0: const TUint32 KSDCardFirstCustomFlag = KBit24; sl@0: sl@0: const TUint KSDDTClk25MHz = 25000; //25000KHz sl@0: const TUint KSDDTClk50MHz = 50000; //50000KHz sl@0: sl@0: class TSDCSD : public TCSD sl@0: { sl@0: public: sl@0: inline TSDCSD(const TCSD& aCSD); sl@0: sl@0: inline TBool SDEraseBlkEn() const; sl@0: inline TBool SDSectorSize() const; sl@0: inline TBool SDWPGrpSize() const; sl@0: }; sl@0: sl@0: class TSDCard : public TMMCard sl@0: { sl@0: public: sl@0: TSDCard(); sl@0: inline TBool IsSDCard() const; sl@0: inline TUint32 ProtectedAreaSize() const; sl@0: inline void SetProtectedAreaSize(TUint32 aPAS); sl@0: inline TUint8 GetAUSize() const; sl@0: inline void SetAUSize(TUint8 aAU); sl@0: inline TInt DeviceSize() const; sl@0: virtual TUint32 PreferredWriteGroupLength() const; sl@0: virtual TInt GetFormatInfo(TLDFormatInfo& aFormatInfo) const; sl@0: virtual TUint32 MinEraseSectorSize() const; sl@0: virtual TUint32 EraseSectorSize() const; sl@0: virtual TInt GetEraseInfo(TMMCEraseInfo& anEraseInfo) const; sl@0: virtual TInt MaxReadBlLen() const; sl@0: virtual TInt MaxWriteBlLen() const; sl@0: virtual TInt64 DeviceSize64() const; sl@0: enum {KPARootDirEndUnknown = 0}; sl@0: inline TUint32 PARootDirEnd() const; sl@0: inline void SetPARootDirEnd(TUint32 aPARootDirEnd); sl@0: virtual TUint MaxTranSpeedInKilohertz() const; sl@0: private: sl@0: TUint32 iProtectedAreaSize; sl@0: TUint32 iPARootDirEnd; sl@0: TUint8 iAUSize; sl@0: TUint8 iPad[3]; sl@0: TUint32 iSpare[4]; sl@0: }; sl@0: sl@0: class TSDCardArray : public TMMCardArray sl@0: { sl@0: public: sl@0: inline TSDCardArray(DSDStack* aOwningStack); sl@0: IMPORT_C virtual TInt AllocCards(); sl@0: sl@0: inline TSDCard& Card(TUint aCardNumber) const; sl@0: inline TSDCard& NewCard(TUint aCardNumber) const; sl@0: void AddCardSDMode(TUint aCardNumber,const TUint8* aCID,TRCA* aNewRCA); sl@0: TInt StoreRCAIfUnique(TUint aCardNumber,TRCA& anRCA); sl@0: IMPORT_C virtual void DeclareCardAsGone(TUint aCardNumber); sl@0: }; sl@0: sl@0: enum TSDAppCmd sl@0: { sl@0: ESDACmdSetBusWidth = 6, sl@0: ESDACmdSDStatus = 13, sl@0: ESDACmdSendNumWrBlocks = 22, sl@0: ESDACmdSetWrBlkEraseCount = 23, sl@0: ESDACmdSDAppOpCond = 41, sl@0: ESDACmdSetClrCardDetect = 42, sl@0: ESDACmdSendSCR = 51 sl@0: }; sl@0: sl@0: enum TSDSpecificCmd sl@0: { sl@0: ESDCmdSendRelativeAddress = 3, sl@0: ESDCmdSwitchFunction = 6, sl@0: ESDCmdSendIfCond = 8 sl@0: }; sl@0: sl@0: class DSDSession : public DMMCSession sl@0: { sl@0: public: sl@0: inline DSDSession(const TMMCCallBack& aCallBack); sl@0: sl@0: static void FillAppCommandDesc(TMMCCommandDesc& aDesc, TSDAppCmd aCmd); sl@0: static void FillAppCommandDesc(TMMCCommandDesc& aDesc, TSDAppCmd aCmd, TMMCArgument aArg); sl@0: sl@0: static void FillSdSpecificCommandDesc(TMMCCommandDesc& aDesc, TSDSpecificCmd aCmd); sl@0: static void FillSdSpecificCommandDesc(TMMCCommandDesc& aDesc, TSDSpecificCmd aCmd, TMMCArgument aArg); sl@0: sl@0: protected: sl@0: // not implemented. No SD specific macros sl@0: // virtual TMMCSMSTFunc GetMacro(TInt aSessNum) const; sl@0: sl@0: private: sl@0: static void FillAppCommandDesc(TMMCCommandDesc& aDesc); sl@0: static void FillSdSpecificCommandDesc(TMMCCommandDesc& aDesc); sl@0: }; sl@0: sl@0: const TInt KSDMaxMBWRetries = 1; sl@0: const TUint32 KSDACMD22BlockLen = 4; sl@0: class DSDStack : public DMMCStack sl@0: { sl@0: public: sl@0: inline DSDStack(TInt aBus, DMMCSocket* aSocket); sl@0: sl@0: IMPORT_C virtual TInt Init(); sl@0: IMPORT_C virtual TMMCErr AcquireStackSM(); sl@0: IMPORT_C virtual TMMCErr CIMReadWriteBlocksSM(); sl@0: IMPORT_C virtual DMMCSession* AllocSession(const TMMCCallBack& aCallBack) const; sl@0: sl@0: virtual void AddressCard(TInt aCardNumber) = 0; sl@0: sl@0: inline TSDCardArray& CardArray() const; sl@0: sl@0: protected: sl@0: IMPORT_C virtual TMMCErr InitStackAfterUnlockSM(); sl@0: sl@0: static TMMCErr InitialiseMemoryCardSMST(TAny* aStackP); sl@0: TMMCErr InitialiseMemoryCardSM(); sl@0: sl@0: static TMMCErr ConfigureMemoryCardSMST(TAny* aStackP); sl@0: TMMCErr ConfigureMemoryCardSM(); sl@0: sl@0: static TMMCErr CIMReadWriteMemoryBlocksSMST(TAny* aStackP); sl@0: sl@0: static TMMCErr BaseModifyCardCapabilitySMST(TAny* aStackP); sl@0: IMPORT_C virtual TMMCErr ModifyCardCapabilitySM(); sl@0: sl@0: static TMMCErr SwitchToHighSpeedModeSMST(TAny* aStackP); sl@0: TMMCErr SwitchToHighSpeedModeSM(); sl@0: sl@0: private: sl@0: TInt iSpare; sl@0: enum TSDCardType {ESDCardTypeUnknown, ESDCardTypeIsMMC, ESDCardTypeIsSD}; sl@0: TSDCardType iCxCardType; // Used when detecting whether an SD Memory card is present. sl@0: TUint8 iACMD22[KSDACMD22BlockLen]; sl@0: sl@0: private: sl@0: // sl@0: // Dummy functions to maintain binary compatibility sl@0: IMPORT_C virtual void Dummy1(); sl@0: IMPORT_C virtual void Dummy2(); sl@0: IMPORT_C virtual void Dummy3(); sl@0: IMPORT_C virtual void Dummy4(); sl@0: // sl@0: // Reserved members to maintain binary compatibility sl@0: TInt iReserved[68]; sl@0: }; sl@0: sl@0: #include sl@0: sl@0: #endif // #ifndef __SDCARD_H__