📄 mmc_protocol.h
字号:
/*
DaVinci ARM Evaluation Software
(c)Texas Instruments 2004
*/
/** \file mmc_protocol.h
\brief MMC Related header, which is protocol specific
*/
#ifndef _MMC_PROTOCOL_H_
#define _MMC_PROTOCOL_H_
/* Commands and their responses */
/* MMC */
#define MMC_SEND_OP_COND (MMCSD_CMD1 | MMCSD_RSP3 )
#define MMC_SET_RELATIVE_ADDR (MMCSD_CMD3 | MMCSD_RSP1)
#define MMC_READ_DAT_UNTIL_STOP (MMCSD_CMD11 | MMCSD_RSP1)
#define MMC_WRITE_DAT_UNTIL_STOP (MMCSD_CMD20 | MMCSD_RSP1)/* | MMCSD_BSYEXP)*/
#define MMC_PROGRAM_CID (MMCSD_CMD26 | MMCSD_RSP1)/* MMCSD_BSYEXP) */ /* Programmed only once by Manufacturer. Hence not implemented */
#define MMC_FAST_IO (MMCSD_CMD39 | MMCSD_RSP4 )
#define MMC_GO_IRQ_STATE (MMCSD_CMD40 | MMCSD_RSP5 )
#define MMC_LOCK_UNLOCK (MMCSD_CMD42 | MMCSD_RSP1 | MMCSD_BSYEXP)
#define MMC_GEN_CMD (MMCSD_CMD56 | MMCSD_RSP1 | MMCSD_BSYEXP)
/* SPI */
#define MMC_SPI_GO_IDLE_STATE (MMCSD_CMD0 | MMCSD_RSP1)
#define MMC_SPI_SEND_OP_COND (MMCSD_CMD1 | MMCSD_RSP1)
#define MMC_SPI_SEND_CSD (MMCSD_CMD9 | MMCSD_RSP1)
#define MMC_SPI_SEND_CID (MMCSD_CMD10| MMCSD_RSP1)
#define MMC_SPI_SEND_STATUS (MMCSD_CMD13 | MMCSD_RSP2)
#define MMC_CRC_ON_OFF (MMCSD_CMD59 | MMCSD_RSP1)
/* Common to SPI & MMC */
#define MMC_SET_BLOCKCOUNT (MMCSD_CMD23 | MMCSD_RSP1 )
#define MMC_TAG_SECTOR_START (MMCSD_CMD32 | MMCSD_RSP1)
#define MMC_TAG_SECTOR_END (MMCSD_CMD33 | MMCSD_RSP1)
#define MMC_UNTAG_SECTOR (MMCSD_CMD34 | MMCSD_RSP1)
#define MMC_TAG_ERASE_GROUP_START (MMCSD_CMD35 | MMCSD_RSP1)
#define MMC_TAG_ERASE_GROUP_END (MMCSD_CMD36 | MMCSD_RSP1)
#define MMC_UNTAG_ERASE_GROUP (MMCSD_CMD37 | MMCSD_RSP1)
#define MMC_ERASE (MMCSD_CMD38 | MMCSD_RSP1 | MMCSD_BSYEXP)
/**
\brief CSD Register Ver. 1.2
*/
typedef struct {
Uint8 crc; ///< 7 bit redundancy check [7:1]
Uint8 ecc; ///< 2 bit ECC code [9:8]
Uint8 fileFormat; ///< 2 bit file format [11:10]
Uint8 tmpWriteProtect; ///< 1 bit to dis/en-able temporary WP [12:12]
Uint8 permWriteProtect; ///< 1 bit to dis/en-able permanent WP [13:13]
Uint8 copy; ///< 1 bit copy flag [14:14]
Uint8 fileFormatGrp; ///< 1 bit file format group [15:15]
Uint8 contentProtApp; ///< 1 bit indicates if content protection application [16:16] - present only in Spec Ver 3.2
Uint8 writeBlPartial; ///< 1 bit indicates if partial write blk [21:21]
Uint8 writeBlLen; ///< 4 bit maximum write block length [25:22]
Uint8 r2wFactor; ///< 3 bit stream write factor [28:26]
Uint8 defaultEcc; ///< 2 bit Manufacturer Default ECC [30:29]
Uint8 wpGrpEnable; ///< 1 bit write protect enable flag [31:31]
Uint8 wpGrpSize; ///< 5 bit write protect group size [36:32]
Uint8 eraseGrpMult; ///< 5 bit erase group size multiplier [41:37]
Uint8 eraseGrpSize; ///< 5 bit erase group size [46:42]
Uint8 cSizeMult; ///< 3 bit device size multiplier [49:47]
Uint8 vddWCurrMax; ///< 3 bit Max. Write Current @ Vdd Max [52:50]
Uint8 vddWCurrMin; ///< 3 bit Max. Write Current @ Vdd Min [55:53]
Uint8 vddRCurrMax; ///< 3 bit Max. Read Current @ Vdd Max [58:56]
Uint8 vddRCurrMin; ///< 3 bit Max. Read Current @ Vdd Min [61:59]
Uint16 cSize; ///< 12 bit device size [73:62]
Uint8 dsrImp; ///< 1 bit flag indicates if MMC has DSR reg [76:76]
Uint8 readBlkMisalign; ///< 1 bit flag indicates rd blk misaligned [77:77]
Uint8 writeBlkMisalign; ///< 1 bit flag indicates write blk misalign [78:78]
Uint8 readBlPartial; ///< 1 bit indicates if partial read blk [79:79]
Uint8 readBlLen; ///< 4 bit maximum Read Block Length [83:80]
Uint16 ccc; ///< 12 bit card command classes [95:84]
Uint8 tranSpeed; ///< 8 bit max data transmission speed [103:96]
Uint8 nsac; ///< 8 bit NSAC [111:104]
Uint8 taac; ///< 8 bit TAAC [119:112]
Uint8 specVers; ///< 4 bit MMC system specification version [125:122]
Uint8 csdStructure; ///< 2 bit structure type field [127:126]
} MMC_ver1_2CSDReg;
/**
\brief CSD Register Ver. 1.1
*/
typedef struct {
Uint8 crc; ///< 7 bit redundancy check [7:1]
Uint8 ecc; ///< 2 bit ECC code [9:8]
Uint8 tmpWriteProtect; ///< 1 bit to dis/en-able temporary WP [12:12]
Uint8 permWriteProtect; ///< 1 bit to dis/en-able permanent WP [13:13]
Uint8 copy; ///< 1 bit copy flag [14:14]
Uint8 writeBlPartial; ///< 1 bit indicates if partial write blk [21:21]
Uint8 writeBlLen; ///< 4 bit maximum write block length [25:22]
Uint8 r2wFactor; ///< 3 bit stream write factor [28:26]
Uint8 defaultEcc; ///< 2 bit Manufacturer Default ECC [30:29]
Uint8 wpGrpEnable; ///< 1 bit write protect enable flag [31:31]
Uint8 wpGrpSize; ///< 5 bit write protect group size [36:32]
Uint8 eraseGrpSize; ///< 5 bit erase group size [41:37]
Uint8 sectSize; ///< 5 bit erase sector size [46:42]
Uint8 cSizeMult; ///< 3 bit device size multiplier [49:47]
Uint8 vddWCurrMax; ///< 3 bit Max. Write Current @ Vdd Max [52:50]
Uint8 vddWCurrMin; ///< 3 bit Max. Write Current @ Vdd Min [55:53]
Uint8 vddRCurrMax; ///< 3 bit Max. Read Current @ Vdd Max [58:56]
Uint8 vddRCurrMin; ///< 3 bit Max. Read Current @ Vdd Min [61:59]
Uint16 cSize; ///< 12 bit device size [73:62]
Uint8 dsrImp; ///< 1 bit flag indicates if MMC has DSR reg [76:76]
Uint8 readBlkMisalign; ///< 1 bit flag indicates rd blk misaligned [77:77]
Uint8 writeBlkMisalign; ///< 1 bit flag indicates write blk misalign [78:78]
Uint8 readBlPartial; ///< 1 bit indicates if partial read blk [79:79]
Uint8 readBlLen; ///< 4 bit maximum Read Block Length [83:80]
Uint16 ccc; ///< 12 bit card command classes [95:84]
Uint8 tranSpeed; ///< 8 bit max data transmission speed [103:96]
Uint8 nsac; ///< 8 bit NSAC [111:104]
Uint8 taac; ///< 8 bit TAAC [119:112]
Uint8 mmcProt; ///< 4 bit MMC protocol version [125:122]
Uint8 csdStructure; ///< 2 bit structure type field [127:126]
} MMC_ver1_1CSDReg;
/**
\brief CID Register - MMC Spec Ver > 1.4
*/
typedef struct {
Uint8 CRC; ///< 7 bit CRC checksum [7:1]
Uint8 MDT_y; ///< 4 bit Manufacturing Date (Year) [11:8]
Uint8 MDT_m; ///< 4 bit Manufacturing Date (Month)[15:12]
Uint32 PSN; ///< 32 bit Serial Number [47:16]
Uint8 PRV_m; ///< 4 bit : 'm' Product Revision Number(n.m) [51:48]
Uint8 PRV_n; ///< 4 bit : 'n' Product Revision Number(n.m) [55:52]
char PNM[6]; ///< 6 ASCII character Product Name [103:46]
Uint16 OID; ///< 16 bit card OEM/Application ID [119:104]
Uint8 MID; ///< 8 bit Manufacturer's ID [127:120]
} MMC_ver3_1specCIDReg;
/**
\brief CID Register - MMC Spec. Ver. 1.4
*/
typedef struct {
Uint8 CRC; ///< 7 bit CRC checksum [7:1]
Uint8 CIN[12]; ///< 96 bit Card Individual Number [103:8]
Uint32 MID; ///< 24 bit Manufacturer's ID [127:104]
} MMC_ver1_4specCIDReg;
/**
\brief SPI mode Card Status Register
*/
typedef struct {
Uint16 wpEraseSkip;
Uint16 generalErr;
Uint16 cardContrErr;
Uint16 cardECCFailed;
Uint16 wpViolation;
Uint16 invalidErase;
Uint16 outOfRange;
Uint16 idle;
Uint16 eraseReset;
Uint16 illegalCmd;
Uint16 crcError;
Uint16 eraseSeqErr;
Uint16 addrErr;
Uint16 paramErr;
} MMC_spiCardStatReg;
/* Function Prototypes */
STATUS MMC_sendOpCond( Uint32 voltageWindow, Uint32 opTimeOut );
STATUS MMC_setRCA( Uint32 rca, MMCSD_cardStatusReg *cardStatus );
STATUS MMC_setBlkCount( Uint32 numBlks );
STATUS MMC_erase( Uint32 startAddr, Uint32 endAddr, Uint16 untag, Uint32 *untagAddr, Uint16 groupFlag);
STATUS MMC_goIRQState( Uint16 *rcaRcvd );
STATUS MMC_setPassword( Uint8 oldPasswordSize, Uint8 newPasswordSize, Uint8 *oldPassword, Uint8 *newPassword,Uint32 cardMemAddr);
STATUS MMC_resetPassword( Uint8 currentPasswordSize, Uint8 *currentPassword,Uint32 cardMemAddr );
Uint8 MMC_cardLock( Uint8 cardLockMode, Uint8 oldPasswordSize, Uint8 newPasswordSize, Uint8 *oldPassword, Uint8 *newPassword,Uint32 cardMemAddr );
Uint8 MMC_cardUnlock( Uint8 cardLockMode, Uint8 currentPasswordSize, Uint8 *currentPassword,Uint32 cardMemAddr );
Uint8 MMC_forcedErase( Uint32 cardMemAddr );
STATUS MMC_fastIO( Uint32 rca, Uint8 regWriteFlag, Uint8 regAddr, Uint8 *regData );
STATUS MMC_genCmd( Bool read, Uint16 *data, Uint32 numWords,Uint32 cardMemAddr );
STATUS MMC_streamRead( Uint32 cardAddr, Uint32 *dest, Uint32 datalength, Uint32 dmaEnable, Uint32 endian);
STATUS MMC_streamWrite( Uint32 cardAddr, Uint32 *src, Uint32 datalength, Uint32 dmaEnable, Uint32 endian);
#endif /* _MMC_PROTOCOL_H_ */
/*@}*/
/* Rev.No. Date/Time ECN No. Modifier */
/* ------- --------- ------- -------- */
/* 1 24 Jun 2004 14:41:01 1864 xjarlika */
/* */
/* Checking in MMCSD drv include and src files */
/********************************************************************/
/* Rev.No. Date/Time ECN No. Modifier */
/* ------- --------- ------- -------- */
/* 2 Jul 15:22:19 8 2049 xjarlika */
/* */
/* FIFOCTL renamed as MMCFIFOCTL */
/* Update due to Register Name Change */
/********************************************************************/
/* Rev.No. Date/Time ECN No. Modifier */
/* ------- --------- ------- -------- */
/* 3 13 Aug 2004 18:21:53 2296 xjarlika */
/* */
/* Updating MMCSD include and src file after inital testing on Hibari*/
/* Updating MMCSD include and src file after inital testing on Hibari*/
/********************************************************************/
/* Rev.No. Date/Time ECN No. Modifier */
/* ------- --------- ------- -------- */
/* 4 24 Aug 2004 14:45:31 2401 xjarlika */
/* */
/* Updating MMCSD drv include and src files after testing on Hibari */
/********************************************************************/
/* Rev.No. Date/Time ECN No. Modifier */
/* ------- --------- ------- -------- */
/* 5 14 Jan 2005 11:26:22 5878 xjarlika */
/* */
/* Updating after testing on Davinci QT */
/********************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -