sdps
Vitis Drivers API Documentation
 All Data Structures Files Functions Variables Macros Groups Pages
SDPS APIs

Functions

s32 XSdPs_CfgInitialize (XSdPs *InstancePtr, XSdPs_Config *ConfigPtr, UINTPTR EffectiveAddr)
 Initializes a specific XSdPs instance so that the driver is ready to use. More...
 
s32 XSdPs_CardInitialize (XSdPs *InstancePtr)
 Initializes the card with the identification mode sequence. More...
 
s32 XSdPs_ReadPolled (XSdPs *InstancePtr, u32 Arg, u32 BlkCnt, u8 *Buff)
 Performs SD read in polled mode. More...
 
s32 XSdPs_WritePolled (XSdPs *InstancePtr, u32 Arg, u32 BlkCnt, const u8 *Buff)
 Performs SD write in polled mode. More...
 
s32 XSdPs_Idle (XSdPs *InstancePtr)
 Idles the SDIO interface. More...
 
s32 XSdPs_Erase (XSdPs *InstancePtr, u32 StartAddr, u32 EndAddr)
 Performs Erase operation on the given address range. More...
 
s32 XSdPs_Sanitize (XSdPs *InstancePtr)
 Performs Sanitize operation on the unmapped user address range. More...
 
s32 XSdPs_Read (XSdPs *InstancePtr, u32 Arg, u32 BlkCnt, u8 *Buff)
 Performs SD read in polled mode. More...
 
s32 XSdPs_Write (XSdPs *InstancePtr, u32 Arg, u32 BlkCnt, const u8 *Buff)
 Performs SD write in polled mode. More...
 
s32 XSdPs_CheckTransferComplete (XSdPs *InstancePtr)
 Checks for the transfer complete. More...
 
s32 XSdPs_IdentifyCard (XSdPs *InstancePtr)
 Identifies the type of card using the CMD0 + CMD1 sequence. More...
 
s32 XSdPs_SdCardInitialize (XSdPs *InstancePtr)
 Initializes the SD card. More...
 
s32 XSdPs_MmcCardInitialize (XSdPs *InstancePtr)
 Initializes the MMC. More...
 
s32 XSdPs_CheckCardDetect (XSdPs *InstancePtr)
 Checks if the card is present or not. More...
 
s32 XSdPs_CardReset (XSdPs *InstancePtr)
 Sends CMD0 to reset the card. More...
 
s32 XSdPs_CardIfCond (XSdPs *InstancePtr)
 Sends command to get the card interface details. More...
 
s32 XSdPs_CardOpCond (XSdPs *InstancePtr)
 Sends command to get the card operating condition. More...
 
s32 XSdPs_GetCardId (XSdPs *InstancePtr)
 Gets the card ID. More...
 
s32 XSdPs_GetCsd (XSdPs *InstancePtr)
 Gets the CSD register from the card. More...
 
s32 XSdPs_CardSetVoltage18 (XSdPs *InstancePtr)
 Sets the card voltage to 1.8 V. More...
 
s32 XSdPs_ResetConfig (XSdPs *InstancePtr)
 Configures the initial Reset. More...
 
void XSdPs_HostConfig (XSdPs *InstancePtr)
 Configures the initial Host. More...
 
s32 XSdPs_CheckResetDone (XSdPs *InstancePtr, u8 Value)
 Checks for Reset Done bits to be cleared after a reset assert. More...
 
s32 XSdPs_SetupVoltageSwitch (XSdPs *InstancePtr)
 Sets up the voltage switch. More...
 
s32 XSdPs_CheckBusHigh (XSdPs *InstancePtr)
 Checks if the CMD and DAT buses are high. More...
 
void XSdPs_Identify_UhsMode (XSdPs *InstancePtr, u8 *ReadBuff)
 Identifies the supported UHS mode. More...
 
void XSdPs_SetTapDelay (XSdPs *InstancePtr)
 Sets the Tap Delay with respect to the speed modes. More...
 
s32 XSdPs_Change_SdBusSpeed (XSdPs *InstancePtr)
 Changes the SD Bus Speed. More...
 
s32 XSdPs_Change_MmcBusSpeed (XSdPs *InstancePtr)
 Changes the eMMC bus speed. More...
 
s32 XSdPs_AutoTuning (XSdPs *InstancePtr)
 Performs the Auto tuning. More...
 
void XSdPs_SetupADMA2DescTbl (XSdPs *InstancePtr, u32 BlkCnt, const u8 *Buff)
 Sets up the ADMA2 descriptor table. More...
 
void XSdPs_SetupADMA2DescTbl64Bit (XSdPs *InstancePtr, u32 BlkCnt)
 Sets up the ADMA2 descriptor table for 64 Bit DMA. More...
 
s32 XSdPs_DllReset (XSdPs *InstancePtr)
 Resets the DLL. More...
 
void XSdPs_IdentifyEmmcMode (XSdPs *InstancePtr, const u8 *ExtCsd)
 Identifies the eMMC speed mode. More...
 
s32 XSdPs_CheckEmmcTiming (XSdPs *InstancePtr, u8 *ExtCsd)
 Checks the eMMC timing. More...
 
s32 XSdPs_SetClock (XSdPs *InstancePtr, u32 SelFreq)
 Sets the clock to the passed frequency. More...
 
s32 XSdPs_CheckVoltage18 (XSdPs *InstancePtr)
 Checks if the voltage is set to 1.8 V or not. More...
 
s32 XSdPs_SetupCmd (XSdPs *InstancePtr, u32 Arg, u32 BlkCnt)
 Initializes the command sequence. More...
 
s32 XSdPs_SendCmd (XSdPs *InstancePtr, u32 Cmd)
 Initiates the Cmd transfer to SD card. More...
 
s32 XSdPs_SetStartAddr (XSdPs *InstancePtr, u32 StartAddr)
 Sets the address of the first write block to be erased. More...
 
s32 XSdPs_SetEndAddr (XSdPs *InstancePtr, u32 EndAddr)
 Sets the address of the last write block to be erased. More...
 
s32 XSdPs_SendErase (XSdPs *InstancePtr)
 Sends Erase command to the device and waits for transfer complete. More...
 
void XSdPs_SetTapDelay_SDR104 (XSdPs *InstancePtr)
 Sets the tap delay for SDR104 uhs mode. More...
 
void XSdPs_SetTapDelay_SDR50 (XSdPs *InstancePtr)
 Sets the tap delay for SDR50 uhs mode. More...
 
void XSdPs_SetTapDelay_DDR50 (XSdPs *InstancePtr)
 Sets the tap delay for DDR50 uhs mode. More...
 
void XSdPs_SetTapDelay_SDR25 (XSdPs *InstancePtr)
 Sets the tap delay for SDR25 uhs mode. More...
 
s32 XSdPs_Switch_Voltage (XSdPs *InstancePtr)
 Switches the SD card voltage from 3v3 to 1v8. More...
 
s32 XSdPs_SetupTransfer (XSdPs *InstancePtr)
 Initiates the transfer to or from SD card. More...
 
s32 XSdPs_Reset (XSdPs *InstancePtr, u8 Value)
 Resets the SD card. More...
 
void XSdPs_SetExecTuning (XSdPs *InstancePtr)
 Sets bit to start execution of tuning. More...
 
s32 XSdPs_SdModeInit (XSdPs *InstancePtr)
 Initializes SD mode. More...
 
s32 XSdPs_MmcModeInit (XSdPs *InstancePtr)
 Initializes MMC mode. More...
 
s32 XSdPs_EmmcModeInit (XSdPs *InstancePtr)
 Initializes eMMC mode. More...
 
void XSdPs_DisableBusPower (XSdPs *InstancePtr)
 Disables the bus power. More...
 
void XSdPs_EnableBusPower (XSdPs *InstancePtr)
 Enables the bus power. More...
 
s32 XSdPs_SdCardEnum (XSdPs *InstancePtr)
 Enumerates the SD card. More...
 
s32 XSdPs_MmcCardEnum (XSdPs *InstancePtr)
 Enumerates the MMC card. More...
 
s32 XSdPs_Execute_Tuning (XSdPs *InstancePtr)
 Performs SD tuning. More...
 
s32 XSdPs_EnableClock (XSdPs *InstancePtr, u16 ClockReg)
 Enables the clock. More...
 
s32 XSdPs_CalcBusSpeed (XSdPs *InstancePtr, u32 *Arg)
 Calculates the bus speed. More...
 
void XSdPs_SetupReadDma (XSdPs *InstancePtr, u16 BlkCnt, u16 BlkSize, u8 *Buff)
 Sets up the DMA for a read transfer from the SD card. More...
 
void XSdPs_SetupWriteDma (XSdPs *InstancePtr, u16 BlkCnt, u16 BlkSize, const u8 *Buff)
 Sets up the DMA for a write transfer to the SD card. More...
 
void XSdPs_Setup32ADMA2DescTbl (XSdPs *InstancePtr, u32 BlkCnt, const u8 *Buff)
 Sets up the ADMA2 descriptor table for 32-bit DMA. More...
 
void XSdPs_Setup64ADMA2DescTbl (XSdPs *InstancePtr, u32 BlkCnt, const u8 *Buff)
 Sets up the ADMA2 descriptor table for 64-bit DMA. More...
 
u32 XSdPs_CalcClock (XSdPs *InstancePtr, u32 SelFreq)
 Calculates the clock divisor value. More...
 
void XSdPs_DllRstCtrl (XSdPs *InstancePtr, u8 EnRst)
 Sets or resets the DLL. More...
 
void XSdPs_ConfigTapDelay (XSdPs *InstancePtr)
 Configures the Tap Delays. More...
 
s32 XSdPs_SetVoltage18 (XSdPs *InstancePtr)
 Sets voltage to 1.8 V. More...
 
void XSdPs_ConfigPower (XSdPs *InstancePtr)
 Configures the Power Level. More...
 
void XSdPs_ConfigDma (XSdPs *InstancePtr)
 Configures the DMA. More...
 
void XSdPs_ConfigInterrupt (XSdPs *InstancePtr)
 Configures the Interrupts. More...
 
s32 XSdPs_CmdTransfer (XSdPs *InstancePtr, u32 Cmd, u32 Arg, u32 BlkCnt)
 Generates SD command. More...
 
s32 XSdps_CheckTransferDone (XSdPs *InstancePtr)
 Checks if the transfer is completed successfully. More...
 
s32 XSdPs_CheckBusIdle (XSdPs *InstancePtr, u32 Value)
 Checks if the CMD/DATA bus is idle or not. More...
 
u32 XSdPs_FrameCmd (XSdPs *InstancePtr, u32 Cmd)
 Frames the Command register for a particular command. More...
 
s32 XSdPs_Change_ClkFreq (XSdPs *InstancePtr, u32 SelFreq)
 Changes the clock frequency to a given value. More...
 
s32 XSdPs_SetBlkSize (XSdPs *InstancePtr, u16 BlkSize)
 Updates Block size for read/write operations. More...
 
s32 XSdPs_Get_BusWidth (XSdPs *InstancePtr, u8 *ReadBuff)
 Gets bus width support by card. More...
 
s32 XSdPs_Change_BusWidth (XSdPs *InstancePtr)
 Sets bus width to 4-bit in card and host. More...
 
s32 XSdPs_Get_BusSpeed (XSdPs *InstancePtr, u8 *ReadBuff)
 Gets bus speed supported by card. More...
 
s32 XSdPs_Get_Status (XSdPs *InstancePtr, u8 *SdStatReg)
 Gets SD card status information. More...
 
s32 XSdPs_Change_BusSpeed (XSdPs *InstancePtr)
 Sets high speed in card and host. More...
 
s32 XSdPs_Get_Mmc_ExtCsd (XSdPs *InstancePtr, u8 *ReadBuff)
 Gets EXT_CSD register of eMMC. More...
 
s32 XSdPs_Set_Mmc_ExtCsd (XSdPs *InstancePtr, u32 Arg)
 Writes EXT_CSD register of eMMC. More...
 
s32 XSdPs_Pullup (XSdPs *InstancePtr)
 Sends pullup command to card before using DAT line 3 (using 4-bit bus). More...
 
s32 XSdPs_Select_Card (XSdPs *InstancePtr)
 Selects card and sets default block size. More...
 
s32 XSdPs_StartReadTransfer (XSdPs *InstancePtr, u32 Arg, u32 BlkCnt, u8 *Buff)
 Starts SD read transfer. More...
 
s32 XSdPs_StartWriteTransfer (XSdPs *InstancePtr, u32 Arg, u32 BlkCnt, u8 *Buff)
 Starts SD write transfer. More...
 
s32 XSdPs_CheckReadTransfer (XSdPs *InstancePtr)
 Checks if the transfer is completed successfully. More...
 
s32 XSdPs_CheckWriteTransfer (XSdPs *InstancePtr)
 Checks for the write transfer completed. More...
 
XSdPs_Config * XSdPs_LookupConfig (UINTPTR BaseAddress)
 Looks up the device configuration based on the unique device ID/BaseAddress. More...
 

Variables

XSdPs_Config XSdPs_ConfigTable []
 Holds the configuration table for the SD devices in the system. More...
 

Function Documentation

s32 XSdPs_AutoTuning ( XSdPs *  InstancePtr)

Performs the Auto tuning.

Parameters
[in,out]InstancePtrPointer to the instance to be worked on.
Returns
  • XST_SUCCESS if the tuning is successful.
  • XST_FAILURE if a tuning command fails or the sampling clock is not selected.

References XSdPs_Config::BaseAddress, XSdPs::BusWidth, XSdPs::CardType, XSdPs::Config, MAX_TUNING_COUNT, XSdPs::TransferMode, XSdPs_CmdTransfer(), and XSdPs_SetExecTuning().

Referenced by XSdPs_Execute_Tuning().

s32 XSdPs_CalcBusSpeed ( XSdPs *  InstancePtr,
u32 *  Arg 
)

Calculates the bus speed.

Parameters
[in,out]InstancePtrPointer to the instance to be worked on.
[out]ArgCMD6 switch argument for the selected bus speed.
Returns
  • XST_SUCCESS if success
  • XST_FAILURE if failure

References XSdPs::BusSpeed, XSdPs::CardType, XSdPs::IsTuningDone, and XSdPs::Mode.

Referenced by XSdPs_Change_MmcBusSpeed(), and XSdPs_Change_SdBusSpeed().

u32 XSdPs_CalcClock ( XSdPs *  InstancePtr,
u32  SelFreq 
)

Calculates the clock divisor value.

Parameters
[in]InstancePtrPointer to the instance to be worked on.
[in]SelFreqSelected frequency.
Returns
Clock divisor value.

References XSdPs::Config, XSdPs::HC_Version, and XSdPs_Config::InputClockHz.

Referenced by XSdPs_SetClock().

s32 XSdPs_CardIfCond ( XSdPs *  InstancePtr)

Sends command to get the card interface details.

Parameters
[in,out]InstancePtrPointer to the instance to be worked on.
Returns
  • XST_SUCCESS if successful.
  • XST_FAILURE if the command or the command line reset fails.

References XSdPs_Config::BaseAddress, XSdPs::Card_Version, XSdPs::Config, XSDPS_CMD8_VOL_PATTERN, XSdPs_CmdTransfer(), XSDPS_CT_ERROR, and XSdPs_Reset().

Referenced by XSdPs_SdCardEnum().

s32 XSdPs_CardInitialize ( XSdPs *  InstancePtr)

Initializes the card with the identification mode sequence.

Parameters
[in,out]InstancePtrPointer to the instance to be worked on.
Returns
  • XST_SUCCESS if initialization was successful
  • XST_FAILURE if failure - could be because a) SD is already initialized b) There is no card inserted c) One of the steps (commands) in the initialization cycle failed

References XSdPs::BusSpeed, XSdPs::BusWidth, XSdPs::CardType, XSdPs::Config, XSdPs::IsReady, XSdPs_Config::RefClk, XSdPs::Switch1v8, XSdPs_Change_ClkFreq(), XSdPs_IdentifyCard(), XSdPs_MmcCardInitialize(), and XSdPs_SdCardInitialize().

s32 XSdPs_CardOpCond ( XSdPs *  InstancePtr)

Sends command to get the card operating condition.

Parameters
[in,out]InstancePtrPointer to the instance to be worked on.
Returns
  • XST_SUCCESS if successful.
  • XST_FAILURE if a command fails, the card does not become ready or the voltage switch fails.

References XSdPs_Config::BaseAddress, XSdPs_Config::BusWidth, XSdPs::CardType, XSdPs::Config, XSdPs::HC_Version, XSdPs::HCS, XSdPs::Switch1v8, XSDPS_ACMD41_3V3, XSDPS_ACMD41_HCS, XSDPS_CMD1_HIGH_VOL, XSdPs_CmdTransfer(), XSDPS_RESPOCR_READY, and XSdPs_Switch_Voltage().

Referenced by XSdPs_MmcCardEnum(), and XSdPs_SdCardEnum().

s32 XSdPs_CardReset ( XSdPs *  InstancePtr)

Sends CMD0 to reset the card.

Parameters
[in]InstancePtrPointer to the instance to be worked on.
Returns
  • XST_SUCCESS if successful.
  • XST_FAILURE if the command fails.

References XSdPs_CmdTransfer().

Referenced by XSdPs_MmcCardEnum(), and XSdPs_SdCardEnum().

s32 XSdPs_CardSetVoltage18 ( XSdPs *  InstancePtr)

Sets the card voltage to 1.8 V.

Parameters
[in]InstancePtrPointer to the instance to be worked on.
Returns
  • XST_SUCCESS if successful.
  • XST_FAILURE if the 1.8 V switch or the clock enable fails.

References XSdPs_Config::BaseAddress, XSdPs::Config, XSdPs_EnableClock(), and XSdPs_SetVoltage18().

Referenced by XSdPs_SdModeInit(), and XSdPs_Switch_Voltage().

s32 XSdPs_CfgInitialize ( XSdPs *  InstancePtr,
XSdPs_Config *  ConfigPtr,
UINTPTR  EffectiveAddr 
)

Initializes a specific XSdPs instance so that the driver is ready to use.

Parameters
[in,out]InstancePtrPointer to the XSdPs instance.
[in]ConfigPtrReference to a structure containing information about a specific SD device. The InstancePtr object is initialized for a specific device specified by the contents of Configuration.
[in]EffectiveAddrDevice base address in the virtual memory address space. The caller is responsible for keeping the address mapping from EffectiveAddr to the device physical base address unchanged once the instance is initialized. Unexpected errors may occur if the address mapping changes after the initialization. If address translation is not used, use ConfigPtr->BaseAddress for this device.
Returns
  • XST_SUCCESS if successful.
  • XST_DEVICE_IS_STARTED if the device is already started. It must be stopped to re-initialize.
  • XST_FAILURE if host reset or initialization fails.
Note
Initializes the host controller. Initial clock of 400 KHz is set. Voltage of 3.3 V is selected as that is supported by host. Interrupts status is enabled and signal disabled by default. Default data direction is card to host and 32 bit ADMA2 is selected. Default Block size is 512 bytes.

References XSdPs_Config::BankNumber, XSdPs_Config::BaseAddress, XSdPs::BlkSize, XSdPs_Config::BusWidth, XSdPs_Config::CardDetect, XSdPs::Config, XSdPs::Dma64BitAddr, XSdPs_Config::HasEMIO, XSdPs::HC_Version, XSdPs::Host_Caps, XSdPs_Config::InputClockHz, XSdPs::IsBusy, XSdPs_Config::IsCacheCoherent, XSdPs::IsReady, XSdPs::IsTuningDone, XSdPs::ITapDelay, XSdPs_Config::ITapDly_DDR_Clk50, XSdPs_Config::ITapDly_SDR_Clk50, XSdPs::Mode, XSdPs::OTapDelay, XSdPs_Config::OTapDly_DDR_Clk200, XSdPs_Config::OTapDly_DDR_Clk50, XSdPs_Config::OTapDly_SDR_Clk100, XSdPs_Config::OTapDly_SDR_Clk200, XSdPs_Config::OTapDly_SDR_Clk50, XSdPs_Config::RefClk, XSdPs::SectorCount, XSdPs::SlcrBaseAddr, XSdPs_Config::SlotType, XSdPs_Config::WriteProtect, XSdPs_HostConfig(), and XSdPs_ResetConfig().

s32 XSdPs_Change_BusSpeed ( XSdPs *  InstancePtr)

Sets high speed in card and host.

Changes clock in host accordingly.

Parameters
[in,out]InstancePtrPointer to the XSdPs instance.
Returns
  • XST_SUCCESS if successful.
  • XST_FAILURE if fail.

References XSdPs_Config::BaseAddress, XSdPs::BusSpeed, XSdPs::CardType, XSdPs::Config, XSdPs::IsReady, XSdPs::IsTuningDone, XSdPs::Mode, XSdPs_Change_ClkFreq(), XSdPs_Change_MmcBusSpeed(), XSdPs_Change_SdBusSpeed(), and XSdPs_Execute_Tuning().

Referenced by XSdPs_EmmcModeInit(), XSdPs_MmcModeInit(), and XSdPs_SdModeInit().

s32 XSdPs_Change_BusWidth ( XSdPs *  InstancePtr)

Sets bus width to 4-bit in card and host.

Parameters
[in]InstancePtrPointer to the XSdPs instance.
Returns
  • XST_SUCCESS if successful.
  • XST_FAILURE if fail.

References XSdPs_Config::BaseAddress, XSdPs_Config::BusWidth, XSdPs::BusWidth, XSdPs::CardType, XSdPs::Config, XSdPs::HC_Version, XSdPs::IsReady, XSdPs::Mode, XSdPs::RelCardAddr, XSdPs_CmdTransfer(), and XSdPs_Set_Mmc_ExtCsd().

Referenced by XSdPs_EmmcModeInit(), XSdPs_MmcModeInit(), and XSdPs_SdModeInit().

s32 XSdPs_Change_ClkFreq ( XSdPs *  InstancePtr,
u32  SelFreq 
)

Changes the clock frequency to a given value.

Parameters
[in]InstancePtrPointer to the XSdPs instance.
[in]SelFreqClock frequency in Hz.
Returns
  • XST_SUCCESS if successful.
  • XST_FAILURE if setting the clock fails.
Note
The clock frequency is changed to the value less than or equal to the given value using the permissible dividers.

References XSdPs_Config::BaseAddress, XSdPs::CardType, XSdPs::Config, XSdPs::HC_Version, XSdPs::IsReady, XSdPs::ITapDelay, XSdPs::Mode, XSdPs::OTapDelay, XSdPs_SetClock(), and XSdPs_SetTapDelay().

Referenced by XSdPs_CardInitialize(), XSdPs_Change_BusSpeed(), XSdPs_MmcCardEnum(), and XSdPs_SdCardEnum().

s32 XSdPs_Change_MmcBusSpeed ( XSdPs *  InstancePtr)

Changes the eMMC bus speed.

Parameters
[in,out]InstancePtrPointer to the instance to be worked on.
Returns
  • XST_SUCCESS if successful.
  • XST_FAILURE if the bus speed calculation, the command or the transfer fails.

References XSdPs_CalcBusSpeed(), XSdps_CheckTransferDone(), and XSdPs_CmdTransfer().

Referenced by XSdPs_Change_BusSpeed().

s32 XSdPs_Change_SdBusSpeed ( XSdPs *  InstancePtr)

Changes the SD Bus Speed.

Parameters
[in,out]InstancePtrPointer to the instance to be worked on.
Returns
  • XST_SUCCESS if successful.
  • XST_FAILURE if the bus speed calculation, the command or the transfer fails.

References XSdPs_Config::BaseAddress, XSdPs::Config, XSdPs::Mode, XSdPs::Switch1v8, XSdPs_CalcBusSpeed(), XSdps_CheckTransferDone(), XSdPs_CmdTransfer(), and XSdPs_SetupReadDma().

Referenced by XSdPs_Change_BusSpeed().

s32 XSdPs_CheckBusHigh ( XSdPs *  InstancePtr)

Checks if the CMD and DAT buses are high.

Parameters
[in]InstancePtrPointer to the instance to be worked on.
Returns
  • XST_SUCCESS if the CMD and DAT lines are high.
  • XST_FAILURE if the lines do not go high within the timeout.

References XSdPs_Config::BaseAddress, XSdPs::Config, and MAX_TIMEOUT.

Referenced by XSdPs_Switch_Voltage().

s32 XSdPs_CheckBusIdle ( XSdPs *  InstancePtr,
u32  Value 
)

Checks if the CMD/DATA bus is idle or not.

Parameters
[in]InstancePtrPointer to the instance to be worked on.
[in]ValueValue to be selected Cmd bus or Dat bus.
Returns
  • XST_SUCCESS if the bus is idle or no card is present.
  • XST_FAILURE if the bus does not become idle within the timeout.

References XSdPs_Config::BaseAddress, and XSdPs::Config.

Referenced by XSdPs_Idle(), XSdPs_SetBlkSize(), and XSdPs_SetupCmd().

s32 XSdPs_CheckCardDetect ( XSdPs *  InstancePtr)

Checks if the card is present or not.

Parameters
[in]InstancePtrPointer to the instance to be worked on.
Returns
  • XST_SUCCESS if the card is present or the slot is embedded.
  • XST_FAILURE if the card is not inserted.

References XSdPs_Config::BaseAddress, XSdPs_Config::CardDetect, XSdPs::Config, XSdPs::HC_Version, and XSdPs::Host_Caps.

Referenced by XSdPs_MmcCardEnum(), and XSdPs_SdCardEnum().

s32 XSdPs_CheckEmmcTiming ( XSdPs *  InstancePtr,
u8 *  ExtCsd 
)

Checks the eMMC timing.

Parameters
[in,out]InstancePtrPointer to the instance to be worked on.
[out]ExtCsdExtended CSD register from the card.
Returns
  • XST_SUCCESS if the HS timing matches the selected mode.
  • XST_FAILURE if reading the EXT_CSD register fails or the HS timing does not match the selected mode.

References XSdPs::Mode, and XSdPs_Get_Mmc_ExtCsd().

Referenced by XSdPs_EmmcModeInit().

s32 XSdPs_CheckReadTransfer ( XSdPs *  InstancePtr)

