Functions
MMC/SD Functions
MMCSD

Functions

CSL_Status MMC_init (void)
CSL_MmcsdHandle MMC_open (CSL_MMCControllerObj *pMmcsdContObj, CSL_MmcsdInstId instId, CSL_MMCSDOpMode opMode, CSL_Status *status)
CSL_Status MMC_close (CSL_MmcsdHandle hMmcsd)
CSL_Status MMC_setCardType (CSL_MMCCardObj *pCardObj, CSL_CardType cardType)
CSL_Status MMC_setCardPtr (CSL_MmcsdHandle hMmcsd, CSL_MMCCardObj *pMmcCardObj)
CSL_Status MMC_setCallBack (CSL_MmcsdHandle hMmcsd, CSL_MMCCallBackObj *pFunction)
CSL_Status MMC_getNumberOfCards (CSL_MmcsdHandle hMmcsd, Uint16 *pActiveNoCard)
CSL_Status MMC_clearResponse (CSL_MmcsdHandle hMmcsd)
CSL_Status MMC_intEnable (CSL_MmcsdHandle hMmcsd, Uint16 maskValue)
CSL_Status MMC_eventEnable (CSL_MmcsdHandle hMmcsd, CSL_MMCSDEventType mmcsdEvent)
CSL_Status MMC_eventDisable (CSL_MmcsdHandle hMmcsd, CSL_MMCSDEventType mmcsdEvent)
Bool MMC_drrdy (CSL_MmcsdHandle hMmcsd, CSL_Status *pStatus)
Bool MMC_dxrdy (CSL_MmcsdHandle hMmcsd, CSL_Status *pStatus)
CSL_Status MMC_saveStatus (CSL_MmcsdHandle hMmcsd)
Uint32 MMC_getStatus (CSL_MmcsdHandle hMmcsd, Uint32 maskValue, CSL_Status *pStatus)
CSL_Status MMC_setupNative (CSL_MmcsdHandle hMmcsd, CSL_MMCSetupNative *pMmcInit)
CSL_Status MMC_config (CSL_MmcsdHandle hMmcsd, CSL_MMCConfig *pMmcConfig)
CSL_Status MMC_getConfig (CSL_MmcsdHandle hMmcsd, CSL_MMCConfig *pMmcConfig)
CSL_Status MMC_sendCmd (CSL_MmcsdHandle hMmcsd, Uint32 cmd, Uint32 arg, Uint16 waitForRsp)
CSL_Status MMC_sendGoIdle (CSL_MmcsdHandle hMmcsd)
CSL_Status MMC_stop (CSL_MmcsdHandle hMmcsd)
CSL_Status MMC_deselectCard (CSL_MmcsdHandle hMmcsd, CSL_MMCCardObj *pMmcCardObj)
CSL_Status MMC_selectCard (CSL_MmcsdHandle hMmcsd, CSL_MMCCardObj *pMmcCardObj)
CSL_Status MMC_sendOpCond (CSL_MmcsdHandle hMmcsd, Uint16 clkDivValue)
CSL_Status MMC_setRca (CSL_MmcsdHandle hMmcsd, CSL_MMCCardObj *pMmcCardObj, Uint16 rCardAddr)
CSL_Status SD_sendRca (CSL_MmcsdHandle hMmcsd, CSL_MMCCardObj *pSdCardObj, Uint16 *pRCardAddr)
CSL_Status MMC_sendAllCID (CSL_MmcsdHandle hMmcsd, CSL_MMCCardIdObj *pMmcCardIdObj)
CSL_Status SD_sendAllCID (CSL_MmcsdHandle hMmcsd, CSL_MMCCardIdObj *pSdCardIdObj)
CSL_Status MMC_getCardCsd (CSL_MmcsdHandle hMmcsd, CSL_MMCCardCsdObj *pMmcCardCsdObj)
CSL_Status SD_getCardCsd (CSL_MmcsdHandle hMmcsd, CSL_MMCCardCsdObj *pSdCardCsdObj)
CSL_Status MMC_read (CSL_MmcsdHandle hMmcsd, Uint32 cardAddr, Uint16 noOfBytes, Uint16 *pReadBuffer)
CSL_Status MMC_write (CSL_MmcsdHandle hMmcsd, Uint32 cardAddr, Uint16 noOfBytes, Uint16 *pWriteBuffer)
CSL_Status MMC_setDmaHandle (CSL_MmcsdHandle hMmcsd, CSL_DMA_Handle hDmaWrite, CSL_DMA_Handle hDmaRead)
CSL_Status MMC_setDataTransferCallback (CSL_MmcsdHandle hMmcsd, CSL_MMCDataTxferCallBackPtr dataTransferCallback)
CSL_Status MMC_setDmaChanConfig (CSL_MmcsdHandle hMmcsd, CSL_MmcsdDmaConfig dmaConfig)
CSL_Status MMC_setEndianMode (CSL_MmcsdHandle hMmcsd, CSL_MmcsdEndianMode writeEndianMode, CSL_MmcsdEndianMode readEndianMode)
CSL_Status MMC_setBlockLength (CSL_MmcsdHandle hMmcsd, Uint32 blockLen)
CSL_Status MMC_setWriteBlkEraseCnt (CSL_MmcsdHandle hMmcsd, Uint32 blkCnt)
CSL_Status SD_setBusWidth (CSL_MmcsdHandle hMmcsd, Uint8 busWidth)
CSL_Status MMC_getCardStatus (CSL_MmcsdHandle hMmcsd, Uint32 *pCardStatus)
CSL_Status SD_configurePullup (CSL_MmcsdHandle hMmcsd, Bool pullupCfg)
AtaError MMC_initState (AtaState *pDrive)
AtaError MMC_issueReadCommand (AtaSector phySector, void *pAtaMediaState, AtaUint16 sectorCount)
AtaError MMC_readNextWord (void *pAtaMediaState, AtaUint16 *pWord)
AtaError MMC_readNextWord1 (void *pAtaMediaState, AtaUint16 *pWord, AtaUint16 word_delta)
AtaError MMC_readNextNWords (void *pAtaMediaState, AtaUint16 *pData, AtaUint16 words)
AtaError MMC_writeSector (AtaSector phySector, void *pAtaMediaState, AtaUint16 *pWord, int byteSwap)
AtaError MMC_readNSectors (void *pAtaMediaState, AtaUint16 *pReadBuf, AtaSector startSector, AtaUint16 sectorCount)
AtaError MMC_writeNSectors (void *pAtaMediaState, AtaUint16 *pWriteBuf, AtaSector startSector, AtaUint16 sectorCount)
AtaError MMC_read_CID (void *pAtaMediaState, unsigned int *pBuf)
AtaError MMC_read_CSD (void *pAtaMediaState, unsigned int *pBuf)
AtaError MMC_writeSectorFlush (void *pAtaMediaState)
int MMC_commandReadyStatusCheck (void *pAtaMediaState)
AtaError MMC_dataReadyStatusCheck (void *pAtaMediaState)
AtaError MMC_busyStatusCheck (void *pAtaMediaState)
AtaUint16 MMC_getSerialID (void *pAtaMediaState, AtaSerialID *pSerID)
AtaUint16 MMC_file_system_format (void *pAtaMediaState)
AtaError MMC_reset (void *pAtaMediaState)
AtaUint16 MMC_get_time (void)
AtaUint16 MMC_get_mod_time (void)
AtaUint16 MMC_get_date (void)
AtaUint16 MMC_get_mod_date (void)
AtaError MMC_flushFat (void *pAtaMediaState)
static AtaError getAtaErrorNo (CSL_Status result)

Function Documentation

static AtaError getAtaErrorNo ( CSL_Status  result) [static]

===========================================================================
getAtaErrorNo

Description
This function checks the return value send by the MMCSD CSL module and returns the corresponding error value to the ATA File system. This function is called in case of any error occurred

Arguments

            result    Result returned by the CSL MMCSD module
     

Return Value AtaError

  • ATA_ERROR_INVALID_PARAM - Returned for Invalid input parameters
  • ATA_ERROR_TIMEOUT - Time out Error Occurred
  • ATA_ERROR_UNSUPPORTED - MMC/SD hardware is not supported

Pre Condition
None

Post Condition
Returns ATA Error codes

Modifies
None

Example

            CSL_Status    result;
            AtaError      ataErr;

            result = MMC_init();

            ataErr = getAtaErrorNo(result);

     

===========================================================================

AtaError MMC_busyStatusCheck ( void *  pAtaMediaState)

===========================================================================
MMC_busyStatusCheck

Description
This function always returns success. No functionality is implemented. This function address is assigned to the function pointer provided by ATA file system.

Arguments

            pAtaMediaState    ATA media state structure
     

Return Value AtaError

  • ATA_ERROR_NONE - Returned for success

Pre Condition
MMC_initState API should be called successfully.

Post Condition
None

Modifies
None

Example

			AtaMMCState    ataMediaState;
			AtaState       ataState;
			AtaState       *pAtaState;
			AtaError       ataErr;

			pAtaState = &ataState;

			ataState->pAtaMediaState = &ataMediaState;

			ataErr = MMC_initState(&ataState);

            ataErr = pAtaState->AtaBusyStatusCheck(ataState->pAtaMediaState);

     

===========================================================================

Referenced by MMC_initState().

CSL_Status MMC_clearResponse ( CSL_MmcsdHandle  hMmcsd)

===========================================================================
MMC_clearResponse

Description
This function clears all eight response registers of MMCSD.

Arguments

            hMmcsd    Handle to the MMCSD
     

Return Value CSL_Status

  • CSL_SOK - successful
  • CSL_ESYS_BADHANDLE - Invalid handle

Pre Condition
MMC_open() API should be called successfully before this.

Post Condition
Clears response

Modifies
MMCSD Response Registers.

Example

			CSL_MMCControllerObj  mmcsdContObj;
            CSL_MmcsdHandle       hMmcsd;
            CSL_MmcsdInstId       instId;
            CSL_status            status;

            instId = CSL_MMCSD0_INST;

            hMmcsd = MMC_open(&mmcsdContObj, instId, CSL_MMCSD_OPMODE_POLLED,
                              &status);

            status = MMC_clearResponse(hMmcsd);
     

===========================================================================

References CSL_MMCControllerObj::mmcRegs.

CSL_Status MMC_close ( CSL_MmcsdHandle  hMmcsd)

===========================================================================
MMC_close

Description
This function closes the specified handle to MMCSD.

Arguments

            hMmcsd    Handle to the MMCSD
     

Return Value CSL_Status

  • CSL_SOK - Close successful
  • CSL_ESYS_BADHANDLE - Invalid handle

Pre Condition
MMC_open() API should be called successfully before this.

Post Condition
Closes the MMC handle

Modifies
MMCSD handle will be assigned to NULL.

Example

			CSL_MMCControllerObj  mmcsdContObj;
            CSL_MmcsdHandle       hMmcsd;
            CSL_MmcsdInstId       instId;
            CSL_status            status;

            instId = CSL_MMCSD0_INST;

            hMmcsd = MMC_open(&mmcsdContObj, instId, CSL_MMCSD_OPMODE_POLLED,
                              &status);

            status = MMC_close(hMmcsd);
     

===========================================================================

References CSL_MMCSD_OPMODE_DMA, DMA_close(), CSL_MMCControllerObj::hDmaRead, CSL_MMCControllerObj::hDmaWrite, CSL_MMCControllerObj::mmcRegs, and CSL_MMCControllerObj::opMode.

int MMC_commandReadyStatusCheck ( void *  pAtaMediaState)

===========================================================================
MMC_commandReadyStatusCheck

Description
This function always returns success. No functionality is implemented. This function address is assigned to the function pointer provided by ATA file system.

Arguments

            pAtaMediaState    ATA media state structure
     

Return Value AtaError

  • ATA_ERROR_NONE - Returned for success

Pre Condition
MMC_initState API should be called successfully.

Post Condition
None

Modifies
None

Example

			AtaMMCState    ataMediaState;
			AtaState       ataState;
			AtaState       *pAtaState;
			AtaError       ataErr;
			int            status;

			pAtaState = &ataState;

			ataState->pAtaMediaState = &ataMediaState;

			ataErr = MMC_initState(&ataState);

            status = pAtaState->AtaCommandReadyStatusCheck(ataState->pAtaMediaState);

     

===========================================================================

Referenced by MMC_initState().

CSL_Status MMC_config ( CSL_MmcsdHandle  hMmcsd,
CSL_MMCConfig pMmcConfig 
)

===========================================================================
MMC_config

Description
Function to configure the MMCSD registers. Register configuration will be done as per the configuration parameters passed to the function.

Arguments

            hMmcsd        Handle to the MMCSD.
            pMmcConfig    Pointer to the MMCSD config parameter.
     

Return Value CSL_Status

  • CSL_SOK - Successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid Parameter

Pre Condition
MMC_open() API should be called before this.

Post Condition
None

Modifies
MMCSD Register will be populated.

Example

            CSL_MmcsdHandle       hMmcsd;
			CSL_MMCControllerObj  mmcsdContObj;
            CSL_MmcsdInstId       instId;
            CSL_status            status;
            CSL_MMCConfig         mmcConfig;

            instId = CSL_MMCSD0_INST;

            hMmcsd = MMC_open(&mmcsdContObj, instId, CSL_MMCSD_OPMODE_POLLED,
                              &status);

            Note: CSL_MMCConfig field are following.
			mmcConfig.mmcblen = CSL_MMCSD_BLOCK_LENGTH;
			mmcConfig.mmcclk  = 0x10 |CSL_MMCSD_MMCCLK_CLKEN_ENABLE;
			mmcConfig.mmcctl  = CSL_MMCSD_MMCCTL_DATEG_F_EDGE;
			mmcConfig.mmcim   = 0x0;
			mmcConfig.mmcnblk = 0x1;
			mmcConfig.mmctod  = CSL_MMCSD_DATA_RW_TIMEOUT;
			mmcConfig.mmctor  = CSL_MMCSD_RESPONSE_TIMEOUT;

            status = MMC_config(hMmcsd, &mmcConfig);
     

===========================================================================

References CSL_MMCConfig::mmcblen, CSL_MMCConfig::mmcclk, CSL_MMCConfig::mmcctl, CSL_MMCConfig::mmcim, CSL_MMCConfig::mmcnblk, CSL_MMCControllerObj::mmcRegs, CSL_MMCConfig::mmctod, and CSL_MMCConfig::mmctor.

AtaError MMC_dataReadyStatusCheck ( void *  pAtaMediaState)

===========================================================================
MMC_dataReadyStatusCheck

Description
This function always returns success. No functionality is implemented. This function address is assigned to the function pointer provided by ATA file system.

Arguments

            pAtaMediaState    ATA media state structure
     

Return Value AtaError

  • ATA_ERROR_NONE - Returned for success

Pre Condition
MMC_initState API should be called successfully.

Post Condition
None

Modifies
None

Example

			AtaMMCState    ataMediaState;
			AtaState       ataState;
			AtaState       *pAtaState;
			AtaError       ataErr;

			pAtaState = &ataState;

			ataState->pAtaMediaState = &ataMediaState;

			ataErr = MMC_initState(&ataState);

            ataErr = pAtaState->AtaDataReadyStatusCheck(ataState->pAtaMediaState);

     

===========================================================================

Referenced by MMC_initState().

CSL_Status MMC_deselectCard ( CSL_MmcsdHandle  hMmcsd,
CSL_MMCCardObj pMmcCardObj 
)

===========================================================================
MMC_deselectCard

Description
This function will send command for deselecting particular card which is assigned in card object.

Arguments

            hMmcsd            Handle to the MMCSD.
            pMmcCardObj       Pointer to the MMCSD Card Info.
     

Return Value CSL_Status

  • CSL_SOK - successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid Parameter
  • CSL_EMMCSD_TIMEOUT - Command Reponse Timeout
  • CSL_EMMCSD_CRCERR - Command CRC Error

Pre Condition
MMC_open() API should be called before this.
RCA value should be properly stored in handle hMmcsd.

Post Condition
Deselects the card

Modifies
MMCSD card object structure.

Example

            CSL_MmcsdHandle         hMmcsd;
			CSL_MMCControllerObj    mmcsdContObj;
            CSL_MMCCardObj          mmcCardObj;
            CSL_MmcsdInstId         instId;
            CSL_status              status;

            instId = CSL_MMCSD0_INST;

            hMmcsd = MMC_open(&mmcsdContObj, instId, CSL_MMCSD_OPMODE_POLLED,
                              &status);

            status = MMC_deselectCard(hMmcsd, &mmcCardObj);
     

