1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kernel/eka/include/drivers/sdcard.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,196 @@
1.4 +// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// SD-specific extensions of generic MMC classes adhering to SD Physical layer simplified spec v2.0
1.18 +//
1.19 +//
1.20 +
1.21 +/**
1.22 + @file
1.23 + @internalComponent
1.24 +*/
1.25 +
1.26 +#ifndef __SDCARD_H__
1.27 +#define __SDCARD_H__
1.28 +
1.29 +#include <drivers/mmc.h>
1.30 +
1.31 +class DSDStack;
1.32 +
1.33 +enum TSDSessionTypeEnum
1.34 + {
1.35 + // empty.
1.36 + };
1.37 +
1.38 +const TUint KSDMinCustomSession = KMMCMinCustomSession + 1024;
1.39 +
1.40 +const TUint32 KSDBusWidth1 = 0x00;
1.41 +const TUint32 KSDBusWidth4 = 0x02;
1.42 +const TUint32 KSDStatusBlockLength = 0x40;
1.43 +
1.44 +const TUint32 KSDSCRLength = 0x08;
1.45 +const TUint32 KSDSwitchFuncLength = 0x40;
1.46 +const TUint32 KSDCheckFunctionHighSpeed = 0x00FFFF01;
1.47 +const TUint32 KSDSwitchFunctionHighSpeed = 0x80FFFF01;
1.48 +
1.49 +const TUint32 KSDCardIsSDCard = KBit16; // KMMCardFirstCustomFlag
1.50 +const TUint32 KSDCardFirstCustomFlag = KBit24;
1.51 +
1.52 +const TUint KSDDTClk25MHz = 25000; //25000KHz
1.53 +const TUint KSDDTClk50MHz = 50000; //50000KHz
1.54 +
1.55 +class TSDCSD : public TCSD
1.56 + {
1.57 +public:
1.58 + inline TSDCSD(const TCSD& aCSD);
1.59 +
1.60 + inline TBool SDEraseBlkEn() const;
1.61 + inline TBool SDSectorSize() const;
1.62 + inline TBool SDWPGrpSize() const;
1.63 + };
1.64 +
1.65 +class TSDCard : public TMMCard
1.66 + {
1.67 +public:
1.68 + TSDCard();
1.69 + inline TBool IsSDCard() const;
1.70 + inline TUint32 ProtectedAreaSize() const;
1.71 + inline void SetProtectedAreaSize(TUint32 aPAS);
1.72 + inline TUint8 GetAUSize() const;
1.73 + inline void SetAUSize(TUint8 aAU);
1.74 + inline TInt DeviceSize() const;
1.75 + virtual TUint32 PreferredWriteGroupLength() const;
1.76 + virtual TInt GetFormatInfo(TLDFormatInfo& aFormatInfo) const;
1.77 + virtual TUint32 MinEraseSectorSize() const;
1.78 + virtual TUint32 EraseSectorSize() const;
1.79 + virtual TInt GetEraseInfo(TMMCEraseInfo& anEraseInfo) const;
1.80 + virtual TInt MaxReadBlLen() const;
1.81 + virtual TInt MaxWriteBlLen() const;
1.82 + virtual TInt64 DeviceSize64() const;
1.83 + enum {KPARootDirEndUnknown = 0};
1.84 + inline TUint32 PARootDirEnd() const;
1.85 + inline void SetPARootDirEnd(TUint32 aPARootDirEnd);
1.86 + virtual TUint MaxTranSpeedInKilohertz() const;
1.87 +private:
1.88 + TUint32 iProtectedAreaSize;
1.89 + TUint32 iPARootDirEnd;
1.90 + TUint8 iAUSize;
1.91 + TUint8 iPad[3];
1.92 + TUint32 iSpare[4];
1.93 + };
1.94 +
1.95 +class TSDCardArray : public TMMCardArray
1.96 + {
1.97 +public:
1.98 + inline TSDCardArray(DSDStack* aOwningStack);
1.99 + IMPORT_C virtual TInt AllocCards();
1.100 +
1.101 + inline TSDCard& Card(TUint aCardNumber) const;
1.102 + inline TSDCard& NewCard(TUint aCardNumber) const;
1.103 + void AddCardSDMode(TUint aCardNumber,const TUint8* aCID,TRCA* aNewRCA);
1.104 + TInt StoreRCAIfUnique(TUint aCardNumber,TRCA& anRCA);
1.105 + IMPORT_C virtual void DeclareCardAsGone(TUint aCardNumber);
1.106 + };
1.107 +
1.108 +enum TSDAppCmd
1.109 + {
1.110 + ESDACmdSetBusWidth = 6,
1.111 + ESDACmdSDStatus = 13,
1.112 + ESDACmdSendNumWrBlocks = 22,
1.113 + ESDACmdSetWrBlkEraseCount = 23,
1.114 + ESDACmdSDAppOpCond = 41,
1.115 + ESDACmdSetClrCardDetect = 42,
1.116 + ESDACmdSendSCR = 51
1.117 + };
1.118 +
1.119 +enum TSDSpecificCmd
1.120 + {
1.121 + ESDCmdSendRelativeAddress = 3,
1.122 + ESDCmdSwitchFunction = 6,
1.123 + ESDCmdSendIfCond = 8
1.124 + };
1.125 +
1.126 +class DSDSession : public DMMCSession
1.127 + {
1.128 +public:
1.129 + inline DSDSession(const TMMCCallBack& aCallBack);
1.130 +
1.131 + static void FillAppCommandDesc(TMMCCommandDesc& aDesc, TSDAppCmd aCmd);
1.132 + static void FillAppCommandDesc(TMMCCommandDesc& aDesc, TSDAppCmd aCmd, TMMCArgument aArg);
1.133 +
1.134 + static void FillSdSpecificCommandDesc(TMMCCommandDesc& aDesc, TSDSpecificCmd aCmd);
1.135 + static void FillSdSpecificCommandDesc(TMMCCommandDesc& aDesc, TSDSpecificCmd aCmd, TMMCArgument aArg);
1.136 +
1.137 +protected:
1.138 + // not implemented. No SD specific macros
1.139 +// virtual TMMCSMSTFunc GetMacro(TInt aSessNum) const;
1.140 +
1.141 +private:
1.142 + static void FillAppCommandDesc(TMMCCommandDesc& aDesc);
1.143 + static void FillSdSpecificCommandDesc(TMMCCommandDesc& aDesc);
1.144 + };
1.145 +
1.146 +const TInt KSDMaxMBWRetries = 1;
1.147 +const TUint32 KSDACMD22BlockLen = 4;
1.148 +class DSDStack : public DMMCStack
1.149 + {
1.150 +public:
1.151 + inline DSDStack(TInt aBus, DMMCSocket* aSocket);
1.152 +
1.153 + IMPORT_C virtual TInt Init();
1.154 + IMPORT_C virtual TMMCErr AcquireStackSM();
1.155 + IMPORT_C virtual TMMCErr CIMReadWriteBlocksSM();
1.156 + IMPORT_C virtual DMMCSession* AllocSession(const TMMCCallBack& aCallBack) const;
1.157 +
1.158 + virtual void AddressCard(TInt aCardNumber) = 0;
1.159 +
1.160 + inline TSDCardArray& CardArray() const;
1.161 +
1.162 +protected:
1.163 + IMPORT_C virtual TMMCErr InitStackAfterUnlockSM();
1.164 +
1.165 + static TMMCErr InitialiseMemoryCardSMST(TAny* aStackP);
1.166 + TMMCErr InitialiseMemoryCardSM();
1.167 +
1.168 + static TMMCErr ConfigureMemoryCardSMST(TAny* aStackP);
1.169 + TMMCErr ConfigureMemoryCardSM();
1.170 +
1.171 + static TMMCErr CIMReadWriteMemoryBlocksSMST(TAny* aStackP);
1.172 +
1.173 + static TMMCErr BaseModifyCardCapabilitySMST(TAny* aStackP);
1.174 + IMPORT_C virtual TMMCErr ModifyCardCapabilitySM();
1.175 +
1.176 + static TMMCErr SwitchToHighSpeedModeSMST(TAny* aStackP);
1.177 + TMMCErr SwitchToHighSpeedModeSM();
1.178 +
1.179 +private:
1.180 + TInt iSpare;
1.181 + enum TSDCardType {ESDCardTypeUnknown, ESDCardTypeIsMMC, ESDCardTypeIsSD};
1.182 + TSDCardType iCxCardType; // Used when detecting whether an SD Memory card is present.
1.183 + TUint8 iACMD22[KSDACMD22BlockLen];
1.184 +
1.185 +private:
1.186 + //
1.187 + // Dummy functions to maintain binary compatibility
1.188 + IMPORT_C virtual void Dummy1();
1.189 + IMPORT_C virtual void Dummy2();
1.190 + IMPORT_C virtual void Dummy3();
1.191 + IMPORT_C virtual void Dummy4();
1.192 + //
1.193 + // Reserved members to maintain binary compatibility
1.194 + TInt iReserved[68];
1.195 + };
1.196 +
1.197 +#include <drivers/sdcard.inl>
1.198 +
1.199 +#endif // #ifndef __SDCARD_H__