Checks if the transfer is completed successfully.

Parameters
[in,out]InstancePtrPointer to the instance to be worked on.
Returns
  • XST_SUCCESS if transfer was successful
  • XST_FAILURE if failure
  • XST_DEVICE_BUSY - if the transfer is still in progress

References XSdPs::IsReady, and XSdPs_CheckTransferComplete().

s32 XSdPs_CheckResetDone ( XSdPs *  InstancePtr,
u8  Value 
)

Checks for Reset Done bits to be cleared after a reset assert.

Parameters
[in]InstancePtrPointer to the instance to be worked on.
[in]ValueBits to be checked to be cleared.
Returns
  • XST_SUCCESS if the bits are cleared.
  • XST_FAILURE if the bits are not cleared within the timeout.

References XSdPs_Config::BaseAddress, and XSdPs::Config.

Referenced by XSdPs_Reset().

s32 XSdPs_CheckTransferComplete ( XSdPs *  InstancePtr)

Checks for the transfer complete.

Parameters
[in,out]InstancePtrPointer to the instance to be worked on.
Returns
  • XST_SUCCESS if transfer was successful
  • XST_FAILURE if failure
  • XST_DEVICE_BUSY - if the transfer is still in progress

References XSdPs_Config::BaseAddress, XSdPs::Config, and XSdPs::IsBusy.

Referenced by XSdPs_CheckReadTransfer(), and XSdPs_CheckWriteTransfer().

s32 XSdps_CheckTransferDone ( XSdPs *  InstancePtr)

Checks if the transfer is completed successfully.

Parameters
[in]InstancePtrPointer to the instance to be worked on.
Returns
  • XST_SUCCESS if the transfer is completed.
  • XST_FAILURE if the transfer does not complete within the timeout or an error interrupt occurs.

References XSdPs_Config::BaseAddress, and XSdPs::Config.

Referenced by XSdPs_Change_MmcBusSpeed(), XSdPs_Change_SdBusSpeed(), XSdPs_Get_BusSpeed(), XSdPs_Get_BusWidth(), XSdPs_Get_Mmc_ExtCsd(), XSdPs_Get_Status(), XSdPs_ReadPolled(), XSdPs_SendErase(), XSdPs_Set_Mmc_ExtCsd(), and XSdPs_WritePolled().

s32 XSdPs_CheckVoltage18 ( XSdPs *  InstancePtr)

Checks if the voltage is set to 1.8 V or not.

Parameters
[in]InstancePtrPointer to the instance to be worked on.
Returns
  • XST_SUCCESS if voltage is 1.8V
  • XST_FAILURE if voltage is not 1.8V

References XSdPs_Config::BaseAddress, and XSdPs::Config.

Referenced by XSdPs_SetVoltage18().

s32 XSdPs_CheckWriteTransfer ( XSdPs *  InstancePtr)

Checks for the write transfer completed.

Parameters
[in,out]InstancePtrPointer to the instance to be worked on.
Returns
  • XST_SUCCESS if transfer was successful
  • XST_FAILURE if failure
  • XST_DEVICE_BUSY - if the transfer is still in progress

References XSdPs::IsReady, and XSdPs_CheckTransferComplete().

s32 XSdPs_CmdTransfer ( XSdPs *  InstancePtr,
u32  Cmd,
u32  Arg,
u32  BlkCnt 
)

Generates SD command.

Parameters
[in]InstancePtrPointer to the instance to be worked on.
[in]CmdCommand to be sent.
[in]ArgArgument to be sent along with the command. This could be address or any other information.
[in]BlkCntBlock count passed by the user.
Returns
  • XST_SUCCESS if initialization was successful
  • XST_FAILURE if failure - could be because another transfer is in progress or command or data inhibit is set
  • XSDPS_CT_ERROR if a command timeout error occurs.
  • The error interrupt status value for other command errors.

References XSdPs_Config::BaseAddress, XSdPs::Config, XSDPS_CT_ERROR, XSdPs_SendCmd(), and XSdPs_SetupCmd().

Referenced by XSdPs_AutoTuning(), XSdPs_CardIfCond(), XSdPs_CardOpCond(), XSdPs_CardReset(), XSdPs_Change_BusWidth(), XSdPs_Change_MmcBusSpeed(), XSdPs_Change_SdBusSpeed(), XSdPs_Get_BusSpeed(), XSdPs_Get_BusWidth(), XSdPs_Get_Mmc_ExtCsd(), XSdPs_Get_Status(), XSdPs_GetCardId(), XSdPs_GetCsd(), XSdPs_IdentifyCard(), XSdPs_Pullup(), XSdPs_Read(), XSdPs_Select_Card(), XSdPs_SendErase(), XSdPs_Set_Mmc_ExtCsd(), XSdPs_SetBlkSize(), XSdPs_SetEndAddr(), XSdPs_SetStartAddr(), XSdPs_SetupVoltageSwitch(), and XSdPs_Write().

void XSdPs_ConfigDma ( XSdPs *  InstancePtr)

Configures the DMA.

Parameters
[in]InstancePtrPointer to the instance to be worked on.

References XSdPs_Config::BaseAddress, XSdPs::Config, and XSdPs::HC_Version.

Referenced by XSdPs_HostConfig().

void XSdPs_ConfigInterrupt ( XSdPs *  InstancePtr)

Configures the Interrupts.

Parameters
[in]InstancePtrPointer to the instance to be worked on.

References XSdPs_Config::BaseAddress, and XSdPs::Config.

Referenced by XSdPs_HostConfig().

void XSdPs_ConfigPower ( XSdPs *  InstancePtr)

Configures the Power Level.

Parameters
[in]InstancePtrPointer to the instance to be worked on.

References XSdPs_Config::BaseAddress, XSdPs::Config, and XSdPs::Host_Caps.

Referenced by XSdPs_HostConfig().

void XSdPs_ConfigTapDelay ( XSdPs *  InstancePtr)

Configures the Tap Delays.

Parameters
[in]InstancePtrPointer to the XSdPs instance.

References XSdPs_Config::BaseAddress, XSdPs::Config, XSdPs::ITapDelay, XSdPs::OTapDelay, XSdPs::SlcrBaseAddr, and XSDPS_ZYNQMP_SD0_BASE.

Referenced by XSdPs_SetTapDelay().

void XSdPs_DisableBusPower ( XSdPs *  InstancePtr)

Disables the bus power.

Parameters
[in]InstancePtrPointer to the instance to be worked on.

References XSdPs_Config::BaseAddress, XSdPs::Config, and XSdPs::HC_Version.

Referenced by XSdPs_Idle(), and XSdPs_ResetConfig().

s32 XSdPs_DllReset ( XSdPs *  InstancePtr)

Resets the DLL.

Parameters
[in]InstancePtrPointer to the XSdPs instance.
Returns
  • XST_SUCCESS if successful.
  • XST_FAILURE if the clock enable fails.

References XSdPs_Config::BaseAddress, XSdPs::Config, XSdPs_DllRstCtrl(), and XSdPs_EnableClock().

Referenced by XSdPs_Execute_Tuning().

void XSdPs_DllRstCtrl ( XSdPs *  InstancePtr,
u8  EnRst 
)

Sets or resets the DLL.

Parameters
[in]InstancePtrPointer to the XSdPs instance.
[in]EnRstFlag indicating whether to Assert or De-assert Reset.
Note
Specific to ZynqMP platform.

References XSdPs_Config::BaseAddress, XSdPs::Config, XSdPs::SlcrBaseAddr, and XSDPS_ZYNQMP_SD0_BASE.

Referenced by XSdPs_DllReset(), and XSdPs_SetTapDelay().

s32 XSdPs_EmmcModeInit ( XSdPs *  InstancePtr)
void XSdPs_EnableBusPower ( XSdPs *  InstancePtr)

Enables the bus power.

Parameters
[in]InstancePtrPointer to the instance to be worked on.

References XSdPs_Config::BaseAddress, XSdPs::Config, and XSdPs::HC_Version.

Referenced by XSdPs_ResetConfig().

s32 XSdPs_EnableClock ( XSdPs *  InstancePtr,
u16  ClockReg 
)

Enables the clock.

Parameters
[in]InstancePtrPointer to the instance to be worked on.
[in]ClockRegClock value to be set.
Returns
  • XST_SUCCESS if success
  • XST_FAILURE if failure

References XSdPs_Config::BaseAddress, and XSdPs::Config.

Referenced by XSdPs_CardSetVoltage18(), XSdPs_DllReset(), and XSdPs_SetClock().

s32 XSdPs_Erase ( XSdPs *  InstancePtr,
u32  StartAddr,
u32  EndAddr 
)

Performs Erase operation on the given address range.

Parameters
[in,out]InstancePtrPointer to the instance to be worked on.
[in]StartAddrAddress of the first write block to be erased.
[in]EndAddrAddress of the last write block of the continuous range to be erased.
Returns
  • XST_SUCCESS if erase is successful
  • XST_FAILURE if failure - could be because another transfer is in progress or card not present or erase operation failure.