===========================================================================

References CSL_MMCCardObj::cardType, CSL_CARD_NONE, CSL_MMCSD_CMD_TOUT_CRC_ERROR, CSL_MMCSD_EVENT_EOFCMD, CSL_MMCSD_EVENT_ERROR_CMDTIMEOUT, CSL_MMCSD_SELECT_DESELECT_CARD, CSL_MMCSD_STUFF_BITS, CSL_MMCControllerObj::mmcRegs, and CSL_MMCControllerObj::numCardsActive.

Bool MMC_drrdy ( CSL_MmcsdHandle  hMmcsd,
CSL_Status *  pStatus 
)

===========================================================================
MMC_drrdy

Description
This function returns data receive ready status. Value returned by this API is useful to decide whether data is available in MMC/SD controller FIFO for reading or not.

Arguments

            hMmcsd     Handle to the MMCSD
            pStatus    Status of API success or failed.
     

Return Value Bool

  • TRUE - Data is available for reading
  • FALSE - Data is not available for reading

Pre Condition
MMC_open() API should be called before this.

Post Condition
None

Modifies
None

Example

			CSL_MMCControllerObj  mmcsdContObj;
            CSL_MmcsdHandle       hMmcsd;
            CSL_MmcsdInstId       instId;
            CSL_status            status;
            Bool                  drrdyStatus;

            instId = CSL_MMCSD0_INST;

            hMmcsd = MMC_open(&mmcsdContObj, instId, CSL_MMCSD_OPMODE_POLLED,
                              &status);

            drrdyStatus = MMC_drrdy(hMmcsd, &status);
     

===========================================================================

References CSL_MMCControllerObj::mmcRegs.

Bool MMC_dxrdy ( CSL_MmcsdHandle  hMmcsd,
CSL_Status *  pStatus 
)

===========================================================================
MMC_dxrdy

Description
This function returns data transmit ready status. Value returned by this API is useful to decide whether data can be written to MMCSD controller FIFO or not.

Arguments

            hMmcsd     Handle to the MMCSD
            pStatus    Status of API success or failed
     

Return Value Bool

  • TRUE - MMCSD FIFO is ready to accept data
  • FALSE - MMCSD FIFO is not ready to accept data

Pre Condition
MMC_open() API should be called before this.

Post Condition
None

Modifies
None

Example

			CSL_MMCControllerObj  mmcsdContObj;
            CSL_MmcsdHandle       hMmcsd;
            CSL_MmcsdInstId       instId;
            CSL_status            status;
            Bool                  dxrdyStatus;

            instId = CSL_MMCSD0_INST;

            hMmcsd = MMC_open(&mmcsdContObj, instId, CSL_MMCSD_OPMODE_POLLED,
                              &status);

            dxrdyStatus = MMC_dxrdy(hMmcsd, &status);
     

===========================================================================

References CSL_MMCControllerObj::mmcRegs.

CSL_Status MMC_eventDisable ( CSL_MmcsdHandle  hMmcsd,
CSL_MMCSDEventType  mmcsdEvent 
)

===========================================================================
MMC_eventDisable

Description
This function disables the MMC events depending on the 'mmcsdEvent' passed as a parameter. This function is useful to disable single interrupt of MMC interrupt mask register in one function call.

Arguments

            hMmcsd        Handle to the MMCSD
            mmcsdEvent    Event type.
     

Return Value CSL_Status

  • CSL_SOK - successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
MMC_open() API should be called successfully.

Post Condition

Modifies
Interrupt will be disabled for particular event.

Example

			CSL_MMCControllerObj  mmcsdContObj;
            CSL_MmcsdHandle       hMmcsd;
            CSL_MmcsdInstId       instId;
            CSL_MMCSDEventType    mmcsdEvent;
            CSL_status            status;

            instId = CSL_MMCSD0_INST;

            hMmcsd = MMC_open(&mmcsdContObj, instId, CSL_MMCSD_OPMODE_POLLED,
                              &status);
            mmcsdEvent = CSL_MMCSD_EDATDNE_INTERRUPT;

            status = MMC_eventDisable(hMmcsd, mmcsdEvent);
     

===========================================================================

References CSL_MMCSD_EBSYDNE_INTERRUPT, CSL_MMCSD_ECRCRD_INTERRUPT, CSL_MMCSD_ECRCRS_INTERRUPT, CSL_MMCSD_ECRCWR_INTERRUPT, CSL_MMCSD_EDATDNE_INTERRUPT, CSL_MMCSD_EDATED_INTERRUPT, CSL_MMCSD_EDRRDY_INTERRUPT, CSL_MMCSD_EDXRDY_INTERRUPT, CSL_MMCSD_ERSPDNE_INTERRUPT, CSL_MMCSD_ETOUTRD_INTERRUPT, CSL_MMCSD_ETOUTRS_INTERRUPT, CSL_MMCSD_ETRNDNE_INTERRUPT, and CSL_MMCControllerObj::mmcRegs.

CSL_Status MMC_eventEnable ( CSL_MmcsdHandle  hMmcsd,
CSL_MMCSDEventType  mmcsdEvent 
)

===========================================================================
MMC_eventEnable

Description
This function enables the MMC events depending on the 'mmcsdEvent' passed as a parameter. This function is useful to enable single interrupt of MMC interrupt mask register in one function call.

Arguments

            hMmcsd        Handle to the MMCSD
            mmcsdEvent    Event type.
     

Return Value CSL_Status

  • CSL_SOK - successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
MMC_open() API should be called successfully. Before enabling interrupt of any type make sure the isr function is plugged in ISR.

Post Condition
Interrupt will be enabled for particular event.

Modifies
MMC interrupt mask register

Example

			CSL_MMCControllerObj  mmcsdContObj;
            CSL_MmcsdHandle       hMmcsd;
            CSL_MmcsdInstId       instId;
            CSL_MMCSDEventType    mmcsdEvent;
            CSL_status            status;

            instId = CSL_MMCSD0_INST;

            hMmcsd = MMC_open(&mmcsdContObj, instId, CSL_MMCSD_OPMODE_POLLED,
                              &status);
            eventType = CSL_MMCSD_EDATDNE_INTERRUPT;

            status = MMC_eventEnable(hMmcsd, mmcsdEvent);
     

===========================================================================

References CSL_MMCSD_EBSYDNE_INTERRUPT, CSL_MMCSD_ECRCRD_INTERRUPT, CSL_MMCSD_ECRCRS_INTERRUPT, CSL_MMCSD_ECRCWR_INTERRUPT, CSL_MMCSD_EDATDNE_INTERRUPT, CSL_MMCSD_EDATED_INTERRUPT, CSL_MMCSD_EDRRDY_INTERRUPT, CSL_MMCSD_EDXRDY_INTERRUPT, CSL_MMCSD_ERSPDNE_INTERRUPT, CSL_MMCSD_ETOUTRD_INTERRUPT, CSL_MMCSD_ETOUTRS_INTERRUPT, CSL_MMCSD_ETRNDNE_INTERRUPT, and CSL_MMCControllerObj::mmcRegs.

AtaUint16 MMC_file_system_format ( void *  pAtaMediaState)

===========================================================================
MMC_file_system_format

Description
This function always returns success. No functionality is implemented. This function address is assigned to the function pointer provided by ATA file system.

Arguments

            pAtaMediaState    ATA media state structure
     

Return Value AtaError

  • ATA_ERROR_NONE - Returned for success

Pre Condition
MMC_initState API should be called successfully.

Post Condition
None

Modifies
None

Example

			AtaMMCState    ataMediaState;
			AtaState       ataState;
			AtaState       *pAtaState;
			AtaError       ataErr;
			AtaUint16      retVal;

			pAtaState = &ataState;

			ataState->pAtaMediaState = &ataMediaState;

			ataErr = MMC_initState(&ataState);

            retVal = pAtaState->AtaFileSystemType(ataState->pAtaMediaState);

     

===========================================================================

Referenced by MMC_initState().

AtaError MMC_flushFat ( void *  pAtaMediaState)

===========================================================================
MMC_flushFat

Description
This function always returns success. No functionality is implemented. This function address is assigned to the function pointer provided by ATA file system.

Arguments

            pAtaMediaState    ATA media state structure
     

Return Value AtaError

  • ATA_ERROR_NONE - Returned for success

Pre Condition
MMC_initState API should be called successfully.

Post Condition
None

Modifies
None

Example

			AtaMMCState    ataMediaState;
			AtaState       ataState;
			AtaState       *pAtaState;
			AtaError       ataErr;

			pAtaState = *ataState;
			pAtaState->pAtaMediaState = &ataMediaState;

			ataErr = MMC_initState(&ataState);

            ataErr = pAtaState->AtaFlushFat(pAtaState->pAtaMediaState);

     

===========================================================================

Referenced by MMC_initState().

AtaUint16 MMC_get_date ( void  )

===========================================================================
MMC_get_date

Description
This function always returns success. No functionality is implemented. This function address is assigned to the function pointer provided by ATA file system.

Arguments

            None
     

Return Value AtaError

  • ATA_ERROR_NONE - Returned for success

Pre Condition
MMC_initState API should be called successfully.

Post Condition
None

Modifies
None

Example

			AtaState       ataState;
			AtaState       *pAtaState;
			AtaError       ataErr;
			AtaUint16      date;

			pAtaState = &ataState;

			ataErr = MMC_initState(&ataState);

            date   = pAtaState->get_date();

     

===========================================================================

Referenced by MMC_initState().

AtaUint16 MMC_get_mod_date ( void  )

===========================================================================
MMC_get_mod_date

Description
This function always returns success. No functionality is implemented. This function address is assigned to the function pointer provided by ATA file system.

Arguments

            None
     

Return Value AtaError

  • ATA_ERROR_NONE - Returned for success

Pre Condition
MMC_initState API should be called successfully.

Post Condition
None

Modifies
None

Example

			AtaState       ataState;
			AtaState       *pAtaState;
			AtaError       ataErr;
			AtaUint16      date;

			pAtaState = &ataState;

			ataErr = MMC_initState(&ataState);

            date   = pAtaState->get_mod_date();

     

===========================================================================

Referenced by MMC_initState().

AtaUint16 MMC_get_mod_time ( void  )

===========================================================================
MMC_get_mod_time

Description
This function always returns success. No functionality is implemented. This function address is assigned to the function pointer provided by ATA file system.

Arguments

            None
     

Return Value AtaError

  • ATA_ERROR_NONE - Returned for success

Pre Condition
MMC_initState API should be called successfully.

Post Condition
None

Modifies
None

Example

			AtaState       ataState;
			AtaState       *pAtaState;
			AtaError       ataErr;
			AtaUint16      time;

			pAtaState = &ataState;

			ataErr = MMC_initState(&ataState);

            time   = pAtaState->get_mod_time();

     

===========================================================================

Referenced by MMC_initState().

AtaUint16 MMC_get_time ( void  )

===========================================================================
MMC_get_time

Description
This function always returns success. No functionality is implemented. This function address is assigned to the function pointer provided by ATA file system.

Arguments

            None
     

Return Value AtaError

  • ATA_ERROR_NONE - Returned for success

Pre Condition
MMC_initState API should be called successfully.

Post Condition
None

Modifies
None

Example

			AtaState       ataState;
			AtaState       *pAtaState;
			AtaError       ataErr;
			AtaUint16      time;

			pAtaState = &ataState;

			ataErr = MMC_initState(&ataState);

            time   = pAtaState->get_time();

     

===========================================================================

Referenced by MMC_initState().

CSL_Status MMC_getCardCsd ( CSL_MmcsdHandle  hMmcsd,
CSL_MMCCardCsdObj pMmcCardCsdObj 
)

===========================================================================
MMC_getCardCsd

Description
This function will update the CSD Structure information of MMC Card.

Arguments

            hMmcsd            Handle to the MMCSD.
            pMmcCardCsdObj    Pointer to the MMC Card CSD Info.
     

Return Value CSL_Status

  • CSL_SOK - successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid Parameter
  • CSL_EMMCSD_TIMEOUT - Command Reponse Timeout
  • CSL_EMMCSD_CRCERR - Command CRC Error

Pre Condition
1. MMC_open() API should be called successfully.
2. MMC_selectCard() API should be called before this so that it will do some needful work for particular card detected.
3. if Card detected is MMC then MMC_sendOpCond()for specific to MMC.

Post Condition
None

Modifies
CSD object structure

Example

            CSL_MmcsdHandle         hMmcsd;
			CSL_MMCControllerObj    mmcsdContObj;
            CSL_MMCCardObj          mmcCardObj;
            CSL_MMCCardCsdObj       mmcCardCsdObj;
            CSL_MmcsdInstId         instId;
            CSL_status              status;
            Uint16                  clkDivValue;

            instId = CSL_MMCSD0_INST;

            hMmcsd = MMC_open(&mmcsdContObj, instId, CSL_MMCSD_OPMODE_POLLED,
                              &status);

            status = MMC_selectCard(hMmcsd, &mmcCardObj);

            clkDivValue = 0x4 //as MMC clock max is 20MHz and
                                Function clock is 100MHz
            status = MMC_sendOpCond(hMmcsd, clkDivValue);

            status = MMC_getCardCsd(hMmcsd, &mmcCardCsdObj);

            For example following value will be populated.
            pMmcCardCsdObj->readBlLen         = ;
            pMmcCardCsdObj->cSize  = ;

            These value will be useful to fetch the card specific information
            as shown below. These figure are tested with 256Mbyte MMC Card

            blockLength  = 512 Bytes
            cardCapacity = 0x260636672 Bytes
            totalSectors = 0x509056 sector

     

===========================================================================

References CSL_MMCCardObj::blockLength, CSL_MMCCardObj::cardCapacity, CSL_MMCControllerObj::cardObj, CSL_MMCCardCsdObj::ccc, CSL_MMCCardCsdObj::contProtApp, CSL_MMCCardCsdObj::copyFlag, CSL_MMCCardCsdObj::crc, CSL_MMCCardObj::csd, CSL_MMCControllerObj::csdSliceInfo, CSL_MMCCardCsdObj::csdStruct, CSL_MMCCardCsdObj::cSize, CSL_MMCCardCsdObj::cSizeMult, CSL_MMCSD_CMD_7, CSL_MMCSD_CMD_9, CSL_MMCSD_CMD_TOUT_CRC_ERROR, CSL_MMCSD_EVENT_CARD_EXITBUSY, CSL_MMCSD_EVENT_EOFCMD, CSL_MMCSD_EVENT_ERROR_CMDTIMEOUT, CSL_MMCSD_MASK_MAX, CSL_MMCSD_SHIFT_MAX, CSL_MMCCardCsdObj::defaultEcc, CSL_MMCCardCsdObj::dsrImp, CSL_MMCCardCsdObj::ecc, CSL_MMCCardCsdObj::eraseGrpMult, CSL_MMCCardCsdObj::eraseGrpSize, CSL_MMCCardCsdObj::fileFmt, CSL_MMCCardCsdObj::fileFmtGrp, CSL_MMCCardCsdObj::mmcProt, CSL_MMCControllerObj::mmcRegs, CSL_MMCCardCsdObj::nsac, CSL_MMCCardCsdObj::permWriteProtect, CSL_MMCCardCsdObj::r2wFactor, CSL_MMCCardObj::rca, CSL_MMCCardCsdObj::readBlkMisalign, CSL_MMCCardCsdObj::readBlLen, CSL_MMCCardCsdObj::readBlPartial, CSL_MMCSDCsdStruct::slice111_96, CSL_MMCSDCsdStruct::slice127_112, CSL_MMCSDCsdStruct::slice15_0, CSL_MMCSDCsdStruct::slice31_16, CSL_MMCSDCsdStruct::slice47_32, CSL_MMCSDCsdStruct::slice63_48, CSL_MMCSDCsdStruct::slice79_64, CSL_MMCSDCsdStruct::slice95_80, CSL_MMCCardCsdObj::taac, CSL_MMCCardCsdObj::tmpWriteProtect, CSL_MMCCardObj::totalSectors, CSL_MMCCardCsdObj::tranSpeed, CSL_MMCCardCsdObj::vddRCurrMax, CSL_MMCCardCsdObj::vddRCurrMin, CSL_MMCCardCsdObj::vddWCurrMax, CSL_MMCCardCsdObj::vddWCurrMin, CSL_MMCCardCsdObj::wpGrpEnable, CSL_MMCCardCsdObj::wpGrpSize, CSL_MMCCardCsdObj::writeBlkMisalign, CSL_MMCCardCsdObj::writeBlLen, and CSL_MMCCardCsdObj::writeBlPartial.

