- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

csl_mmcsd.h
Go to the documentation of this file.

    00001 /*  ===========================================================================
    00002  *   Copyright (c) Texas Instruments Inc 2002, 2003, 2004, 2005, 2008
    00003  *
    00004  *   Use of this software is controlled by the terms and conditions found in
    00005  *   the license agreement under which this software has been supplied.
    00006  *  ===========================================================================
    00007  */
    00008
    00035 /* ============================================================================
    00036  * Revision History
    00037  * ================
    00038  * 16-Sep-2008 Added Header File of MMC/SD CSL.
    00039  * 16-Jun-2009 Added DMA mode support
    00040  * 26-Jun-2009 Code modified as per review comments
    00041  * 26-Jun-2009 Added SDHC card support
    00042  * 25-Feb-2010 Added second callback support  KR022510
    00043  * 10-Mar-2010 Pedro updates
    00044  * 05-Apr-2010 - Incorporated Frank's comments
    00045  * 06-Apr-2010 - Removed MMC_setDmaCallback() API as the functionality of
    00046  *               DMA callback function is replaced by write done callback function
    00047  * 06-Apr-2010 - Renamed write done callback function to data transfer callback
    00048  *               since it is used by both MMC write and read APIs. Renamed
    00049  *               all the related functions and data structures
    00050  * 08-Apr-2010 - Formatted the code to have uniform style
    00051  * 10-Apr-2010 - Added doxygen comments for few enums and structures
    00052  * 12-Apr-2010 - Merged the code with CSL PG2.0 modifications
    00053  *               Added Enum CSL_MmcsdEndianMode to choose the endian mode of MMCSD
    00054  *               Added API prototype for MMC_setEndianMode()
    00055  * 16-Apr-2010 - Added API SD_configurePullup() to configure SD card pull-up
    00056  *               resistor
    00057  * 19-Apr-2010 - Added APIs
    00058  *             - MMC_setBlockLength()
    00059  *             - MMC_setWriteBlkEraseCnt()
    00060  *             - SD_setBusWidth()
    00061  *             - MMC_getCardStatus()
    00062  * 30-Apr-2010 - Incorporated internal review comments
    00063  * ============================================================================
    00064  */
    00065
    00066 #ifndef _CSL_MMCSD_H_
    00067 #define _CSL_MMCSD_H_
    00068
    00069 #ifdef __cplusplus
    00070 extern "C" {
    00071 #endif
    00072
    00073 #include <soc.h>
    00074 #include <csl_types.h>
    00075 #include <csl_error.h>
    00076 #include <csl_dma.h>
    00077 #include <tistdtypes.h>
    00078
    00108 /*****************************************************************************\
    00109           MMCSD global macro declarations
    00110 \*****************************************************************************/
    00111
    00116 #define CSL_MMCSD_STUFF_BITS                  (0x0000)
    00117
    00118 #define CSL_SD_HC_ECHO_PATTERN                (0xAAu)
    00119
    00120 #define CSL_SD_HC_VHS_ECHO                    (0x100u)
    00121
    00122 #define CSL_MMCSD_SHIFT_MAX                   (16)
    00123
    00124 #define CSL_MMCSD_MASK_MAX                    (0xFFFF)
    00125
    00126 #define CSL_MMCSD_ACTIVE                      (0x0)
    00127
    00128 #define CSL_MMCSD_RESET                       (0x1u)
    00129
    00130 #define CSL_MMCSD_RESET_COUNT                 (0x20u)
    00131
    00132 #define CSL_MMCSD_ENABLE                      (0x1u)
    00133
    00134 #define CSL_MMCSD_DISABLE                     (0x0)
    00135
    00136 #define CSL_MMCSD_ISR_TXMT                    (0x0)
    00137
    00138 #define CSL_MMCSD_ISR_RCV                     (0x1)
    00139
    00140 #define CSL_MMCSD_DELAY_TIME                  (100U)
    00141
    00142 #define CSL_MMCSD_RESPONSE_TIMEOUT            (0xFFFF)
    00143
    00144 #define CSL_MMCSD_DATA_RW_TIMEOUT             (0xFFFF)
    00145
    00146 #define CSL_MMCSD_CLK_DIV_INIT                (124)
    00147
    00148 #define CSL_MMCSD_BUSY_STATE                  (0x01)
    00149
    00150 #define CSL_MMCSD_FIFO_EMPTY                  (0x20)
    00151
    00152 #define CSL_MMCSD_CMDDAT_RESET                (0x03)
    00153
    00154 #define CSL_SD_CARD_DETECTED                  (0x0120)
    00155
    00156 #define CSL_MMC_CARD_DETECTED                 (0x8000)
    00157
    00158 #define CSL_MMCSD_RESP_DONE                   (0x04)
    00159
    00160 #define CSL_MMCSD_BLOCK_LENGTH                (512u)
    00161
    00162 #define CSL_MMCSD_BLOCK_LEN_MAX               (0x0FFFu)
    00163
    00164 #define CSL_MMCSD_READ_READY                  (0x0400)
    00165
    00166 #define CSL_MMCSD_WRITE_READY                 (0x0200)
    00167
    00168 #define CSL_MMCSD_DISPATCH_TABLE_SIZE         (12U)
    00169
    00170 #define CSL_MMCSD_NULL                        (0)
    00171
    00172 #define CSL_MMCSD_RESP_COUNT                  (8)
    00173
    00174 #define CSL_MMC_MAX_CLOCK_RATE                (0xFFu)
    00175
    00176 #define CSL_MMC_CMD8_ARG                      (0x1AAu)
    00177
    00178 #define CSL_MMC_CMD1_ARG                      (0x00ff8000u)
    00179
    00180 #define CSL_MMC_ACMD41_ARG_HCS                (0x40ff8000u)
    00181
    00182 #define CSL_MMC_ACMD41_ARG_NOHCS              (0x00ff8000u)
    00183
    00184 #define CSL_MMC_BUSWIDTH_4BIT                 (0x00000002u)
    00185
    00186 #define CSL_MMC_BUSWIDTH_1BIT                 (0x00000001u)
    00187
    00188
    00190 #define CSL_MMSCD_ACMD41_RETRY_COUNT          (1000u)
    00191
    00192 #define CSL_MMSCD_CMD1_RETRY_COUNT            (1000u)
    00193
    00194 #define CSL_MMSCD_READ_WRITE_RETRY_COUNT      (1000u)
    00195
    00197 #define CSL_MMCSD_WRITE_INIT_CMD              (0x0210)
    00198
    00199 #define CSL_MMCSD_WRITE_BLOCK_CMD             (0x2A18)
    00200
    00201 #define CSL_MMCSD_READ_BLOCK_CMD              (0xA211)
    00202
    00203 #define CSL_MMCSD_WRITE_MULTIPLE_BLOCK_CMD    (0x2A19u)
    00204
    00205 #define CSL_MMCSD_READ_MULTIPLE_BLOCK_CMD     (0xA212)
    00206
    00207 #define CSL_MMCSD_ALL_SEND_CID_CMD            (0x0402)
    00208
    00209 #define CSL_MMCSD_CARD_INIT0_CMD              (0x4000)
    00210
    00211 #define CSL_MMCSD_SDHC_CARD_INIT_CMD          (0x0208)
    00212
    00213 #define CSL_MMCSD_SD_CARD_INIT_CMD            (0x0237)
    00214
    00215 #define CSL_MMCSD_MMCS_CARD_INIT_CMD          (0x0601)
    00216
    00217 #define CSL_MMCSD_SET_BLKLEN_CMD              (0x0210)
    00218
    00219 #define CSL_MMCSD_STOP_CMD                    (0x038C)
    00220
    00221 #define CSL_MMCSD_CMD_0                       (0x0000)
    00222
    00223 #define CSL_MMCSD_CMD_1                       (0x0601)
    00224
    00225 #define CSL_MMCSD_CMD_2                       (0x0402)
    00226
    00227 #define CSL_MMCSD_CMD_3                       (0x0203)
    00228
    00229 #define CSL_MMCSD_CMD_6                       (0x0206)
    00230
    00231 #define CSL_MMCSD_CMD_7                       (0x0307)
    00232
    00233 #define CSL_MMCSD_CMD_8                       (0x0208)
    00234
    00235 #define CSL_MMCSD_CMD_9                       (0x0409)
    00236
    00237 #define CSL_MMCSD_CMD_13                      (0x020D)
    00238
    00239 #define CSL_MMCSD_ACMD_23                     (0x0217)
    00240
    00241 #define CSL_MMCSD_CMD_41                      (0x0629)
    00242
    00243 #define CSL_MMCSD_ACMD_42                     (0x022A)
    00244
    00245 #define CSL_MMCSD_CMD_55                      (0x0237)
    00246
    00247 #define CSL_MMCSD_CMD41_RESP                  (0x80FF8000u)
    00248
    00249 #define CSL_MMCSD_CMD1_RESP                   (0x80FF8000u)
    00250
    00251 #define CSL_MMCSD_SDHC_RESP                   (0x40000000u)
    00252
    00253 #define CSL_MMCSD_CARDCHECK_COUNT             (3u)
    00254
    00258 /*****************************************************************************\
    00259           MMCSD global typedef declarations
    00260 \*****************************************************************************/
    00261
    00270 typedef enum {
    00271     CSL_MMCSD0_INST    = (0U),
    00272     CSL_MMCSD1_INST    = (1U),
    00273     CSL_MMCSD_INST_INV = (2U)
    00274 } CSL_MmcsdInstId;
    00275
    00282 typedef enum {
    00283     CSL_MMCSD_RESPTYPE_NO   = 0,
    00284     CSL_MMCSD_RESPTYPE_R1   = 1U,
    00285     CSL_MMCSD_RESPTYPE_R2   = 2U,
    00286     CSL_MMCSD_RESPTYPE_R3   = 3U,
    00287     CSL_MMCSD_RESPTYPE_R4   = 4U,
    00288     CSL_MMCSD_RESPTYPE_R5   = 5U,
    00289     CSL_MMCSD_RESPTYPE_R6   = 6U
    00290 } CSL_MmcsdRespType;
    00291
    00295 typedef enum {
    00296     CSL_MMCSD_RESPBUSY_NO   = 0,
    00297     CSL_MMCSD_RESPBUSY_YES  = 1U
    00298 } CSL_MmcsdRespBusy;
    00299
    00305 typedef enum {
    00306     CSL_MMCSD_LINECHR_PUSHPULL  = 0,
    00307     CSL_MMCSD_LINECHR_OPENDRAIN = 1U
    00308 } CSL_MmcsdLineChr;
    00309
    00316 typedef enum {
    00317     CSL_MMCSD_CMDTYPE_BC    = 0,
    00318     CSL_MMCSD_CMDTYPE_BCR   = 1U,
    00319     CSL_MMCSD_CMDTYPE_AC    = 2U,
    00320     CSL_MMCSD_CMDTYPE_ADTC  = 3U
    00321 } CSL_MmcsdCmdType;
    00322
    00330 typedef enum {
    00331     CSL_MMCSD_GO_IDLE_STATE                 = 0,
    00333     CSL_MMCSD_SEND_OP_COND_MMC_CARD         = 1U,
    00335     CSL_MMCSD_ALL_SEND_CID                  = 2U,
    00337     CSL_MMCSD_RELATIVE_ADDR                 = 3U,
    00341     CSL_MMCSD_SET_DSR                       = 4U,
    00343     CSL_MMCSD_CMD_IDX_RSV_5                 = 5U,
    00345     CSL_MMCSD_CMD_SWITCH_MMC_CARD           = 6U,
    00347     CSL_MMCSD_SELECT_DESELECT_CARD          = 7U,
    00349     CSL_MMCSD_CMD_SEND_IF_COND_EXT_CSD      = 8U,
    00353     CSL_MMCSD_SEND_CSD                      = 9U,
    00355     CSL_MMCSD_SEND_CID                      = 10U,
    00357     CSL_MMCSD_READ_DAT_UNTIL_STOP_MMC_CARD  = 11U,
    00359     CSL_MMCSD_STOP_TRANSMISSION             = 12U,
    00361     CSL_MMCSD_SEND_STATUS                   = 13U,
    00363     CSL_MMCSD_CMD_IDX_RSV_14                = 14U,
    00365     CSL_MMCSD_GO_INACTIVE_STATE             = 15U,
    00367     CSL_MMCSD_SET_BLOCKLEN                  = 16U,
    00369     CSL_MMCSD_READ_SINGLE_BLOCK             = 17U,
    00371     CSL_MMCSD_READ_MULTIPLE_BLOCK           = 18U,
    00373     CSL_MMCSD_CMD_IDX_RSV_19                = 19U,
    00375     CSL_MMCSD_WRITE_DAT_UNTIL_STOP_MMC_CARD = 20U,
    00377     CSL_MMCSD_CMD_IDX_RSV_21                = 21U,
    00379     CSL_MMCSD_CMD_IDX_RSV_22                = 22U,
    00381     CSL_MMCSD_SET_BLOCK_COUNT_MMC_CARD      = 23U,
    00385     CSL_MMCSD_WRITE_BLOCK                   = 24U,
    00387     CSL_MMCSD_WRITE_MULTIPLE_BLOCK          = 25U,
    00389     CSL_MMCSD_PROGRAM_CID_MMC_CARD          = 26U,
    00391     CSL_MMCSD_PROGRAM_CSD                   = 27U,
    00393     CSL_MMCSD_SET_WRITE_PROT                = 28U,
    00397     CSL_MMCSD_CLR_WRITE_PROT                = 29U,
    00401     CSL_MMCSD_SEND_WRITE_PROT               = 30U,
    00405     CSL_MMCSD_CMD_IDX_RSV_31                = 31U,
    00407     CSL_MMCSD_ERASE_WR_BLK_START_SD_CARD    = 32U,
    00410     CSL_MMCSD_ERASE_WR_BLK_END_SD_CARD      = 33U,
    00413     CSL_MMCSD_CMD_IDX_RSV_34                = 34U,
    00415     CSL_MMCSD_ERASE_GROUP_START_MMC_CARD    = 35U,
    00418     CSL_MMCSD_ERASE_GROUP_END_MMC_CARD      = 36U,
    00421     CSL_MMCSD_CMD_IDX_RSV_37                = 37U,
    00423     CSL_MMCSD_ERASE                         = 38U,
    00425     CSL_MMCSD_FAST_IO_MMC_CARD              = 39U,
    00427     CSL_MMCSD_GO_IRQ_STATE_MMC_CARD         = 40U,
    00429     CSL_MMCSD_CMD_IDX_RSV_41                = 41U,
    00431     CSL_MMCSD_LOCK_UNLOCK                   = 42U,
    00433     CSL_MMCSD_CMD_IDX_RSV_43                = 43U,
    00435     CSL_MMCSD_CMD_IDX_RSV_44                = 44U,
    00437     CSL_MMCSD_CMD_IDX_RSV_45                = 45U,
    00439     CSL_MMCSD_CMD_IDX_RSV_46                = 46U,
    00441     CSL_MMCSD_CMD_IDX_RSV_47                = 47U,
    00443     CSL_MMCSD_CMD_IDX_RSV_48                = 48U,
    00445     CSL_MMCSD_CMD_IDX_RSV_49                = 49U,
    00447     CSL_MMCSD_CMD_IDX_RSV_50                = 50U,
    00449     CSL_MMCSD_CMD_IDX_RSV_51                = 51U,
    00451     CSL_MMCSD_CMD_IDX_RSV_52                = 52U,
    00453     CSL_MMCSD_CMD_IDX_RSV_53                = 53U,
    00455     CSL_MMCSD_CMD_IDX_RSV_54                = 54U,
    00457     CSL_MMCSD_APP_CMD                       = 55U,
    00460     CSL_MMCSD_GEN_CMD                       = 56U,
    00464     CSL_MMCSD_CMD_IDX_RSV_57                = 57U,
    00466     CSL_MMCSD_CMD_IDX_RSV_58                = 58U,
    00468     CSL_MMCSD_CMD_IDX_RSV_59                = 59U,
    00470     CSL_MMCSD_CMD_IDX_RSV_60                = 60U,
    00472     CSL_MMCSD_CMD_IDX_RSV_61                = 61U,
    00474     CSL_MMCSD_CMD_IDX_RSV_62                = 62U,
    00476     CSL_MMCSD_CMD_IDX_RSV_63                = 63U
    00478 } CSL_MmcsdCmdIndex;
    00479
    00483 typedef enum {
    00484     CSL_MMCSD_DIR_WRITE     = 0,
    00485     CSL_MMCSD_DIR_READ      = 1U,
    00486     CSL_MMCSD_DIR_DONTCARE  = 2U
    00487 } CSL_MmcsdDir;
    00488
    00492 typedef enum
    00493 {
    00494     CSL_CARD_NONE = 0,
    00495     CSL_SD_CARD   = 1U,
    00496     CSL_MMC_CARD  = 2U
    00497 } CSL_CardType;
    00498
    00503 typedef enum {
    00504     CSL_MMCSD_EVENT_TRNDNE              = (1U << 12U),
    00506     CSL_MMCSD_EVENT_DATED               = (1U << 11U),
    00508     CSL_MMCSD_EVENT_READ                = (1U << 10U),
    00510     CSL_MMCSD_EVENT_WRITE               = (1U << 9U),
    00512     CSL_MMCSD_EVENT_ERROR_CMDCRC        = (1U << 7U),
    00514     CSL_MMCSD_EVENT_ERROR_DATACRC       = ((1U << 6U)|(1U << 5U)),
    00516     CSL_MMCSD_EVENT_ERROR_CMDTIMEOUT    = ((1U) << (4U)),
    00518     CSL_MMCSD_EVENT_ERROR_DATATIMEOUT   = ((1U) << (3U)),
    00520     CSL_MMCSD_EVENT_EOFCMD              = (1U << 2U),
    00523     CSL_MMCSD_EVENT_CARD_EXITBUSY       = ((1U) << (1U)),
    00525     CSL_MMCSD_EVENT_BLOCK_XFERRED       = 1U
    00527 } CSL_MmcsdEvent;
    00528
    00533 typedef enum
    00534 {
    00535     CSL_MMCSD_EDATDNE_INTERRUPT = 1U,
    00537     CSL_MMCSD_EBSYDNE_INTERRUPT = (1U << 1U),
    00539     CSL_MMCSD_ERSPDNE_INTERRUPT = (1U << 2U),
    00541     CSL_MMCSD_ETOUTRD_INTERRUPT = (1U << 3U),
    00543     CSL_MMCSD_ETOUTRS_INTERRUPT = (1U << 4U),
    00545     CSL_MMCSD_ECRCWR_INTERRUPT  = (1U << 5U),
    00547     CSL_MMCSD_ECRCRD_INTERRUPT  = (1U << 6U),
    00549     CSL_MMCSD_ECRCRS_INTERRUPT  = (1U << 7U),
    00551     CSL_MMCSD_RSV_BIT           = (1U << 8U),
    00553     CSL_MMCSD_EDXRDY_INTERRUPT  = (1U << 9U),
    00555     CSL_MMCSD_EDRRDY_INTERRUPT  = (1U << 10U),
    00557     CSL_MMCSD_EDATED_INTERRUPT  = (1U << 11U),
    00559     CSL_MMCSD_ETRNDNE_INTERRUPT = (1U << 12U),
    00561     CSL_MMCSD_INTERRUPT_NONE    = (1U << 13U)
    00563 } CSL_MMCSDEventType;
    00564
    00569 typedef enum
    00570 {
    00571     CSL_MMCSD_OPMODE_POLLED    = 0,
    00573     CSL_MMCSD_OPMODE_INTERRUPT = 1U,
    00575     CSL_MMCSD_OPMODE_DMA       = 2U,
    00577     CSL_MMCSD_OPMODE_NONE      = 3U
    00579 } CSL_MMCSDOpMode;
    00580
    00586 typedef enum {
    00587     CSL_MMCSD_ENDIAN_LITTLE = 0,
    00588     CSL_MMCSD_ENDIAN_BIG    = 1U
    00589 } CSL_MmcsdEndianMode;
    00590
    00594 #define CSL_MMCSD_EVENT_ERROR   (CSL_MMCSD_EVENT_ERROR_CMDCRC |     \
    00595                                  CSL_MMCSD_EVENT_ERROR_DATACRC |    \
    00596                                  CSL_MMCSD_EVENT_ERROR_CMDTIMEOUT | \
    00597                                  CSL_MMCSD_EVENT_ERROR_DATATIMEOUT)
    00598
    00602 #define CSL_MMCSD_CMD_TOUT_CRC_ERROR   (CSL_MMCSD_EVENT_ERROR_CMDCRC |     \
    00603                                         CSL_MMCSD_EVENT_ERROR_CMDTIMEOUT)
    00604
    00608 #define CSL_MMCSD_DATA_TOUT_CRC_ERROR   (CSL_MMCSD_EVENT_ERROR_DATACRC |    \
    00609                                          CSL_MMCSD_EVENT_ERROR_DATATIMEOUT)
    00610
    00623 typedef struct {
    00624     Uint16               idx;
    00626     CSL_MmcsdRespType    respType;
    00628     CSL_MmcsdRespBusy    busy;
    00630     CSL_MmcsdCmdType     type;
    00632     CSL_MmcsdDir         dir;
    00634     CSL_MmcsdLineChr     lineChr;
    00636 } CSL_MmcsdCmd;
    00637
    00644 typedef struct {
    00645     Uint16    response[CSL_MMCSD_RESP_COUNT];
    00655 } CSL_MmcsdResponse;
    00656
    00661 typedef struct {
    00662     Uint16    dmaEnable;
    00664     Uint16    dat3EdgeDetection;
    00666     Uint16    enableClkPin;
    00668     Uint16    cdiv;
    00670     Uint16    rspTimeout;
    00672     Uint16    dataTimeout;
    00674     Uint16    blockLen;
    00676 } CSL_MMCSetupNative;
    00677
    00682 typedef struct {
    00683     Uint16    mmcctl;
    00684     Uint16    mmcclk;
    00685     Uint16    mmcim;
    00686     Uint16    mmctor;
    00687     Uint16    mmctod;
    00688     Uint16    mmcblen;
    00689     Uint16    mmcnblk;
    00690 } CSL_MMCConfig;
    00691
    00696 typedef struct
    00697 {
    00698     Uint16    slice127_112;
    00699     Uint16    slice111_96;
    00700     Uint16    slice95_80;
    00701     Uint16    slice79_64;
    00702     Uint16    slice63_48;
    00703     Uint16    slice47_32;
    00704     Uint16    slice31_16;
    00705     Uint16    slice15_0;
    00706 } CSL_MMCSDCidStruct;
    00707
    00712 typedef struct {
    00713     Uint16    mfgId;
    00714     Uint16    oemAppId;
    00715     Uint8     productName[6];
    00716     Uint16    productRev;
    00717     Uint32    serialNumber;
    00718     Uint16    month;
    00719     Uint16    year;
    00721     Uint16    checksum;
    00722 } CSL_MMCCardIdObj;
    00723
    00728 typedef struct
    00729 {
    00730     Uint16    slice127_112;
    00731     Uint16    slice111_96;
    00732     Uint16    slice95_80;
    00733     Uint16    slice79_64;
    00734     Uint16    slice63_48;
    00735     Uint16    slice47_32;
    00736     Uint16    slice31_16;
    00737     Uint16    slice15_0;
    00738 } CSL_MMCSDCsdStruct;
    00739
    00744 typedef struct {
    00745     Uint16 csdStruct;
    00746     Uint16    mmcProt;
    00747     Uint16    taac;
    00748     Uint16    nsac;
    00749     Uint16    tranSpeed;
    00750     Uint16    ccc;
    00751     Uint16    readBlLen;
    00752     Uint16    readBlPartial;
    00753     Uint16    writeBlkMisalign;
    00754     Uint16    readBlkMisalign;
    00755     Uint16    dsrImp;
    00756     Uint16    cSize;
    00757     Uint16    vddRCurrMin;
    00758     Uint16    vddRCurrMax;
    00759     Uint16    vddWCurrMin;
    00760     Uint16    vddWCurrMax;
    00761     Uint16    cSizeMult;
    00762     Uint16    eraseBlkEnable;
    00763     Uint16    eraseGrpSize;
    00764     Uint16    eraseGrpMult;
    00765     Uint16    wpGrpSize;
    00766     Uint16    wpGrpEnable;
    00767     Uint16    defaultEcc;
    00768     Uint16    r2wFactor;
    00769     Uint16    writeBlLen;
    00770     Uint16    writeBlPartial;
    00771     Uint16    contProtApp;
    00772     Uint16    fileFmtGrp;
    00773     Uint16    copyFlag;
    00774     Uint16    permWriteProtect;
    00775     Uint16    tmpWriteProtect;
    00776     Uint16    fileFmt;
    00777     Uint16    ecc;
    00778     Uint16    crc;
    00779 } CSL_MMCCardCsdObj;
    00780
    00785 typedef struct {
    00786     Uint16    securitySysId;
    00787     Uint16    securitySysVers;
    00788     Uint16    maxLicenses;
    00789     Uint32    xStatus;
    00790 } CSL_MMCCardXCsdObj;
    00791
    00796 typedef struct {
    00797     Uint16                rca;
    00800     Uint16                ST0;
    00802     Uint16                ST1;
    00804     Uint16                cardIndex;
    00806     Uint32                maxXfrRate;
    00808     Uint32                readAccessTime;
    00810     Uint32 cardCapacity;
    00816     Uint32                blockLength;
    00818     Uint32                totalSectors;
    00820     Uint32                lastAddrRead;
    00822     Uint32                lastAddrWritten;
    00824     CSL_CardType          cardType;
    00826     CSL_MMCCardIdObj      *cid;
    00828     CSL_MMCCardCsdObj     *csd;
    00830     CSL_MMCCardXCsdObj    *xcsd;
    00832     Bool                  sdHcDetected;
    00834     Bool                  cardAtaFsOpen;
    00836     Uint16                cardMscStatus;
    00838 } CSL_MMCCardObj;
    00839
    00844 typedef void (* CSL_MMCCallBackPtr)(void);
    00845
    00853 typedef void (*CSL_MMCDataTxferCallBackPtr)(void *mmcsdHandle);/* KR022510 */
    00854
    00859 typedef struct {
    00860    CSL_MMCCallBackPtr isr[CSL_MMCSD_DISPATCH_TABLE_SIZE];
    00862 } CSL_MMCCallBackObj;
    00863
    00869 typedef struct
    00870 {
    00871     Bool                     pingPongEnable;
    00878     CSL_DMAAutoReloadMode    autoMode;
    00879     CSL_DMATxBurstLen        burstLen;
    00880     CSL_DMAInterruptState    dmaInt;
    00881     CSL_DMAChanDir           chanDir;
    00882 } CSL_MmcsdDmaConfig;
    00883
    00888 typedef struct {
    00889     CSL_MmcsdRegsOvly              mmcRegs;
    00891     CSL_MMCCardObj                 *cardObj;
    00893     Uint16                         numCardsActive;
    00895     CSL_MMCCallBackObj             *callBackTbl;
    00897     CSL_MMCSDOpMode                opMode;
    00899     CSL_DMA_Handle                 hDmaWrite;
    00901     CSL_DMA_Handle                 hDmaRead;
    00903     CSL_DMA_Config                 dmaWriteCfg;
    00905     CSL_DMA_Config                 dmaReadCfg;
    00907     CSL_MMCDataTxferCallBackPtr    dataTransferCallback;
    00909     Bool                           isCallbackSet;
    00911     CSL_MMCSDCidStruct             cidSliceInfo;
    00913     CSL_MMCSDCsdStruct             csdSliceInfo;
    00915     CSL_MmcsdEndianMode            readEndianMode;
    00917     CSL_MmcsdEndianMode            writeEndianMode;
    00919     Uint16                         blockLen;
    00921 } CSL_MMCControllerObj;
    00922
    00927 typedef CSL_MMCControllerObj    *CSL_MmcsdHandle;
    00928
    00932 /******************************************************************************
    00933  * CSL MMCSD function declarations
    00934  *****************************************************************************/
    00975 CSL_Status MMC_init(void);
    00976
    01030 CSL_MmcsdHandle MMC_open(CSL_MMCControllerObj    *pMmcsdContObj,
    01031                          CSL_MmcsdInstId         instId,
    01032                          CSL_MMCSDOpMode         opMode,
    01033                          CSL_Status              *status);
    01034
    01075 CSL_Status MMC_close(CSL_MmcsdHandle    hMmcsd);
    01076
    01115 CSL_Status MMC_setCardType(CSL_MMCCardObj    *pCardObj,
    01116                            CSL_CardType      cardType);
    01117
    01162 CSL_Status MMC_setCardPtr(CSL_MmcsdHandle    hMmcsd,
    01163                           CSL_MMCCardObj     *pMmcCardObj);
    01164
    01217 CSL_Status MMC_setCallBack(CSL_MmcsdHandle       hMmcsd,
    01218                            CSL_MMCCallBackObj    *pFunction);
    01219
    01263 CSL_Status MMC_getNumberOfCards(CSL_MmcsdHandle    hMmcsd,
    01264                                 Uint16             *pActiveNoCard);
    01265
    01306 CSL_Status MMC_clearResponse(CSL_MmcsdHandle    hMmcsd);
    01307
    01360 CSL_Status MMC_intEnable(CSL_MmcsdHandle    hMmcsd,
    01361                          Uint16             maskValue);
    01362
    01411 CSL_Status MMC_eventEnable(CSL_MmcsdHandle       hMmcsd,
    01412                            CSL_MMCSDEventType    mmcsdEvent);
    01413
    01460 CSL_Status MMC_eventDisable(CSL_MmcsdHandle       hMmcsd,
    01461                             CSL_MMCSDEventType    mmcsdEvent);
    01462
    01507 Bool MMC_drrdy(CSL_MmcsdHandle    hMmcsd,
    01508                CSL_Status         *pStatus);
    01509
    01554 Bool MMC_dxrdy(CSL_MmcsdHandle    hMmcsd,
    01555                CSL_Status         *pStatus);
    01556
    01599 CSL_Status MMC_saveStatus(CSL_MmcsdHandle    hMmcsd);
    01600
    01650 Uint32 MMC_getStatus(CSL_MmcsdHandle    hMmcsd,
    01651                      Uint32             maskValue,
    01652                      CSL_Status         *pStatus);
    01653
    01705 CSL_Status MMC_setupNative(CSL_MmcsdHandle       hMmcsd,
    01706                            CSL_MMCSetupNative    *pMmcInit);
    01707
    01761 CSL_Status MMC_config(CSL_MmcsdHandle    hMmcsd,
    01762                       CSL_MMCConfig      *pMmcConfig);
    01763
    01808 CSL_Status MMC_getConfig(CSL_MmcsdHandle    hMmcsd,
    01809                          CSL_MMCConfig      *pMmcConfig);
    01810
    01870 CSL_Status MMC_sendCmd(CSL_MmcsdHandle    hMmcsd,
    01871                        Uint32             cmd,
    01872                        Uint32             arg,
    01873                        Uint16             waitForRsp);
    01874
    01916 CSL_Status MMC_sendGoIdle(CSL_MmcsdHandle    hMmcsd);
    01917
    01966 CSL_Status MMC_stop(CSL_MmcsdHandle    hMmcsd);
    01967
    02015 CSL_Status MMC_deselectCard(CSL_MmcsdHandle    hMmcsd,
    02016                             CSL_MMCCardObj     *pMmcCardObj);
    02017
    02069 CSL_Status MMC_selectCard(CSL_MmcsdHandle    hMmcsd,
    02070                           CSL_MMCCardObj     *pMmcCardObj);
    02071
    02124 CSL_Status MMC_sendOpCond(CSL_MmcsdHandle    hMmcsd,
    02125                           Uint16             clkDivValue);
    02126
    02195 CSL_Status MMC_setRca(CSL_MmcsdHandle     hMmcsd,
    02196                       CSL_MMCCardObj      *pMmcCardObj,
    02197                       Uint16              rCardAddr);
    02198
    02267 CSL_Status SD_sendRca(CSL_MmcsdHandle     hMmcsd,
    02268                       CSL_MMCCardObj      *pSdCardObj,
    02269                       Uint16              *pRCardAddr);
    02270
    02332 CSL_Status MMC_sendAllCID(CSL_MmcsdHandle     hMmcsd,
    02333                           CSL_MMCCardIdObj    *pMmcCardIdObj);
    02334
    02397 CSL_Status SD_sendAllCID(CSL_MmcsdHandle     hMmcsd,
    02398                          CSL_MMCCardIdObj    *pSdCardIdObj);
    02399
    02468 CSL_Status MMC_getCardCsd(CSL_MmcsdHandle      hMmcsd,
    02469                           CSL_MMCCardCsdObj    *pMmcCardCsdObj);
    02470
    02535 CSL_Status SD_getCardCsd(CSL_MmcsdHandle      hMmcsd,
    02536                          CSL_MMCCardCsdObj    *pSdCardCsdObj);
    02537
    02645 CSL_Status MMC_read(CSL_MmcsdHandle    hMmcsd,
    02646                     Uint32             cardAddr,
    02647                     Uint16             noOfBytes,
    02648                     Uint16             *pReadBuffer);
    02649
    02758 CSL_Status MMC_write(CSL_MmcsdHandle    hMmcsd,
    02759                      Uint32             cardAddr,
    02760                      Uint16             noOfBytes,
    02761                      Uint16             *pWriteBuffer);
    02762
    02825 CSL_Status MMC_setDmaHandle (CSL_MmcsdHandle    hMmcsd,
    02826                              CSL_DMA_Handle     hDmaWrite,
    02827                              CSL_DMA_Handle     hDmaRead);
    02828
    02898 CSL_Status MMC_setDataTransferCallback(CSL_MmcsdHandle                hMmcsd,
    02899                                        CSL_MMCDataTxferCallBackPtr    dataTransferCallback);
    02900
    02983 CSL_Status MMC_setDmaChanConfig (CSL_MmcsdHandle       hMmcsd,
    02984                                  CSL_MmcsdDmaConfig    dmaConfig);
    02985
    03038 CSL_Status MMC_setEndianMode (CSL_MmcsdHandle        hMmcsd,
    03039                               CSL_MmcsdEndianMode    writeEndianMode,
    03040                               CSL_MmcsdEndianMode    readEndianMode);
    03041
    03098 CSL_Status MMC_setBlockLength (CSL_MmcsdHandle    hMmcsd,
    03099                                Uint32             blockLen);
    03100
    03150 CSL_Status MMC_setWriteBlkEraseCnt(CSL_MmcsdHandle    hMmcsd,
    03151                                    Uint32             blkCnt);
    03152
    03203 CSL_Status SD_setBusWidth(CSL_MmcsdHandle    hMmcsd,
    03204                           Uint8              busWidth);
    03205
    03256 CSL_Status MMC_getCardStatus(CSL_MmcsdHandle    hMmcsd,
    03257                              Uint32             *pCardStatus);
    03258
    03314 CSL_Status SD_configurePullup(CSL_MmcsdHandle    hMmcsd,
    03315                               Bool               pullupCfg);
    03316
    03320 /******************************************************************************
    03321  * CSL MMCSD Inline function
    03322  *****************************************************************************/
    03368 static inline
    03369 CSL_MMCSDEventType MMC_getEventId(
    03370                           CSL_MmcsdHandle     hMmcsd)
    03371 {
    03372
    03373     if(hMmcsd->mmcRegs->MMCST0 & CSL_MMCSD_MMCST0_DATDNE_MASK)
    03374         return CSL_MMCSD_EDATDNE_INTERRUPT;
    03375     if(hMmcsd->mmcRegs->MMCST0 & CSL_MMCSD_MMCST0_BSYDNE_MASK)
    03376         return CSL_MMCSD_EBSYDNE_INTERRUPT;
    03377     if(hMmcsd->mmcRegs->MMCST0 & CSL_MMCSD_MMCST0_RSPDNE_MASK)
    03378         return CSL_MMCSD_ERSPDNE_INTERRUPT;
    03379     if(hMmcsd->mmcRegs->MMCST0 & CSL_MMCSD_MMCST0_TOUTRD_MASK)
    03380         return CSL_MMCSD_ETOUTRD_INTERRUPT;
    03381     if(hMmcsd->mmcRegs->MMCST0 & CSL_MMCSD_MMCST0_TOUTRS_MASK)
    03382         return CSL_MMCSD_ETOUTRS_INTERRUPT;
    03383     if(hMmcsd->mmcRegs->MMCST0 & CSL_MMCSD_MMCST0_CRCWR_MASK)
    03384         return CSL_MMCSD_ECRCWR_INTERRUPT;
    03385     if(hMmcsd->mmcRegs->MMCST0 & CSL_MMCSD_MMCST0_CRCRD_MASK)
    03386         return CSL_MMCSD_ECRCRD_INTERRUPT;
    03387     if(hMmcsd->mmcRegs->MMCST0 & CSL_MMCSD_MMCST0_CRCRS_MASK)
    03388         return CSL_MMCSD_ECRCRS_INTERRUPT;
    03389     if(hMmcsd->mmcRegs->MMCST0 & CSL_MMCSD_MMCST0_DXRDY_MASK)
    03390         return CSL_MMCSD_EDXRDY_INTERRUPT;
    03391     if(hMmcsd->mmcRegs->MMCST0 & CSL_MMCSD_MMCST0_DRRDY_MASK)
    03392         return CSL_MMCSD_EDRRDY_INTERRUPT;
    03393     if(hMmcsd->mmcRegs->MMCST0 & CSL_MMCSD_MMCST0_DATED_MASK)
    03394         return CSL_MMCSD_EDATED_INTERRUPT;
    03395     if(hMmcsd->mmcRegs->MMCST0 & CSL_MMCSD_MMCST0_TRNDNE_MASK)
    03396         return CSL_MMCSD_ETRNDNE_INTERRUPT;
    03397
    03398     return CSL_MMCSD_INTERRUPT_NONE;
    03399 }
    03403 #ifdef __cplusplus
    03404 }
    03405 #endif
    03406 #endif /* _CSL_MMCSD_H_ */
    03407