References XSdPs_Config::BaseAddress, XSdPs_Config::CardDetect, XSdPs::CardSpecData, XSdPs::Config, XSdPs::HC_Version, XSdPs::Host_Caps, XSdPs::IsBusy, XSdPs::IsReady, XSdPs_Config::RefClk, XSdPs::TransferMode, XSdPs_SendErase(), XSdPs_SetEndAddr(), and XSdPs_SetStartAddr().

s32 XSdPs_Execute_Tuning ( XSdPs *  InstancePtr)

Performs SD tuning.

Parameters
[in,out]InstancePtrPointer to the instance to be worked on.
Returns
  • XST_SUCCESS if the tuning is successful.
  • XST_FAILURE if the DLL reset or the auto tuning fails.

References XSdPs_AutoTuning(), and XSdPs_DllReset().

Referenced by XSdPs_Change_BusSpeed().

u32 XSdPs_FrameCmd ( XSdPs *  InstancePtr,
u32  Cmd 
)

Frames the Command register for a particular command.

Parameters
[in]InstancePtrPointer to the instance to be worked on.
[in]CmdCommand to be sent.
Returns
Command register value complete with response type and data, CRC and index related flags.
Note
This generates only the command register value, that is, the upper 16 bits of the transfer mode and command register. This value is already shifted to be upper 16 bits and can be directly OR'ed with transfer mode register value.

References XSdPs::CardType.

Referenced by XSdPs_SendCmd().

s32 XSdPs_Get_BusSpeed ( XSdPs *  InstancePtr,
u8 *  ReadBuff 
)

Gets bus speed supported by card.

Parameters
[in,out]InstancePtrPointer to the XSdPs instance.
[out]ReadBuffBuffer to store function group support data returned by card.
Returns
  • XST_SUCCESS if successful.
  • XST_FAILURE if fail.

References XSdPs::Config, XSdPs_Config::IsCacheCoherent, XSdPs::IsReady, XSdps_CheckTransferDone(), XSdPs_CmdTransfer(), and XSdPs_SetupReadDma().

Referenced by XSdPs_SdModeInit().

s32 XSdPs_Get_BusWidth ( XSdPs *  InstancePtr,
u8 *  ReadBuff 
)

Gets bus width support by card.

Parameters
[in,out]InstancePtrPointer to the XSdPs instance.
[out]ReadBuffBuffer to store SCR register returned by card.
Returns
  • XST_SUCCESS if successful.
  • XST_FAILURE if fail.

References XSdPs::Config, XSdPs_Config::IsCacheCoherent, XSdPs::IsReady, XSdPs::RelCardAddr, XSdps_CheckTransferDone(), XSdPs_CmdTransfer(), and XSdPs_SetupReadDma().

Referenced by XSdPs_SdModeInit().

s32 XSdPs_Get_Mmc_ExtCsd ( XSdPs *  InstancePtr,
u8 *  ReadBuff 
)

Gets EXT_CSD register of eMMC.

Parameters
[in,out]InstancePtrPointer to the XSdPs instance.
[out]ReadBuffBuffer to store EXT_CSD.
Returns
  • XST_SUCCESS if successful.
  • XST_FAILURE if fail.

References XSdPs::Config, XSdPs_Config::IsCacheCoherent, XSdPs::IsReady, XSdps_CheckTransferDone(), XSdPs_CmdTransfer(), and XSdPs_SetupReadDma().

Referenced by XSdPs_CheckEmmcTiming(), XSdPs_EmmcModeInit(), and XSdPs_MmcModeInit().

s32 XSdPs_Get_Status ( XSdPs *  InstancePtr,
u8 *  SdStatReg 
)

Gets SD card status information.

Parameters
[in,out]InstancePtrPointer to the XSdPs instance.
[out]SdStatRegBuffer to store status data returned by card.
Returns
  • XST_SUCCESS if successful.
  • XST_FAILURE if fail.

References XSdPs::Config, XSdPs_Config::IsCacheCoherent, XSdPs::IsReady, XSdPs::RelCardAddr, XSdps_CheckTransferDone(), XSdPs_CmdTransfer(), and XSdPs_SetupReadDma().

s32 XSdPs_GetCardId ( XSdPs *  InstancePtr)

Gets the card ID.

Parameters
[in,out]InstancePtrPointer to the instance to be worked on.
Returns
  • XST_SUCCESS if successful.
  • XST_FAILURE if a command fails or the relative card address is not obtained.

References XSdPs_Config::BaseAddress, XSdPs::CardID, XSdPs::CardType, XSdPs::Config, XSdPs::RelCardAddr, and XSdPs_CmdTransfer().

Referenced by XSdPs_MmcCardEnum(), and XSdPs_SdCardEnum().

s32 XSdPs_GetCsd ( XSdPs *  InstancePtr)

Gets the CSD register from the card.

Parameters
[in,out]InstancePtrPointer to the instance to be worked on.
Returns
  • XST_SUCCESS if successful.
  • XST_FAILURE if the command fails or the CSD structure version is not supported.

References XSdPs_Config::BaseAddress, XSdPs::Card_Version, XSdPs::CardSpecData, XSdPs::CardType, XSdPs::Config, XSdPs::RelCardAddr, XSdPs::SectorCount, XSDPS_BLK_SIZE_512_MASK, and XSdPs_CmdTransfer().

Referenced by XSdPs_MmcCardEnum(), and XSdPs_SdCardEnum().

void XSdPs_HostConfig ( XSdPs *  InstancePtr)

Configures the initial Host.

Parameters
[in,out]InstancePtrPointer to the instance to be worked on.

References XSdPs_Config::BaseAddress, XSdPs::Config, XSdPs::TransferMode, XSDPS_BLK_SIZE_512_MASK, XSdPs_ConfigDma(), XSdPs_ConfigInterrupt(), and XSdPs_ConfigPower().

Referenced by XSdPs_CfgInitialize().

void XSdPs_Identify_UhsMode ( XSdPs *  InstancePtr,
u8 *  ReadBuff 
)

Identifies the supported UHS mode.

Assigns the corresponding tap delay API to the Config_TapDelay pointer based on the supported bus speed.

Parameters
[in,out]InstancePtrPointer to the XSdPs instance.
[in]ReadBuffResponse for CMD6.

References XSdPs::Config, XSdPs_Config::InputClockHz, XSdPs::Mode, UHS_DDR50_SUPPORT, UHS_SDR104_SUPPORT, UHS_SDR25_SUPPORT, UHS_SDR50_SUPPORT, XSdPs_SetTapDelay_DDR50(), XSdPs_SetTapDelay_SDR104(), XSdPs_SetTapDelay_SDR25(), and XSdPs_SetTapDelay_SDR50().

Referenced by XSdPs_SdModeInit().

s32 XSdPs_IdentifyCard ( XSdPs *  InstancePtr)

Identifies the type of card using the CMD0 + CMD1 sequence.

Parameters
[in,out]InstancePtrPointer to the XSdPs instance.
Returns
  • XST_SUCCESS if successful
  • XST_FAILURE if failure

References XSdPs_Config::BaseAddress, XSdPs::CardType, XSdPs::Config, XSdPs::HC_Version, XSdPs::Host_Caps, XSDPS_ACMD41_HCS, XSDPS_CMD1_HIGH_VOL, XSdPs_CmdTransfer(), and XSdPs_Reset().

Referenced by XSdPs_CardInitialize().

s32 XSdPs_Idle ( XSdPs *  InstancePtr)

Idles the SDIO interface.

Parameters
[in]InstancePtrPointer to the XSdPs instance.
Returns
  • XST_SUCCESS if the SDIO interface is idled.
  • XST_FAILURE if the bus does not become idle or the reset fails.

References XSdPs::Config, XSdPs::IsReady, XSdPs_Config::RefClk, XSdPs_CheckBusIdle(), XSdPs_DisableBusPower(), and XSdPs_Reset().

XSdPs_Config* XSdPs_LookupConfig ( UINTPTR  BaseAddress)

Looks up the device configuration based on the unique device ID/BaseAddress.

The XSdPs_ConfigTable[] contains the configuration info for each device in the system.

Parameters
[in]BaseAddressBase address of the device.
Returns
A pointer to the configuration found or NULL if the specified device ID/BaseAddress was not found. See xsdps.h for the definition of XSdPs_Config.
Note
In XSCT/classic flow, the device configuration is looked up by DeviceId.

References XSdPs_Config::Name, and XSdPs_ConfigTable.

s32 XSdPs_MmcCardEnum ( XSdPs *  InstancePtr)

Enumerates the MMC card.

Parameters
[in,out]InstancePtrPointer to the instance to be worked on.
Returns
  • XST_SUCCESS if the card is enumerated.
  • XST_FAILURE if the card is not present or one of the enumeration steps fails.