CSL_Status MMC_getCardStatus ( CSL_MmcsdHandle  hMmcsd,
Uint32 *  pCardStatus 
)

===========================================================================
MMC_getCardStatus

Description
Function to get the status of the memory card. This function sends CMD13 to memory card to get the status. Memory card status will have the useful information to determine the card status and errors if any occurred. Refer to MMC/SD specification for the details of fields contained in the MMC/SD status.

Arguments

            hMmcsd         MMCSD handle
            pCardStatus    Pointer to store the status sent by the card
     

Return Value

  • CSL_SOK - Returned for Success
  • CSL_ESYS_BADHANDLE - Invalid MMSDC handle
  • CSL_ESYS_INVPARAMS - Invalid input parameters
  • CSL_EMMCSD_TIMEOUT - Command Reponse Timeout
  • CSL_EMMCSD_CRCERR - Command CRC Error

Pre Condition
MMC_open() function should be called successfully

Post Condition
Gets card status

Modifies
Card status pointer

Example


			CSL_MMCControllerObj    mmcsdContObj;
            CSL_MmcsdHandle         hMmcsd;
            CSL_MmcsdInstId         instId;
            CSL_status              status;
            Uint32                  cardStatus;

            instId = CSL_MMCSD0_INST;

            hMmcsd = MMC_open(&mmcsdContObj, instId, CSL_MMCSD_OPMODE_DMA,
                              &status);

            status = MMC_getCardStatus(hMmcsd, &cardStatus);
    

===========================================================================

References CSL_MMCControllerObj::cardObj, CSL_MMCSD_CMD_13, CSL_MMCSD_CMD_TOUT_CRC_ERROR, CSL_MMCSD_EVENT_EOFCMD, CSL_MMCSD_EVENT_ERROR_CMDTIMEOUT, CSL_MMCSD_SHIFT_MAX, CSL_MMCControllerObj::mmcRegs, and CSL_MMCCardObj::rca.

CSL_Status MMC_getConfig ( CSL_MmcsdHandle  hMmcsd,
CSL_MMCConfig pMmcConfig 
)

===========================================================================
MMC_getConfig

Description
This function will fetch the information present in the MMCSD registers and update to passed the config parameter.

Arguments

            hMmcsd        Handle to the MMCSD.
            pMmcConfig    Pointer to the MMCSD config Parameter.
     

Return Value CSL_Status

  • CSL_SOK - successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid Parameter

Pre Condition
MMC_open() API should be called before this.

Post Condition
None

Modifies
None.

Example

            CSL_MmcsdHandle       hMmcsd;
			CSL_MMCControllerObj  pMmcsdContObj;
            CSL_MmcsdInstId       instId;
            CSL_status            status;
            CSL_MMCConfig         pMmcConfig)

            instId = CSL_MMCSD0_INST;

            hMmcsd = MMC_open(&pMmcsdContObj, instId, CSL_MMCSD_OPMODE_POLLED,
                              &status);

            status = MMC_getConfig(hMmcsd, &pMmcConfig);
     

===========================================================================

References CSL_MMCConfig::mmcblen, CSL_MMCConfig::mmcclk, CSL_MMCConfig::mmcctl, CSL_MMCConfig::mmcim, CSL_MMCConfig::mmcnblk, CSL_MMCControllerObj::mmcRegs, CSL_MMCConfig::mmctod, and CSL_MMCConfig::mmctor.

CSL_Status MMC_getNumberOfCards ( CSL_MmcsdHandle  hMmcsd,
Uint16 *  pActiveNoCard 
)

===========================================================================
MMC_getNumberOfCards

Description
Get the number of cards information from the MMC handler.

Arguments

            hMmcsd           Handle to the MMCSD
            pActiveNoCard    pointer to store number of active card info.
     

Return Value CSL_Status

  • CSL_SOK - successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid Parameter

Pre Condition
MMC_open() API should be called before this.

Post Condition
None

Modifies
None

Example

			CSL_MMCControllerObj  mmcsdContObj;
            CSL_MmcsdHandle       hMmcsd;
            Uint16                activeNoCard;
            CSL_MmcsdInstId       instId;
            CSL_status            status;

            instId = CSL_MMCSD0_INST;
            hMmcsd = MMC_open(&mmcsdContObj, instId, CSL_MMCSD_OPMODE_POLLED,
                              &status);

            status = MMC_getNumberOfCards(hMmcsd, &activeNoCard);

     

===========================================================================

References CSL_MMCControllerObj::numCardsActive.

AtaUint16 MMC_getSerialID ( void *  pAtaMediaState,
AtaSerialID *  pSerID 
)

===========================================================================
MMC_getSerialID

Description
This function always returns success. No functionality is implemented. This function address is assigned to the function pointer provided by ATA file system.

Arguments

            pAtaMediaState    ATA media state structure
            pID               Pointer to store the serial Id
     

Return Value AtaError

  • ATA_ERROR_NONE - Returned for success

Pre Condition
MMC_initState API should be called successfully.

Post Condition
None

Modifies
None

Example

			AtaMMCState    ataMediaState;
			AtaState       ataState;
			AtaState       *pAtaState;
			AtaError       ataErr;
			AtaSerialID    serId;

			pAtaState= &ataState;

			ataState->pAtaMediaState = &ataMediaState;

			ataErr = MMC_initState(&ataState);

            retVal = pAtaState->AtaGetSerialID(ataState->pAtaMediaState,
                                               &serId);

     

===========================================================================

Referenced by MMC_initState().

Uint32 MMC_getStatus ( CSL_MmcsdHandle  hMmcsd,
Uint32  maskValue,
CSL_Status *  pStatus 
)

===========================================================================
MMC_getStatus

Description
This function return the status of particular field of MMCST0 and MMCST1 register according to the passed mask value. Value of MMCST1 will be stored in upper 16 bits and value of MMCST0 will be stored in lower 16 bits of the returned value.

Arguments

            hMmcsd       Handle to the MMCSD
            maskValue    Mask value to specify the field.
            pStatus      Status of API success or failed.
     

Return Value Uint32

  • status - MMCST0 and MMCST1 register value.

Pre Condition
MMC_open() API should be called before this.

Post Condition
None

Modifies
None

Example

			CSL_MMCControllerObj  mmcsdContObj;
            CSL_MmcsdHandle       hMmcsd;
            CSL_MmcsdInstId       instId;
            Uint16                maskValue;
            CSL_status            status;
            Uint32                mmcStatus;
            Uint32                maskValue;

            instId = CSL_MMCSD0_INST;
            hMmcsd = MMC_open(&mmcsdContObj, instId, CSL_MMCSD_OPMODE_POLLED,
                              &status);

			// Get the value of mmcst0 register
            maskValue = 0x0000FFFF;

            mmcStatus = MMC_getStatus(hMmcsd, maskValue, &status);
     

===========================================================================

References CSL_MMCSD_SHIFT_MAX, and CSL_MMCControllerObj::mmcRegs.

CSL_Status MMC_init ( void  )

===========================================================================
MMC_init

Description
This is the initialization function for the MMCSD CSL. The function must be called before calling any other API from MMCSD CSL. This function is for enabling the clock to the MMCSD Controller and routing MMCSD pins to the external serial port. This function should be called only once during system initialization time. This function gates the clock for the two MMCSD modules. Application programs may disable the clocks for MMCSD module which is not in use.

Arguments

     

Return Value CSL_Status

  • CSL_SOK - MMCSD initialization successfully

Pre Condition
This should be call first before calling any other MMCSD Function.

Post Condition
None

Modifies
None

Example

            CSL_status       status;

            status = MMC_init();
     

===========================================================================

References CSL_MMCSD_RESET_COUNT.

AtaError MMC_initState ( AtaState pDrive)

===========================================================================
MMC_initState

Description
This function initializes ATA state structure. Initializes all function pointers in the ATA state structure with appropriate function address. This function should be called by the application programs before transferring the control over the media to ATA file system.

Arguments

            pDrive    ATA state structure pointer
     

Return Value AtaError

  • ATA_ERROR_NONE - Returned for success
  • ATA_ERROR_INVALID_PARAM - Returned for Invalid input parameters

Pre Condition
None

Post Condition
Initializes ATA state structure

Modifies
ATA state structure

Example

			AtaState       ataState;
			AtaError       ataErr;

			ataErr = MMC_initState(&ataState);

     

===========================================================================

References MMC_busyStatusCheck(), MMC_commandReadyStatusCheck(), MMC_dataReadyStatusCheck(), MMC_file_system_format(), MMC_flushFat(), MMC_get_date(), MMC_get_mod_date(), MMC_get_mod_time(), MMC_get_time(), MMC_getSerialID(), MMC_issueReadCommand(), MMC_readNextNWords(), MMC_readNextWord(), MMC_readNextWord1(), MMC_readWriteControl(), MMC_reset(), MMC_writeSectorFlush(), and AtaMMCState::pDrive.

CSL_Status MMC_intEnable ( CSL_MmcsdHandle  hMmcsd,
Uint16  maskValue 
)

===========================================================================
MMC_intEnable

Description
This function will enable or disable interrupts for MMCSD depending on the passed mask value for interrupt. MMC interrupt mask register will be configured by this API. This function is useful to enable the multiple MMC interrupts in one function call.

Arguments

            hMmcsd       Handle to the MMCSD
            maskValue    mask value to specify the interrupt state.
     

Return Value CSL_Status

  • CSL_SOK - successful
  • CSL_ESYS_BADHANDLE - Invalid handle

Pre Condition
MMC_open() API should be called successfully before this. Before enabling interrupt of any type make sure the isr function is plugged in ISR.

Post Condition
Enables MMC interrupts

Modifies
MMC interrupt mask register

Example

			CSL_MMCControllerObj  mmcsdContObj;
            CSL_MmcsdHandle       hMmcsd;
            CSL_MmcsdInstId       instId;
            Uint16                maskValue;
            CSL_status            status;

            instId = CSL_MMCSD0_INST;

            hMmcsd = MMC_open(&mmcsdContObj, instId, CSL_MMCSD_OPMODE_POLLED,
                              &status);
            NOTE: Use the bit mask values of MMCIM register defined
                  cslr_mmcsd.h file for making the mask value.

            maskValue = CSL_MMCSD_MMCIM_ETRNDNE_MASK |
                        CSL_MMCSD_MMCIM_EDATED_MASK;

            status = MMC_intEnable(hMmcsd, maskValue);
     

===========================================================================

References CSL_MMCControllerObj::mmcRegs.

Referenced by MMC_read(), and MMC_write().

AtaError MMC_issueReadCommand ( AtaSector  phySector,
void *  pAtaMediaState,
AtaUint16  sectorCount 
)

===========================================================================
MMC_issueReadCommand

Description
This function is used to fetch all normal data from the media. A sector is always assumed to be 256 16-bit words by the high-level API

Programs calling this function should assign proper value to ATA_No_Swap in case of using that varaible.

Arguments

            phySector         Sector number from which data needs to be read
            pAtaMediaState    ATA media state structure
            sectorCount       Number of sectors to read
     

Return Value AtaError

  • ATA_ERROR_NONE - Returned for success
  • ATA_ERROR_INVALID_PARAM - Returned for Invalid input parameters
  • ATA_ERROR_TIMEOUT - Time out Error Occurred
  • ATA_ERROR_UNSUPPORTED - MMC/SD hardware is not supported

Pre Condition
MMC_initState API should be called successfully.

Post Condition
Reads Data from MMC/SD card

Modifies
Global Read buffer

Example

			AtaMMCState    ataMediaState;
			AtaState       ataState;
			AtaState       *pAtaState;
			AtaError       ataErr;
			AtaSector      phySector;
			AtaUint16      sectCnt;

			pAtaState = &ataState;

			phySector = 0;
			sectCnt   = 16;
			ataState->pAtaMediaState = &ataMediaState;

			ataErr = MMC_initState(&ataState);

            ataErr = pAtaState->AtaIssueReadCommand(phySector,
                                                    ataState->pAtaMediaState,
                                                    sectCnt);

     

===========================================================================

References CSL_MMCControllerObj::cardObj, CSL_MMCSD_ENDIAN_BIG, CSL_MMCSD_ENDIAN_LITTLE, CSL_MMCSD_PAGE_SIZE, getAtaErrorNo(), AtaMMCState::hMmcSd, MMC_read(), MMC_writeNSectors(), MMC_writeSector(), CSL_MMCControllerObj::readEndianMode, CSL_MMCCardObj::sdHcDetected, and CSL_MMCCardObj::totalSectors.

Referenced by MMC_initState(), MMC_readNextWord(), and MMC_readNextWord1().

CSL_MmcsdHandle MMC_open ( CSL_MMCControllerObj pMmcsdContObj,
CSL_MmcsdInstId  instId,
CSL_MMCSDOpMode  opMode,
CSL_Status *  status 
)

===========================================================================
MMC_open

Description
This function opens the CSL MMCSD module and returns handle to the MMCSD object structure. Parameter 'opMode' is provided to select the operating mode of the MMCSD module. Opmode information is stored in the MMCSD handle and is used in data transfer APIs.

NOTE: THIS API SETS THE ENDIAN MODE OF MMCSD READ AND WRITE OPERATIONS TO LITTLE ENDIAN. USE MMC_setEndianMode() TO CHANGE ENDIAN MODE.

Arguments

            pMmcsdContObj    MMCSD Controller object structure
            instId           Instance number for MMCSD
            opMode           Operating mode of the MMCSD module
            status           Status of the function call
     

Return Value CSL_MmmcsdHandle
Valid MMCSD handle will be returned if status value is equal to CSL_SOK.

Pre Condition
MMC_init() API should be called before MMC_open().

Post Condition
1. The status is returned in the status variable. If status returned is

  • CSL_SOK - Valid MMCSD handle is returned
  • CSL_ESYS_INVPARAMS - resource is already in use
    2. CSL_MmmcsdObj object structure is populated

Modifies
1. The status variable
2. CSL_MmmcsdObj object structure

Example

			CSL_MMCControllerObj  pMmcsdContObj;
            CSL_MmcsdHandle       hMmcsd;
            CSL_MmcsdInstId       instId;
            CSL_status            status;

            instId = CSL_MMCSD0_INST;
            status =  MMC_init();
            hMmcsd = MMC_open(&pMmcsdContObj, instId, CSL_MMCSD_OPMODE_POLLED,
                              &status);
            ...
    

===========================================================================

References CSL_DMA_Config::autoMode, CSL_MMCControllerObj::blockLen, CSL_DMA_Config::burstLen, CSL_DMA_Config::chanDir, CSL_DMA_AUTORELOAD_DISABLE, CSL_DMA_EVENT_TRIGGER, CSL_DMA_EVT_MMC_SD0_RX, CSL_DMA_EVT_MMC_SD0_TX, CSL_DMA_EVT_MMC_SD1_RX, CSL_DMA_EVT_MMC_SD1_TX, CSL_DMA_INTERRUPT_DISABLE, CSL_DMA_PING_PONG_DISABLE, CSL_DMA_READ, CSL_DMA_TRANSFER_IO_MEMORY, CSL_DMA_TXBURST_8WORD, CSL_DMA_WRITE, CSL_MMCSD0_INST, CSL_MMCSD1_INST, CSL_MMCSD_ENDIAN_LITTLE, CSL_MMCSD_OPMODE_DMA, CSL_MMCSD_OPMODE_INTERRUPT, CSL_MMCSD_OPMODE_POLLED, CSL_DMA_Config::dataLen, CSL_DMA_Config::destAddr, CSL_DMA_Config::dmaEvt, CSL_DMA_Config::dmaInt, CSL_MMCControllerObj::dmaReadCfg, CSL_MMCControllerObj::dmaWriteCfg, CSL_MMCControllerObj::hDmaRead, CSL_MMCControllerObj::hDmaWrite, CSL_MMCControllerObj::isCallbackSet, CSL_MMCControllerObj::mmcRegs, CSL_MMCControllerObj::opMode, CSL_DMA_Config::pingPongMode, CSL_MMCControllerObj::readEndianMode, CSL_DMA_Config::srcAddr, CSL_DMA_Config::trfType, CSL_DMA_Config::trigger, and CSL_MMCControllerObj::writeEndianMode.

CSL_Status MMC_read ( CSL_MmcsdHandle  hMmcsd,
Uint32  cardAddr,
Uint16  noOfBytes,
Uint16 *  pReadBuffer 
)

