Software Drivers

xsdps.c File Reference


Detailed Description

Contains the interface functions of the XSdPs driver. See xsdps.h for a detailed description of the device and driver.

 MODIFICATION HISTORY:

 Ver   Who    Date     Changes
 ----- ---    -------- -----------------------------------------------
 1.00a hk/sg  10/17/13 Initial release
 2.0   hk     12/13/13 Added check for arm to use sleep.h and its API's
 2.1   hk     04/18/14 Add sleep for microblaze designs. CR# 781117.

 

#include "xsdps.h"

Functions

u32 XSdPs_FrameCmd (u32 Cmd)
int XSdPs_CmdTransfer (XSdPs *InstancePtr, u32 Cmd, u32 Arg, u32 BlkCnt)
void XSdPs_SetupADMA2DescTbl (XSdPs *InstancePtr, u32 BlkCnt, const u8 *Buff)
int XSdPs_CfgInitialize (XSdPs *InstancePtr, XSdPs_Config *ConfigPtr, u32 EffectiveAddr)
int XSdPs_SdCardInitialize (XSdPs *InstancePtr)
int XSdPs_ReadPolled (XSdPs *InstancePtr, u32 Arg, u32 BlkCnt, u8 *Buff)
int XSdPs_WritePolled (XSdPs *InstancePtr, u32 Arg, u32 BlkCnt, const u8 *Buff)
int XSdPs_Select_Card (XSdPs *InstancePtr)
int XSdPs_MmcCardInitialize (XSdPs *InstancePtr)


Function Documentation

int XSdPs_CfgInitialize XSdPs InstancePtr,
XSdPs_Config ConfigPtr,
u32  EffectiveAddr
 

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

Parameters:
InstancePtr is a pointer to the XSdPs instance.
ConfigPtr is a reference to a structure containing information about a specific SD device. This function initializes an InstancePtr object for a specific device specified by the contents of Config.
EffectiveAddr is the device 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 this function is invoked. Unexpected errors may occur if the address mapping changes after this function is called. If address translation is not used, use ConfigPtr->Config.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.
Note:
This function initializes the host controller. Initial clock of 400KHz is set. Voltage of 3.3V 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. Defualt Block size is 512 bytes.

int XSdPs_CmdTransfer XSdPs InstancePtr,
u32  Cmd,
u32  Arg,
u32  BlkCnt
 

This function does SD command generation.

Parameters:
InstancePtr is a pointer to the instance to be worked on.
Cmd is the command to be sent.
Arg is the argument to be sent along with the command. This could be address or any other information
BlkCnt - Block 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

u32 XSdPs_FrameCmd u32  Cmd  ) 
 

This function frames the Command register for a particular command. Note that this generates only the command register value i.e. 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.

Parameters:
Command to be sent.
Returns:
Command register value complete with response type and data, CRC and index related flags.

int XSdPs_MmcCardInitialize XSdPs InstancePtr  ) 
 

Mmc initialization is done in this function

Parameters:
InstancePtr is a pointer 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:
This function initializes the SD card 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.

int XSdPs_ReadPolled XSdPs InstancePtr,
u32  Arg,
u32  BlkCnt,
u8 *  Buff
 

This function performs SD read in polled mode.

Parameters:
InstancePtr is a pointer to the instance to be worked on.
Arg is the address passed by the user that is to be sent as argument along with the command.
BlkCnt - Block count passed by the user.
Buff - Pointer 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

int XSdPs_SdCardInitialize XSdPs InstancePtr  ) 
 

SD initialization is done in this function

Parameters:
InstancePtr is a pointer 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:
This function initializes the SD card 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.

int XSdPs_Select_Card XSdPs InstancePtr  ) 
 

Selects card and sets default block size

Parameters:
InstancePtr is a pointer to the XSdPs instance.
Returns:
  • XST_SUCCESS if successful.
  • XST_FAILURE if fail.
Note:
None.

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

API to setup ADMA2 descriptor table

Parameters:
InstancePtr is a pointer to the XSdPs instance.
BlkCnt - block count.
Buff pointer to data buffer.
Returns:
None
Note:
None.

int XSdPs_WritePolled XSdPs InstancePtr,
u32  Arg,
u32  BlkCnt,
const u8 *  Buff
 

This function performs SD write in polled mode.

Parameters:
InstancePtr is a pointer to the instance to be worked on.
Arg is the address passed by the user that is to be sent as argument along with the command.
BlkCnt - Block count passed by the user.
Buff - Pointer 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
Copyright @ 1995-2014 Xilinx, Inc. All rights reserved.