References XSdPs::BusSpeed, SD_CLK_26_MHZ, XSdPs_CardOpCond(), XSdPs_CardReset(), XSdPs_Change_ClkFreq(), XSdPs_CheckCardDetect(), XSdPs_GetCardId(), XSdPs_GetCsd(), and XSdPs_Select_Card().

Referenced by XSdPs_MmcCardInitialize().

s32 XSdPs_MmcCardInitialize ( XSdPs *  InstancePtr)

Initializes the MMC.

Parameters
[in,out]InstancePtrPointer to the instance to be worked on.
Returns
  • XST_SUCCESS if initialization was successful
  • XST_FAILURE if failure - could be because a) MMC is already initialized b) There is no card inserted c) One of the steps (commands) in the initialization cycle failed
Note
The card is initialized by following its initialization and identification state diagram. CMD0 is sent to reset card. CMD1 sent to identify voltage and high capacity support CMD2 and CMD3 are sent to obtain Card ID and Relative card address respectively. CMD9 is sent to read the card specific data.

References XSdPs_Config::BaseAddress, XSdPs::BlkSize, XSdPs::Card_Version, XSdPs::CardType, XSdPs::Config, CSD_SPEC_VER_3, XSdPs::HC_Version, XSdPs::Mode, XSDPS_BLK_SIZE_512_MASK, XSdPs_EmmcModeInit(), XSdPs_MmcCardEnum(), XSdPs_MmcModeInit(), and XSdPs_SetBlkSize().

Referenced by XSdPs_CardInitialize().

s32 XSdPs_MmcModeInit ( XSdPs *  InstancePtr)

Initializes MMC mode.

Parameters
[in,out]InstancePtrPointer to the instance to be worked on.
Returns
  • XST_SUCCESS if initialization is successful
  • XST_FAILURE if failure

References XSdPs::BusWidth, EXT_CSD_DEVICE_TYPE_BYTE, EXT_CSD_DEVICE_TYPE_HIGH_SPEED, EXT_CSD_SEC_COUNT_BYTE1, EXT_CSD_SEC_COUNT_BYTE2, EXT_CSD_SEC_COUNT_BYTE3, EXT_CSD_SEC_COUNT_BYTE4, XSdPs::Mode, XSdPs::SectorCount, XSdPs_Change_BusSpeed(), XSdPs_Change_BusWidth(), and XSdPs_Get_Mmc_ExtCsd().

Referenced by XSdPs_MmcCardInitialize().

s32 XSdPs_Pullup ( XSdPs *  InstancePtr)

Sends pullup command to card before using DAT line 3 (using 4-bit bus).

Parameters
[in]InstancePtrPointer to the XSdPs instance.
Returns
  • XST_SUCCESS if successful.
  • XST_FAILURE if fail.

References XSdPs::IsReady, XSdPs::RelCardAddr, and XSdPs_CmdTransfer().

s32 XSdPs_Read ( XSdPs *  InstancePtr,
u32  Arg,
u32  BlkCnt,
u8 *  Buff 
)

Performs SD read in polled mode.

Parameters
[in,out]InstancePtrPointer to the instance to be worked on.
[in]ArgAddress passed by the user that is to be sent as argument along with the command.
[in]BlkCntBlock count passed by the user.
[out]BuffPointer to the data buffer for a DMA transfer.
Returns
  • XST_SUCCESS if initialization was successful
  • XST_FAILURE if failure - could be because another transfer is in progress or command or data inhibit is set

References XSdPs::BlkSize, XSdPs_CmdTransfer(), and XSdPs_SetupReadDma().

Referenced by XSdPs_ReadPolled(), and XSdPs_StartReadTransfer().

s32 XSdPs_ReadPolled ( XSdPs *  InstancePtr,
u32  Arg,
u32  BlkCnt,
u8 *  Buff 
)

Performs SD read in polled mode.

Parameters
[in,out]InstancePtrPointer to the instance to be worked on.
[in]ArgAddress passed by the user that is to be sent as argument along with the command.
[in]BlkCntBlock count passed by the user.
[out]BuffPointer to the data buffer for a DMA transfer.
Returns
  • XST_SUCCESS if initialization was successful
  • XST_FAILURE if failure - could be because another transfer is in progress or command or data inhibit is set

References XSdPs::BlkSize, XSdPs::Config, XSdPs::IsBusy, XSdPs_Config::IsCacheCoherent, XSdPs::IsReady, XSdPs_Config::RefClk, XSdps_CheckTransferDone(), XSdPs_Read(), and XSdPs_SetupTransfer().

s32 XSdPs_Reset ( XSdPs *  InstancePtr,
u8  Value 
)

Resets the SD card.

Parameters
[in]InstancePtrPointer to the instance to be worked on.
[in]ValueType of reset.
Returns
  • XST_SUCCESS if initialization was successful
  • XST_FAILURE if failure

References XSdPs_Config::BaseAddress, XSdPs::Config, and XSdPs_CheckResetDone().

Referenced by XSdPs_CardIfCond(), XSdPs_IdentifyCard(), XSdPs_Idle(), and XSdPs_ResetConfig().

s32 XSdPs_ResetConfig ( XSdPs *  InstancePtr)

Configures the initial Reset.

Parameters
[in]InstancePtrPointer to the instance to be worked on.
Returns
  • XST_SUCCESS if successful.
  • XST_FAILURE if the controller reset fails.

References XSdPs_Config::BaseAddress, XSdPs::Config, XSdPs::Host_Caps, XSdPs_DisableBusPower(), XSdPs_EnableBusPower(), and XSdPs_Reset().

Referenced by XSdPs_CfgInitialize().

s32 XSdPs_Sanitize ( XSdPs *  InstancePtr)

Performs Sanitize operation on the unmapped user address range.

Parameters
[in]InstancePtrPointer to the instance to be worked on.
Returns
  • XST_SUCCESS if Sanitize is successful
  • XST_FAILURE if failure - could be because another transfer is in progress or card not present or Sanitize operation failure.

References XSdPs::Config, XSdPs::IsBusy, XSdPs::IsReady, XSdPs_Config::RefClk, and XSdPs_Set_Mmc_ExtCsd().

s32 XSdPs_SdCardEnum ( XSdPs *  InstancePtr)

Enumerates the SD card.

Parameters
[in,out]InstancePtrPointer to the instance to be worked on.
Returns
  • XST_SUCCESS if the card is enumerated.
  • XST_FAILURE if the card is not present or one of the enumeration steps fails.

References XSdPs::BusSpeed, XSdPs::HC_Version, SD_CLK_19_MHZ, SD_CLK_25_MHZ, XSdPs_CardIfCond(), XSdPs_CardOpCond(), XSdPs_CardReset(), XSdPs_Change_ClkFreq(), XSdPs_CheckCardDetect(), XSdPs_GetCardId(), XSdPs_GetCsd(), and XSdPs_Select_Card().

Referenced by XSdPs_SdCardInitialize().

s32 XSdPs_SdCardInitialize ( XSdPs *  InstancePtr)

Initializes the SD card.

Parameters
[in,out]InstancePtrPointer to the instance to be worked on.
Returns
  • XST_SUCCESS if initialization was successful
  • XST_FAILURE if failure - could be because a) SD is already initialized b) There is no card inserted c) One of the steps (commands) in the initialization cycle failed
Note
The SD card is initialized by following its initialization and identification state diagram. CMD0 is sent to reset card. CMD8 and ACDM41 are sent to identify voltage and high capacity support CMD2 and CMD3 are sent to obtain Card ID and Relative card address respectively. CMD9 is sent to read the card specific data.

References XSdPs_Config::BusWidth, XSdPs::Config, XSdPs_SdCardEnum(), and XSdPs_SdModeInit().

Referenced by XSdPs_CardInitialize().

s32 XSdPs_Select_Card ( XSdPs *  InstancePtr)

Selects card and sets default block size.

Parameters
[in]InstancePtrPointer to the XSdPs instance.
Returns
  • XST_SUCCESS if successful.
  • XST_FAILURE if fail.
  • XSDPS_CT_ERROR if Command Transfer fail.

References XSdPs::IsReady, XSdPs::RelCardAddr, and XSdPs_CmdTransfer().

Referenced by XSdPs_MmcCardEnum(), and XSdPs_SdCardEnum().

s32 XSdPs_SendCmd ( XSdPs *  InstancePtr,
u32  Cmd 
)

Initiates the Cmd transfer to SD card.

Parameters
[in]InstancePtrPointer to the instance to be worked on.
[in]CmdCommand to be sent.
Returns
  • XST_SUCCESS if initialization was successful
  • XST_FAILURE if failure

References XSdPs_Config::BaseAddress, XSdPs::Config, XSdPs::TransferMode, and XSdPs_FrameCmd().

Referenced by XSdPs_CmdTransfer().