===========================================================================
MMC_read

Description
This function reads data from the memory card at a given address and populates the data to read buffer.

'cardAddr' represents the address location in the card to be accessed. For the standard capacity cards this parameter will be a value in multiples of 512. That means to read a sector number 1 cardAddr will be 1*512, to read a sector number 2 cardAddr will be 2*512 and so on. For the high capacity cards 'cardAddr' parameter will be same as the sector number. That means to read a sector number 1 cardAddr will be 1, to read a sector number 2 cardAddr will be 2 and so on. Reason for this is high capacity cards uses BLOCK addressing instead of the BYTE addressing used by the standard capacity cards to increase the addressable memory capacity.

Detection of high capacity cards can be verified using the flag 'sdHcDetected' in the MMCSD card object structure. sdHcDetected = TRUE - SD card is high capacity card sdHcDetected = FALSE - SD card is standard capacity card

NOTE: CARE SHOULD BE TAKEN WHILE PASSING THE 'cardAddr' PARAMETER. USING BYTE ADDRESSING WITH HIGH CAPACITY CARDS WILL LEAD TO OUT OF SECTOR BOUNDARY ACCESS AND RESULTS IN CODE HANGING FOR MMCSD RESPONSE.

NOTE: Endian mode of the data transfer depends on the parameter 'readEndianMode' in the MMC handle. Default value for the endian mode is 'LITTLE ENDIAN' which will be set during MMC open. Endian mode can be configured using MMC_setEndianMode(). DO NOT CHANGE THE ENDIAN MODE WITH OUT USING THIS API.

NOTE: When transferring data in DMA mode, word swap will be done for the data buffer when MMCSD is configured for little endian mode. No word swap is required in upper SW layers.

Arguments

            hMmcsd         Handle to the MMCSD.
            cardAddr       Location to read from.
            noOfBytes      Number of bytes to read.
            pReadBuffer    Pointer to a buffer.
     

Return Value CSL_Status

  • CSL_SOK - Close successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid Parameter
  • CSL_EMMCSD_TIMEOUT - card Response time out

Pre Condition
1. MMC_open() API should be called successfully.
2. MMC_selectCard() API should be called before this so that it will do some needful work for particular card detected.
3. MMC_sendOpCond()for specific to card.
4. If card detected is SD then call SD_getCardCsd() specific to SD. If card detected is MMC then call MMC_getCardCsd() specific to MMC

Post Condition
Populates data to read buffer.

Modifies
Read data buffer.

Example

            CSL_MmcsdHandle       hMmcsd;
			CSL_MMCControllerObj  mmcsdContObj;
            CSL_MMCCardObj        sdCardObj;
            CSL_MMCCardCsdObj     sdCardCsdObj;
            CSL_MmcsdInstId       instId;
            CSL_status            status;
            Uint16                clkDivValue;
            Uint16                noOfBytes;
            Uint16                cardAddr;
            Uint16                readBuffer[256];

            instId = CSL_MMCSD0_INST;

            hMmcsd = MMC_open(&mmcsdContObj, instId, CSL_MMCSD_OPMODE_POLLED,
                              &status);

            status = MMC_selectCard(hMmcsd, &sdCardObj);

            clkDivValue = 0x1 //as SD clock max is 50MHz and Function clock is 100MHz
            status = MMC_sendOpCond(hMmcsd, clkDivValue);

            status = SD_getCardCsd(hMmcsd, &sdCardCsdObj);
            For example following value will be populated.
            sdCardCsdObj.readBlLen = ;
            sdCardCsdObj.cSize     = ;
            These values will be useful to fetch the card specific information
            like these-----
            These figure are tested with 1GB SD Card
            blockLength      = 512 Bytes
            cardCapacity     = 0x1015808000 Bytes
            totalSectors     = 0x1984000 sector

            cardAddr = 0x200;
            noOfBytes = 512;

            status = MMC_read(hMmcsd, cardAddr, noOfBytes, readBuffer);
     

===========================================================================

References CSL_MMCControllerObj::blockLen, CSL_DMA_Config::burstLen, CSL_MMCControllerObj::cardObj, CSL_DMA_TXBURST_4WORD, CSL_MMCSD_BLOCK_LENGTH, CSL_MMCSD_BUSY_STATE, CSL_MMCSD_CMD_TOUT_CRC_ERROR, CSL_MMCSD_DATA_TOUT_CRC_ERROR, CSL_MMCSD_ENDIAN_LITTLE, CSL_MMCSD_EVENT_CARD_EXITBUSY, CSL_MMCSD_EVENT_EOFCMD, CSL_MMCSD_FIFO_EMPTY, CSL_MMCSD_MASK_MAX, CSL_MMCSD_OPMODE_DMA, CSL_MMCSD_OPMODE_INTERRUPT, CSL_MMCSD_OPMODE_POLLED, CSL_MMCSD_READ_BLOCK_CMD, CSL_MMCSD_READ_MULTIPLE_BLOCK_CMD, CSL_MMCSD_READ_READY, CSL_MMCSD_SHIFT_MAX, CSL_MMCSD_STOP_CMD, CSL_MMCSD_STUFF_BITS, CSL_MMSCD_READ_WRITE_RETRY_COUNT, CSL_DMA_Config::dataLen, CSL_MMCControllerObj::dataTransferCallback, CSL_DMA_Config::destAddr, DMA_config(), DMA_start(), DMA_stop(), DMA_swapWords(), CSL_MMCControllerObj::dmaReadCfg, CSL_MMCControllerObj::hDmaRead, IRQ_globalDisable(), IRQ_globalRestore(), CSL_MMCControllerObj::isCallbackSet, CSL_MMCCardObj::lastAddrRead, MMC_ierDisable(), MMC_ierEnable(), MMC_intEnable(), CSL_MMCControllerObj::mmcRegs, CSL_MMCControllerObj::opMode, CSL_MMCControllerObj::readEndianMode, and CSL_MMCCardObj::sdHcDetected.

Referenced by MMC_issueReadCommand(), and MMC_readNSectors().

AtaError MMC_read_CID ( void *  pAtaMediaState,
unsigned int *  pBuf 
)

===========================================================================
MMC_read_CID

Description
This function is used to read the MMCSD card identification information. CID information stored in the internal MMCSD handle is copied to the given data buffer. This function stores 8 words each of length 16bit into the given buffer.

Arguments

            pAtaMediaState    ATA media state structure
            pBuf              Pointer to data buffer to store CID information
     

Return Value AtaError

  • ATA_ERROR_NONE - Returned for success
  • ATA_ERROR_INVALID_PARAM - Returned for Invalid input parameters

Pre Condition
MMC_Open and MMC_sendAllCID/SD_sendAllCID APIs should be called successfully.

Post Condition
Writes CID data to given buffer

Modifies
Data in pBuf

Example

            CSL_MMCControllerObj    pMmcsdContObj;
            CSL_MmcsdHandle 		mmcsdHandle;
            CSL_MMCCardIdObj 		sdCardIdObj;
			AtaMMCState             ataMediaState;
			AtaState                ataState;
			AtaError                ataErr;
			unsigned int            csdBuf[8];
			CSL_Status              status;

            ataState->pAtaMediaState = &ataMediaState;

            //Open MMCSD module
	        mmcsdHandle = MMC_open(&pMmcsdContObj, CSL_MMCSD0_INST,
	                               CSL_MMCSD_OPMODE_POLLED, &status);
	        //Configure MMCSD module
	        ....
	        ....
	        //Read the CID information form card and store it in MMCSD handle
	        status = SD_sendAllCID(mmcsdHandle, &sdCardIdObj);

	        //Read the CID data from the internal handle
	     	ataErr = MMC_read_CID(ataState->pAtaMediaState, csdBuf);

     

===========================================================================

References CSL_MMCControllerObj::csdSliceInfo, and AtaMMCState::hMmcSd.

AtaError MMC_read_CSD ( void *  pAtaMediaState,
unsigned int *  pBuf 
)

===========================================================================
MMC_read_CSD

Description
This function is used to read the MMCSD card specific information. CSD information stored in the internal MMCSD handle is copied to the given data buffer. This function stores 8 words each of length 16bit into the given buffer.

Arguments

            pAtaMediaState    ATA media state structure
            pBuf              Pointer to data buffer to store CSD information
     

Return Value AtaError

  • ATA_ERROR_NONE - Returned for success
  • ATA_ERROR_INVALID_PARAM - Returned for Invalid input parameters

Pre Condition
MMC_Open and MMC_getCardCsd/SD_getCardCsd APIs should be called successfully.

Post Condition
Writes CSD data to given buffer

Modifies
Data in pBuf

Example

            CSL_MMCControllerObj    pMmcsdContObj;
            CSL_MmcsdHandle 		mmcsdHandle;
            CSL_MMCCardCsdObj 		sdCardCsdObj;
			AtaMMCState             ataMediaState;
			AtaState                ataState;
			AtaError                ataErr;
			unsigned int            csdBuf[8];
			CSL_Status              status;

            ataState->pAtaMediaState = &ataMediaState;

            //Open MMCSD module
	        mmcsdHandle = MMC_open(&pMmcsdContObj, CSL_MMCSD0_INST,
	                               CSL_MMCSD_OPMODE_POLLED, &status);
	        //Configure MMCSD module
	        ....
	        ....
	        //Read the CSD information form card and store it in MMCSD handle
	        status = SD_getCardCsd(mmcsdHandle, &sdCardCsdObj);

	        //Read the CSD data from the internal handle
	     	ataErr = MMC_read_CSD(ataState->pAtaMediaState, csdBuf);

     

===========================================================================

References CSL_MMCControllerObj::csdSliceInfo, and AtaMMCState::hMmcSd.

AtaError MMC_readNextNWords ( void *  pAtaMediaState,
AtaUint16 *  pData,
AtaUint16  words 
)

===========================================================================
MMC_readNextNWords

Description
This function is used to read N words next to the previously read word from the media. This function calls MMC_readNextWord API N number of times to read the data words. High level APIs should be aware of this and use MMC_readNextWord and MMC_readNextNWords APIs with care.

Arguments

            pAtaMediaState    ATA media state structure
            pData             Pointer to store the data words
            word              Number of words to read
     

Return Value AtaError

  • ATA_ERROR_NONE - Returned for success
  • ATA_ERROR_INVALID_PARAM - Returned for Invalid input parameters
  • ATA_ERROR_TIMEOUT - Time out Error Occurred
  • ATA_ERROR_UNSUPPORTED - MMC/SD hardware is not supported

Pre Condition
MMC_initState API should be called successfully.

Post Condition
Reads data from media

Modifies
Global Read buffer

Example

 			#define CSL_MMCSD_BUF_SIZE (16u)

			AtaMMCState    ataMediaState;
			AtaState       ataState;
			AtaState       *pAtaState;
			AtaError       ataErr;
			AtaUint16      dataBuf[CSL_MMCSD_BUF_SIZE];
			AtaUint16      words;

			pAtaState = &ataState;

			words  = CSL_MMCSD_BUF_SIZE;
			ataState->pAtaMediaState = &ataMediaState;

			ataErr = MMC_initState(&ataState);

            ataErr = pAtaState->AtaReadNextNWords(ataState->pAtaMediaState,
                                                  dataBuf, words);

     

===========================================================================

References MMC_readNextWord().

Referenced by MMC_initState().

AtaError MMC_readNextWord ( void *  pAtaMediaState,
AtaUint16 *  pWord 
)

===========================================================================
MMC_readNextWord

Description
This function is used to read a word next to the previously read word from the media. This function reads the words from the buffered data and send to the application. After reading 256 words from the global read buffer, this functions reads 256 words from the media and stores in the global read buffer. MMC_issueReadCommand functions should be called before calling this function for first time.

Arguments

            pAtaMediaState    ATA media state structure
            pWord             Pointer to store the data word
     

Return Value AtaError

  • ATA_ERROR_NONE - Returned for success
  • ATA_ERROR_INVALID_PARAM - Returned for Invalid input parameters
  • ATA_ERROR_TIMEOUT - Time out Error Occurred
  • ATA_ERROR_UNSUPPORTED - MMC/SD hardware is not supported

Pre Condition
MMC_initState API should be called successfully.
MMC_issueReadCommand should be called when calling MMC_readNextWord function for first time

Post Condition
Copies a data word into pWord

Modifies
Data in pWord

Example


			AtaMMCState    ataMediaState;
			AtaState       ataState;
			AtaState       *pAtaState;
			AtaError       ataErr;
			AtaUint16      data;
			AtaSector      phySector;
			AtaUint16      sectCnt;

			pAtaState = &ataState;

			ataState->pAtaMediaState = &ataMediaState;

			ataErr = MMC_initState(&ataState);

            ataErr = pAtaState->AtaIssueReadCommand(phySector,
                                                    ataState->pAtaMediaState,
                                                    sectCnt);

            ataErr = pAtaState->AtaReadNextWord(ataState->pAtaMediaState,
                                                &data);

     

===========================================================================

References MMC_issueReadCommand().

Referenced by MMC_initState(), and MMC_readNextNWords().

AtaError MMC_readNextWord1 ( void *  pAtaMediaState,
AtaUint16 *  pWord,
AtaUint16  word_delta 
)

===========================================================================
MMC_readNextWord1

Description
This function is used to read a word next to the previously read word from the media. This function reads the words from the buffered data and send to the application. After readinmg 256 words from the global read buffer, this functions reads 256 words from the media and stores in the global read buffer. MMC_issueReadCommand functions should be called before calling this function for first time.

Arguments

            pAtaMediaState    ATA media state structure
            pWord             Pointer to store the data word

     

Return Value AtaError

  • ATA_ERROR_NONE - Returned for success
  • ATA_ERROR_INVALID_PARAM - Returned for Invalid input parameters
  • ATA_ERROR_TIMEOUT - Time out Error Occurred
  • ATA_ERROR_UNSUPPORTED - MMC/SD hardware is not supported

Pre Condition
MMC_initState API should be called successfully.
MMC_issueReadCommand should be called when calling MMC_readNextWord function for first time

Post Condition
Copies a data word into pWord

Modifies
Data in pWord

Example


			AtaMMCState    ataMediaState;
			AtaState       ataState;
			AtaState       *pAtaState;
			AtaError       ataErr;
			AtaUint16      data;
			AtaSector      phySector;
			AtaUint16      sectCnt;

			pAtaState = &ataState;

			ataState->pAtaMediaState = &ataMediaState;

			ataErr = MMC_initState(&ataState);

            ataErr = pAtaState->AtaIssueReadCommand(phySector,
                                                    ataState->pAtaMediaState,
                                                    sectCnt);

            ataErr = pAtaState->AtaReadNextWord(ataState->pAtaMediaState,
                                                &data);

     

===========================================================================

===========================================================================
MMC_readNextWord1

Description
This function is used to read a word next to the previously read word from the media. This function reads the words from the buffered data and send to the application. After readinmg 256 words from the global read buffer, this functions reads 256 words from the media and stores in the global read buffer. MMC_issueReadCommand functions should be called before calling this function for first time.

Arguments

            pAtaMediaState    ATA media state structure
            pWord             Pointer to store the data word
			word_delta        word increment
     

Return Value AtaError

  • ATA_ERROR_NONE - Returned for success
  • ATA_ERROR_INVALID_PARAM - Returned for Invalid input parameters
  • ATA_ERROR_TIMEOUT - Time out Error Occurred
  • ATA_ERROR_UNSUPPORTED - MMC/SD hardware is not supported

Pre Condition
MMC_initState API should be called successfully.
MMC_issueReadCommand should be called when calling MMC_readNextWord function for first time

Post Condition
Copies a data word into pWord

Modifies
Data in pWord

Example


			AtaMMCState    ataMediaState;
			AtaState       ataState;
			AtaState       *pAtaState;
			AtaError       ataErr;
			AtaUint16      data;
			AtaSector      phySector;
			AtaUint16      sectCnt;

			pAtaState = &ataState;

			ataState->pAtaMediaState = &ataMediaState;

			ataErr = MMC_initState(&ataState);

            ataErr = pAtaState->AtaIssueReadCommand(phySector,
                                                    ataState->pAtaMediaState,
                                                    sectCnt);

            ataErr = pAtaState->AtaReadNextWord(ataState->pAtaMediaState,
                                                &data);

     

===========================================================================

References MMC_issueReadCommand().

Referenced by MMC_initState().

AtaError MMC_readNSectors ( void *  pAtaMediaState,
AtaUint16 *  pReadBuf,
AtaSector  startSector,
AtaUint16  sectorCount 
)

