os/kernelhwsrv/kernel/eka/include/drivers/sdcard.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 1999-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 // SD-specific extensions of generic MMC classes adhering to SD Physical layer simplified spec v2.0
    15 // 
    16 //
    17 
    18 /**
    19  @file
    20  @internalComponent
    21 */
    22 
    23 #ifndef __SDCARD_H__
    24 #define __SDCARD_H__
    25 
    26 #include <drivers/mmc.h>
    27 
    28 class DSDStack;
    29 
    30 enum TSDSessionTypeEnum
    31 	{
    32 	// empty.
    33 	};
    34 
    35 const TUint KSDMinCustomSession = KMMCMinCustomSession + 1024;
    36 
    37 const TUint32 KSDBusWidth1				 = 0x00;	
    38 const TUint32 KSDBusWidth4				 = 0x02;
    39 const TUint32 KSDStatusBlockLength		 = 0x40;
    40 
    41 const TUint32 KSDSCRLength				 = 0x08;
    42 const TUint32 KSDSwitchFuncLength		 = 0x40;
    43 const TUint32 KSDCheckFunctionHighSpeed	 = 0x00FFFF01;
    44 const TUint32 KSDSwitchFunctionHighSpeed = 0x80FFFF01;
    45 
    46 const TUint32 KSDCardIsSDCard			 = KBit16;	// KMMCardFirstCustomFlag
    47 const TUint32 KSDCardFirstCustomFlag	 = KBit24;
    48 
    49 const TUint   KSDDTClk25MHz				 = 25000; //25000KHz
    50 const TUint   KSDDTClk50MHz				 = 50000; //50000KHz
    51 
    52 class TSDCSD : public TCSD
    53 	{
    54 public:
    55 	inline TSDCSD(const TCSD& aCSD);
    56 
    57 	inline TBool SDEraseBlkEn() const;
    58 	inline TBool SDSectorSize() const;
    59 	inline TBool SDWPGrpSize() const;
    60 	};
    61 
    62 class TSDCard : public TMMCard
    63 	{
    64 public:
    65 	TSDCard();
    66 	inline TBool IsSDCard() const;
    67 	inline TUint32 ProtectedAreaSize() const;
    68 	inline void SetProtectedAreaSize(TUint32 aPAS);
    69 	inline TUint8 GetAUSize() const;
    70 	inline void SetAUSize(TUint8 aAU);
    71 	inline TInt DeviceSize() const;
    72 	virtual TUint32 PreferredWriteGroupLength() const;
    73 	virtual TInt GetFormatInfo(TLDFormatInfo& aFormatInfo) const;
    74 	virtual TUint32 MinEraseSectorSize() const;
    75 	virtual TUint32 EraseSectorSize() const;
    76 	virtual TInt GetEraseInfo(TMMCEraseInfo& anEraseInfo) const;
    77 	virtual TInt MaxReadBlLen() const;
    78 	virtual TInt MaxWriteBlLen() const;
    79 	virtual TInt64 DeviceSize64() const;
    80 	enum {KPARootDirEndUnknown = 0};
    81 	inline TUint32 PARootDirEnd() const;
    82 	inline void SetPARootDirEnd(TUint32 aPARootDirEnd);
    83 	virtual TUint MaxTranSpeedInKilohertz() const;
    84 private:
    85 	TUint32 iProtectedAreaSize;
    86 	TUint32 iPARootDirEnd;
    87 	TUint8	iAUSize;
    88 	TUint8 iPad[3];
    89 	TUint32 iSpare[4];
    90 	};
    91 
    92 class TSDCardArray : public TMMCardArray
    93 	{
    94 public:
    95 	inline TSDCardArray(DSDStack* aOwningStack);
    96 	IMPORT_C virtual TInt AllocCards();
    97 
    98 	inline TSDCard& Card(TUint aCardNumber) const;
    99 	inline TSDCard& NewCard(TUint aCardNumber) const;
   100 	void AddCardSDMode(TUint aCardNumber,const TUint8* aCID,TRCA* aNewRCA);
   101 	TInt StoreRCAIfUnique(TUint aCardNumber,TRCA& anRCA);
   102 	IMPORT_C virtual void DeclareCardAsGone(TUint aCardNumber);
   103 	};
   104 
   105 enum TSDAppCmd
   106 	{
   107 	ESDACmdSetBusWidth = 6,
   108 	ESDACmdSDStatus = 13,
   109 	ESDACmdSendNumWrBlocks = 22,
   110 	ESDACmdSetWrBlkEraseCount = 23,
   111 	ESDACmdSDAppOpCond = 41,
   112 	ESDACmdSetClrCardDetect = 42,
   113 	ESDACmdSendSCR = 51
   114 	};
   115 
   116 enum TSDSpecificCmd
   117 	{
   118 	ESDCmdSendRelativeAddress = 3,
   119 	ESDCmdSwitchFunction = 6,
   120 	ESDCmdSendIfCond = 8
   121 	};
   122 
   123 class DSDSession : public DMMCSession
   124 	{
   125 public:
   126 	inline DSDSession(const TMMCCallBack& aCallBack);
   127 
   128 	static void FillAppCommandDesc(TMMCCommandDesc& aDesc, TSDAppCmd aCmd);
   129 	static void FillAppCommandDesc(TMMCCommandDesc& aDesc, TSDAppCmd aCmd, TMMCArgument aArg);
   130 
   131 	static void FillSdSpecificCommandDesc(TMMCCommandDesc& aDesc, TSDSpecificCmd aCmd);
   132 	static void FillSdSpecificCommandDesc(TMMCCommandDesc& aDesc, TSDSpecificCmd aCmd, TMMCArgument aArg);
   133 
   134 protected:
   135 	// not implemented.  No SD specific macros
   136 //	virtual TMMCSMSTFunc GetMacro(TInt aSessNum) const;
   137 
   138 private:
   139 	static void FillAppCommandDesc(TMMCCommandDesc& aDesc);
   140 	static void FillSdSpecificCommandDesc(TMMCCommandDesc& aDesc);
   141 	};
   142 
   143 const TInt KSDMaxMBWRetries = 1;
   144 const TUint32 KSDACMD22BlockLen = 4;
   145 class DSDStack : public DMMCStack
   146 	{
   147 public:
   148 	inline DSDStack(TInt aBus, DMMCSocket* aSocket);
   149 	
   150 	IMPORT_C virtual TInt Init();
   151 	IMPORT_C virtual TMMCErr AcquireStackSM();
   152 	IMPORT_C virtual TMMCErr CIMReadWriteBlocksSM();
   153 	IMPORT_C virtual DMMCSession* AllocSession(const TMMCCallBack& aCallBack) const;
   154 
   155 	virtual void AddressCard(TInt aCardNumber) = 0;
   156 
   157 	inline TSDCardArray& CardArray() const;
   158 
   159 protected:
   160 	IMPORT_C virtual TMMCErr InitStackAfterUnlockSM();
   161 
   162 	static TMMCErr InitialiseMemoryCardSMST(TAny* aStackP);
   163 	TMMCErr InitialiseMemoryCardSM();
   164 
   165 	static TMMCErr ConfigureMemoryCardSMST(TAny* aStackP);
   166 	TMMCErr ConfigureMemoryCardSM();
   167 
   168 	static TMMCErr CIMReadWriteMemoryBlocksSMST(TAny* aStackP);
   169 
   170 	static TMMCErr BaseModifyCardCapabilitySMST(TAny* aStackP);
   171     IMPORT_C virtual TMMCErr ModifyCardCapabilitySM();
   172 
   173 	static TMMCErr SwitchToHighSpeedModeSMST(TAny* aStackP);
   174     TMMCErr SwitchToHighSpeedModeSM();
   175 
   176 private:
   177 	TInt iSpare;
   178 	enum TSDCardType {ESDCardTypeUnknown, ESDCardTypeIsMMC, ESDCardTypeIsSD};
   179 	TSDCardType iCxCardType; 			// Used when detecting whether an SD Memory card is present.
   180 	TUint8 iACMD22[KSDACMD22BlockLen];
   181 
   182 private:
   183     //
   184     // Dummy functions to maintain binary compatibility
   185     IMPORT_C virtual void Dummy1();
   186     IMPORT_C virtual void Dummy2();
   187     IMPORT_C virtual void Dummy3();
   188     IMPORT_C virtual void Dummy4();
   189     //
   190     // Reserved members to maintain binary compatibility
   191     TInt iReserved[68];
   192 	};
   193 
   194 #include <drivers/sdcard.inl>
   195 
   196 #endif	// #ifndef __SDCARD_H__