s32 XSdPs_SendErase ( XSdPs *  InstancePtr)

Sends Erase command to the device and waits for transfer complete.

Parameters
[in]InstancePtrPointer to the instance to be worked on.
Returns
  • XST_SUCCESS if erase operation is successful
  • XST_FAILURE if failure - could be because erase operation failed.

References XSdps_CheckTransferDone(), and XSdPs_CmdTransfer().

Referenced by XSdPs_Erase().

s32 XSdPs_Set_Mmc_ExtCsd ( XSdPs *  InstancePtr,
u32  Arg 
)

Writes EXT_CSD register of eMMC.

Parameters
[in]InstancePtrPointer to the XSdPs instance.
[in]ArgArgument to be sent along with the command.
Returns
  • XST_SUCCESS if successful.
  • XST_FAILURE if fail.

References XSdPs::IsReady, XSdps_CheckTransferDone(), and XSdPs_CmdTransfer().

Referenced by XSdPs_Change_BusWidth(), XSdPs_EmmcModeInit(), and XSdPs_Sanitize().

s32 XSdPs_SetBlkSize ( XSdPs *  InstancePtr,
u16  BlkSize 
)

Updates Block size for read/write operations.

Parameters
[in,out]InstancePtrPointer to the instance to be worked on.
[in]BlkSizeBlock size passed by the user.
Returns
  • XST_SUCCESS if successful.
  • XST_FAILURE if the bus is not idle or the command fails.

References XSdPs_Config::BaseAddress, XSdPs::BlkSize, XSdPs::Config, XSdPs::IsReady, XSdPs_CheckBusIdle(), and XSdPs_CmdTransfer().

Referenced by XSdPs_MmcCardInitialize(), XSdPs_SdModeInit(), and XSdPs_SetupTransfer().

s32 XSdPs_SetClock ( XSdPs *  InstancePtr,
u32  SelFreq 
)

Sets the clock to the passed frequency.

Parameters
[in]InstancePtrPointer to the instance to be worked on.
[in]SelFreqSelected frequency.
Returns
  • XST_SUCCESS if successful.
  • XST_FAILURE if the clock enable fails or the DLL is not ready within the timeout.

References XSdPs_Config::BaseAddress, XSdPs::CardType, XSdPs::Config, XSdPs::Mode, XSdPs_CalcClock(), and XSdPs_EnableClock().

Referenced by XSdPs_Change_ClkFreq().

s32 XSdPs_SetEndAddr ( XSdPs *  InstancePtr,
u32  EndAddr 
)

Sets the address of the last write block to be erased.

Parameters
[in]InstancePtrPointer to the instance to be worked on.
[in]EndAddrAddress of the last write block.
Returns
  • XST_SUCCESS if Set End Address is successful.
  • XST_FAILURE if failure - could be because failed to set EndAddr.

References XSdPs::CardType, and XSdPs_CmdTransfer().

Referenced by XSdPs_Erase().

void XSdPs_SetExecTuning ( XSdPs *  InstancePtr)

Sets bit to start execution of tuning.

Parameters
[in]InstancePtrPointer to the instance to be worked on.

References XSdPs_Config::BaseAddress, and XSdPs::Config.

Referenced by XSdPs_AutoTuning().

s32 XSdPs_SetStartAddr ( XSdPs *  InstancePtr,
u32  StartAddr 
)

Sets the address of the first write block to be erased.

Parameters
[in]InstancePtrPointer to the instance to be worked on.
[in]StartAddrAddress of the first write block.
Returns
  • XST_SUCCESS if Set start Address is successful
  • XST_FAILURE if failure - could be because failed to set StartAddr.

References XSdPs::CardType, and XSdPs_CmdTransfer().

Referenced by XSdPs_Erase().

void XSdPs_SetTapDelay ( XSdPs *  InstancePtr)

Sets the Tap Delay with respect to the speed modes.

Parameters
[in]InstancePtrPointer to the XSdPs instance.

References XSdPs::Mode, XSdPs_ConfigTapDelay(), and XSdPs_DllRstCtrl().

Referenced by XSdPs_Change_ClkFreq().

void XSdPs_SetTapDelay_DDR50 ( XSdPs *  InstancePtr)

Sets the tap delay for DDR50 uhs mode.

Parameters
[in,out]InstancePtrPointer to the instance to be worked on.

References XSdPs::Config, XSdPs::ITapDelay, XSdPs_Config::ITapDly_DDR_Clk50, XSdPs::OTapDelay, XSdPs_Config::OTapDly_DDR_Clk50, and XSdPs_Config::SlotType.

Referenced by XSdPs_Identify_UhsMode().

void XSdPs_SetTapDelay_SDR104 ( XSdPs *  InstancePtr)

Sets the tap delay for SDR104 uhs mode.

Parameters
[in,out]InstancePtrPointer to the instance to be worked on.

References XSdPs_Config::BankNumber, XSdPs::Config, XSdPs::OTapDelay, and XSdPs_Config::OTapDly_SDR_Clk200.

Referenced by XSdPs_Identify_UhsMode().

void XSdPs_SetTapDelay_SDR25 ( XSdPs *  InstancePtr)

Sets the tap delay for SDR25 uhs mode.

Parameters
[in,out]InstancePtrPointer to the instance to be worked on.

References XSdPs::Config, XSdPs::ITapDelay, XSdPs_Config::ITapDly_SDR_Clk50, XSdPs::OTapDelay, XSdPs_Config::OTapDly_SDR_Clk50, and XSdPs_Config::SlotType.

Referenced by XSdPs_Identify_UhsMode().

void XSdPs_SetTapDelay_SDR50 ( XSdPs *  InstancePtr)

Sets the tap delay for SDR50 uhs mode.

Parameters
[in,out]InstancePtrPointer to the instance to be worked on.

References XSdPs::Config, XSdPs::OTapDelay, and XSdPs_Config::OTapDly_SDR_Clk100.

Referenced by XSdPs_Identify_UhsMode().

void XSdPs_Setup32ADMA2DescTbl ( XSdPs *  InstancePtr,
u32  BlkCnt,
const u8 *  Buff 
)

Sets up the ADMA2 descriptor table for 32-bit DMA.

Parameters
[in,out]InstancePtrPointer to the XSdPs instance.
[in]BlkCntBlock count.
[in]BuffPointer to data buffer.

References XSdPs_Adma2Descriptor32::Address, XSdPs::Adma2_DescrTbl32, XSdPs_Adma2Descriptor32::Attribute, XSdPs_Config::BaseAddress, XSdPs::Config, XSdPs_Config::IsCacheCoherent, and XSdPs_Adma2Descriptor32::Length.

Referenced by XSdPs_SetupADMA2DescTbl().

void XSdPs_Setup64ADMA2DescTbl ( XSdPs *  InstancePtr,
u32  BlkCnt,
const u8 *  Buff 
)

Sets up the ADMA2 descriptor table for 64-bit DMA.

Parameters
[in,out]InstancePtrPointer to the XSdPs instance.
[in]BlkCntBlock count.
[in]BuffPointer to data buffer.

References XSdPs_Adma2Descriptor64::Address, XSdPs::Adma2_DescrTbl64, XSdPs_Adma2Descriptor64::Attribute, XSdPs_Config::BaseAddress, XSdPs::Config, XSdPs_Config::IsCacheCoherent, and XSdPs_Adma2Descriptor64::Length.

Referenced by XSdPs_SetupADMA2DescTbl().

void XSdPs_SetupADMA2DescTbl ( XSdPs *  InstancePtr,
u32  BlkCnt,
const u8 *  Buff 
)

Sets up the ADMA2 descriptor table.

Parameters
[in,out]InstancePtrPointer to the XSdPs instance.
[in]BlkCntBlock count.
[in]BuffPointer to data buffer.

References XSdPs::HC_Version, XSdPs_Setup32ADMA2DescTbl(), and XSdPs_Setup64ADMA2DescTbl().

Referenced by XSdPs_SetupReadDma(), and XSdPs_SetupWriteDma().

void XSdPs_SetupADMA2DescTbl64Bit ( XSdPs *  InstancePtr,
u32  BlkCnt 
)

Sets up the ADMA2 descriptor table for 64 Bit DMA.

Parameters
[in,out]InstancePtrPointer to the XSdPs instance.
[in]BlkCntBlock count.

References XSdPs_Adma2Descriptor64::Address, XSdPs::Adma2_DescrTbl64, XSdPs_Adma2Descriptor64::Attribute, XSdPs_Config::BaseAddress, XSdPs::Config, XSdPs::Dma64BitAddr, XSdPs_Config::IsCacheCoherent, and XSdPs_Adma2Descriptor64::Length.

Referenced by XSdPs_SetupReadDma(), and XSdPs_SetupWriteDma().

s32 XSdPs_SetupCmd ( XSdPs *  InstancePtr,
u32  Arg,
u32  BlkCnt 
)

Initializes the command sequence.