===========================================================================
MMC_readNSectors

Description
This function is used to read N sectors from MMC/SD card. Data buffer should be large enough to hold the data read from multiple sectors. Each sector size will be 512 bytes

Arguments

            pAtaMediaState    ATA media state structure
            pReadBuf          Pointer to store read data
            startSector       Starting sector number to read
            sectorCount       Number of sectors to read
     

Return Value AtaError

  • ATA_ERROR_NONE - Returned for success
  • ATA_ERROR_INVALID_PARAM - Returned for Invalid input parameters
  • ATA_ERROR_TIMEOUT - Time out Error Occurred
  • ATA_ERROR_UNSUPPORTED - MMC/SD hardware is not supported

Pre Condition
MMC_initState API should be called successfully.

Post Condition
Reads data from media

Modifies
Read buffer

Example

 			#define CSL_MMCSD_BUF_SIZE (256u)

			AtaMMCState    ataMediaState;
			AtaState       ataState;
			AtaError       ataErr;
			AtaUint16      dataBuf[CSL_MMCSD_BUF_SIZE];
			AtaUint16      words;
			Uint16         sectNum;

            ataState->pAtaMediaState = &ataMediaState;
			words   = CSL_MMCSD_BUF_SIZE;
			sectNum = 0;

			ataErr = MMC_initState(&ataState);

            ataErr = MMC_readNSectors(ataState->pAtaMediaStatee, dataBuf,
                                      words, sectNum, 8);

     

===========================================================================

References CSL_MMCControllerObj::cardObj, CSL_MMCSD_PAGE_SIZE, getAtaErrorNo(), AtaMMCState::hMmcSd, MMC_read(), CSL_MMCCardObj::sdHcDetected, and CSL_MMCCardObj::totalSectors.

AtaError MMC_reset ( void *  pAtaMediaState)

===========================================================================
MMC_reset

Description
This function always returns success. No functionality is implemented. This function address is assigned to the function pointer provided by ATA file system.

Arguments

            pAtaMediaState    ATA media state structure
     

Return Value AtaError

  • ATA_ERROR_NONE - Returned for success

Pre Condition
MMC_initState API should be called successfully.

Post Condition
None

Modifies
None

Example

			AtaMMCState    ataMediaState;
			AtaState       ataState;
			AtaState       *pAtaState;
			AtaError       ataErr;

			pAtaState = &ataState;

			ataState->pAtaMediaState = &ataMediaState;

			ataErr = MMC_initState(&ataState);

            ataErr = pAtaState->AtaReset(ataState->pAtaMediaState);

     

===========================================================================

Referenced by MMC_initState().

CSL_Status MMC_saveStatus ( CSL_MmcsdHandle  hMmcsd)

===========================================================================
MMC_saveStatus

Description
This function stores the value of MMCST0 and MMCST1 registers in the card object strutcure present in the MMCSD handle.

Arguments

            hMmcsd    Handle to the MMCSD
     

Return Value CSL_Status

  • CSL_SOK - Successful
  • CSL_ESYS_BADHANDLE - Invalid handle

Pre Condition
MMC_open() API should be called before this.

Post Condition
Saves the value of MMCST0 and MMCST1

Modifies
Card object structure

Example

			CSL_MMCControllerObj  mmcsdContObj;
            CSL_MmcsdHandle       hMmcsd;
            CSL_MmcsdInstId       instId;
            Uint16                maskValue;
            CSL_status            status;

            instId = CSL_MMCSD0_INST;

            hMmcsd = MMC_open(&mmcsdContObj, instId, CSL_MMCSD_OPMODE_POLLED,
                              &status);

            status = MMC_saveStatus(hMmcsd);
     

===========================================================================

References CSL_MMCControllerObj::cardObj, CSL_MMCControllerObj::mmcRegs, CSL_MMCCardObj::ST0, and CSL_MMCCardObj::ST1.

CSL_Status MMC_selectCard ( CSL_MmcsdHandle  hMmcsd,
CSL_MMCCardObj pMmcCardObj 
)

===========================================================================
MMC_selectCard

Description
This function detects which card (MMC/SD/SDHC) is inserted. Information of the card detected will be populated to the card object structure passed as parameter.

MMC object structure passed to this function should global structure variable which persists till end of the program since it is stored by MMCSD CSL for reference in other APIs.

Arguments

            hMmcsd            Handle to the MMCSD.
            pMmcCardObj       Pointer to the MMCSD Card Info.
     

Return Value CSL_Status

  • CSL_SOK - successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid Parameter
  • CSL_EMMCSD_TIMEOUT - Command Reponse Timeout
  • CSL_EMMCSD_CRCERR - Command CRC Error

Pre Condition
MMC_open() API should be called before this.

Post Condition
None

Modifies
None.

Example

            CSL_MmcsdHandle       hMmcsd;
			CSL_MMCControllerObj  mmcsdContObj;
            CSL_MMCCardObj        mmcCardObj;
            CSL_MmcsdInstId       instId;
            CSL_status            status;

            instId = CSL_MMCSD0_INST;

            hMmcsd = MMC_open(&mmcsdContObj, instId, CSL_MMCSD_OPMODE_POLLED,
                              &status);

            status = MMC_selectCard(hMmcsd, &mmcCardObj);
     

===========================================================================

References CSL_MMCControllerObj::cardObj, CSL_MMCCardObj::cardType, CSL_CARD_NONE, CSL_MMC_ACMD41_ARG_HCS, CSL_MMC_ACMD41_ARG_NOHCS, CSL_MMC_CARD, CSL_MMC_CMD1_ARG, CSL_MMC_CMD8_ARG, CSL_MMCSD_CARD_INIT0_CMD, CSL_MMCSD_CLK_DIV_INIT, CSL_MMCSD_CMD1_RESP, CSL_MMCSD_CMD41_RESP, CSL_MMCSD_CMD_41, CSL_MMCSD_DATA_RW_TIMEOUT, CSL_MMCSD_EVENT_EOFCMD, CSL_MMCSD_EVENT_ERROR, CSL_MMCSD_EVENT_ERROR_CMDCRC, CSL_MMCSD_EVENT_ERROR_CMDTIMEOUT, CSL_MMCSD_MASK_MAX, CSL_MMCSD_MMCS_CARD_INIT_CMD, CSL_MMCSD_RESPONSE_TIMEOUT, CSL_MMCSD_SD_CARD_INIT_CMD, CSL_MMCSD_SDHC_CARD_INIT_CMD, CSL_MMCSD_SDHC_RESP, CSL_MMCSD_SHIFT_MAX, CSL_MMCSD_STUFF_BITS, CSL_MMSCD_ACMD41_RETRY_COUNT, CSL_MMSCD_CMD1_RETRY_COUNT, CSL_SD_CARD, CSL_SD_HC_ECHO_PATTERN, CSL_SD_HC_VHS_ECHO, CSL_MMCControllerObj::mmcRegs, CSL_MMCControllerObj::numCardsActive, and CSL_MMCCardObj::sdHcDetected.

CSL_Status MMC_sendAllCID ( CSL_MmcsdHandle  hMmcsd,
CSL_MMCCardIdObj pMmcCardIdObj 
)

===========================================================================
MMC_sendAllCID

Description
This will fetch the Information about MMC Card Id and update into the passed id structure.

Arguments

            hMmcsd           Handle to the MMCSD.
            pMmcCardIdObj    Pointer to the MMC Card ID Info.
     

Return Value CSL_Status

  • CSL_SOK - successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid Parameter
  • CSL_EMMCSD_TIMEOUT - Command Reponse Timeout
  • CSL_EMMCSD_CRCERR - Command CRC Error

Pre Condition
1.MMC_open() API should be called successfully.
2.MMC_selectCard() API should be called before this so that it will do some needful work for particular card detected.
3.If Card detected is MMC then MMC_sendOpCond() for specific to MMC.

Post Condition
None

Modifies
pMmcCardIdObj will be populated.

Example

            CSL_MmcsdHandle         hMmcsd;
			CSL_MMCControllerObj    mmcsdContObj;
            CSL_MMCCardObj          mmcCardObj;
            CSL_MMCCardIdObj        mmcCardIdObj;
            CSL_MmcsdInstId         instId;
            CSL_status              status;
            Uint16                  clkDivValue;

            instId = CSL_MMCSD0_INST;

            hMmcsd = MMC_open(&mmcsdContObj, instId, CSL_MMCSD_OPMODE_POLLED,
                              &status);

            status = MMC_selectCard(hMmcsd, &mmcCardObj);

            clkDivValue = 0x4 //As MMC clock max is 20MHz and
                                Function clock is 100MHz
            status = MMC_sendOpCond(hMmcsd, clkDivValue);

            status = MMC_sendAllCID(hMmcsd, &mmcCardIdObj);
            For example following value will be populated.
            pMmcCardIdObj->mfgId         = ;
            pMmcCardIdObj->serialNumber  = ;
            pMmcCardIdObj->monthCode     = ;
     

===========================================================================

References CSL_MMCControllerObj::cardObj, CSL_MMCCardIdObj::checksum, CSL_MMCCardObj::cid, CSL_MMCControllerObj::cidSliceInfo, CSL_MMCSD_CMD_2, CSL_MMCSD_CMD_TOUT_CRC_ERROR, CSL_MMCSD_EVENT_EOFCMD, CSL_MMCSD_EVENT_ERROR_CMDTIMEOUT, CSL_MMCSD_STUFF_BITS, CSL_MMCCardIdObj::mfgId, CSL_MMCControllerObj::mmcRegs, CSL_MMCCardIdObj::month, CSL_MMCCardIdObj::oemAppId, CSL_MMCCardIdObj::productName, CSL_MMCCardIdObj::serialNumber, CSL_MMCSDCidStruct::slice111_96, CSL_MMCSDCidStruct::slice127_112, CSL_MMCSDCidStruct::slice15_0, CSL_MMCSDCidStruct::slice31_16, CSL_MMCSDCidStruct::slice47_32, CSL_MMCSDCidStruct::slice63_48, CSL_MMCSDCidStruct::slice79_64, CSL_MMCSDCidStruct::slice95_80, and CSL_MMCCardIdObj::year.

CSL_Status MMC_sendCmd ( CSL_MmcsdHandle  hMmcsd,
Uint32  cmd,
Uint32  arg,
Uint16  waitForRsp 
)

===========================================================================
MMC_sendCmd

Description
This is used to send a command to the memory card. Lower 16 bits of the parameter 'cmd' should contain the command that needs to be written to MMCCMD1 register. Upper 16 bits of the 'cmd' should contain the data that needs to be written to MMCCMD2 register.

NOTE:SETTING THE MMCCMD2 VALUE TO '1' IS ALLOWED ONLY TO DATA WRITE COMMANDS THAT USES DMA FOR DATA TRANSFER. FOR OTHER COMMANDS UPPER 16 BITS OF 'CMD' SHOULD ALWAYS BE ZERO.

Arguments

            hMmcsd        Handle to the MMCSD.
            cmd           Command index.
            arg           Argument.
            waitForRsp    Wait cycle for response.
     

Return Value CSL_Status

  • CSL_SOK - Close successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_EMMCSD_TIMEOUT - Command Reponse Timeout
  • CSL_EMMCSD_CRCERR - Command CRC Error

Pre Condition
MMC_open() API should be called before this.

Post Condition
None

Modifies
None.

Example

            CSL_MmcsdHandle       hMmcsd;
			CSL_MMCControllerObj  mmcsdContObj;
            CSL_MmcsdInstId       instId;
            CSL_status            status;
            Uint32                cmd;
            Uint32                arg;
            Uint16                waitForRsp;

            instId = CSL_MMCSD0_INST;

            hMmcsd = MMC_open(&mmcsdContObj, instId, CSL_MMCSD_OPMODE_POLLED,
                              &status);

            cmd        = CSL_MMCSD_WRITE_INIT_CMD;
            arg        = CSL_MMCSD_ARG_RESET;
            waitForRsp = CSL_MMCSD_RESPONSE_TIMEOUT;

            status = MMC_sendCmd(hMmcsd, cmd, arg, waitForRsp);
     

===========================================================================

References CSL_MMCSD_CMD_TOUT_CRC_ERROR, CSL_MMCSD_EVENT_EOFCMD, CSL_MMCSD_EVENT_ERROR_CMDTIMEOUT, CSL_MMCSD_MASK_MAX, CSL_MMCSD_SHIFT_MAX, and CSL_MMCControllerObj::mmcRegs.

CSL_Status MMC_sendGoIdle ( CSL_MmcsdHandle  hMmcsd)

===========================================================================
MMC_sendGoIdle

Description
This function broadcasts Go Idle command for Setting all cards to the idle state.

Arguments

            hMmcsd    Handle to the MMCSD
     

Return Value CSL_Status

  • CSL_SOK - Close successful
  • CSL_ESYS_BADHANDLE - Invalid handle

Pre Condition
This should be called just after MMC_open() API.

Post Condition
None

Modifies
None

Example

            CSL_MmcsdHandle         hMmcsd;
			CSL_MMCControllerObj    mmcsdContObj;
            CSL_MmcsdInstId         instId;
            CSL_status              status;

            instId = CSL_MMCSD0_INST;

            hMmcsd = MMC_open(&mmcsdContObj, instId, CSL_MMCSD_OPMODE_POLLED,
                              &status);

            status = MMC_sendGoIdle(hMmcsd);
     

===========================================================================

References CSL_MMCSD_GO_IDLE_STATE, CSL_MMCSD_STUFF_BITS, and CSL_MMCControllerObj::mmcRegs.

CSL_Status MMC_sendOpCond ( CSL_MmcsdHandle  hMmcsd,
Uint16  clkDivValue 
)

===========================================================================
MMC_sendOpCond

Description
This function will set the clock to the SD or MMC Card according to passed parameter of Card Type.

Arguments

            hMmcsd            Handle to the MMCSD
            clkDivValue       Clock Div value for MMC or SD card.
     

Return Value CSL_Status

  • CSL_SOK - successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid Parameter

Pre Condition
1:MMC_open() API should be called successfully.
2:MMC_selectCard() API should be called before this so that it will do some needful work for particular card detected.

Post Condition
None

Modifies
None

Example

            CSL_MmcsdHandle         hMmcsd;
			CSL_MMCControllerObj    mmcsdContObj;
            CSL_MMCCardObj          mmcCardObj;
            CSL_MmcsdInstId         instId;
            CSL_status              status;
            Uint16                  clkDivValue;

            instId = CSL_MMCSD0_INST;

            hMmcsd = MMC_open(&mmcsdContObj, instId, CSL_MMCSD_OPMODE_POLLED,
                              &status);

            status = MMC_selectCard(hMmcsd, &mmcCardObj);

            pMmmcCardObj->cardType = CSL_MMC_CARD;

            clkDivValue = 0x4 //as MMC clock max is 20MHz and Function clock is 100MHz
            status = MMC_sendOpCond(hMmcsd, clkDivValue);
     

===========================================================================

References CSL_MMCControllerObj::cardObj, CSL_MMCCardObj::cardType, CSL_MMC_CARD, CSL_MMC_MAX_CLOCK_RATE, CSL_SD_CARD, and CSL_MMCControllerObj::mmcRegs.

CSL_Status MMC_setBlockLength ( CSL_MmcsdHandle  hMmcsd,
Uint32  blockLen 
)

===========================================================================
MMC_setBlockLength

Description
This function is used to set block length of the memory card using command 16. In the case of a Standard Capacity SD Memory Card or MMC card, command 16 sets the block length(in bytes) for all following block commands (read, write, lock). Default block length is fixed to 512 bytes. In the case of a High Capacity SD memory card, block length set by CMD16 command does not affect the memory read and write commands. Always 512 bytes fixed block length is used.

This API does not verify the value of block length passed as parameter. Calling functions should make sure that the block length passed is proper with respect to the card under operation.

Arguments

            hMmcsd      MMCSD handle
            blockLen    Length of the memory card block
     

Return Value

  • CSL_SOK - Returned for Success
  • CSL_ESYS_BADHANDLE - Invalid MMSDC handle
  • CSL_EMMCSD_TIMEOUT - Command Reponse Timeout
  • CSL_EMMCSD_CRCERR - Command CRC Error

Pre Condition
MMC_open() function should be called successfully

Post Condition
Sets MMC/SD block length

Modifies
None