Parameters
[in]InstancePtrPointer to the instance to be worked on.
[in]ArgAddress passed by the user that is to be sent as argument along with the command.
[in]BlkCntBlock count passed by the user.
Returns
  • XST_SUCCESS if successful.
  • XST_FAILURE if the command line is not idle.

References XSdPs_Config::BaseAddress, XSdPs::Config, and XSdPs_CheckBusIdle().

Referenced by XSdPs_CmdTransfer().

void XSdPs_SetupReadDma ( XSdPs *  InstancePtr,
u16  BlkCnt,
u16  BlkSize,
u8 *  Buff 
)

Sets up the DMA for a read transfer from the SD card.

Parameters
[in,out]InstancePtrPointer to the instance to be worked on.
[in]BlkCntBlock count passed by the user.
[in]BlkSizeBlock size passed by the user.
[out]BuffPointer to the data buffer for a DMA transfer.

References ADDRESS_BEYOND_32BIT, XSdPs_Config::BaseAddress, XSdPs::Config, XSdPs::Dma64BitAddr, XSdPs_Config::IsCacheCoherent, XSdPs::TransferMode, XSdPs_SetupADMA2DescTbl(), and XSdPs_SetupADMA2DescTbl64Bit().

Referenced by XSdPs_Change_SdBusSpeed(), XSdPs_Get_BusSpeed(), XSdPs_Get_BusWidth(), XSdPs_Get_Mmc_ExtCsd(), XSdPs_Get_Status(), and XSdPs_Read().

s32 XSdPs_SetupTransfer ( XSdPs *  InstancePtr)

Initiates the transfer to or from SD card.

Parameters
[in,out]InstancePtrPointer to the instance to be worked on.
Returns
  • XST_SUCCESS if initialization was successful
  • XST_FAILURE if failure

References XSdPs_Config::BaseAddress, XSdPs_Config::CardDetect, XSdPs::Config, XSdPs::HC_Version, XSdPs::Host_Caps, XSDPS_BLK_SIZE_512_MASK, and XSdPs_SetBlkSize().

Referenced by XSdPs_ReadPolled(), XSdPs_StartReadTransfer(), XSdPs_StartWriteTransfer(), and XSdPs_WritePolled().

s32 XSdPs_SetupVoltageSwitch ( XSdPs *  InstancePtr)

Sets up the voltage switch.

Parameters
[in]InstancePtrPointer to the instance to be worked on.
Returns
  • XST_SUCCESS if successful.
  • XST_FAILURE if CMD11 fails or the CMD and DAT lines do not go low within the timeout.

References XSdPs_Config::BaseAddress, XSdPs::Config, and XSdPs_CmdTransfer().

Referenced by XSdPs_Switch_Voltage().

void XSdPs_SetupWriteDma ( XSdPs *  InstancePtr,
u16  BlkCnt,
u16  BlkSize,
const u8 *  Buff 
)

Sets up the DMA for a write transfer to the SD card.

Parameters
[in,out]InstancePtrPointer to the instance to be worked on.
[in]BlkCntBlock count passed by the user.
[in]BlkSizeBlock size passed by the user.
[in]BuffPointer to the data buffer for a DMA transfer.

References ADDRESS_BEYOND_32BIT, XSdPs_Config::BaseAddress, XSdPs::Config, XSdPs::Dma64BitAddr, XSdPs_Config::IsCacheCoherent, XSdPs::TransferMode, XSdPs_SetupADMA2DescTbl(), and XSdPs_SetupADMA2DescTbl64Bit().

Referenced by XSdPs_Write().

s32 XSdPs_SetVoltage18 ( XSdPs *  InstancePtr)

Sets voltage to 1.8 V.

Parameters
[in]InstancePtrPointer to the instance to be worked on.
Returns
  • XST_SUCCESS if successful
  • XST_FAILURE if failure

References XSdPs_Config::BaseAddress, XSdPs::Config, and XSdPs_CheckVoltage18().

Referenced by XSdPs_CardSetVoltage18().

s32 XSdPs_StartReadTransfer ( XSdPs *  InstancePtr,
u32  Arg,
u32  BlkCnt,
u8 *  Buff 
)

Starts SD read transfer.

Parameters
[in,out]InstancePtrPointer to the instance to be worked on.
[in]ArgAddress passed by the user that is to be sent as argument along with the command.
[in]BlkCntBlock count passed by the user.
[out]BuffPointer to the data buffer for a DMA transfer.
Returns
  • XST_SUCCESS if Transfer initialization was successful
  • XST_FAILURE if failure - could be because another transfer is in progress or command or data inhibit is set

References XSdPs::IsBusy, XSdPs::IsReady, XSdPs_Read(), and XSdPs_SetupTransfer().

s32 XSdPs_StartWriteTransfer ( XSdPs *  InstancePtr,
u32  Arg,
u32  BlkCnt,
u8 *  Buff 
)

Starts SD write transfer.

Parameters
[in,out]InstancePtrPointer to the instance to be worked on.
[in]ArgAddress passed by the user that is to be sent as argument along with the command.
[in]BlkCntBlock count passed by the user.
[in]BuffPointer to the data buffer for a DMA transfer.
Returns
  • XST_SUCCESS if Transfer initialization was successful
  • XST_FAILURE if failure - could be because another transfer is in progress or command or data inhibit is set

References XSdPs::IsBusy, XSdPs::IsReady, XSdPs_SetupTransfer(), and XSdPs_Write().

s32 XSdPs_Switch_Voltage ( XSdPs *  InstancePtr)

Switches the SD card voltage from 3v3 to 1v8.

Parameters
[in]InstancePtrPointer to the XSdPs instance.
Returns
  • XST_SUCCESS if successful
  • XST_FAILURE if failure

References XSdPs_CardSetVoltage18(), XSdPs_CheckBusHigh(), and XSdPs_SetupVoltageSwitch().

Referenced by XSdPs_CardOpCond().

s32 XSdPs_Write ( XSdPs *  InstancePtr,
u32  Arg,
u32  BlkCnt,
const u8 *  Buff 
)

Performs SD write in polled mode.

Parameters
[in,out]InstancePtrPointer to the instance to be worked on.
[in]ArgAddress passed by the user that is to be sent as argument along with the command.
[in]BlkCntBlock count passed by the user.
[in]BuffPointer to the data buffer for a DMA transfer.
Returns
  • XST_SUCCESS if initialization was successful
  • XST_FAILURE if failure - could be because another transfer is in progress or command or data inhibit is set

References XSdPs::BlkSize, XSdPs_CmdTransfer(), and XSdPs_SetupWriteDma().

Referenced by XSdPs_StartWriteTransfer(), and XSdPs_WritePolled().

s32 XSdPs_WritePolled ( XSdPs *  InstancePtr,
u32  Arg,
u32  BlkCnt,
const u8 *  Buff 
)

Performs SD write in polled mode.

Parameters
[in,out]InstancePtrPointer to the instance to be worked on.
[in]ArgAddress passed by the user that is to be sent as argument along with the command.
[in]BlkCntBlock count passed by the user.
[in]BuffPointer to the data buffer for a DMA transfer.
Returns
  • XST_SUCCESS if initialization was successful
  • XST_FAILURE if failure - could be because another transfer is in progress or command or data inhibit is set

References XSdPs::Config, XSdPs::IsBusy, XSdPs::IsReady, XSdPs_Config::RefClk, XSdps_CheckTransferDone(), XSdPs_SetupTransfer(), and XSdPs_Write().

Variable Documentation

XSdPs_Config XSdPs_ConfigTable[]
Initial value:
=
{
{
XPAR_XSDPS_0_DEVICE_ID,
XPAR_XSDPS_0_BASEADDR,
XPAR_XSDPS_0_SDIO_CLK_FREQ_HZ,
XPAR_XSDPS_0_HAS_CD,
XPAR_XSDPS_0_HAS_WP,
XPAR_XSDPS_0_BUS_WIDTH,
XPAR_XSDPS_0_MIO_BANK,
XPAR_XSDPS_0_HAS_EMIO,
XPAR_XSDPS_0_SLOT_TYPE,
XPAR_XSDPS_0_IS_CACHE_COHERENT,
XPAR_XSDPS_0_CLK_50_SDR_ITAP_DLY,
XPAR_XSDPS_0_CLK_50_SDR_OTAP_DLY,
XPAR_XSDPS_0_CLK_50_DDR_ITAP_DLY,
XPAR_XSDPS_0_CLK_50_DDR_OTAP_DLY,
XPAR_XSDPS_0_CLK_100_SDR_OTAP_DLY,
XPAR_XSDPS_0_CLK_200_SDR_OTAP_DLY,
XPAR_XSDPS_0_CLK_200_DDR_OTAP_DLY
}
}

Holds the configuration table for the SD devices in the system.

Holds the configuration table for each SDPS instance.

Referenced by XSdPs_LookupConfig().