Example


			CSL_MMCControllerObj  mmcsdContObj;
            CSL_MmcsdHandle       hMmcsd;
            CSL_MmcsdInstId       instId;
            CSL_status            status;

            instId = CSL_MMCSD0_INST;

            hMmcsd = MMC_open(&mmcsdContObj, instId, CSL_MMCSD_OPMODE_DMA,
                              &status);

            status = MMC_setBlockLength(hMmcsd, CSL_MMCSD_BLOCK_LENGTH);
            ...
    

===========================================================================

References CSL_MMCControllerObj::blockLen, CSL_MMCSD_CMD_TOUT_CRC_ERROR, CSL_MMCSD_EVENT_EOFCMD, CSL_MMCSD_EVENT_ERROR_CMDTIMEOUT, CSL_MMCSD_MASK_MAX, CSL_MMCSD_SET_BLKLEN_CMD, CSL_MMCSD_SHIFT_MAX, and CSL_MMCControllerObj::mmcRegs.

CSL_Status MMC_setCallBack ( CSL_MmcsdHandle  hMmcsd,
CSL_MMCCallBackObj pFunction 
)

===========================================================================
MMC_setCallBack

Description
This function sets the address of call back routines which will be called from MMCSD ISR.

Arguments

            hMmcsd       Handle to the MMCSD.
            pFunction    Pointer to the isr function.
     

Return Value CSL_Status

  • CSL_SOK - successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid Parameter

Pre Condition
MMC_open() API should be called before this.

Post Condition
None

Modifies
None.

Example

            #define MMCSD_ISR_FUNCTION_MAX (4u)
            void mmcsd0_tx_isr(void);
            void mmcsd0_rcv_isr(void);
            void mmcsd1_tx_isr(void);
            void mmcsd1_rcv_isr(void);

            CSL_MMCControllerObj  mmcsdContObj;
            CSL_MmcsdHandle       hMmcsd;
            CSL_MmcsdInstId       instId;
            CSL_status            status;
            CSL_MMCCallBackObj    callBckFun;

            instId = CSL_MMCSD0_INST;
            hMmcsd = MMC_open(&mmcsdContObj, instId, CSL_MMCSD_OPMODE_POLLED,
                              &status);

			callBckFun.isr[CSL_MMCSD_ISR_TXMT] = mmcsd_tx_isr;
			callBckFun.isr[CSL_MMCSD_ISR_RCV]  = mmcsd_rcv_isr;

            status = MMC_setCallBack(hMmcsd, &callBckFun);
     

===========================================================================

References CSL_MMCControllerObj::callBackTbl.

CSL_Status MMC_setCardPtr ( CSL_MmcsdHandle  hMmcsd,
CSL_MMCCardObj pMmcCardObj 
)

===========================================================================
MMC_setCardPtr

Description
This function will set the card object information address into the MMCSD handle. Implementation is limited only to the software layer.

Arguments

            hMmcsd            Handle to the MMCSD.
            CSL_MMCCardObj    Pointer to the MMCSD Card Object.
     

Return Value CSL_Status

  • CSL_SOK - successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid Parameter

Pre Condition
MMC_open() API should be called successfully before this.

Post Condition
None

Modifies
Card object structure

Example

            CSL_MMCCardObj        mmcCardObj;
			CSL_MMCControllerObj  mmcsdContObj;
            CSL_MmcsdHandle       hMmcsd;
            CSL_MmcsdInstId       instId;
            CSL_status            status;

            instId = CSL_MMCSD0_INST;

            hMmcsd = MMC_open(&mmcsdContObj, instId, CSL_MMCSD_OPMODE_POLLED,
                              &status);

            status = MMC_setCardPtr(hMmcsd, &mmcCardObj);
     

===========================================================================

References CSL_MMCControllerObj::cardObj.

CSL_Status MMC_setCardType ( CSL_MMCCardObj pCardObj,
CSL_CardType  cardType 
)

===========================================================================
MMC_setCardType

Description
This API just updates the software structure and does not update any hardware registers

Arguments

            pCardObj    Pointer to the card object.
            cardType    type of card MMC or SD.
     

Return Value CSL_Status

  • CSL_SOK - successful
  • CSL_ESYS_INVPARAMS - Invalid Parameter

Pre Condition
None.

Post Condition
None

Modifies
None

Example


            CSL_MMCCardObj        cardObj;
            CSL_CardType          cardType;

            cardType = CSL_SD_CARD;

            status = MMC_setCardType(&cardObj, cardType);
     

===========================================================================

References CSL_MMCCardObj::cardType, CSL_MMC_CARD, and CSL_SD_CARD.

CSL_Status MMC_setDataTransferCallback ( CSL_MmcsdHandle  hMmcsd,
CSL_MMCDataTxferCallBackPtr  dataTransferCallback 
)

===========================================================================
MMC_setDataTransferCallback

Description
This function stores the data transfer call back function pointer in the MMCSD handle. This callback pointer is used by the MMCSD write and read APIs to issue callback during data transfer operations. This is to facilitate application/driver programs handle MMCSD interrupt in their own way depending on their requirements. Callback function is used when MMCSD is operating in DMA or interrupt mode. During DMA mode operation, call back function will be called after starting the DMA data transfer. During interrupt mode operation call back function will be called 1. For checking read/write command response 2. For checking transit/receive ready bit 3. For checking data done bit

In both the operating modes callback function should wait for the MMCSD interrupt. Upon receiving the interrupt, all the MMCSD events should be disabled. MMCSD handle will be passed to the callback function as a parameter.

Setting the callback function is optional for DMA mode but is mandatory for interrupt mode operation. MMC_read/MMC_write APIs return with error in case of no callback is set and MMCSD is configured for interrupt mode.

NOTE: Same callback pointer will be used by write and read APIs. Callback function is applicable to DMA and interrupt mode only. Should not call this API when MMCSD is operation in polled mode.

Arguments

            hMmcsd                  MMCSD handle
            dataTransferCallback    Transfer done callback pointer
     

Return Value

  • CSL_SOK - Returned for Success
  • CSL_ESYS_BADHANDLE - Invalid MMSDC handle
  • CSL_ESYS_INVPARAMS - Invalid input parameters

Pre Condition
MMC_open() function should be called successfully

Post Condition
Stores the transfer done callback pointer in MMC handle

Modifies
MMC handle

Example

            CSL_MmcsdHandle                hMmcsd;
            CSL_MMCDataTxferCallBackPtr    dataTransferCallback;
            CSL_MmcsdInstId                instId;
            CSL_status                     status;

            instId = CSL_MMCSD0_INST;

            hMmcsd = MMC_open(&pMmcsdContObj, instId, CSL_MMCSD_OPMODE_DMA,
                              &status);

            status = MMC_setDataTransferCallback(hMmcsd, dataTransferCallback);
            ...
    

===========================================================================

References CSL_MMCControllerObj::dataTransferCallback, and CSL_MMCControllerObj::isCallbackSet.

CSL_Status MMC_setDmaChanConfig ( CSL_MmcsdHandle  hMmcsd,
CSL_MmcsdDmaConfig  dmaConfig 
)

===========================================================================
MMC_setDmaChanConfig

Description
This function is used to set the DMA channel configurations. DMA channel configuration values sent by the application are stored in the MMCSD handle and used by the MMC write and read functions. DMA read and write channel configurations can be set independently with only one channel at a time using this function. Direction of the DMA channel is identified using the member 'chanDir' of CSL_MMCDmaConfig structure. Operating mode of the MMCSD module needs to be set to DMA mode for using this API.

Members of CSL_MMCDmaConfig structure are subset of CSL_DMA_Config structure. Other configuration values DMA source address, destination address, DMA data length etc are not configurable by MMCSD application program and are set by the MMCSD read/write API depending on the request from file system.

Only 4word and 8word DMA burst length is allowed for MMCSD (burstLen). Any other burst length will be ignored and DMA will be configured to 8word burst length by default.

This API is an optional one. Default DMA configurations are assigned by the MMC_open function. No need to call this API until and unless a different DMA configurations are required by the application.

NOTE:This API should not be called when MMCSD is operating Polled mode.

Arguments

            hMmcsd       MMCSD handle
            dmaConfig    DMA configuration structure
     

Return Value

  • CSL_SOK - Returned for Success
  • CSL_ESYS_BADHANDLE - Invalid MMSDC handle
  • CSL_ESYS_INVPARAMS - Invalid configuration parameters

Pre Condition
MMC_open() function should be called successfully

Post Condition
Stores the DMA configuration values in MMC handle

Modifies
MMC handle

Example

			CSL_MMCControllerObj    pMmcsdContObj;
            CSL_MmcsdHandle         hMmcsd;;
            CSL_MmcsdDmaConfig      dmaWriteCfg;
            CSL_MmcsdDmaConfig      dmaReadCfg;
            CSL_MmcsdInstId         instId;
            CSL_status              status;

            instId = CSL_MMCSD0_INST;

            hMmcsd = MMC_open(&pMmcsdContObj, instId, CSL_MMCSD_OPMODE_DMA,
                              &status);

			dmaWriteCfg.autoMode     = CSL_DMA_AUTORELOAD_DISABLE;
			dmaWriteCfg.burstLen     = CSL_DMA_TXBURST_8WORD;
			dmaWriteCfg.chanDir      = CSL_DMA_WRITE;
			dmaWriteCfg.dmaInt       = CSL_DMA_INTERRUPT_ENABLE;

			// Set the DMA write channel configuration
            status = MMC_setDmaChanConfig(hMmcsd, dmaWriteCfg);

			dmaReadCfg.autoMode     = CSL_DMA_AUTORELOAD_DISABLE;
			dmaReadCfg.burstLen     = CSL_DMA_TXBURST_8WORD;
			dmaReadCfg.chanDir      = CSL_DMA_READ;
			dmaReadCfg.dmaInt       = CSL_DMA_INTERRUPT_ENABLE;

			// Set the DMA read channel configuration
            status = MMC_setDmaChanConfig(hMmcsd, dmaReadCfg);

    

===========================================================================

References CSL_DMA_Config::autoMode, CSL_MmcsdDmaConfig::autoMode, CSL_DMA_Config::burstLen, CSL_MmcsdDmaConfig::burstLen, CSL_MmcsdDmaConfig::chanDir, CSL_DMA_AUTORELOAD_DISABLE, CSL_DMA_AUTORELOAD_ENABLE, CSL_DMA_INTERRUPT_DISABLE, CSL_DMA_INTERRUPT_ENABLE, CSL_DMA_READ, CSL_DMA_TXBURST_4WORD, CSL_DMA_TXBURST_8WORD, CSL_DMA_WRITE, CSL_MMCSD_OPMODE_DMA, CSL_DMA_Config::dmaInt, CSL_MmcsdDmaConfig::dmaInt, CSL_MMCControllerObj::dmaReadCfg, CSL_MMCControllerObj::dmaWriteCfg, CSL_MMCControllerObj::opMode, CSL_MmcsdDmaConfig::pingPongEnable, and CSL_DMA_Config::pingPongMode.

CSL_Status MMC_setDmaHandle ( CSL_MmcsdHandle  hMmcsd,
CSL_DMA_Handle  hDmaWrite,
CSL_DMA_Handle  hDmaRead 
)

===========================================================================
MMC_setDmaHandle

Description
This function stores the DMA handles sent by the application program. DMA handle stored in MMCSD handle will be used by the MMC read/write APIs to transfer the data in DMA mode. This API requires that MMCSD operating mode should be set to DMA using MMC_open function. DMA channel handles should be sent by the application in proper order. DMA channel needs to opened before calling this API. This channels will be closed by the MMC_close API.

NOTE:This API should not be called when MMCSD is operating Polled mode.

Arguments

            hMmcsd       MMCSD handle
            hDmaWrite    Handle to DMA channel used for MMCSD write operation
            hDmaRead     Handle to DMA channel used for MMCSD read operation
     

Return Value

  • CSL_SOK - Returned for Success
  • CSL_ESYS_BADHANDLE - Invalid MMSDC handle
  • CSL_ESYS_INVPARAMS - Invalid DMA handle

Pre Condition
MMC_open() and DMA_open() functions should be called successfully

Post Condition
Stores the DMA handle in MMC handle

Modifies
MMC handle

Example

			CSL_MMCControllerObj  pMmcsdContObj;
            CSL_MmcsdHandle       hMmcsd;
            CSL_DMA_Handle        dmaWrHandle;
            CSL_DMA_Handle        dmaRdHandle;
            CSL_DMA_ChannelObj    dmaWrChanObj;
            CSL_DMA_ChannelObj    dmaRdChanObj;

            CSL_MmcsdInstId       instId;
            CSL_status            status;

            instId = CSL_MMCSD0_INST;

            hMmcsd = MMC_open(&pMmcsdContObj, instId, CSL_MMCSD_OPMODE_DMA,
                              &status);

            dmaWrHandle = DMA_open(&dmaWrChanObj, CSL_DMA_CHAN0);

            dmaRdHandle = DMA_open(&dmaRdChanObj, CSL_DMA_CHAN1);

            // Set DMA handle
            status = MMC_setDmaHandle(hMmcsd, dmaWrHandle, dmaRdHandle);
            ...
    

===========================================================================

References CSL_MMCSD_OPMODE_DMA, CSL_MMCControllerObj::hDmaRead, CSL_MMCControllerObj::hDmaWrite, and CSL_MMCControllerObj::opMode.

CSL_Status MMC_setEndianMode ( CSL_MmcsdHandle  hMmcsd,
CSL_MmcsdEndianMode  writeEndianMode,
CSL_MmcsdEndianMode  readEndianMode 
)

===========================================================================
MMC_setEndianMode

Description
This function is used to set endian mode of the MMC/SD controller. Endian mode set using this API decides the way in which data is transferred from FIFO to storage device.

Default endianness of MMCSD controller: Chip C5504 and C5505: LITTLE ENDIAN. Chip C5514 and C5515: BIG ENDIAN.

Arguments

            hMmcsd             MMCSD handle
            writeEndianMode    Endian mode for MMC/SD write operation
            readEndianMode     Endian mode for MMC/SD read operation
     

Return Value

  • CSL_SOK - Returned for Success
  • CSL_ESYS_BADHANDLE - Invalid MMSDC handle
  • CSL_ESYS_INVPARAMS - Invalid input parameters

Pre Condition
MMC_open() function should be called successfully

Post Condition
Sets MMC/SD endian mode for write and operations

Modifies
MMC/SD control register

Example


			CSL_MMCControllerObj  pMmcsdContObj;
            CSL_MmcsdHandle       hMmcsd;
            CSL_MmcsdInstId       instId;
            CSL_status            status;

            instId = CSL_MMCSD0_INST;

            hMmcsd = MMC_open(&pMmcsdContObj, instId, CSL_MMCSD_OPMODE_DMA,
                              &status);

            status = MMC_setEndianMode(hMmcsd, CSL_MMCSD_ENDIAN_LITTLE,
                                      CSL_MMCSD_ENDIAN_LITTLE);
            ...
    

===========================================================================

References CSL_MMCSD_ENDIAN_BIG, CSL_MMCSD_ENDIAN_LITTLE, CSL_MMCControllerObj::mmcRegs, CSL_MMCControllerObj::readEndianMode, and CSL_MMCControllerObj::writeEndianMode.

CSL_Status MMC_setRca ( CSL_MmcsdHandle  hMmcsd,
CSL_MMCCardObj pMmcCardObj,
Uint16  rCardAddr 
)

===========================================================================
MMC_setRca

Description
This function sets the relative card address for MMC Card. Relative card address is stored in CSL_MMCCardObj which can used by other MMCSD CSL APIs.

Application programs should use only this function to set the RCA of MMC card. RCA passed to this function will be stored in the MMCSD handle and is used by other MMCSD CSL APIs.

NOTE: THIS FUNCTION IS SPECIFIC TO MMC CARD AND SHOULD NOT BE USED WITH THE SD CARD. FOR MMC CARD CMD3(SET_RELATIVE_ADDR) IS USED TO SET THE CARD ADDRESS AND FOR SD CARD CMD3(SEND_RELATIVE_ADDR) IS USED TO REQUEST THE CARD ADDRESS.

Arguments

            hMmcsd            Handle to the MMCSD.
            pMmcCardObj       Pointer to the MMC Card Info.
            rCardAddr         Relative card address.
     

Return Value CSL_Status

  • CSL_SOK - successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid Parameter
  • CSL_EMMCSD_TIMEOUT - Command Reponse Timeout
  • CSL_EMMCSD_CRCERR - Command CRC Error

Pre Condition
1:MMC_open() API should be called successfully.
2:MMC_selectCard() API should be called before this so that it will do some needful work for particular card detected.
3: If Card detected is MMC then MMC_sendOpCond() for specific to MMC.

Post Condition
None

Modifies
None

Example

            CSL_MmcsdHandle         hMmcsd;
			CSL_MMCControllerObj    mmcsdContObj;
            CSL_MMCCardObj          mmcCardObj;
            CSL_MmcsdInstId         instId;
            CSL_status              status;
            Uint16                  clkDivValue;
            Uint16                  rCardAddr;

            instId = CSL_MMCSD0_INST;

            hMmcsd = MMC_open(&mmcsdContObj, instId, CSL_MMCSD_OPMODE_POLLED,
                              &status);

            status = MMC_selectCard(hMmcsd, &mmcCardObj);

            clkDivValue = 0x4 //as MMC clock max is 20MHz and Function clock is 100MHz
            status = MMC_sendOpCond(hMmcsd, clkDivValue);
            rCardAddr = 0x100;

            status = MMC_setRca(hMmcsd, &mmcCardObj, rCardAddr);
     

===========================================================================

References CSL_MMCControllerObj::cardObj, CSL_MMCSD_CMD_TOUT_CRC_ERROR, CSL_MMCSD_EVENT_EOFCMD, CSL_MMCSD_EVENT_ERROR_CMDTIMEOUT, CSL_MMCSD_RELATIVE_ADDR, CSL_MMCSD_STUFF_BITS, CSL_MMCControllerObj::mmcRegs, and CSL_MMCCardObj::rca.

CSL_Status MMC_setupNative ( CSL_MmcsdHandle  hMmcsd,
CSL_MMCSetupNative pMmcInit 
)

===========================================================================
MMC_setupNative

Description
This function will set initial configuration to all the MMCSD registers.

Arguments

            hMmcsd      Handle to the MMCSD.
            pMmcInit    Pointer to CSL_MMCSetupNative state variable.
     

Return Value CSL_Status

  • CSL_SOK - successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid Parameter

Pre Condition
MMC_open() API should be called before this.

Post Condition
MMCSD Registers will be populated.

Modifies
MMCSD Registers

Example

            CSL_MmcsdHandle       hMmcsd;
			CSL_MMCControllerObj  pMmcsdContObj;
            CSL_MmcsdInstId       instId;
            CSL_status            status;
            CSL_MMCConfig         mmcInit;

            instId = CSL_MMCSD0_INST;

            hMmcsd = MMC_open(&pMmcsdContObj, instId, CSL_MMCSD_OPMODE_POLLED,
                              &status);

            Note: CSL_MMCConfig field are following.
            mmcInit.dmaEnable         = CSL_MMCSD_MMCCMD2_DMATRIG_NO;
            mmcInit.dat3EdgeDetection = CSL_MMCSD_MMCCTL_DATEG_DISABLE;
            mmcInit.cdiv              = CSL_MMCSD_CLK_DIV_INIT;
            mmcInit.rspTimeout        = CSL_MMCSD_RESPONSE_TIMEOUT;
            mmcInit.dataTimeout       = CSL_MMCSD_DATA_RW_TIMEOUT;
            mmcInit.blockLen          = CSL_MMCSD_MIN_BLOCK_LENGTH;

            status = MMC_setupNative(hMmcsd, &mmcInit);
     

===========================================================================

References CSL_MMCSetupNative::blockLen, CSL_MMCSetupNative::cdiv, CSL_MMCSetupNative::dat3EdgeDetection, CSL_MMCSetupNative::dataTimeout, CSL_MMCControllerObj::mmcRegs, and CSL_MMCSetupNative::rspTimeout.

CSL_Status MMC_setWriteBlkEraseCnt ( CSL_MmcsdHandle  hMmcsd,
Uint32  blkCnt 
)

===========================================================================
MMC_setWriteBlkEraseCnt

Description
Function to set the number of write blocks to be preerased before writing. Set write block erase count command need to be used for faster multiple block write command. Calling this function is not mandatory. In case of calling this API for better performance, it should be called just before calling MMC_write function.

Arguments

            hMmcsd      MMCSD handle
            blkCnt      Number of blocks
     

Return Value

  • CSL_SOK - Returned for Success
  • CSL_ESYS_BADHANDLE - Invalid MMSDC handle
  • CSL_EMMCSD_TIMEOUT - Command Reponse Timeout
  • CSL_EMMCSD_CRCERR - Command CRC Error

Pre Condition
MMC_open() function should be called successfully

Post Condition
Sets preerase block count

Modifies
None

Example


			CSL_MMCControllerObj    mmcsdContObj;
            CSL_MmcsdHandle         hMmcsd;
            CSL_MmcsdInstId         instId;
            CSL_status              status;

            instId = CSL_MMCSD0_INST;

            hMmcsd = MMC_open(&mmcsdContObj, instId, CSL_MMCSD_OPMODE_DMA,
                              &status);

            status = MMC_setWriteBlkEraseCnt(hMmcsd, 16);
            ...
    

===========================================================================

References CSL_MMCControllerObj::cardObj, CSL_MMCSD_ACMD_23, CSL_MMCSD_CMD_55, CSL_MMCSD_CMD_TOUT_CRC_ERROR, CSL_MMCSD_EVENT_EOFCMD, CSL_MMCSD_EVENT_ERROR_CMDTIMEOUT, CSL_MMCSD_MASK_MAX, CSL_MMCSD_SHIFT_MAX, CSL_MMCControllerObj::mmcRegs, and CSL_MMCCardObj::rca.

CSL_Status MMC_stop ( CSL_MmcsdHandle  hMmcsd)

===========================================================================
MMC_stop

Description
Function to stop the MMC/SD transfer and receive events. This function sends CMD12 to the memory card.

NOTE: STOP command should be sent to the card when it is in 'data'(read) or 'rcv'(write) state. Sending STOP command while the card in any other state will result in command timeout.

Arguments

            hMmcsd            Handle to the MMCSD
     

Return Value CSL_Status

  • CSL_SOK - Close successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_EMMCSD_TIMEOUT - Command Reponse Timeout
  • CSL_EMMCSD_CRCERR - Command CRC Error

Pre Condition
MMC_open() API should be called before this.
Card should be addressed.

Post Condition
None

Modifies
None

Example

            CSL_MmcsdHandle         hMmcsd;
			CSL_MMCControllerObj    mmcsdContObj;
            CSL_MmcsdInstId         instId;
            CSL_status              status;

            instId = CSL_MMCSD0_INST;

            hMmcsd = MMC_open(&mmcsdContObj, instId, CSL_MMCSD_OPMODE_POLLED,
                              &status);

            status = MMC_stop(hMmcsd);
     

===========================================================================

References CSL_MMCSD_CMD_TOUT_CRC_ERROR, CSL_MMCSD_EVENT_CARD_EXITBUSY, CSL_MMCSD_EVENT_EOFCMD, CSL_MMCSD_EVENT_ERROR_CMDTIMEOUT, CSL_MMCSD_STOP_TRANSMISSION, CSL_MMCSD_STUFF_BITS, and CSL_MMCControllerObj::mmcRegs.

CSL_Status MMC_write ( CSL_MmcsdHandle  hMmcsd,
Uint32  cardAddr,
Uint16  noOfBytes,
Uint16 *  pWriteBuffer 
)

===========================================================================
MMC_write

Description
This function writes data in the write data buffer to the memory card at a given address.

'cardAddr' represents the address location in the card to be accessed. For the standard capacity cards this parameter will be a value in multiples of 512. That means to write a sector number 1 cardAddr will be 1*512, to write a sector number 2 cardAddr will be 2*512 and so on. For the high capacity cards 'cardAddr' parameter will be same as the sector number. That means to write a sector number 1 cardAddr will be 1, to write a sector number 2 cardAddr will be 2 and so on. Reason for this is high capacity cards uses BLOCK addressing instead of the BYTE addressing used by the standard capacity cards to increase the addressable memory capacity.

Detection of high capacity cards can be verified using the flag 'sdHcDetected' in the MMCSD card object structure. sdHcDetected = TRUE - SD card is high capacity card sdHcDetected = FALSE - SD card is standard capacity card

NOTE: CARE SHOULD BE TAKEN WHILE PASSING THE 'cardAddr' PARAMETER. USING BYTE ADDRESSING WITH HIGH CAPACITY CARDS WILL LEAD TO OUT OF SECTOR BOUNDARY ACCESS AND RESULTS IN CODE HANGING FOR MMCSD RESPONSE.

NOTE: Endian mode of the data transfer depends on the parameter 'writeEndianMode' in the MMC handle. Default value for the endian mode is 'LITTLE ENDIAN' which will be set during MMC open. Endian mode can be configured using MMC_setEndianMode(). DO NOT CHANGE THE ENDIAN MODE WITH OUT USING THIS API.

NOTE: When transferring data in DMA mode, word swap will be done for the data buffer when MMCSD is configured for little endian mode. No word swap is required in upper SW layers.

Arguments

            hMmcsd            Handle to the MMCSD
            cardAddr          location to read from.
            noOfBytes         no of bytes to read.
            pWriteBuffer      pointer to a buffer.
     

Return Value CSL_Status

  • CSL_SOK - Close successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid Parameter
  • CSL_EMMCSD_TIMEOUT - card Response time out

Pre Condition
1.MMC_open() API should be called successfully.
2.MMC_selectCard() API should be called before this so that it will do some needful work for particular card detected.
3. MMC_sendOpCond()for specific to card .
4. If Card detected is SD then call SD_getCardCsd() specific to SD. If Card detected is SD then call MMC_getCardCsd() specific to MMC

Post Condition
Writes the data to card

Modifies
MMC/SD card will populated with the passed buffer values.

Example

            CSL_MmcsdHandle       hMmcsd;
			CSL_MMCControllerObj  mmcsdContObj;
            CSL_MMCCardObj        sdCardObj;
            CSL_MMCCardCsdObj     sdCardCsdObj;
            CSL_MmcsdInstId       instId;
            CSL_status            status;
            Uint16                clkDivValue;
            Uint16                noOfBytes;
            Uint16                cardAddr;
            Uint16                writeBuffer[256];

            instId = CSL_MMCSD0_INST;

            hMmcsd = MMC_open(&mmcsdContObj, instId, CSL_MMCSD_OPMODE_POLLED,
                              &status);

            status = MMC_selectCard(hMmcsd, &sdCardObj);

            sdCardObj.cardType = CSL_SD_CARD;
             clkDivValue = 0x1 //as SD clock max is 50MHz and Function
                                 clock is 100MHz
            status = MMC_sendOpCond(hMmcsd, clkDivValue);

            status = SD_getCardCsd(hMmcsd, &sdCardCsdObj);
            For example following value will be populated.
            pSdCardCsdObj->readBlLen         = ;
            pSdCardCsdObj->cSize  = ;
            These value will be useful to fetch the card specific information
            These figure are tested with 1GB Ultra SD Card
            blockLength  = 512 Bytes
            cardCapacity = 0x1015808000 Bytes
            totalSectors = 0x1984000 sector

            cardAddr = 0x200;
            noOfBytes = 512;

            status = MMC_write(hMmcsd, cardAddr, noOfBytes, &writeBuffer);
     

===========================================================================

References CSL_MMCControllerObj::blockLen, CSL_DMA_Config::burstLen, CSL_MMCControllerObj::cardObj, CSL_DMA_TXBURST_4WORD, CSL_MMCSD_BLOCK_LENGTH, CSL_MMCSD_BUSY_STATE, CSL_MMCSD_CMD_TOUT_CRC_ERROR, CSL_MMCSD_ENDIAN_LITTLE, CSL_MMCSD_EVENT_CARD_EXITBUSY, CSL_MMCSD_EVENT_EOFCMD, CSL_MMCSD_EVENT_ERROR, CSL_MMCSD_FIFO_EMPTY, CSL_MMCSD_MASK_MAX, CSL_MMCSD_OPMODE_DMA, CSL_MMCSD_OPMODE_INTERRUPT, CSL_MMCSD_OPMODE_POLLED, CSL_MMCSD_SHIFT_MAX, CSL_MMCSD_STOP_CMD, CSL_MMCSD_STUFF_BITS, CSL_MMCSD_WRITE_BLOCK_CMD, CSL_MMCSD_WRITE_MULTIPLE_BLOCK_CMD, CSL_MMCSD_WRITE_READY, CSL_MMSCD_READ_WRITE_RETRY_COUNT, CSL_DMA_Config::dataLen, CSL_MMCControllerObj::dataTransferCallback, DMA_config(), DMA_start(), DMA_stop(), DMA_swapWords(), CSL_MMCControllerObj::dmaWriteCfg, CSL_MMCControllerObj::hDmaWrite, IRQ_globalDisable(), IRQ_globalRestore(), CSL_MMCControllerObj::isCallbackSet, CSL_MMCCardObj::lastAddrWritten, MMC_ierDisable(), MMC_ierEnable(), MMC_intEnable(), CSL_MMCControllerObj::mmcRegs, CSL_MMCControllerObj::opMode, CSL_MMCCardObj::sdHcDetected, CSL_DMA_Config::srcAddr, and CSL_MMCControllerObj::writeEndianMode.

Referenced by MMC_writeNSectors(), and MMC_writeSector().

AtaError MMC_writeNSectors ( void *  pAtaMediaState,
AtaUint16 *  pWriteBuf,
AtaSector  startSector,
AtaUint16  sectorCount 
)

===========================================================================
MMC_writeNSectors

Description
This function is used to write N number of sectors to MMC/SD card. Each sector size will be 512 bytes

Arguments

            pAtaMediaState    ATA media state structure
            pWriteBuf         Pointer to write data buffer
            startSector       Starting sector number to write
            sectorCount       Number of sectors to write
     

Return Value AtaError

  • ATA_ERROR_NONE - Returned for success
  • ATA_ERROR_INVALID_PARAM - Returned for Invalid input parameters
  • ATA_ERROR_TIMEOUT - Time out Error Occurred
  • ATA_ERROR_UNSUPPORTED - MMC/SD hardware is not supported

Pre Condition
MMC_initState API should be called successfully.

Post Condition
Writes data to media

Modifies
Data in the MMC/SD card

Example

 			#define CSL_MMCSD_BUF_SIZE (256u)

			AtaMMCState    ataMediaState;
			AtaState       ataState;
			AtaError       ataErr;
			AtaUint16      dataBuf[CSL_MMCSD_BUF_SIZE];
			AtaUint16      words;
			Uint16         sectNum;

            ataState->pAtaMediaState = &ataMediaState;
			words   = CSL_MMCSD_BUF_SIZE;
			sectNum = 0;

			ataErr = MMC_initState(&ataState);

            ataErr = MMC_writeNSectors(ataState->pAtaMediaState, dataBuf,
                                       words, sectNum, 8);

     

===========================================================================

References CSL_MMCControllerObj::cardObj, CSL_MMCSD_PAGE_SIZE, getAtaErrorNo(), AtaMMCState::hMmcSd, MMC_write(), CSL_MMCCardObj::sdHcDetected, and CSL_MMCCardObj::totalSectors.

Referenced by MMC_issueReadCommand(), and MMC_readWriteControl().

AtaError MMC_writeSector ( AtaSector  phySector,
void *  pAtaMediaState,
AtaUint16 *  pWord,
int  byteSwap 
)

===========================================================================
MMC_writeSector

Description
This function is used to write data to the media. This function can write 512 bytes of data at one time.

Programs calling this function should assign proper value to ATA_No_Swap in case of using that varaible.

Arguments

            phySector         Sector number from which data needs to be read
            pAtaMediaState    ATA media state structure
            pWord             Write data buffer
            byteSwap          Flag to request for the byte swap
     

Return Value AtaError

  • ATA_ERROR_NONE - Returned for success
  • ATA_ERROR_INVALID_PARAM - Returned for Invalid input parameters
  • ATA_ERROR_TIMEOUT - Time out Error Occurred
  • ATA_ERROR_UNSUPPORTED - MMC/SD hardware is not supported

Pre Condition
MMC_initState API should be called successfully.

Post Condition
Writes Data to MMC/SD card

Modifies
MMCSD Sector data

Example

 			#define CSL_MMCSD_BUF_SIZE (256u)

			AtaMMCState    ataMediaState;
			AtaState       ataState;
			AtaState       *pAtaState;
			AtaError       ataErr;
			AtaSector      phySector;
			AtaUint16      writeBuf[CSL_MMCSD_BUF_SIZE];

			pAtaState = &ataState;

			phySector = 0;
			ataState->pAtaMediaState = &ataMediaState;

			ataErr = MMC_initState(&ataState);

            ataErr = pAtaState->AtaWriteSector(phySector,
                                               ataState->pAtaMediaState,
                                               writeBuf, FALSE);

     

===========================================================================

References CSL_MMCControllerObj::cardObj, CSL_MMCSD_ENDIAN_BIG, CSL_MMCSD_ENDIAN_LITTLE, CSL_MMCSD_PAGE_SIZE, getAtaErrorNo(), AtaMMCState::hMmcSd, MMC_write(), CSL_MMCCardObj::sdHcDetected, CSL_MMCCardObj::totalSectors, and CSL_MMCControllerObj::writeEndianMode.

Referenced by MMC_issueReadCommand(), and MMC_readWriteControl().

AtaError MMC_writeSectorFlush ( void *  pAtaMediaState)

===========================================================================
MMC_writeSectorFlush

Description
This function always returns success. No functionality is implemented. This function address is assigned to the function pointer provided by ATA file system.

Arguments

            pAtaMediaState    ATA media state structure
     

Return Value AtaError

  • ATA_ERROR_NONE - Returned for success

Pre Condition
MMC_initState API should be called successfully.

Post Condition
None

Modifies
None

Example

			AtaMMCState    ataMediaState;
			AtaState       ataState;
			AtaState       *pAtaState;
			AtaError       ataErr;

			pAtaState = &ataState;

			ataState->pAtaMediaState = &ataMediaState;

			ataErr = MMC_initState(&ataState);

            ataErr = pAtaState->AtaWriteSectorFlush(ataState->pAtaMediaState);

     

===========================================================================

Referenced by MMC_initState().

CSL_Status SD_configurePullup ( CSL_MmcsdHandle  hMmcsd,
Bool  pullupCfg 
)

===========================================================================
SD_configurePullup

Description
Function to Connenct/Disconnect the SD card internal pull-up resistors. This function is specific to SD card; cannot be used with MMC card

Arguments

            hMmcsd         MMCSD handle
            pullupCfg      Flag indicate the pull-up configuration
                             0 - Disconnects the pull-up resistor
                             1 - Connects the pull-up resistor
     

Return Value

  • CSL_SOK - Returned for Success
  • CSL_ESYS_BADHANDLE - Invalid MMSDC handle
  • CSL_ESYS_INVPARAMS - Invalid input parameters
  • CSL_EMMCSD_TIMEOUT - Command Reponse Timeout
  • CSL_EMMCSD_CRCERR - Command CRC Error

Pre Condition
MMC_open() function should be called successfully
Card should be selected

Post Condition
Connencts/Disconnects SD card pull-up resistor

Modifies
None

Example


			CSL_MMCControllerObj    mmcsdContObj;
            CSL_MmcsdHandle         hMmcsd;
            CSL_MmcsdInstId         instId;
            CSL_status              status;
            Uint32                  cardStatus;

            instId = CSL_MMCSD0_INST;

            hMmcsd = MMC_open(&mmcsdContObj, instId, CSL_MMCSD_OPMODE_DMA,
                              &status);
            ....

            //Select the card

            ....

            status = SD_configurePullup(hMmcsd, 0);
    

===========================================================================

References CSL_MMCControllerObj::cardObj, CSL_MMCSD_ACMD_42, CSL_MMCSD_CMD_55, CSL_MMCSD_CMD_TOUT_CRC_ERROR, CSL_MMCSD_EVENT_EOFCMD, CSL_MMCSD_EVENT_ERROR_CMDTIMEOUT, CSL_MMCControllerObj::mmcRegs, and CSL_MMCCardObj::rca.

CSL_Status SD_getCardCsd ( CSL_MmcsdHandle  hMmcsd,
CSL_MMCCardCsdObj pSdCardCsdObj 
)

===========================================================================
SD_getCardCsd

Description
This function will update the CSD Structure info of SD Card.

Arguments

            hMmcsd            Handle to the MMCSD.
            pSdCardCsdObj     Pointer to the SD Card CSD Info.
     

Return Value CSL_Status

  • CSL_SOK - successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid Parameter
  • CSL_EMMCSD_TIMEOUT - Command Reponse Timeout
  • CSL_EMMCSD_CRCERR - Command CRC Error

Pre Condition
1:MMC_open() API should be called successfully.
2:MMC_selectCard() API should be called before this so that it will do some needful work for particular card detected.
3:If Card detected is SD then MMC_sendOpCond()for specific to SD.

Post Condition
None

Modifies
None

Example

            CSL_MmcsdHandle       hMmcsd;
			CSL_MMCControllerObj  mmcsdContObj;
            CSL_MMCCardObj        sdCardObj;
            CSL_MMCCardCsdObj     sdCardCsdObj;
            CSL_MmcsdInstId       instId;
            CSL_status            status;
            Uint16                clkDivValue;

            instId = CSL_MMCSD0_INST;

            hMmcsd = MMC_open(&mmcsdContObj, instId, CSL_MMCSD_OPMODE_POLLED,
                              &status);

            status = MMC_selectCard(hMmcsd, &sdCardObj);

            clkDivValue = 0x1 //As SD clock max is 50MHz and Function clock is 100MHz
            status = MMC_sendOpCond(hMmcsd, clkDivValue);

            status = SD_getCardCsd(hMmcsd, &sdCardCsdObj);
            For example following value will be populated.
            sdCardCsdObj.readBlLen         = ;
            sdCardCsdObj.cSize  = ;
            These values will be useful to fetch the card specific information
            like these-----
            These figure are tested with 1GB Ultra SD Card
            blockLength      = 512 Bytes
            cardCapacity     = 0x1015808000 Bytes
            totalSectors     = 0x1984000 sector
     

===========================================================================

References CSL_MMCCardObj::blockLength, CSL_MMCCardObj::cardCapacity, CSL_MMCControllerObj::cardObj, CSL_MMCCardCsdObj::ccc, CSL_MMCCardCsdObj::copyFlag, CSL_MMCCardCsdObj::crc, CSL_MMCCardObj::csd, CSL_MMCControllerObj::csdSliceInfo, CSL_MMCCardCsdObj::csdStruct, CSL_MMCCardCsdObj::cSize, CSL_MMCCardCsdObj::cSizeMult, CSL_MMC_BUSWIDTH_4BIT, CSL_MMCSD_CMD_55, CSL_MMCSD_CMD_6, CSL_MMCSD_CMD_7, CSL_MMCSD_CMD_9, CSL_MMCSD_CMD_TOUT_CRC_ERROR, CSL_MMCSD_EVENT_EOFCMD, CSL_MMCSD_EVENT_ERROR_CMDTIMEOUT, CSL_MMCSD_MASK_MAX, CSL_MMCSD_SHIFT_MAX, CSL_MMCCardCsdObj::dsrImp, CSL_MMCCardCsdObj::ecc, CSL_MMCCardCsdObj::eraseBlkEnable, CSL_MMCCardCsdObj::eraseGrpSize, CSL_MMCCardCsdObj::fileFmt, CSL_MMCCardCsdObj::fileFmtGrp, CSL_MMCControllerObj::mmcRegs, CSL_MMCCardCsdObj::nsac, CSL_MMCCardCsdObj::permWriteProtect, CSL_MMCCardCsdObj::r2wFactor, CSL_MMCCardObj::rca, CSL_MMCCardCsdObj::readBlkMisalign, CSL_MMCCardCsdObj::readBlLen, CSL_MMCCardCsdObj::readBlPartial, CSL_MMCSDCsdStruct::slice111_96, CSL_MMCSDCsdStruct::slice127_112, CSL_MMCSDCsdStruct::slice15_0, CSL_MMCSDCsdStruct::slice31_16, CSL_MMCSDCsdStruct::slice47_32, CSL_MMCSDCsdStruct::slice63_48, CSL_MMCSDCsdStruct::slice79_64, CSL_MMCSDCsdStruct::slice95_80, CSL_MMCCardCsdObj::taac, CSL_MMCCardCsdObj::tmpWriteProtect, CSL_MMCCardObj::totalSectors, CSL_MMCCardCsdObj::tranSpeed, CSL_MMCCardCsdObj::vddRCurrMax, CSL_MMCCardCsdObj::vddRCurrMin, CSL_MMCCardCsdObj::vddWCurrMax, CSL_MMCCardCsdObj::vddWCurrMin, CSL_MMCCardCsdObj::wpGrpEnable, CSL_MMCCardCsdObj::wpGrpSize, CSL_MMCCardCsdObj::writeBlkMisalign, CSL_MMCCardCsdObj::writeBlLen, and CSL_MMCCardCsdObj::writeBlPartial.

CSL_Status SD_sendAllCID ( CSL_MmcsdHandle  hMmcsd,
CSL_MMCCardIdObj pSdCardIdObj 
)

===========================================================================
SD_sendAllCID

Description
This will fetch the Information about SD Card Id and update into the passed id structure.

Arguments

            hMmcsd           Handle to the MMCSD.
            pSdCardIdObj     Pointer to the SD Card ID Info.
     

Return Value CSL_Status

  • CSL_SOK - successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid Parameter
  • CSL_EMMCSD_TIMEOUT - Command Reponse Timeout
  • CSL_EMMCSD_CRCERR - Command CRC Error

Pre Condition
1:MMC_open() API should be called successfully.
2:MMC_selectCard() API should be called before this so that it will do some needful work for particular card detected.
3:If Card detected is SD then MMC_sendOpCond() specific to SD.

Post Condition
None

Modifies
pSdCardIdObj object will be populated.

Example

            CSL_MmcsdHandle         hMmcsd;
			CSL_MMCControllerObj    mmcsdContObj;
            CSL_MMCCardObj          sdCardObj;
            CSL_MMCCardIdObj        sdCardIdObj;
            CSL_MmcsdInstId         instId;
            CSL_status              status;
            Uint16                  clkDivValue;

            instId = CSL_MMCSD0_INST;

            hMmcsd = MMC_open(&mmcsdContObj, instId, CSL_MMCSD_OPMODE_POLLED,
                              &status);

            status = MMC_selectCard(hMmcsd, &sdCardObj);

            clkDivValue = 0x1 //As SD clock max is 50MHz and
                                Function clock is 100MHz
            status = MMC_sendOpCond(hMmcsd, clkDivValue);

            status = SD_sendAllCID(hMmcsd, &sdCardIdObj);

            For example following value will be populated.
            sdCardIdObj.mfgId         = ;
            sdCardIdObj.serialNumber  = ;
            sdCardIdObj.monthCode     = ;
     

===========================================================================

References CSL_MMCControllerObj::cardObj, CSL_MMCCardIdObj::checksum, CSL_MMCCardObj::cid, CSL_MMCControllerObj::cidSliceInfo, CSL_MMCSD_CMD_2, CSL_MMCSD_CMD_TOUT_CRC_ERROR, CSL_MMCSD_EVENT_EOFCMD, CSL_MMCSD_EVENT_ERROR_CMDTIMEOUT, CSL_MMCSD_STUFF_BITS, CSL_MMCCardIdObj::mfgId, CSL_MMCControllerObj::mmcRegs, CSL_MMCCardIdObj::month, CSL_MMCCardIdObj::oemAppId, CSL_MMCCardIdObj::productName, CSL_MMCCardIdObj::serialNumber, CSL_MMCSDCidStruct::slice111_96, CSL_MMCSDCidStruct::slice127_112, CSL_MMCSDCidStruct::slice15_0, CSL_MMCSDCidStruct::slice31_16, CSL_MMCSDCidStruct::slice47_32, CSL_MMCSDCidStruct::slice63_48, CSL_MMCSDCidStruct::slice79_64, CSL_MMCSDCidStruct::slice95_80, and CSL_MMCCardIdObj::year.

CSL_Status SD_sendRca ( CSL_MmcsdHandle  hMmcsd,
CSL_MMCCardObj pSdCardObj,
Uint16 *  pRCardAddr 
)

===========================================================================
SD_sendRca

Description
This function sends request for relative card address(RCA) of SD Card. RCA value published by SD card will be populated to card address parameter. RCA is also stored in CSL_MMCCardObj to use in other MMCSD CSL APIs.

Application programs should use only this function to requesting the RCA from SD card. RCA published by the SD card will be stored in the MMCSD handle and is used by other MMCSD CSL APIs.

NOTE: THIS FUNCTION IS SPECIFIC TO SD CARD AND SHOULD NOT BE USED WITH THE MMC CARD. FOR MMC CARD CMD3(SET_RELATIVE_ADDR) IS USED TO SET THE CARD ADDRESS AND FOR SD CARD CMD3(SEND_RELATIVE_ADDR) IS USED TO REQUEST THE CARD ADDRESS.

Arguments

            hMmcsd            Handle to the MMCSD.
            pSdCardObj        Pointer to the SD Card Info.
            pRCardAddr        Pointer to store relative card address.
     

Return Value CSL_Status

  • CSL_SOK - successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid Parameter
  • CSL_EMMCSD_TIMEOUT - Command Reponse Timeout
  • CSL_EMMCSD_CRCERR - Command CRC Error

Pre Condition
1:MMC_open() API should be called successfully.
2:MMC_selectCard() API should be called before this so that it will do some needful work for particular card detected.
3:If Card detected is SD then MMC_sendOpCond() for specific to SD.

Post Condition
None

Modifies
pRCardAddr variable will be populated.

Example

            CSL_MmcsdHandle         hMmcsd;
			CSL_MMCControllerObj    mmcsdContObj;
            CSL_MMCCardObj          sdCardObj;
            CSL_MmcsdInstId         instId;
            CSL_status              status;
            Uint16                  clkDivValue;
            Uint16                  rCardAddr;

            instId = CSL_MMCSD0_INST;

            hMmcsd = MMC_open(&mmcsdContObj, instId, CSL_MMCSD_OPMODE_POLLED,
                              &status);

            status = MMC_selectCard(hMmcsd, &sdCardObj);

            clkDivValue = 0x1; //As SD clock max is 50MHz and Function clock is 100MHz

            status = MMC_sendOpCond(hMmcsd, clkDivValue);
            status = SD_sendRca(hMmcsd, &sdCardObj, &rCardAddr);
     

===========================================================================

References CSL_MMCControllerObj::cardObj, CSL_MMCSD_CMD_TOUT_CRC_ERROR, CSL_MMCSD_EVENT_EOFCMD, CSL_MMCSD_EVENT_ERROR_CMDTIMEOUT, CSL_MMCSD_RELATIVE_ADDR, CSL_MMCSD_STUFF_BITS, CSL_MMCControllerObj::mmcRegs, and CSL_MMCCardObj::rca.

CSL_Status SD_setBusWidth ( CSL_MmcsdHandle  hMmcsd,
Uint8  busWidth 
)

===========================================================================
SD_setBusWidth

Description
Function to set the bus with for SD card. This function sends ACMD6 to the SD card to configure the bus width. This function should be called after selecting the card using CMD7.

NOTE: This function is specific to SD card.Should not be used with MMC.

Arguments

            hMmcsd        MMCSD handle
            busWidth      bus width of the card; 0 - 1 bit, 1 - 4 bit
     

Return Value

  • CSL_SOK - Returned for Success
  • CSL_ESYS_BADHANDLE - Invalid MMSDC handle
  • CSL_ESYS_INVPARAMS - Invalid input parameters
  • CSL_EMMCSD_TIMEOUT - Command Reponse Timeout
  • CSL_EMMCSD_CRCERR - Command CRC Error

Pre Condition
MMC_open() function should be called successfully

Post Condition
Sets SD card bus width

Modifies
None

Example


			CSL_MMCControllerObj    mmcsdContObj;
            CSL_MmcsdHandle         hMmcsd;
            CSL_MmcsdInstId         instId;
            CSL_status              status;

            instId = CSL_MMCSD0_INST;

            hMmcsd = MMC_open(&mmcsdContObj, instId, CSL_MMCSD_OPMODE_DMA,
                              &status);

            status = SD_setBusWidth(hMmcsd, 1);
            ...
    

===========================================================================

References CSL_MMCControllerObj::cardObj, CSL_MMCSD_CMD_55, CSL_MMCSD_CMD_6, CSL_MMCSD_CMD_TOUT_CRC_ERROR, CSL_MMCSD_EVENT_EOFCMD, CSL_MMCSD_EVENT_ERROR_CMDTIMEOUT, CSL_MMCSD_MASK_MAX, CSL_MMCSD_SHIFT_MAX, CSL_MMCControllerObj::mmcRegs, and CSL_MMCCardObj::rca.